Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support for displaying sign-in or sign-up initially #116

Merged
merged 5 commits into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/src/components/supa_email_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
});
Expand All @@ -227,22 +231,21 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
final _formKey = GlobalKey<FormState>();
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
late bool _isSigningIn;
late final Map<String, MetadataController> _metadataControllers;

bool _isLoading = false;

/// 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,
Expand Down
Loading