1
1
import 'package:flutter/material.dart' ;
2
2
import 'package:flutter_bloc/flutter_bloc.dart' ;
3
- import 'package:flutter_signin_button/flutter_signin_button .dart' ;
3
+ import 'package:flutter_screenutil/flutter_screenutil .dart' ;
4
4
import 'package:go_router/go_router.dart' ;
5
5
import 'package:monumento/application/authentication/#_register/#_register_bloc.dart' ;
6
6
import 'package:monumento/gen/assets.gen.dart' ;
@@ -39,6 +39,7 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
39
39
@override
40
40
Widget build (BuildContext context) {
41
41
return Scaffold (
42
+ backgroundColor: AppColor .appBackground,
42
43
body: SingleChildScrollView (
43
44
child: ConstrainedBox (
44
45
constraints: BoxConstraints (
@@ -58,17 +59,14 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
58
59
children: [
59
60
const SizedBox (height: 24 ),
60
61
Assets .desktop.logoDesktop.svg (width: 220 ),
61
- const SizedBox (
62
- height: 24 ,
63
- ),
62
+ const SizedBox (height: 24 ),
64
63
Center (
65
64
child: Card (
66
65
child: Container (
67
66
padding: const EdgeInsets .symmetric (
68
67
horizontal: 32 , vertical: 50 ),
69
68
width: 380 ,
70
- child: BlocListener <LoginRegisterBloc ,
71
- LoginRegisterState >(
69
+ child: BlocListener <LoginRegisterBloc , LoginRegisterState >(
72
70
bloc: locator <LoginRegisterBloc >(),
73
71
listener: (context, state) {
74
72
if (state is LoginFailed ) {
@@ -85,13 +83,12 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
85
83
),
86
84
),
87
85
backgroundColor: AppColor .appWarningRed,
88
- behavior: SnackBarBehavior .floating,
86
+ behavior: SnackBarBehavior .floating,
89
87
),
90
88
);
91
89
}
92
90
},
93
- child: BlocBuilder <LoginRegisterBloc ,
94
- LoginRegisterState >(
91
+ child: BlocBuilder <LoginRegisterBloc , LoginRegisterState >(
95
92
bloc: locator <LoginRegisterBloc >(),
96
93
builder: (context, state) {
97
94
if (state is LoginRegisterLoading ) {
@@ -112,23 +109,35 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
112
109
context.pushReplacement ('/' );
113
110
}
114
111
}
112
+
115
113
return Column (
116
114
children: [
117
115
SizedBox (
118
116
width: double .infinity,
119
- child: SignInButton (
120
- padding: const EdgeInsets .all (4 ),
121
- Buttons .GoogleDark ,
117
+ child: CustomElevatedButton (
118
+ style: ElevatedButton .styleFrom (
119
+ foregroundColor: AppColor .appBlack,
120
+ backgroundColor: AppColor .appWhite,
121
+ elevation: 2 ,
122
+ padding: EdgeInsets .symmetric (
123
+ horizontal: 16 , vertical: 12 ),
124
+ shape: RoundedRectangleBorder (
125
+ borderRadius: BorderRadius .circular (4 ),
126
+ ),
127
+ ),
128
+ leading: SizedBox (
129
+ height: 28. h,
130
+ child: Assets .googleLogo.image (),
131
+ ),
132
+ isDesktop: true ,
122
133
onPressed: () {
123
- locator <LoginRegisterBloc >().add (
124
- LoginWithGooglePressed (),
125
- );
134
+ locator <LoginRegisterBloc >()
135
+ .add (LoginWithGooglePressed ());
126
136
},
137
+ text: '# With Google' ,
127
138
),
128
139
),
129
- const SizedBox (
130
- height: 22 ,
131
- ),
140
+ const SizedBox (height: 22 ),
132
141
const Text (
133
142
'Or' ,
134
143
style: TextStyle (
@@ -137,26 +146,22 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
137
146
fontWeight: FontWeight .w400,
138
147
),
139
148
),
140
- const SizedBox (
141
- height: 22 ,
142
- ),
149
+ const SizedBox (height: 22 ),
143
150
CustomTextField (
144
- controller: emailController,
145
- text: 'Email' ,
146
- isDesktop: true ,
147
- validateFunction: (value) {
148
- if (value == null || value.isEmpty) {
149
- return 'Please enter email.' ;
150
- } else if (! value.contains ('@' )) {
151
- return 'Please enter a valid email.' ;
152
- }
153
- return null ;
154
- },
155
- autoValid:
156
- AutovalidateMode .onUserInteraction),
157
- const SizedBox (
158
- height: 16 ,
151
+ controller: emailController,
152
+ text: 'Email' ,
153
+ isDesktop: true ,
154
+ validateFunction: (value) {
155
+ if (value == null || value.isEmpty) {
156
+ return 'Please enter email.' ;
157
+ } else if (! value.contains ('@' )) {
158
+ return 'Please enter a valid email.' ;
159
+ }
160
+ return null ;
161
+ },
162
+ autoValid: AutovalidateMode .onUserInteraction,
159
163
),
164
+ const SizedBox (height: 16 ),
160
165
CustomTextField (
161
166
controller: passwordController,
162
167
text: 'Password' ,
@@ -180,22 +185,18 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
180
185
? Icons .visibility_off
181
186
: Icons .visibility),
182
187
),
183
- autoValid:
184
- AutovalidateMode .onUserInteraction,
185
- ),
186
- const SizedBox (
187
- height: 16 ,
188
+ autoValid: AutovalidateMode .onUserInteraction,
188
189
),
190
+ const SizedBox (height: 16 ),
189
191
Align (
190
192
alignment: Alignment .bottomRight,
191
193
child: TextButton (
192
194
onPressed: () {
193
195
context.push ('/reset-password' );
194
196
},
195
197
style: ButtonStyle (
196
- overlayColor: WidgetStateProperty .all (
197
- Colors .transparent,
198
- ),
198
+ overlayColor:
199
+ WidgetStateProperty .all (Colors .transparent),
199
200
),
200
201
child: Text (
201
202
'Forgot Password?' ,
@@ -207,50 +208,27 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
207
208
),
208
209
),
209
210
),
210
- const SizedBox (
211
- height: 48 ,
212
- ),
211
+ const SizedBox (height: 48 ),
213
212
SizedBox (
214
213
width: double .infinity,
215
214
child: CustomElevatedButton (
216
215
isDesktop: true ,
217
216
onPressed: () {
218
- if (formKey.currentState!
219
- .validate ()) {
217
+ if (formKey.currentState! .validate ()) {
220
218
locator <LoginRegisterBloc >().add (
221
219
LoginWithEmailPressed (
222
220
email: emailController.text,
223
- password:
224
- passwordController.text,
225
- ),
226
- );
227
- } else {
228
- ScaffoldMessenger .of (context)
229
- .showSnackBar (
230
- SnackBar (
231
- content: Text (
232
- 'Please enter valid email and password' ,
233
- style: AppTextStyles .s14 (
234
- color: AppColor .appWhite,
235
- fontType: FontType .MEDIUM ,
236
- isDesktop: true ,
237
- ),
238
- ),
239
- backgroundColor:
240
- AppColor .appSecondary,
221
+ password: passwordController.text,
241
222
),
242
223
);
243
224
}
244
225
},
245
226
text: 'Login' ,
246
227
),
247
228
),
248
- const SizedBox (
249
- height: 26 ,
250
- ),
229
+ const SizedBox (height: 26 ),
251
230
Row (
252
- mainAxisAlignment:
253
- MainAxisAlignment .center,
231
+ mainAxisAlignment: MainAxisAlignment .center,
254
232
children: [
255
233
Text (
256
234
'Don\' t have an account?' ,
@@ -264,12 +242,6 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
264
242
onPressed: () {
265
243
context.push ('/register' );
266
244
},
267
- style: ButtonStyle (
268
- overlayColor:
269
- WidgetStateProperty .all (
270
- Colors .transparent,
271
- ),
272
- ),
273
245
child: Text (
274
246
'#' ,
275
247
style: AppTextStyles .s14 (
@@ -288,7 +260,7 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
288
260
),
289
261
),
290
262
),
291
- )
263
+ ),
292
264
],
293
265
),
294
266
),
0 commit comments