Move loading into fab button of login

This commit is contained in:
Brandon Presley 2023-12-29 15:12:10 +13:00
parent e478552587
commit 9c93ea1008

View File

@ -32,6 +32,7 @@ class _LoginPageState extends State<LoginPage> {
print("Error signing in $error"); print("Error signing in $error");
setState(() { setState(() {
failedMessage = error.toString(); failedMessage = error.toString();
loggingIn = false;
}); });
Future.delayed(const Duration(seconds: 10), () { Future.delayed(const Duration(seconds: 10), () {
@ -67,46 +68,45 @@ class _LoginPageState extends State<LoginPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer<ZenithClientProvider>( return Consumer<ZenithClientProvider>(
builder: (context, provider, child) => Scaffold( builder: (context, provider, child) => Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary, backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text("Login"), title: const Text("Login"),
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Center( child: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
TextFormField( TextFormField(
controller: serverController, controller: serverController,
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: 'Server', hintText: 'https://matrix.org'), labelText: 'Server', hintText: 'https://matrix.org'),
), ),
TextFormField( TextFormField(
controller: usernameController, controller: usernameController,
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: 'Username', hintText: 'john'), labelText: 'Username', hintText: 'john'),
), ),
TextFormField( TextFormField(
controller: passwordController, controller: passwordController,
decoration: const InputDecoration(labelText: 'Password'), decoration: const InputDecoration(labelText: 'Password'),
obscureText: true, obscureText: true,
onFieldSubmitted: (value) => connectMatrix(), onFieldSubmitted: (value) => connectMatrix(),
), ),
Text(failedMessage, Text(failedMessage,
style: Theme.of(context).textTheme.headlineSmall) style: Theme.of(context).textTheme.headlineSmall)
], ],
),
), ),
), ),
), floatingActionButton: FloatingActionButton(
floatingActionButton: loggingIn onPressed: loggingIn ? null : connectMatrix,
? const CircularProgressIndicator() tooltip: 'Log in',
: FloatingActionButton( child: loggingIn
onPressed: connectMatrix, ? const CircularProgressIndicator()
tooltip: 'Log in', : const Icon(Icons.login),
child: const Icon(Icons.login), )),
),
),
); );
} }
} }