import 'package:wanisdriver/Provider/language_provider.dart'; import 'package:wanisdriver/Screen/UpdateProfileScreen.dart'; import 'package:wanisdriver/widgets/custom_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_lucide/flutter_lucide.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; import '../Provider/authentification_provider.dart'; import '../Provider/utils_singleton.dart'; import '../Screen/AppSettingScreen.dart'; import '../Screen/MainScreen.dart'; import '../Screen/NavigationScreen.dart'; import '../Screen/Password/changePasswordFirstStepScreen.dart'; import '../Screen/Support.dart'; import '../Screen/privacyScreen.dart'; import '../Screen/vehicule_Screen.dart'; import '../config/constants/arabe.dart' as Language; import '../routes/app_routes.dart'; import '../services/ride_socket_service_manager.dart'; import '../utils/colors.dart'; import 'SettingsCard.dart'; class SettingsList extends StatefulWidget { const SettingsList({Key? key}) : super(key: key); @override _SettingsListState createState() => _SettingsListState(); } class _SettingsListState extends State { int selectedLanguageIndex = 1; // Default selection for Arabic @override Widget build(BuildContext context) { final isDarkMode = Theme.of(context).brightness == Brightness.dark; final auth = Provider.of(context, listen: false); final language = Provider.of(context); bool isArabic = language.currentLangCode == Language.ar; return ListView( padding: const EdgeInsets.symmetric(horizontal: 16.0), children: [ SettingsCard( icon: LucideIcons.circle_user_round, title: 'User Informations', onTap: () { Navigator.push( context, MaterialPageRoute(builder: (context) => const UpdateProfileScreen()), ); }, ), SettingsCard( icon: LucideIcons.car, title: 'Vehicle', onTap: () { Navigator.push( context, MaterialPageRoute(builder: (context) => const VehiculeScreen()), ); }, ), SettingsCard( icon: LucideIcons.map, title: 'Navigation', onTap: () { Navigator.push( context, MaterialPageRoute(builder: (context) => const Navigationscreen()), ); }, ), SettingsCard( icon: LucideIcons.settings, title: 'App Settings', onTap: () { Navigator.push( context, MaterialPageRoute(builder: (context) => const AppSettingScreen()), ); }, ), SettingsCard( icon: LucideIcons.phone, title: 'Contact Us', onTap: () { Navigator.push( context, MaterialPageRoute(builder: (context) => const Support()), ); }, ), SettingsCard( icon: LucideIcons.log_out, title: 'Logout', iconColor: Colors.red, onTap: () { _showLogoutBottomSheet(context, auth); }, ), SettingsCard( icon: LucideIcons.hash, title: "${language.translate("Referral Code :")} #${utils.user?.driver?.referralCode} ", trailing: Text("(${utils.user?.driver?.referralcount})"), ), ], ); } void _showLogoutBottomSheet(BuildContext context, auth) { final isDarkMode = Theme.of(context).brightness == Brightness.dark; showModalBottomSheet( context: context, isScrollControlled: true, backgroundColor: Colors.transparent, builder: (BuildContext context) { return Container( decoration: BoxDecoration( color: isDarkMode ? AppColors.blackBackgroundColor : Colors.white, borderRadius: const BorderRadius.only( topLeft: Radius.circular(30), topRight: Radius.circular(30), ), ), child: Padding( padding: const EdgeInsets.all(30), child: Column( mainAxisSize: MainAxisSize.min, children: [ // Drag handle Container( width: 40, height: 4, decoration: BoxDecoration( color: Colors.grey.shade300, borderRadius: BorderRadius.circular(2), ), ), const SizedBox(height: 30), // Icon with gradient background Container( width: 80, height: 80, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Colors.red.shade400, Colors.red.shade600, ], ), borderRadius: BorderRadius.circular(40), boxShadow: [ BoxShadow( color: Colors.red.shade200, blurRadius: 20, offset: const Offset(0, 8), ), ], ), child: const Icon( Icons.power_settings_new_rounded, size: 40, color: Colors.white, ), ), const SizedBox(height: 25), // Title Txt( text: languageSingleton.translate('Logout'), style: TextStyle( fontSize: 24, fontWeight: FontWeight.w700, fontFamily: 'Poppins', color: isDarkMode ? AppColors.white : const Color(0xFF1A202C), letterSpacing: -0.5, ), ), const SizedBox(height: 12), // Description Txt( text: languageSingleton.translate( 'You will be redirected to the login screen.\nMake sure you have saved your work.'), textAlign: TextAlign.center, style: TextStyle( fontSize: 14, fontFamily: 'Poppins', color: isDarkMode ? AppColors.darkSecondaryText : Colors.grey.shade600, height: 1.5, ), ), const SizedBox(height: 30), // Buttons Row( children: [ // Cancel Button Expanded( child: SizedBox( height: 50, child: OutlinedButton( onPressed: () { Navigator.of(context).pop(); }, style: OutlinedButton.styleFrom( foregroundColor: isDarkMode ? AppColors.white : Colors.grey.shade700, side: BorderSide( color: isDarkMode ? Colors.grey.shade700 : Colors.grey.shade300, width: 1.5, ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15), ), ), child: Txt( text: languageSingleton.translate('Cancel'), style: const TextStyle( fontSize: 15, fontWeight: FontWeight.w600, fontFamily: 'Poppins', ), ), ), ), ), const SizedBox(width: 15), // Logout Button Expanded( child: SizedBox( height: 50, child: ElevatedButton( onPressed: () async { print("Log Out -------------------------"); await auth.logOut(); await RideSocketServiceManager.stopService(); Get.offAllNamed(AppRoutes.login); }, style: ElevatedButton.styleFrom( backgroundColor: Colors.red.shade500, foregroundColor: Colors.white, elevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15), ), ), child: Txt( text: languageSingleton.translate('Logout'), style: const TextStyle( fontSize: 15, fontWeight: FontWeight.w700, fontFamily: 'Poppins', ), ), ), ), ), ], ), const SizedBox(height: 20), ], ), ), ); }, ); } }