Skip to content

Commit 6abcc0c

Browse files
authored
Add signup form example (#113)
* add signup form * fix suggestion
1 parent 2b4975e commit 6abcc0c

File tree

15 files changed

+325
-20
lines changed

15 files changed

+325
-20
lines changed

app/devtools_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: This file stores settings for Dart & Flutter DevTools.
2+
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
3+
extensions:

app/lib/presentation/navigation/routers.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ enum Routes {
2121
String get path => '/$name';
2222
String get subPath => name;
2323

24-
void nav(BuildContext context, {Object? extra}) {
24+
void go(BuildContext context, {Object? extra}) {
2525
context.router.goNamed(
2626
name,
2727
extra: extra,
@@ -63,7 +63,7 @@ class Routers {
6363
return;
6464
}
6565
debugPrint('Navigating to app route');
66-
Routes.app.nav(context);
66+
Routes.app.go(context);
6767
break;
6868
case AuthStateUnauthenticated _:
6969
debugPrint(
@@ -74,7 +74,7 @@ class Routers {
7474
return;
7575
}
7676
debugPrint('Navigating to auth route');
77-
Routes.auth.nav(context);
77+
Routes.auth.go(context);
7878
break;
7979
case _:
8080
}

app/lib/presentation/resources/dim.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Dimen {
77
static const loadingSpinnerSize = 32.0;
88
static const loadingSpinnerSizeS = 16.0;
99

10-
static const double loginFormMaxWidth = 400.0;
10+
static const double authFormMaxWidth = 400.0;
1111

1212
static const spacingXxs = 2.0;
1313
static const spacingXs = 4.0;

app/lib/presentation/resources/locale/generated/intl/messages_en.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class MessageLookup extends MessageLookupByLibrary {
3131
"This website uses cookies",
3232
),
3333
"ctaLogin": MessageLookupByLibrary.simpleMessage("Login"),
34+
"ctaSignUp": MessageLookupByLibrary.simpleMessage("Sign Up"),
3435
"errorEmailInvalid": MessageLookupByLibrary.simpleMessage(
3536
"Please enter a valid email address.",
3637
),
@@ -43,9 +44,18 @@ class MessageLookup extends MessageLookupByLibrary {
4344
"errorPasswordWeak": MessageLookupByLibrary.simpleMessage(
4445
"Password is too weak.",
4546
),
47+
"errorPasswordsDoNotMatch": MessageLookupByLibrary.simpleMessage(
48+
"Passwords do not match.",
49+
),
50+
"hintTermsAndConditions": MessageLookupByLibrary.simpleMessage(
51+
"This should open the terms and conditions URL.",
52+
),
4653
"labelAgreeToTerms": MessageLookupByLibrary.simpleMessage(
4754
"I agree to the Terms and Conditions",
4855
),
56+
"labelConfirmPassword": MessageLookupByLibrary.simpleMessage(
57+
"Confirm Password",
58+
),
4959
"labelEmail": MessageLookupByLibrary.simpleMessage("Email"),
5060
"labelPassword": MessageLookupByLibrary.simpleMessage("Password"),
5161
"loginErrorInvalidCredentials": MessageLookupByLibrary.simpleMessage(
@@ -67,5 +77,9 @@ class MessageLookup extends MessageLookupByLibrary {
6777
"titleLoginSubtitle": MessageLookupByLibrary.simpleMessage(
6878
"Use your email and password to login to your account.",
6979
),
80+
"titleSignUp": MessageLookupByLibrary.simpleMessage("Sign Up"),
81+
"titleSignUpSubtitle": MessageLookupByLibrary.simpleMessage(
82+
"Create an account using your email and password.",
83+
),
7084
};
7185
}

app/lib/presentation/resources/locale/generated/l10n.dart

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/lib/presentation/resources/locale/intl_en.arb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,21 @@
88
"pleaseTryAgainLaterWeArenworkingToFixTheIssue": "Please try again later, we are\nworking to fix the issue.",
99
"sorryWeDidntFindAnyProduct": "Sorry we didn't find any product",
1010
"ctaLogin": "Login",
11+
"ctaSignUp": "Sign Up",
1112
"labelEmail": "Email",
1213
"labelPassword": "Password",
14+
"labelConfirmPassword": "Confirm Password",
15+
"errorPasswordsDoNotMatch": "Passwords do not match.",
1316
"passwordInstructions": "Min 8 characters long: 1 uppercase letter, 1 lowercase letter, 1 number, and 1 special character.",
1417
"labelAgreeToTerms": "I agree to the Terms and Conditions",
1518
"errorEmailRequired": "Email is required.",
1619
"errorPasswordRequired": "Password is required.",
1720
"titleLogin": "Login",
21+
"titleSignUp": "Sign Up",
1822
"titleLoginSubtitle": "Use your email and password to login to your account.",
23+
"titleSignUpSubtitle": "Create an account using your email and password.",
1924
"errorEmailInvalid": "Please enter a valid email address.",
2025
"errorPasswordWeak": "Password is too weak.",
21-
"loginErrorInvalidCredentials": "Invalid email or password."
26+
"loginErrorInvalidCredentials": "Invalid email or password.",
27+
"hintTermsAndConditions": "This should open the terms and conditions URL."
2228
}

app/lib/presentation/ui/pages/auth/login/login_form.dart

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:app/presentation/navigation/routers.dart';
12
import 'package:app/presentation/resources/locale/generated/l10n.dart';
23
import 'package:app/presentation/resources/resources.dart';
34
import 'package:app/presentation/ui/components/primary_button.dart';
@@ -52,6 +53,7 @@ class _LoginFormState extends State<LoginForm> {
5253
labelText: S.of(context).labelEmail,
5354
),
5455
keyboardType: TextInputType.emailAddress,
56+
autofillHints: const [AutofillHints.username, AutofillHints.email],
5557
controller: emailController,
5658
validator: (value) {
5759
if (!FormValidator.isEmail(value)) {
@@ -101,9 +103,8 @@ class _LoginFormState extends State<LoginForm> {
101103
IconButton(
102104
onPressed: () {
103105
ScaffoldMessenger.of(context).showSnackBar(
104-
const SnackBar(
105-
content: Text(
106-
"This should open the terms and conditions URL."),
106+
SnackBar(
107+
content: Text(S.of(context).hintTermsAndConditions),
107108
),
108109
);
109110
},
@@ -147,6 +148,26 @@ class _LoginFormState extends State<LoginForm> {
147148
);
148149
},
149150
),
151+
const Gap(Dimen.spacingL),
152+
const Row(
153+
mainAxisAlignment: MainAxisAlignment.center,
154+
children: [
155+
Expanded(child: Divider()),
156+
Padding(
157+
padding: EdgeInsets.symmetric(horizontal: Dimen.spacingS),
158+
child: Text("OR"),
159+
),
160+
Expanded(child: Divider()),
161+
],
162+
),
163+
const Gap(Dimen.spacingM),
164+
SizedBox(
165+
width: double.infinity,
166+
child: TextButton(
167+
onPressed: () => Routes.signup.go(context),
168+
child: Text(S.of(context).ctaSignUp.toUpperCase()),
169+
),
170+
),
150171
],
151172
),
152173
);

app/lib/presentation/ui/pages/auth/login/login_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:app/presentation/resources/resources.dart';
22
import 'package:app/presentation/ui/pages/auth/login/login_form.dart';
3+
import 'package:flutter/foundation.dart';
34
import 'package:flutter/material.dart';
45

56
class LoginPage extends StatelessWidget {
@@ -11,7 +12,7 @@ class LoginPage extends StatelessWidget {
1112
body: Center(
1213
child: Container(
1314
constraints: const BoxConstraints(
14-
maxWidth: Dimen.loginFormMaxWidth,
15+
maxWidth: kIsWeb ? Dimen.authFormMaxWidth : double.infinity,
1516
),
1617
child: const Card(
1718
child: Padding(

0 commit comments

Comments
 (0)