Modified SignInButton for Google and Apple login options in the login page

This commit is contained in:
Van Leemput Dayron
2025-11-03 01:47:36 +01:00
parent de52dae0f4
commit 882f7c8963
3 changed files with 62 additions and 111 deletions

View File

@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import '../blocs/auth/auth_bloc.dart';
import '../blocs/auth/auth_event.dart';
import '../blocs/auth/auth_state.dart';
import 'package:sign_in_button/sign_in_button.dart';
/// Login page widget for user authentication.
///
@@ -73,11 +74,11 @@ class _LoginPageState extends State<LoginPage> {
}
context.read<AuthBloc>().add(
AuthSignInRequested(
email: _emailController.text.trim(),
password: _passwordController.text,
),
);
AuthSignInRequested(
email: _emailController.text.trim(),
password: _passwordController.text,
),
);
}
@override
@@ -187,13 +188,25 @@ class _LoginPageState extends State<LoginPage> {
child: ElevatedButton(
onPressed: isLoading ? null : () => _login(context),
style: ElevatedButton.styleFrom(
backgroundColor:
Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black,
foregroundColor:
Theme.of(context).brightness == Brightness.dark
? Colors.black
: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: isLoading
? const CircularProgressIndicator(
color: Colors.white,
? CircularProgressIndicator(
color:
Theme.of(context).brightness ==
Brightness.dark
? Colors.black
: Colors.white,
)
: const Text(
'Se connecter',
@@ -236,104 +249,25 @@ class _LoginPageState extends State<LoginPage> {
const SizedBox(height: 20),
// Social login buttons
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Google
Column(
children: [
GestureDetector(
onTap: isLoading
? null
: () {
context
.read<AuthBloc>()
.add(AuthGoogleSignInRequested());
},
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.grey.withValues(alpha: 0.3),
spreadRadius: 1,
blurRadius: 3,
offset: const Offset(0, 1),
),
],
border: Border.all(
color: Colors.grey.shade300,
width: 1,
),
),
child: Center(
child: Image.asset(
'assets/icons/google.png',
width: 24,
height: 24,
),
),
),
),
const SizedBox(height: 8),
const Text('Google'),
],
),
const SizedBox(width: 40),
// Apple
Column(
children: [
GestureDetector(
onTap: isLoading
? null
: () {
context
.read<AuthBloc>()
.add(AuthAppleSignInRequested());
},
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.grey.withValues(alpha: 0.3),
spreadRadius: 1,
blurRadius: 3,
offset: const Offset(0, 1),
),
],
border: Border.all(
color: Colors.grey.shade300,
width: 1,
),
),
child: Center(
child: Image.asset(
'assets/icons/apple_white.png',
width: 24,
height: 24,
color: Colors.white,
),
),
),
),
const SizedBox(height: 8),
const Text('Apple'),
],
),
],
SignInButton(
Buttons.google,
onPressed: () {
context.read<AuthBloc>().add(
AuthGoogleSignInRequested(),
);
},
),
const SizedBox(height: 40),
const SizedBox(height: 16),
SignInButton(
Buttons.apple,
onPressed: () {
context.read<AuthBloc>().add(
AuthAppleSignInRequested(),
);
},
),
],
),
),

View File

@@ -376,6 +376,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
font_awesome_flutter:
dependency: transitive
description:
name: font_awesome_flutter
sha256: b9011df3a1fa02993630b8fb83526368cf2206a711259830325bab2f1d2a4eb0
url: "https://pub.dev"
source: hosted
version: "10.12.0"
geoclue:
dependency: transitive
description:
@@ -944,6 +952,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.1"
sign_in_button:
dependency: "direct main"
description:
name: sign_in_button
sha256: "7bcd5e3ca5f80578da6a92b8749badf4003cf4dc578b5cb737b9082871354ff8"
url: "https://pub.dev"
source: hosted
version: "4.0.1"
sign_in_with_apple:
dependency: "direct main"
description:

View File

@@ -56,6 +56,7 @@ dependencies:
firebase_storage: ^13.0.3
url_launcher: ^6.3.2
sign_in_with_apple: ^7.0.1
sign_in_button: ^4.0.1
dev_dependencies:
flutter_launcher_icons: ^0.13.1