improvements

This commit is contained in:
Myzel394 2022-08-16 20:26:22 +02:00
parent f7b1c51d09
commit ae1a5c8b07
3 changed files with 25 additions and 4 deletions

View File

@ -51,6 +51,16 @@ extension ShowSnackBar on BuildContext {
); );
} }
void showLongErrorSnackBar({
required final String message,
}) {
showSnackBar(
message: message,
backgroundColor: Colors.red,
duration: const Duration(seconds: 6),
);
}
void showSuccessSnackBar({ void showSuccessSnackBar({
required final String message, required final String message,
}) { }) {

View File

@ -63,7 +63,7 @@ class _LoginScreenState extends AuthState<LoginScreen> with Loadable {
await _signIn(); await _signIn();
} catch (error) { } catch (error) {
if (mounted) { if (mounted) {
context.showErrorSnackBar(message: error.toString()); context.showLongErrorSnackBar(message: 'Invalid password or email');
emailController.clear(); emailController.clear();
passwordController.clear(); passwordController.clear();
@ -100,19 +100,26 @@ class _LoginScreenState extends AuthState<LoginScreen> with Loadable {
'Sign in to your account. If you do not have one already, we will automatically set up one for you.', 'Sign in to your account. If you do not have one already, we will automatically set up one for you.',
), ),
const SizedBox(height: MEDIUM_SPACE), const SizedBox(height: MEDIUM_SPACE),
TextFormField( TextField(
controller: emailController, controller: emailController,
autofocus: true, autofocus: true,
autofillHints: const [AutofillHints.email], autofillHints: const [AutofillHints.email],
decoration: const InputDecoration(labelText: 'Email'), keyboardType: TextInputType.emailAddress,
textInputAction: TextInputAction.next,
decoration: const InputDecoration(
labelText: 'Email',
prefixIcon: Icon(Icons.email),
),
), ),
const SizedBox(height: SMALL_SPACE), const SizedBox(height: SMALL_SPACE),
TextFormField( TextField(
obscureText: true, obscureText: true,
controller: passwordController, controller: passwordController,
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: 'Password', labelText: 'Password',
prefixIcon: Icon(Icons.lock),
), ),
onSubmitted: (value) => callWithLoading(signIn),
), ),
const SizedBox(height: MEDIUM_SPACE), const SizedBox(height: MEDIUM_SPACE),
ElevatedButton.icon( ElevatedButton.icon(

View File

@ -121,6 +121,10 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
await previousCameraController?.dispose(); await previousCameraController?.dispose();
if (!mounted) {
return;
}
controller = cameraController; controller = cameraController;
// Update UI if controller updates // Update UI if controller updates