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'; import 'package:real_estate_mobile/features/auth/presentation/screens/twitter_login_screen.dart'; class SocialLoginButtons extends ConsumerWidget { final String? role; final String? agentTypeId; final String mode; const SocialLoginButtons({ super.key, this.role, this.agentTypeId, this.mode = 'signup', }); void _showComingSoon(BuildContext context) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('Coming soon'), duration: Duration(seconds: 1), behavior: SnackBarBehavior.floating, ), ); } Future _handleTwitterLogin(BuildContext context, WidgetRef ref) async { final result = await Navigator.push?>( context, MaterialPageRoute(builder: (_) => const TwitterLoginScreen()), ); if (result != null) { ref.read(authProvider.notifier).completeTwitterLogin( result, role: role, agentTypeId: agentTypeId, mode: mode, ); } } @override 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: isLoading ? null : () => _showComingSoon(context), child: const Icon( Icons.apple, size: 28, color: AppColors.primaryDark, ), ), const SizedBox(width: 32), // Google _SocialButton( onTap: isLoading ? null : () => ref.read(authProvider.notifier).signInWithGoogle( role: role, agentTypeId: agentTypeId, mode: mode, ), child: SvgPicture.asset( 'assets/icons/google.svg', width: 24, height: 24, ), ), const SizedBox(width: 32), // X (Twitter) _SocialButton( onTap: isLoading ? null : () => _handleTwitterLogin(context, ref), child: SvgPicture.asset( 'assets/icons/x.svg', width: 24, height: 24, ), ), const SizedBox(width: 32), // Facebook _SocialButton( onTap: isLoading ? null : () => ref.read(authProvider.notifier).signInWithFacebook( role: role, agentTypeId: agentTypeId, mode: mode, ), child: SvgPicture.asset( 'assets/icons/facebook.svg', width: 24, height: 24, ), ), ], ); } } class _SocialButton extends StatelessWidget { final VoidCallback? onTap; final Widget child; const _SocialButton({ required this.onTap, required this.child, }); @override Widget build(BuildContext context) { return GestureDetector( onTap: onTap, child: Opacity( opacity: onTap != null ? 1.0 : 0.5, child: SizedBox( width: 40, height: 40, child: Center(child: child), ), ), ); } }