@@ -109,6 +109,8 @@ class AddAccountPage extends StatefulWidget {
109
109
}
110
110
111
111
class _AddAccountPageState extends State <AddAccountPage > {
112
+ bool _inProgress = false ;
113
+
112
114
final ServerUrlTextEditingController _controller = ServerUrlTextEditingController ();
113
115
late ServerUrlParseResult _parseResult;
114
116
@@ -141,17 +143,25 @@ class _AddAccountPageState extends State<AddAccountPage> {
141
143
}
142
144
assert (url != null );
143
145
144
- // TODO(#35): show feedback that we're working, while fetching server settings
145
- final serverSettings = await getServerSettings (realmUrl: url! );
146
- // https://github.com/dart-lang/linter/issues/4007
147
- // ignore: use_build_context_synchronously
148
- if (! context.mounted) {
149
- return ;
150
- }
146
+ setState (() {
147
+ _inProgress = true ;
148
+ });
149
+ try {
150
+ final serverSettings = await getServerSettings (realmUrl: url! );
151
+ // https://github.com/dart-lang/linter/issues/4007
152
+ // ignore: use_build_context_synchronously
153
+ if (! context.mounted) {
154
+ return ;
155
+ }
151
156
152
- // TODO(#36): support login methods beyond email/password
153
- Navigator .push (context,
154
- EmailPasswordLoginPage .buildRoute (serverSettings: serverSettings));
157
+ // TODO(#36): support login methods beyond email/password
158
+ Navigator .push (context,
159
+ EmailPasswordLoginPage .buildRoute (serverSettings: serverSettings));
160
+ } finally {
161
+ setState (() {
162
+ _inProgress = false ;
163
+ });
164
+ }
155
165
}
156
166
157
167
@override
@@ -164,7 +174,11 @@ class _AddAccountPageState extends State<AddAccountPage> {
164
174
165
175
// TODO(#35): more help to user on entering realm URL
166
176
return Scaffold (
167
- appBar: AppBar (title: const Text ('Add an account' )),
177
+ appBar: AppBar (title: const Text ('Add an account' ),
178
+ bottom: _inProgress
179
+ ? const PreferredSize (preferredSize: Size .fromHeight (4 ),
180
+ child: LinearProgressIndicator (minHeight: 4 )) // 4 restates default
181
+ : null ),
168
182
body: SafeArea (
169
183
minimum: const EdgeInsets .all (8 ),
170
184
child: Center (
@@ -181,7 +195,7 @@ class _AddAccountPageState extends State<AddAccountPage> {
181
195
helperText: kLayoutPinningHelperText)),
182
196
const SizedBox (height: 8 ),
183
197
ElevatedButton (
184
- onPressed: errorText == null
198
+ onPressed: ! _inProgress && errorText == null
185
199
? () => _onSubmitted (context)
186
200
: null ,
187
201
child: const Text ('Continue' )),
0 commit comments