@@ -26,47 +26,15 @@ class _KerioLoginViewState extends State<KerioLoginView> {
2626 final ip = await AppSharedPreferences .kerioIP;
2727 final username = await AppSharedPreferences .kerioUsername;
2828 final password = await AppSharedPreferences .kerioPassword;
29- final enabled = await AppSharedPreferences .kerioAutoLogin;
3029
3130 _ipController.text = ip ?? '' ;
32- if (ip != null && username != null && password != null && enabled == true ) {
31+ if (ip != null && username != null && password != null ) {
3332 _ipController.text = ip;
3433 _usernameController.text = username;
3534 _passwordController.text = password;
36- _login (true );
3735 }
3836 }
3937
40- void _login (bool auto) async {
41- final ip = _ipController.text;
42- final username = _usernameController.text;
43- final password = _passwordController.text;
44-
45- if (ip.isEmpty || username.isEmpty || password.isEmpty) {
46- _showMessage ('Please fill in all fields' );
47- return ;
48- }
49- if (! auto) {
50- _showMessage ('Login request sent' );
51- }
52- bloc.onKerioLoginClick (auto, ip, username, password);
53- }
54-
55- void _showMessage (String message) {
56- showDialog (
57- context: context,
58- builder: (context) => AlertDialog (
59- content: Text (message),
60- actions: [
61- TextButton (
62- onPressed: () => Navigator .of (context).pop (),
63- child: const Text ('OK' ),
64- ),
65- ],
66- ),
67- );
68- }
69-
7038 @override
7139 Widget build (BuildContext context) {
7240 return SizedBox (
@@ -146,7 +114,7 @@ class _KerioLoginViewState extends State<KerioLoginView> {
146114 }
147115 }
148116 },
149- icon: Image .asset ('assets/kerio.dart. png' , width: 24 , height: 24 ),
117+ icon: Image .asset ('assets/kerio.png' , width: 24 , height: 24 ),
150118 ),
151119 ),
152120 keyboardType: TextInputType .url,
@@ -206,7 +174,7 @@ class _KerioLoginViewState extends State<KerioLoginView> {
206174 Expanded (
207175 flex: 2 ,
208176 child: ElevatedButton (
209- onPressed: () => _login (false ),
177+ onPressed: () => _login (),
210178 style: ElevatedButton .styleFrom (
211179 shape: const RoundedRectangleBorder (
212180 borderRadius: BorderRadius .all (Radius .circular (8 )),
@@ -242,4 +210,35 @@ class _KerioLoginViewState extends State<KerioLoginView> {
242210 },
243211 );
244212 }
213+
214+ void _login () async {
215+ final ip = _ipController.text;
216+ final username = _usernameController.text;
217+ final password = _passwordController.text;
218+
219+ if (ip.isEmpty || username.isEmpty || password.isEmpty) {
220+ _showMessage ('Please fill in all fields' );
221+ return ;
222+ }
223+ await AppSharedPreferences .setKerioIP (ip);
224+ await AppSharedPreferences .setKerioUsername (username);
225+ await AppSharedPreferences .setKerioPassword (password);
226+ _showMessage ('Login request sent' );
227+ bloc.onKerioLoginClick ();
228+ }
229+
230+ void _showMessage (String message) {
231+ showDialog (
232+ context: context,
233+ builder: (context) => AlertDialog (
234+ content: Text (message),
235+ actions: [
236+ TextButton (
237+ onPressed: () => Navigator .of (context).pop (),
238+ child: const Text ('OK' ),
239+ ),
240+ ],
241+ ),
242+ );
243+ }
245244}
0 commit comments