feat: implement social login functionality with Google, Facebook, and Twitter, including API integration and platform-specific configurations.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
||||
import 'package:real_estate_mobile/features/auth/presentation/providers/auth_provider.dart';
|
||||
|
||||
class SocialLoginButtons extends StatelessWidget {
|
||||
class SocialLoginButtons extends ConsumerWidget {
|
||||
const SocialLoginButtons({super.key});
|
||||
|
||||
void _showComingSoon(BuildContext context) {
|
||||
@@ -16,13 +18,16 @@ class SocialLoginButtons extends StatelessWidget {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final authState = ref.watch(authProvider);
|
||||
final isLoading = authState.status == AuthStatus.loading;
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// Apple
|
||||
_SocialButton(
|
||||
onTap: () => _showComingSoon(context),
|
||||
onTap: isLoading ? null : () => _showComingSoon(context),
|
||||
child: const Icon(
|
||||
Icons.apple,
|
||||
size: 28,
|
||||
@@ -32,7 +37,9 @@ class SocialLoginButtons extends StatelessWidget {
|
||||
const SizedBox(width: 32),
|
||||
// Google
|
||||
_SocialButton(
|
||||
onTap: () => _showComingSoon(context),
|
||||
onTap: isLoading
|
||||
? null
|
||||
: () => ref.read(authProvider.notifier).signInWithGoogle(),
|
||||
child: SvgPicture.asset(
|
||||
'assets/icons/google.svg',
|
||||
width: 24,
|
||||
@@ -42,7 +49,9 @@ class SocialLoginButtons extends StatelessWidget {
|
||||
const SizedBox(width: 32),
|
||||
// X (Twitter)
|
||||
_SocialButton(
|
||||
onTap: () => _showComingSoon(context),
|
||||
onTap: isLoading
|
||||
? null
|
||||
: () => ref.read(authProvider.notifier).signInWithTwitter(),
|
||||
child: SvgPicture.asset(
|
||||
'assets/icons/x.svg',
|
||||
width: 24,
|
||||
@@ -52,7 +61,9 @@ class SocialLoginButtons extends StatelessWidget {
|
||||
const SizedBox(width: 32),
|
||||
// Facebook
|
||||
_SocialButton(
|
||||
onTap: () => _showComingSoon(context),
|
||||
onTap: isLoading
|
||||
? null
|
||||
: () => ref.read(authProvider.notifier).signInWithFacebook(),
|
||||
child: SvgPicture.asset(
|
||||
'assets/icons/facebook.svg',
|
||||
width: 24,
|
||||
@@ -65,7 +76,7 @@ class SocialLoginButtons extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _SocialButton extends StatelessWidget {
|
||||
final VoidCallback onTap;
|
||||
final VoidCallback? onTap;
|
||||
final Widget child;
|
||||
|
||||
const _SocialButton({
|
||||
@@ -77,10 +88,13 @@ class _SocialButton extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: SizedBox(
|
||||
width: 40,
|
||||
height: 40,
|
||||
child: Center(child: child),
|
||||
child: Opacity(
|
||||
opacity: onTap != null ? 1.0 : 0.5,
|
||||
child: SizedBox(
|
||||
width: 40,
|
||||
height: 40,
|
||||
child: Center(child: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user