From 9f284d87a40ff4a706c938dea4796d8febcd235c Mon Sep 17 00:00:00 2001 From: Tyler Date: Fri, 4 Oct 2024 12:07:24 +0900 Subject: [PATCH] feat: Support for displaying sign-in or sign-up initially (#116) * Support for displaying sign-in or sign-up initially * Better indication of isSigningIn parameter Co-authored-by: Tyler * fix: update variable name * remove the extra metadata controllers --------- Co-authored-by: Grzegorz Kowal Co-authored-by: kowalgregy --- lib/src/components/supa_email_auth.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/src/components/supa_email_auth.dart b/lib/src/components/supa_email_auth.dart index 11f782f..c91a3f2 100644 --- a/lib/src/components/supa_email_auth.dart +++ b/lib/src/components/supa_email_auth.dart @@ -197,6 +197,9 @@ class SupaEmailAuth extends StatefulWidget { /// Localization for the form final SupaEmailAuthLocalization localization; + /// Whether the form should display sign-in or sign-up initially + final bool isInitiallySigningIn; + /// Icons or custom prefix widgets for email UI final Widget? prefixIconEmail; final Widget? prefixIconPassword; @@ -215,6 +218,7 @@ class SupaEmailAuth extends StatefulWidget { this.metadataFields, this.extraMetadata, this.localization = const SupaEmailAuthLocalization(), + this.isInitiallySigningIn = true, this.prefixIconEmail = const Icon(Icons.email), this.prefixIconPassword = const Icon(Icons.lock), }); @@ -227,6 +231,7 @@ class _SupaEmailAuthState extends State { final _formKey = GlobalKey(); final _emailController = TextEditingController(); final _passwordController = TextEditingController(); + late bool _isSigningIn; late final Map _metadataControllers; bool _isLoading = false; @@ -234,15 +239,13 @@ class _SupaEmailAuthState extends State { /// The user has pressed forgot password button bool _isRecoveringPassword = false; - /// Whether the user is signing in or signing up - bool _isSigningIn = true; - /// Focus node for email field final FocusNode _emailFocusNode = FocusNode(); @override void initState() { super.initState(); + _isSigningIn = widget.isInitiallySigningIn; _metadataControllers = Map.fromEntries((widget.metadataFields ?? []).map( (metadataField) => MapEntry( metadataField.key,