Skip to content

Commit 6ff9809

Browse files
authored
Merge pull request #253 from Chalhotra/fix_google_button
Fixes google # button
2 parents 7d20365 + 03cd054 commit 6ff9809

File tree

6 files changed

+126
-100
lines changed

6 files changed

+126
-100
lines changed

assets/google_logo.png

10.4 KB
Loading

lib/gen/assets.gen.dart

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/presentation/authentication/desktop/#_view_desktop.dart

+51-79
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:flutter/material.dart';
22
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';
44
import 'package:go_router/go_router.dart';
55
import 'package:monumento/application/authentication/#_register/#_register_bloc.dart';
66
import 'package:monumento/gen/assets.gen.dart';
@@ -39,6 +39,7 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
3939
@override
4040
Widget build(BuildContext context) {
4141
return Scaffold(
42+
backgroundColor: AppColor.appBackground,
4243
body: SingleChildScrollView(
4344
child: ConstrainedBox(
4445
constraints: BoxConstraints(
@@ -58,17 +59,14 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
5859
children: [
5960
const SizedBox(height: 24),
6061
Assets.desktop.logoDesktop.svg(width: 220),
61-
const SizedBox(
62-
height: 24,
63-
),
62+
const SizedBox(height: 24),
6463
Center(
6564
child: Card(
6665
child: Container(
6766
padding: const EdgeInsets.symmetric(
6867
horizontal: 32, vertical: 50),
6968
width: 380,
70-
child: BlocListener<LoginRegisterBloc,
71-
LoginRegisterState>(
69+
child: BlocListener<LoginRegisterBloc, LoginRegisterState>(
7270
bloc: locator<LoginRegisterBloc>(),
7371
listener: (context, state) {
7472
if (state is LoginFailed) {
@@ -85,13 +83,12 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
8583
),
8684
),
8785
backgroundColor: AppColor.appWarningRed,
88-
behavior: SnackBarBehavior.floating,
86+
behavior: SnackBarBehavior.floating,
8987
),
9088
);
9189
}
9290
},
93-
child: BlocBuilder<LoginRegisterBloc,
94-
LoginRegisterState>(
91+
child: BlocBuilder<LoginRegisterBloc, LoginRegisterState>(
9592
bloc: locator<LoginRegisterBloc>(),
9693
builder: (context, state) {
9794
if (state is LoginRegisterLoading) {
@@ -112,23 +109,35 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
112109
context.pushReplacement('/');
113110
}
114111
}
112+
115113
return Column(
116114
children: [
117115
SizedBox(
118116
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,
122133
onPressed: () {
123-
locator<LoginRegisterBloc>().add(
124-
LoginWithGooglePressed(),
125-
);
134+
locator<LoginRegisterBloc>()
135+
.add(LoginWithGooglePressed());
126136
},
137+
text: '# With Google',
127138
),
128139
),
129-
const SizedBox(
130-
height: 22,
131-
),
140+
const SizedBox(height: 22),
132141
const Text(
133142
'Or',
134143
style: TextStyle(
@@ -137,26 +146,22 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
137146
fontWeight: FontWeight.w400,
138147
),
139148
),
140-
const SizedBox(
141-
height: 22,
142-
),
149+
const SizedBox(height: 22),
143150
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,
159163
),
164+
const SizedBox(height: 16),
160165
CustomTextField(
161166
controller: passwordController,
162167
text: 'Password',
@@ -180,22 +185,18 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
180185
? Icons.visibility_off
181186
: Icons.visibility),
182187
),
183-
autoValid:
184-
AutovalidateMode.onUserInteraction,
185-
),
186-
const SizedBox(
187-
height: 16,
188+
autoValid: AutovalidateMode.onUserInteraction,
188189
),
190+
const SizedBox(height: 16),
189191
Align(
190192
alignment: Alignment.bottomRight,
191193
child: TextButton(
192194
onPressed: () {
193195
context.push('/reset-password');
194196
},
195197
style: ButtonStyle(
196-
overlayColor: WidgetStateProperty.all(
197-
Colors.transparent,
198-
),
198+
overlayColor:
199+
WidgetStateProperty.all(Colors.transparent),
199200
),
200201
child: Text(
201202
'Forgot Password?',
@@ -207,50 +208,27 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
207208
),
208209
),
209210
),
210-
const SizedBox(
211-
height: 48,
212-
),
211+
const SizedBox(height: 48),
213212
SizedBox(
214213
width: double.infinity,
215214
child: CustomElevatedButton(
216215
isDesktop: true,
217216
onPressed: () {
218-
if (formKey.currentState!
219-
.validate()) {
217+
if (formKey.currentState!.validate()) {
220218
locator<LoginRegisterBloc>().add(
221219
LoginWithEmailPressed(
222220
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,
241222
),
242223
);
243224
}
244225
},
245226
text: 'Login',
246227
),
247228
),
248-
const SizedBox(
249-
height: 26,
250-
),
229+
const SizedBox(height: 26),
251230
Row(
252-
mainAxisAlignment:
253-
MainAxisAlignment.center,
231+
mainAxisAlignment: MainAxisAlignment.center,
254232
children: [
255233
Text(
256234
'Don\'t have an account?',
@@ -264,12 +242,6 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
264242
onPressed: () {
265243
context.push('/register');
266244
},
267-
style: ButtonStyle(
268-
overlayColor:
269-
WidgetStateProperty.all(
270-
Colors.transparent,
271-
),
272-
),
273245
child: Text(
274246
'#',
275247
style: AppTextStyles.s14(
@@ -288,7 +260,7 @@ class _LoginViewDesktopState extends State<LoginViewDesktop> {
288260
),
289261
),
290262
),
291-
)
263+
),
292264
],
293265
),
294266
),

lib/presentation/authentication/desktop/widgets/sign_up_decider_widget.dart

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_signin_button/flutter_signin_button.dart';
2+
import 'package:flutter_screenutil/flutter_screenutil.dart';
33
import 'package:go_router/go_router.dart';
4+
import 'package:monumento/gen/assets.gen.dart';
45
import 'package:monumento/utils/app_colors.dart';
56
import 'package:monumento/utils/app_text_styles.dart';
67
import 'package:monumento/utils/constants.dart';
@@ -25,11 +26,24 @@ class _#DeciderWidgetState extends State<#DeciderWidget> {
2526
children: [
2627
SizedBox(
2728
width: double.infinity,
28-
child: SignInButton(
29-
padding: const EdgeInsets.all(4),
30-
Buttons.Google,
31-
text: '# with Google',
32-
onPressed: widget.on#WithGooglePressed,
29+
child: SizedBox(
30+
width: double.infinity,
31+
child: CustomElevatedButton(
32+
isDesktop: true,
33+
onPressed: widget.on#WithGooglePressed,
34+
style: ElevatedButton.styleFrom(
35+
foregroundColor: AppColor.appBlack,
36+
backgroundColor: AppColor.appWhite, // Text and icon color
37+
elevation: 2, // Shadow
38+
padding: EdgeInsets.symmetric(
39+
horizontal: 16, vertical: 12), // Padding
40+
shape: RoundedRectangleBorder(
41+
borderRadius: BorderRadius.circular(4), // Border radius
42+
),
43+
),
44+
leading: SizedBox(height: 28.h, child: Assets.googleLogo.image()),
45+
text: '# with Google',
46+
),
3347
),
3448
),
3549
const SizedBox(

lib/presentation/authentication/mobile/#_view_mobile.dart

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
3+
import 'package:flutter_screenutil/flutter_screenutil.dart';
34
import 'package:flutter_signin_button/button_list.dart';
45
import 'package:flutter_signin_button/button_view.dart';
56
import 'package:go_router/go_router.dart';
@@ -105,14 +106,30 @@ class _LoginViewMobileState extends State<LoginViewMobile> {
105106
children: [
106107
SizedBox(
107108
width: double.infinity,
108-
child: SignInButton(
109-
padding: const EdgeInsets.all(4),
110-
Buttons.Google,
109+
child: CustomElevatedButton(
110+
style: ElevatedButton.styleFrom(
111+
foregroundColor: AppColor.appBlack,
112+
backgroundColor: AppColor
113+
.appWhite, // Text and icon color
114+
elevation: 2, // Shadow
115+
padding: EdgeInsets.symmetric(
116+
horizontal: 16,
117+
vertical: 12), // Padding
118+
shape: RoundedRectangleBorder(
119+
borderRadius: BorderRadius.circular(
120+
4), // Border radius
121+
),
122+
),
123+
leading: SizedBox(
124+
height: 28.h,
125+
child: Assets.googleLogo.image(),
126+
),
127+
isDesktop: true,
111128
onPressed: () {
112-
locator<LoginRegisterBloc>().add(
113-
LoginWithGooglePressed(),
114-
);
129+
locator<LoginRegisterBloc>()
130+
.add(LoginWithGooglePressed());
115131
},
132+
text: '# With Google',
116133
),
117134
),
118135
const SizedBox(

0 commit comments

Comments
 (0)