@@ -12,18 +12,101 @@ class AuthenticationPage extends StatelessWidget {
12
12
create: (context) => AuthenticationBloc (
13
13
authenticationRepository: context.read <HtAuthenticationRepository >(),
14
14
),
15
- child: const _AuthenticationView (),
15
+ child: _AuthenticationView (),
16
16
);
17
17
}
18
18
}
19
19
20
20
class _AuthenticationView extends StatelessWidget {
21
- const _AuthenticationView ();
21
+ _AuthenticationView ();
22
+
23
+ final _emailController = TextEditingController ();
24
+ final _passwordController = TextEditingController ();
22
25
23
26
@override
24
27
Widget build (BuildContext context) {
25
- return const Placeholder (
26
- child: Text ('AUTHENTICATION PAGE' ),
28
+
29
+ return Scaffold (
30
+ body: SafeArea (
31
+ child: BlocBuilder <AuthenticationBloc , AuthenticationState >(
32
+ builder: (context, state) {
33
+ if (state is AuthenticationLoading ) {
34
+ return const Center (child: CircularProgressIndicator ());
35
+ }
36
+ if (state is AuthenticationFailure ) {
37
+ WidgetsBinding .instance.addPostFrameCallback ((_) {
38
+ ScaffoldMessenger .of (context).showSnackBar (
39
+ SnackBar (content: Text (state.errorMessage)),
40
+ );
41
+ });
42
+ }
43
+ return Padding (
44
+ padding: const EdgeInsets .all (16 ),
45
+ child: Column (
46
+ mainAxisAlignment: MainAxisAlignment .center,
47
+ children: [
48
+ const Text (
49
+ 'Sign In' ,
50
+ style: TextStyle (fontSize: 24 , fontWeight: FontWeight .bold),
51
+ ),
52
+ const SizedBox (height: 32 ),
53
+ TextFormField (
54
+ controller: _emailController,
55
+ decoration: const InputDecoration (
56
+ labelText: 'Email' ,
57
+ border: OutlineInputBorder (),
58
+ ),
59
+ keyboardType: TextInputType .emailAddress,
60
+ ),
61
+ const SizedBox (height: 16 ),
62
+ TextFormField (
63
+ controller: _passwordController,
64
+ decoration: const InputDecoration (
65
+ labelText: 'Password' ,
66
+ border: OutlineInputBorder (),
67
+ ),
68
+ obscureText: true ,
69
+ ),
70
+ const SizedBox (height: 32 ),
71
+ ElevatedButton (
72
+ onPressed: () {
73
+ context.read <AuthenticationBloc >().add (
74
+ AuthenticationEmailSignInRequested (
75
+ email: _emailController.text,
76
+ password: _passwordController.text,
77
+ ),
78
+ );
79
+ },
80
+ child: const Text ('Sign In with Email' ),
81
+ ),
82
+ const SizedBox (height: 16 ),
83
+ ElevatedButton (
84
+ onPressed: () {
85
+ context
86
+ .read <AuthenticationBloc >()
87
+ .add (const AuthenticationGoogleSignInRequested ());
88
+ },
89
+ style: ElevatedButton .styleFrom (
90
+ backgroundColor: Colors .white,
91
+ foregroundColor: Colors .black,
92
+ ),
93
+ child: const Text ('Sign In with Google' ),
94
+ ),
95
+ const SizedBox (height: 16 ),
96
+ ElevatedButton (
97
+ onPressed: () {
98
+ context
99
+ .read <AuthenticationBloc >()
100
+ .add (const AuthenticationAnonymousSignInRequested ());
101
+ },
102
+ child: const Text ('Sign In Anonymously' ),
103
+ ),
104
+ ],
105
+ ),
106
+ );
107
+ },
108
+ ),
109
+ ),
27
110
);
28
111
}
29
112
}
0 commit comments