Skip to content

Commit fdd6832

Browse files
committed
login: Show progress indicator during server-settings request
Fixes-partly: zulip#35
1 parent 14fc0de commit fdd6832

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

lib/widgets/login.dart

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ class AddAccountPage extends StatefulWidget {
107107
}
108108

109109
class _AddAccountPageState extends State<AddAccountPage> {
110+
bool _inProgress = false;
111+
110112
final ServerUrlTextEditingController _controller = ServerUrlTextEditingController();
111113
late ServerUrlParseResult _parseResult;
112114

@@ -138,8 +140,18 @@ class _AddAccountPageState extends State<AddAccountPage> {
138140
}
139141
assert(url != null);
140142

141-
// TODO(#35): show feedback that we're working, while fetching server settings
142-
final serverSettings = await getServerSettings(realmUrl: url!);
143+
final GetServerSettingsResult serverSettings;
144+
setState(() {
145+
_inProgress = true;
146+
});
147+
try {
148+
serverSettings = await getServerSettings(realmUrl: url!);
149+
// TODO(#35) report errors
150+
} finally {
151+
setState(() {
152+
_inProgress = false;
153+
});
154+
}
143155
if (context.mounted) {} // https://github.com/dart-lang/linter/issues/4007
144156
else {
145157
return;
@@ -173,10 +185,12 @@ class _AddAccountPageState extends State<AddAccountPage> {
173185
? null
174186
: error.message(),
175187
suffixIcon: IconButton(
176-
onPressed: error == null || error.shouldDeferFeedback()
188+
onPressed: !_inProgress && (error == null || error.shouldDeferFeedback())
177189
? () => _onSubmitted(context)
178190
: null, // disabled; errorText will be present
179-
icon: const Icon(Icons.arrow_forward))))))));
191+
icon: _inProgress
192+
? const CircularProgressIndicator.adaptive()
193+
: const Icon(Icons.arrow_forward))))))));
180194
}
181195
}
182196

0 commit comments

Comments
 (0)