Skip to content

Commit 9f284d8

Browse files
dshukertjrGrzegorz Kowalkowalgregy
authored
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 <[email protected]> * fix: update variable name * remove the extra metadata controllers --------- Co-authored-by: Grzegorz Kowal <[email protected]> Co-authored-by: kowalgregy <[email protected]>
1 parent 785387f commit 9f284d8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/src/components/supa_email_auth.dart

+6-3
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ class SupaEmailAuth extends StatefulWidget {
197197
/// Localization for the form
198198
final SupaEmailAuthLocalization localization;
199199

200+
/// Whether the form should display sign-in or sign-up initially
201+
final bool isInitiallySigningIn;
202+
200203
/// Icons or custom prefix widgets for email UI
201204
final Widget? prefixIconEmail;
202205
final Widget? prefixIconPassword;
@@ -215,6 +218,7 @@ class SupaEmailAuth extends StatefulWidget {
215218
this.metadataFields,
216219
this.extraMetadata,
217220
this.localization = const SupaEmailAuthLocalization(),
221+
this.isInitiallySigningIn = true,
218222
this.prefixIconEmail = const Icon(Icons.email),
219223
this.prefixIconPassword = const Icon(Icons.lock),
220224
});
@@ -227,22 +231,21 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
227231
final _formKey = GlobalKey<FormState>();
228232
final _emailController = TextEditingController();
229233
final _passwordController = TextEditingController();
234+
late bool _isSigningIn;
230235
late final Map<String, MetadataController> _metadataControllers;
231236

232237
bool _isLoading = false;
233238

234239
/// The user has pressed forgot password button
235240
bool _isRecoveringPassword = false;
236241

237-
/// Whether the user is signing in or signing up
238-
bool _isSigningIn = true;
239-
240242
/// Focus node for email field
241243
final FocusNode _emailFocusNode = FocusNode();
242244

243245
@override
244246
void initState() {
245247
super.initState();
248+
_isSigningIn = widget.isInitiallySigningIn;
246249
_metadataControllers = Map.fromEntries((widget.metadataFields ?? []).map(
247250
(metadataField) => MapEntry(
248251
metadataField.key,

0 commit comments

Comments
 (0)