1
1
import 'package:flutter/material.dart' ;
2
+ import 'package:pref/pref.dart' ;
2
3
import 'package:quacker/client/client_regular_account.dart' ;
4
+ import 'package:quacker/client/login_webview.dart' ;
3
5
import 'package:quacker/generated/l10n.dart' ;
4
- import 'package:provider/provider.dart' ;
5
- import 'package:pref/pref.dart' ;
6
- import 'package:quacker/ui/errors.dart' ;
7
6
8
7
class SettingsAccountFragment extends StatefulWidget {
9
8
const SettingsAccountFragment ({super .key});
@@ -15,13 +14,12 @@ class SettingsAccountFragment extends StatefulWidget {
15
14
class _SettingsAccountFragment extends State <SettingsAccountFragment > {
16
15
@override
17
16
Widget build (BuildContext context) {
18
- var model = context.read <XRegularAccount >();
19
17
return Scaffold (
20
18
appBar: AppBar (
21
19
title: Text (L10n .current.account),
22
20
actions: [
23
21
IconButton (
24
- onPressed: () => showDialog (context: context, builder: (_) => addDialog (model )),
22
+ onPressed: () => Navigator . push (context, MaterialPageRoute ( builder: (_) => const TwitterLoginWebview () )),
25
23
icon: const Icon (Icons .add))
26
24
],
27
25
),
@@ -37,127 +35,19 @@ class _SettingsAccountFragment extends State<SettingsAccountFragment> {
37
35
itemBuilder: (BuildContext itemContext, int index) {
38
36
return Card (
39
37
child: ListTile (
40
- title: Text (data[index]['id' ].toString ()),
41
- subtitle: Text (data[index]['email' ].toString ()),
42
- leading: Icon (Icons .account_circle),
43
- trailing: Row (mainAxisSize: MainAxisSize .min, children: [
44
- IconButton (
45
- icon: Icon (Icons .refresh),
46
- onPressed: () async {
47
- await addAccount (data[index]['id' ] as String , data[index]['password' ] as String ,
48
- data[index]['email' ].toString ());
49
- setState (() {});
50
- },
51
- ),
52
- IconButton (
53
- icon: Icon (Icons .delete),
54
- onPressed: () async {
55
- await deleteAccount (data[index]['id' ].toString ());
56
- setState (() {});
57
- },
58
- )
59
- ]),
60
- onTap: () => showDialog (
61
- context: context,
62
- builder: (_) => addDialog (model,
63
- username: data[index]['id' ] as String ,
64
- password: data[index]['password' ] as String ,
65
- email: data[index]['email' ].toString ())),
66
- ));
38
+ title: Text (L10n .of (context).account),
39
+ subtitle: Text (L10n .of (context).unknown),
40
+ leading: Icon (Icons .account_circle),
41
+ trailing: IconButton (
42
+ icon: Icon (Icons .delete),
43
+ onPressed: () async {
44
+ await deleteAccount (data[index]['id' ].toString ());
45
+ setState (() {});
46
+ },
47
+ )));
67
48
});
68
49
}
69
50
}),
70
51
);
71
52
}
72
53
}
73
-
74
- class addDialog extends StatefulWidget {
75
- final XRegularAccount model;
76
- final String username;
77
- final String password;
78
- final String email;
79
-
80
- const addDialog (this .model, {super .key, this .username = "" , this .password = "" , this .email = "" });
81
-
82
- @override
83
- State <addDialog> createState () => _addDialog ();
84
- }
85
-
86
- class _addDialog extends State <addDialog> {
87
- bool hidePassword = true ;
88
-
89
- TextEditingController _username = TextEditingController ();
90
- TextEditingController _password = TextEditingController ();
91
- TextEditingController _email = TextEditingController ();
92
-
93
- Widget build (BuildContext context) {
94
- _username.text = widget.username;
95
- _password.text = widget.password;
96
- _email.text = widget.email;
97
-
98
- return AlertDialog (
99
- title: Text (L10n .of (context).account),
100
- content: Column (mainAxisSize: MainAxisSize .min, children: [
101
- Flexible (
102
- child: TextField (
103
- controller: _username,
104
- decoration: InputDecoration (
105
- isDense: true , label: Text (L10n .of (context).loginNameTwitterAcc), border: const OutlineInputBorder ()),
106
- ),
107
- ),
108
- const SizedBox (
109
- height: 8.0 ,
110
- ),
111
- Flexible (
112
- child: TextField (
113
- controller: _password,
114
- obscureText: hidePassword,
115
- decoration: InputDecoration (
116
- isDense: true ,
117
- label: Text (L10n .of (context).passwordTwitterAcc),
118
- border: const OutlineInputBorder (),
119
- suffixIcon: IconButton (
120
- icon: Icon (hidePassword ? Icons .visibility : Icons .visibility_off),
121
- onPressed: () => setState (() => hidePassword = ! hidePassword),
122
- ),
123
- ),
124
- ),
125
- ),
126
- const SizedBox (
127
- height: 8.0 ,
128
- ),
129
- Flexible (
130
- child: TextField (
131
- controller: _email,
132
- keyboardType: TextInputType .emailAddress,
133
- decoration: InputDecoration (
134
- isDense: true , label: Text (L10n .of (context).emailTwitterAcc), border: const OutlineInputBorder ()),
135
- ),
136
- ),
137
- const SizedBox (
138
- height: 8.0 ,
139
- ),
140
- const Padding (
141
- padding: EdgeInsets .all (8.0 ),
142
- child: Text (
143
- "⚠️ 2FA is currently not supported ⚠️" ,
144
- textAlign: TextAlign .center,
145
- )),
146
- ]),
147
- actions: [
148
- TextButton (
149
- onPressed: () async {
150
- final response = await addAccount (_username.text, _password.text, _email.text);
151
- if (context.mounted) {
152
- showSnackBar (context, icon: '' , message: response);
153
- }
154
- Navigator .pop (context);
155
-
156
- setState (() {});
157
- },
158
- child: Text (L10n .of (context).login)),
159
- TextButton (onPressed: () => Navigator .pop (context), child: Text (L10n .of (context).close)),
160
- ],
161
- );
162
- }
163
- }
0 commit comments