2026-02-23 19:23:30 +05:30
|
|
|
import 'package:flutter/material.dart';
|
2026-03-26 00:07:31 +05:30
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2026-02-23 19:23:30 +05:30
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
2026-03-26 00:07:31 +05:30
|
|
|
import 'package:real_estate_mobile/features/auth/presentation/providers/auth_provider.dart';
|
2026-02-23 19:23:30 +05:30
|
|
|
|
2026-03-26 00:07:31 +05:30
|
|
|
class SocialLoginButtons extends ConsumerWidget {
|
2026-02-23 19:23:30 +05:30
|
|
|
const SocialLoginButtons({super.key});
|
|
|
|
|
|
|
|
|
|
void _showComingSoon(BuildContext context) {
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
const SnackBar(
|
|
|
|
|
content: Text('Coming soon'),
|
|
|
|
|
duration: Duration(seconds: 1),
|
|
|
|
|
behavior: SnackBarBehavior.floating,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
2026-03-26 00:07:31 +05:30
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
|
final authState = ref.watch(authProvider);
|
|
|
|
|
final isLoading = authState.status == AuthStatus.loading;
|
|
|
|
|
|
2026-02-23 19:23:30 +05:30
|
|
|
return Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
// Apple
|
|
|
|
|
_SocialButton(
|
2026-03-26 00:07:31 +05:30
|
|
|
onTap: isLoading ? null : () => _showComingSoon(context),
|
2026-02-23 19:23:30 +05:30
|
|
|
child: const Icon(
|
|
|
|
|
Icons.apple,
|
|
|
|
|
size: 28,
|
|
|
|
|
color: AppColors.primaryDark,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 32),
|
|
|
|
|
// Google
|
|
|
|
|
_SocialButton(
|
2026-03-26 00:07:31 +05:30
|
|
|
onTap: isLoading
|
|
|
|
|
? null
|
|
|
|
|
: () => ref.read(authProvider.notifier).signInWithGoogle(),
|
2026-02-23 19:23:30 +05:30
|
|
|
child: SvgPicture.asset(
|
|
|
|
|
'assets/icons/google.svg',
|
|
|
|
|
width: 24,
|
|
|
|
|
height: 24,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 32),
|
|
|
|
|
// X (Twitter)
|
|
|
|
|
_SocialButton(
|
2026-03-26 00:07:31 +05:30
|
|
|
onTap: isLoading
|
|
|
|
|
? null
|
|
|
|
|
: () => ref.read(authProvider.notifier).signInWithTwitter(),
|
2026-02-23 19:23:30 +05:30
|
|
|
child: SvgPicture.asset(
|
|
|
|
|
'assets/icons/x.svg',
|
|
|
|
|
width: 24,
|
|
|
|
|
height: 24,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 32),
|
|
|
|
|
// Facebook
|
|
|
|
|
_SocialButton(
|
2026-03-26 00:07:31 +05:30
|
|
|
onTap: isLoading
|
|
|
|
|
? null
|
|
|
|
|
: () => ref.read(authProvider.notifier).signInWithFacebook(),
|
2026-02-23 19:23:30 +05:30
|
|
|
child: SvgPicture.asset(
|
|
|
|
|
'assets/icons/facebook.svg',
|
|
|
|
|
width: 24,
|
|
|
|
|
height: 24,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _SocialButton extends StatelessWidget {
|
2026-03-26 00:07:31 +05:30
|
|
|
final VoidCallback? onTap;
|
2026-02-23 19:23:30 +05:30
|
|
|
final Widget child;
|
|
|
|
|
|
|
|
|
|
const _SocialButton({
|
|
|
|
|
required this.onTap,
|
|
|
|
|
required this.child,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: onTap,
|
2026-03-26 00:07:31 +05:30
|
|
|
child: Opacity(
|
|
|
|
|
opacity: onTap != null ? 1.0 : 0.5,
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
width: 40,
|
|
|
|
|
height: 40,
|
|
|
|
|
child: Center(child: child),
|
|
|
|
|
),
|
2026-02-23 19:23:30 +05:30
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|