From 9c93ea10087613976c8e3f2a485a9165fc116da4 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Fri, 29 Dec 2023 15:12:10 +1300 Subject: [PATCH] Move loading into fab button of login --- lib/login.dart | 76 +++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/login.dart b/lib/login.dart index 9e35f79..fd6e17f 100644 --- a/lib/login.dart +++ b/lib/login.dart @@ -32,6 +32,7 @@ class _LoginPageState extends State { print("Error signing in $error"); setState(() { failedMessage = error.toString(); + loggingIn = false; }); Future.delayed(const Duration(seconds: 10), () { @@ -67,46 +68,45 @@ class _LoginPageState extends State { Widget build(BuildContext context) { return Consumer( builder: (context, provider, child) => Scaffold( - appBar: AppBar( - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - title: const Text("Login"), - ), - body: Padding( - padding: const EdgeInsets.all(16.0), - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - TextFormField( - controller: serverController, - decoration: const InputDecoration( - labelText: 'Server', hintText: 'https://matrix.org'), - ), - TextFormField( - controller: usernameController, - decoration: const InputDecoration( - labelText: 'Username', hintText: 'john'), - ), - TextFormField( - controller: passwordController, - decoration: const InputDecoration(labelText: 'Password'), - obscureText: true, - onFieldSubmitted: (value) => connectMatrix(), - ), - Text(failedMessage, - style: Theme.of(context).textTheme.headlineSmall) - ], + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + title: const Text("Login"), + ), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextFormField( + controller: serverController, + decoration: const InputDecoration( + labelText: 'Server', hintText: 'https://matrix.org'), + ), + TextFormField( + controller: usernameController, + decoration: const InputDecoration( + labelText: 'Username', hintText: 'john'), + ), + TextFormField( + controller: passwordController, + decoration: const InputDecoration(labelText: 'Password'), + obscureText: true, + onFieldSubmitted: (value) => connectMatrix(), + ), + Text(failedMessage, + style: Theme.of(context).textTheme.headlineSmall) + ], + ), ), ), - ), - floatingActionButton: loggingIn - ? const CircularProgressIndicator() - : FloatingActionButton( - onPressed: connectMatrix, - tooltip: 'Log in', - child: const Icon(Icons.login), - ), - ), + floatingActionButton: FloatingActionButton( + onPressed: loggingIn ? null : connectMatrix, + tooltip: 'Log in', + child: loggingIn + ? const CircularProgressIndicator() + : const Icon(Icons.login), + )), ); } }