diff --git a/l10n.yaml b/l10n.yaml new file mode 100644 index 00000000..42544565 --- /dev/null +++ b/l10n.yaml @@ -0,0 +1,3 @@ +arb-dir: lib/l10n +template-arb-file: intl_en.arb +output-localization-file: app_localizations.dart diff --git a/lib/l10n/intl_ar.arb b/lib/l10n/intl_ar.arb new file mode 100644 index 00000000..e01858b5 --- /dev/null +++ b/lib/l10n/intl_ar.arb @@ -0,0 +1,86 @@ +{ + "feedback_title": "نموذج الملاحظات", + "feedback_failed_msg": "لم يتم إرسال تعليقاتك. يرجى المحاولة مرة أخرى", + + "guide_title": "نموذج الملاحظات", + + "register_title": "التسجيل", + "register_details": "من فضلك ادخل بياناتك", + "register_name": "اسم المستخدم", + "email_id": "الاسم الكامل", + "enter_name": "أدخل الاسم", + "register_email": "أدخل بريدك الإلكتروني", + "register_password": "دخل كلمة المرور", + "register_Confirm_password": "أكيد كلمة المرو", + "agree": " وافق على", + "t_and": "و ", + "conditions": " الخاصة بالمركز الاتحادي للتنافسية والإحصاء", + "terms_conditions": "الشروط والأحكام ", + "privacy_policy":" وسياسة الخصوصية", + "account_confirmation": "ل لديك حساب؟ سجل الدخول ", + "login_title": "سجيل الدخول", + + "profile_title": "نموذج الملاحظات", + "my_profile": "ملفي الشخصي", + "logout": "تسجيل الخروج", + "full_name": "الاسم الكامل", + "dob": "تاريخ الميلاد", + "region": "الدولة/المنطقة", + "cancel": "إلغاء", + "confirm": "تأكيد", + "change_password": "تغيير كلمة المرور", + "sure_save_page": " هل أنت متأكد أنك ترغب في حفظ هذه الصفحة؟", + "not_able_to_change": " بمجرد الحفظ، لن تتمكن من تعديل اسمك أو تاريخ ", + "save": "يحفظ", + "name": "اسم", + + + "nav_home": "الصفحة الرئيسية", + "nav_uae": "أرقام الإمارات", + "nav_competitiveness": "القدرة التنافسية", + "country_profile": "ملف تعريف الدولة", + + + "agree_terms_conditions": "يرجى الموافقة على الشروط والأحكام.", + "retry":"Retry", + "select": "يختار", + "email_exists": "البريد الإلكتروني موجود", + "email_exists_msg": "معرف البريد الإلكتروني موجود بالفعل. الرجاء استخدام بريد إلكتروني مختلف.", + "email_invalid": "البريد الإلكتروني غير صالح أو قيد الاستخدام بالفعل.", + "required": "مطلوب", + "only40charac": "يجب ألا يتجاوز 40 حرفًا", + "invalid_characters": "أحرف غير صالحة", + "invalid_email": "البريد الإلكتروني غير صالح", + "password_invalid": "تحتوي كلمة المرور على أحرف غير صالحة", + "password_match": "كلمات المرور غير متطابقة", + "only8charac": "يجب أن تتكون كلمة المرور من 8 أحرف على الأقل", + + "manage_user": "دارة المستخدمين", + "user_name": "اسم المستخدم", + "reg_date": "تاريخ التسجيل", + "status": "تمت الموافقة", + "denied": "مرفوض", + "pending": "يد الانتظار", + "approve_msg": "هل أنت متأكد أنك ترغب في تغيير الحالة إلى \"{newStatus}\"؟", + "yes": "نعم", + "no": "لا", + "no_result_found": "لم يتم العثور على نتائج", + "search": "يبحث", + "approved": "موافقة", + + "create_new_password": "إنشاء كلمة مرور جديدة", + "different_password": "يجب أن تكون كلمة المرور الجديدة مختلفة عن كلمة المرور المستخدمة سابقًا.", + "old_password": "كلمة المرور القديمة", + "enter_new_password": "أدخل كلمة المرور الجديدة", + "confirm_new_password": "تأكيد كلمة المرور الجديدة", + "password_changed_successfully": "م تغيير كلمة المرور بنجاح", + "enter_old_password": "أدخل كلمة المرور القديمة", + "your_old_password_incorrect": "كلمة المرور القديمة الخاصة بك غير صحيحة.", + "failed_to_update_password": "", + "password_update_successfully": "تم تحديث كلمة المرور بنجاح.", + "new_password_not_same_as_old": "كلمة المرور الجديدة يجب ألا تكون نفس كلمة المرور القديمة", + "password_between_8_to_40": "يجب أن تتراوح كلمة المرور بين 8 و64 حرفًا", + "new_password_required": "كلمة المرور الجديدة مطلوبة", + "old_password_is_required": "كلمة المرور القديمة مطلوبة", + "confirm_password_is_required": "تأكيد كلمة المرور مطلوب" + } \ No newline at end of file diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb new file mode 100644 index 00000000..5b58e7ce --- /dev/null +++ b/lib/l10n/intl_en.arb @@ -0,0 +1,87 @@ +{ + + + "feedback_title": "FeedBack", + "feedback_failed_msg": "Your feedback could not be submitted. Please try again", + + "register_title": "Register", + "register_details": "Please enter your details", + "register_name": "Username", + "email_id": "Email ID", + "enter_name": "Enter your User Name", + "register_email": "Enter your email", + "register_password": "Enter your password", + "register_Confirm_password": "Confirm password", + "agree": "I agree to ", + "t_and": "and", + "conditions": " of Fcsc", + "terms_conditions": "terms & conditions", + "privacy_policy":"privacy policy", + "account_confirmation": "Already have an account? Login", + "login_title": "Login", + + "profile_title": "Edit Profile", + "my_profile": "My Profile", + "logout": "Logout", + "full_name": "Full Name*", + "dob": "Date of Birth*", + "region": "Country/Region", + "cancel": "Cancel", + "confirm": "Confirm", + "change_password": "Change Password", + "sure_save_page": "Are you sure you want to save this page? ", + "not_able_to_change": "Once saved, you will not be able to change your ", + "save": "Save", + "name": "Name", + + + "guide_title": "User Guide", + + "nav_home": "HOME", + "nav_uae": "UAE Numbers", + "nav_competitiveness": "Competitiveness", + "country_profile": "Country Profile", + + "agree_terms_conditions": "Please agree to terms and conditions.", + "retry": "Retry", + "select": "Select", + "email_exists": "Email exists", + "email_exists_msg": "Email ID already exists. Please use a different email.", + "email_invalid": "The email is invalid or already in use.", + "required": "Required", + "only40charac": "Must not exceed 40 characters", + "invalid_characters": "Invalid Characters", + "invalid_email": "Invalid Email", + "password_invalid": "Password contains invalid characters", + "password_match": "Passwords do not match", + "only8charac": "Password must be at least 8characters", + + "manage_user": "Manage user", + "user_name": "User Name", + "reg_date": "Registration Date", + "status": "Status", + "denied": "Denied", + "pending": "Pending", + "approved": "Approved", + "approve_msg": "Are you sure you want to change the status to {newStatus}?", + "yes": "Yes", + "no": "No", + "no_result_found": "No results found", + "search": "Search", + + "create_new_password": "Create New Password", + "different_password": "Your New Password Must Be Different form Previously Used Password", + "old_password": "Old Password", + "enter_new_password": "Enter new password", + "confirm_new_password": "Confirm new password", + "password_changed_successfully": "Password Changed Successfully", + "enter_old_password": "Enter old Password", + "your_old_password_incorrect": "Your old password is incorrect.", + "failed_to_update_password": "", + "password_update_successfully": "Password updated successfully.", + "new_password_not_same_as_old": "New password must not be the same as the old password", + "password_between_8_to_40": "Password must be between 8 and 64 characters", + "new_password_required": "New password is required", + "old_password_is_required": "Old password is required", + "confirm_password_is_required": "Confirm password is required" +} diff --git a/lib/main.dart b/lib/main.dart index a388e49b..4500ffd5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,6 +10,8 @@ import 'package:uae_stat/domain/entities/language_locale.dart'; import 'package:uae_stat/domain/use_cases/auth_use_case.dart'; import 'package:uae_stat/presentation/Screens/profilepage.dart'; import 'package:uae_stat/presentation/Screens/auth_verification/registration.dart'; +import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -22,14 +24,19 @@ void main() async { ); } -class MainApp extends StatelessWidget { +class MainApp extends ConsumerWidget { const MainApp({super.key}); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { + final locale = ref.watch(localeProvider); + return MaterialApp.router( debugShowCheckedModeBanner: false, - routerConfig: router, // Use the GoRouter instance from app_router.dart + routerConfig: router, + locale: locale, + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales,// Use the GoRouter instance from app_router.dart ); } } diff --git a/lib/presentation/Screens/auth_verification/create_new_pw.dart b/lib/presentation/Screens/auth_verification/create_new_pw.dart index 1d0ddbda..1fa3a802 100644 --- a/lib/presentation/Screens/auth_verification/create_new_pw.dart +++ b/lib/presentation/Screens/auth_verification/create_new_pw.dart @@ -6,6 +6,7 @@ import 'package:uae_stat/config/my_router.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/presentation/Screens/profilepage.dart'; import 'package:uae_stat/presentation/components/space.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import '../../../config/my_theme.dart'; @@ -206,7 +207,8 @@ class _CreateNewPwState extends State { children: [ SizedBox(height: screenHeight / 6), Text( - "Create New Password", + // "Create New Password", + AppLocalizations.of(context)!.create_new_password, style: TextStyle( fontSize: 24, fontWeight: FontWeight.bold, @@ -216,7 +218,8 @@ class _CreateNewPwState extends State { TextFormField( obscureText: _obscureOldPassword, decoration: InputDecoration( - hintText: 'Enter old password', + // hintText: 'Enter old password', + hintText: AppLocalizations.of(context)!.old_password, prefixIcon: Icon(Icons.lock, color: Colors.blue), suffixIcon: IconButton( icon: Icon( @@ -240,7 +243,8 @@ class _CreateNewPwState extends State { TextFormField( obscureText: _obscureNewPassword, decoration: InputDecoration( - hintText: 'Enter new password', + // hintText: 'Enter new password', + hintText: AppLocalizations.of(context)!.enter_new_password, prefixIcon: Icon(Icons.lock, color: Colors.blue), suffixIcon: IconButton( icon: Icon( @@ -263,7 +267,8 @@ class _CreateNewPwState extends State { TextFormField( obscureText: _obscureConfirmPassword, decoration: InputDecoration( - hintText: 'Confirm new password', + // hintText: 'Confirm new password', + hintText: AppLocalizations.of(context)!.confirm_new_password, prefixIcon: Icon(Icons.lock, color: Colors.blue), suffixIcon: IconButton( icon: Icon( @@ -306,7 +311,7 @@ class _CreateNewPwState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - "Save", + AppLocalizations.of(context)!.save, style: TextStyle(fontSize: 18, color: Colors.white), ), SizedBox(width: 2), @@ -348,7 +353,8 @@ class _CreateNewPwState extends State { Icon(Icons.check_circle_outlined, color: Color(0xFF8AC681), size: 80), SizedBox(height: 20), Text( - "Password Changed Successfully", + // "Password Changed Successfully", + AppLocalizations.of(context)!.password_changed_successfully, textAlign: TextAlign.center, style: TextStyle( fontSize: 16, diff --git a/lib/presentation/Screens/auth_verification/registration.dart b/lib/presentation/Screens/auth_verification/registration.dart index 7c7f207b..2683cde7 100644 --- a/lib/presentation/Screens/auth_verification/registration.dart +++ b/lib/presentation/Screens/auth_verification/registration.dart @@ -1,11 +1,15 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:pocketbase/pocketbase.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/presentation/Screens/profilepage.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; +import '../../components/my_toggle.dart'; import '../../routes/auth_routes/login_route.dart'; class RegisterScreen extends StatefulWidget { @@ -288,6 +292,32 @@ class _RegisterScreenState extends State { } return Scaffold( + appBar: AppBar( + actions: [ + Consumer( + builder: (context, ref, _) { + final locale = ref.watch(localeProvider); // Current locale + return + MyToggle(isOn: locale?.languageCode == 'en', + knobTextWhenOn: 'ع', + knobTextWhenOff: 'EN', + pathColorWhenOn: Colors.grey.shade300, + pathColorWhenOff: Colors.grey.shade300, + onTap: (){ + ref.read(localeProvider.notifier).toggleLocale(); + },); + // IconButton( + // icon: Icon(locale?.languageCode == 'en' + // ? Icons.toggle_off_outlined + // : Icons.toggle_on_outlined,), + // onPressed: () { + // ref.read(localeProvider.notifier).toggleLocale(); + // }, + // ); + }, + ), + ], + ), backgroundColor: Colors.white, body: registrationSuccess ? Padding( @@ -407,12 +437,13 @@ class _RegisterScreenState extends State { children: [ SizedBox(height: screenheight / 15), Text( - 'Register', + // 'Register', + AppLocalizations.of(context)!.register_title, style: TextStyle( fontSize: 32, fontWeight: FontWeight.w400), ), SizedBox(height: 10), - Text('Please enter your details'), + Text(AppLocalizations.of(context)!.register_details), SizedBox(height: 20), // Display this if registration is pending approval @@ -420,7 +451,8 @@ class _RegisterScreenState extends State { controller: _usernameController, focusNode: _focusNodes[0], decoration: InputDecoration( - hintText: _showHints[0] ? 'Username' : null, + // hintText: _showHints[0] ? 'Username' : null, + hintText: _showHints[0] ? AppLocalizations.of(context)!.register_name : null, prefixIcon: Icon( Icons.person, color: Colors.blue, @@ -440,7 +472,8 @@ class _RegisterScreenState extends State { decoration: InputDecoration( // hintText: 'Enter your email', hintText: - _showHints[1] ? 'Enter your email' : null, + _showHints[1] ? AppLocalizations.of(context)!.register_email : null, + // _showHints[1] ? 'Enter your email' : null, prefixIcon: Icon( Icons.email, color: Colors.blue, @@ -463,7 +496,8 @@ class _RegisterScreenState extends State { obscureText: _obscurePassword, decoration: InputDecoration( hintText: - _showHints[2] ? 'Enter your password' : null, + _showHints[2] ? AppLocalizations.of(context)!.register_password : null, + // _showHints[2] ? 'Enter your password' : null, prefixIcon: Icon( Icons.lock, color: Colors.blue, @@ -495,7 +529,8 @@ class _RegisterScreenState extends State { obscureText: _obscureConfirmPassword, decoration: InputDecoration( hintText: - _showHints[3] ? 'Confirm password' : null, + _showHints[3] ? AppLocalizations.of(context)!.register_Confirm_password : null, + // _showHints[3] ? 'Confirm password' : null, prefixIcon: Icon( Icons.lock, color: Colors.blue, @@ -544,17 +579,20 @@ class _RegisterScreenState extends State { Expanded( child: Text.rich( TextSpan( - text: 'I agree to ', + text: AppLocalizations.of(context)!.agree, + // text: 'I agree to ', children: [ TextSpan( - text: 'Terms & Conditions', + text: AppLocalizations.of(context)!.terms_conditions, + // text: 'Terms & Conditions', style: TextStyle(color: Colors.blue), ), - TextSpan(text: ' and '), + TextSpan(text: AppLocalizations.of(context)!.t_and), TextSpan( - text: 'Privacy Policy', + text: AppLocalizations.of(context)!.privacy_policy, style: TextStyle(color: Colors.blue), ), + TextSpan(text: AppLocalizations.of(context)!.conditions), ], ), ), @@ -593,7 +631,8 @@ class _RegisterScreenState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - "Register", + // "Register", + AppLocalizations.of(context)!.register_title, style: TextStyle( fontSize: 16, color: Colors.white), ), @@ -606,7 +645,7 @@ class _RegisterScreenState extends State { ), SizedBox(height: 10), Text( - "Already have an account?", + AppLocalizations.of(context)!.account_confirmation, style: TextStyle( fontSize: 16, color: Colors.grey[600]), ), @@ -628,7 +667,7 @@ class _RegisterScreenState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - "Login", + AppLocalizations.of(context)!.login_title, style: TextStyle( fontSize: 16, color: Colors.white), ), diff --git a/lib/presentation/components/indicators/locale_provider.dart b/lib/presentation/components/indicators/locale_provider.dart new file mode 100644 index 00000000..45ef764b --- /dev/null +++ b/lib/presentation/components/indicators/locale_provider.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + + +class LocaleNotifier extends StateNotifier { + LocaleNotifier() : super(const Locale('en')); // Default locale is English + + /// Toggles between English and Arabic + void toggleLocale() { + state = (state == const Locale('en')) ? const Locale('ar') : const Locale('en'); + } + + + void setLocale(Locale locale) { + state = locale; + } +} + +final localeProvider = StateNotifierProvider( + (ref) => LocaleNotifier(), +); diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart b/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart index f87edba9..e21aca1b 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart @@ -10,7 +10,7 @@ import 'package:image_picker/image_picker.dart'; import 'package:intl/intl.dart'; import 'package:pocketbase/pocketbase.dart'; import 'package:shared_preferences/shared_preferences.dart'; - +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import '../../../Screens/auth_verification/changepassword.dart'; import '../custom_drawer_routes.dart'; @@ -402,7 +402,7 @@ class _EditProfileState extends State { @override Widget build(BuildContext context) { return BaseScaffold( - title: Text("Profile"), + title: Text(AppLocalizations.of(context)!.my_profile), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.only(left: 10.0, right: 10.0, top: 3.0), @@ -526,7 +526,7 @@ class _EditProfileState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - "User Name", + AppLocalizations.of(context)!.register_name, style: TextStyle( fontSize: 16, fontWeight: FontWeight.w500, @@ -552,7 +552,7 @@ class _EditProfileState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - "Email ID", + AppLocalizations.of(context)!.email_id, style: TextStyle( fontSize: 16, fontWeight: FontWeight.w500, @@ -577,7 +577,7 @@ class _EditProfileState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - "Full Name*", + AppLocalizations.of(context)!.full_name, style: TextStyle( fontSize: 16, fontWeight: FontWeight.w500, @@ -651,7 +651,7 @@ class _EditProfileState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - "Country/Region*", + AppLocalizations.of(context)!.region, style: TextStyle( fontSize: 16, fontWeight: FontWeight.w500), ), @@ -710,12 +710,12 @@ class _EditProfileState extends State { SizedBox(height: 10), Text.rich( TextSpan( - text: 'I agree to the ', + text: AppLocalizations.of(context)!.agree, style: TextStyle(color: Colors.black), children: [ TextSpan( - text: 'Terms & Conditions', + text: AppLocalizations.of(context)!.terms_conditions, style: TextStyle( color: Colors.blue, decoration: @@ -728,12 +728,12 @@ class _EditProfileState extends State { }, ), TextSpan( - text: ' and ', + text: AppLocalizations.of(context)!.t_and, style: TextStyle( color: Colors.black), ), TextSpan( - text: 'Privacy Policy', + text: AppLocalizations.of(context)!.privacy_policy, style: TextStyle( color: Colors.blue, decoration: @@ -746,7 +746,7 @@ class _EditProfileState extends State { }, ), TextSpan( - text: ' of FCSC.', + text: AppLocalizations.of(context)!.conditions, style: TextStyle( color: Colors.black), ), @@ -789,7 +789,7 @@ class _EditProfileState extends State { context.go('/createNewPw/$userId/$email'); }, child: Text( - "Change Password", + AppLocalizations.of(context)!.change_password, style: TextStyle( color: Colors.blue, decoration: TextDecoration.underline), @@ -806,7 +806,7 @@ class _EditProfileState extends State { color: Colors.white, ), label: Text( - 'Save', + AppLocalizations.of(context)!.save, style: TextStyle(color: Colors.white), ), style: ElevatedButton.styleFrom( diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart b/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart index 6be42872..4d8a7f10 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart @@ -4,6 +4,7 @@ import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:intl/intl.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:pocketbase/pocketbase.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; @@ -208,7 +209,8 @@ class _FeedbackFormState extends State @override Widget build(BuildContext context) { return BaseScaffold( - title: Text("Feedback"), + // title: Text("Feedback"), + title: Text(AppLocalizations.of(context)!.feedback_title), // appBar: AppBar( // backgroundColor: const Color(0xFFf8f9ff), // title: Text(context.translate('Feedback Form', 'نموذج الملاحظات')), @@ -464,8 +466,8 @@ class _FeedbackFormState extends State const Text("Failed to Share Feedback", style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)), const SizedBox(height: 10), - const Text("Your feedback could not be submitted. Please try again.", - style: TextStyle(fontSize: 16), textAlign: TextAlign.center), + Text(AppLocalizations.of(context)!.feedback_failed_msg, + style: const TextStyle(fontSize: 16), textAlign: TextAlign.center), const SizedBox(height: 30), ElevatedButton( onPressed: () { diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart b/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart index 3f3cfc5a..2406f9a8 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart @@ -4,6 +4,7 @@ import 'package:pocketbase/pocketbase.dart'; import 'package:uae_stat/presentation/components/my_bottom_nav_bar.dart'; import 'package:uae_stat/presentation/components/my_drawer.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; class ManageUserRouter extends StatefulWidget { late final Widget title; @@ -18,7 +19,7 @@ class _ManageUserRouterState extends State { bool _isAscending = true; List filteredUserData = []; - final List statusOptions = ['Approved', 'Denied', 'Pending']; + // final List statusOptions = ['Approved', 'Denied', 'Pending']; Color getStatusColor(String status) { switch (status) { @@ -130,7 +131,8 @@ class _ManageUserRouterState extends State { height: myheight / 30, ), Text( - 'Are you sure you want to change \n the status to $newStatus?', + // 'Are you sure you want to change \n the status to $newStatus?', + AppLocalizations.of(context)!.approve_msg(newStatus), style: TextStyle(fontSize: 15), textAlign: TextAlign.center, ), @@ -168,7 +170,7 @@ class _ManageUserRouterState extends State { width: 2.0, // Set the border width ), ), - child: Text('No'), + child: Text(AppLocalizations.of(context)!.no), ), TextButton( onPressed: () async { @@ -207,7 +209,8 @@ class _ManageUserRouterState extends State { ), ), child: Text( - 'Yes', + // 'Yes', + AppLocalizations.of(context)!.yes, style: TextStyle(color: Colors.white), ), ), @@ -221,9 +224,20 @@ class _ManageUserRouterState extends State { @override Widget build(BuildContext context) { + + final Map statusOptions = { + 'Approved': AppLocalizations.of(context)!.approved, + 'Denied': AppLocalizations.of(context)!.denied, + 'Pending': AppLocalizations.of(context)!.pending, + }; + + double myheight = MediaQuery.of(context).size.height; return BaseScaffold( - title: Text("Manage User"), + // title: Text("Manage User"), + title: Text( + AppLocalizations.of(context)!.manage_user, + ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.only(left: 10.0, right: 10.0, top: 3.0), @@ -251,21 +265,23 @@ class _ManageUserRouterState extends State { sortAscending: _isAscending, columns: [ DataColumn( - label: const Text('User Name'), + label: Text( + AppLocalizations.of(context)!.user_name, + ), onSort: (columnIndex, ascending) { _sort((user) => user.userName.toLowerCase(), columnIndex, ascending); }, ), DataColumn( - label: const Text('Email ID'), + label: Text( AppLocalizations.of(context)!.email_id,), onSort: (columnIndex, ascending) { _sort((user) => user.emailId.toLowerCase(), columnIndex, ascending); }, ), DataColumn( - label: const Text('Registration Date'), + label: Text(AppLocalizations.of(context)!.reg_date,), onSort: (columnIndex, ascending) { _sort( (user) => DateFormat('dd/MM/yyyy') @@ -276,7 +292,7 @@ class _ManageUserRouterState extends State { }, ), DataColumn( - label: const Text('Status'), + label: Text(AppLocalizations.of(context)!.status,), onSort: (columnIndex, ascending) { _sort((user) => user.status.toLowerCase(), columnIndex, ascending); @@ -311,13 +327,13 @@ class _ManageUserRouterState extends State { DataCell( DropdownButton( value: user.status, - items: statusOptions.map((status) { + items: statusOptions.entries.map((status) { return DropdownMenuItem( - value: status, + value: status.key, child: Text( - status, + status.value, style: TextStyle( - color: getStatusColor(status)), + color: getStatusColor(status.key),), ), ); }).toList(), diff --git a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart index 5bdb2c9f..b8f7f0a4 100644 --- a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart +++ b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart @@ -1,9 +1,13 @@ import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; +import 'package:uae_stat/presentation/components/my_toggle.dart'; +import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:pocketbase/pocketbase.dart'; import 'package:shared_preferences/shared_preferences.dart'; -class BaseScaffold extends StatefulWidget { +class BaseScaffold extends ConsumerWidget { final Widget body; final Widget title; final bool? showBackButton; @@ -98,10 +102,54 @@ class _BaseScaffoldState extends State { } @override - Widget build(BuildContext context) { + Widget build(BuildContext context ,WidgetRef ref) { + final locale = ref.watch(localeProvider); + final localeNotifier = ref.read(localeProvider.notifier); + // Get the current route to highlight the active item String currentRoute = GoRouterState.of(context).matchedLocation; double myheight = MediaQuery.of(context).size.height; double mywidth = MediaQuery.of(context).size.width; + return Scaffold( + appBar: AppBar(title: title, backgroundColor : appbarColor,actions: [ + // IconButton(onPressed: () {}, icon: Icon(Icons.toggle_off_outlined)), + MyToggle(isOn: locale?.languageCode == 'en', + knobTextWhenOn: 'ع', + knobTextWhenOff: 'EN', + pathColorWhenOn: Colors.grey.shade300, + pathColorWhenOff: Colors.grey.shade300, + onTap: (){ + ref.read(localeProvider.notifier).toggleLocale(); + },), + ], + leading: + // Stack( + // children: [ + // // Show the back button if showBackButton is true, otherwise show the drawer menu + // if (showBackButton == true) + // Positioned( + // left: 0, + // child: IconButton( + // color: Colors.white, + // icon: Icon(Icons.arrow_back_ios_new), + // onPressed: () { + // Navigator.of(context).pop(); + // }, + // ), + // ), + // // Show the drawer icon in all cases + // Positioned( + // right: 0, + // child: IconButton( + // color: (showBackButton == true)? Colors.white : Colors.black, + // icon: Icon(Icons.menu), + // onPressed: () { + // // Open the drawer using the Scaffold context + // Scaffold.of(context).openDrawer(); + // }, + // ), + // ), + // ], + // ), return Scaffold( appBar: AppBar( diff --git a/pubspec.lock b/pubspec.lock index 0b782f6e..df3242b9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,23 +5,23 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab" + sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834 url: "https://pub.dev" source: hosted - version: "76.0.0" + version: "72.0.0" _macros: dependency: transitive description: dart source: sdk - version: "0.3.3" + version: "0.3.2" analyzer: dependency: transitive description: name: analyzer - sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e" + sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139 url: "https://pub.dev" source: hosted - version: "6.11.0" + version: "6.7.0" analyzer_plugin: dependency: transitive description: @@ -74,50 +74,50 @@ packages: dependency: transitive description: name: build - sha256: cef23f1eda9b57566c81e2133d196f8e3df48f244b317368d65c5943d91148f0 + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.4.1" build_config: dependency: transitive description: name: build_config - sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33" + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "1.1.1" build_daemon: dependency: transitive description: name: build_daemon - sha256: "294a2edaf4814a378725bfe6358210196f5ea37af89ecd81bfa32960113d4948" + sha256: "79b2aef6ac2ed00046867ed354c88778c9c0f029df8a20fe10b5436826721ef9" url: "https://pub.dev" source: hosted - version: "4.0.3" + version: "4.0.2" build_resolvers: dependency: transitive description: name: build_resolvers - sha256: "99d3980049739a985cf9b21f30881f46db3ebc62c5b8d5e60e27440876b1ba1e" + sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" url: "https://pub.dev" source: hosted - version: "2.4.3" + version: "2.4.2" build_runner: dependency: "direct dev" description: name: build_runner - sha256: "74691599a5bc750dc96a6b4bfd48f7d9d66453eab04c7f4063134800d6a5c573" + sha256: "028819cfb90051c6b5440c7e574d1896f8037e3c96cf17aaeb054c9311cfbf4d" url: "https://pub.dev" source: hosted - version: "2.4.14" + version: "2.4.13" build_runner_core: dependency: transitive description: name: build_runner_core - sha256: "22e3aa1c80e0ada3722fe5b63fd43d9c8990759d0a2cf489c8c5d7b2bdebc021" + sha256: f8126682b87a7282a339b871298cc12009cb67109cfa1614d6436fb0289193e0 url: "https://pub.dev" source: hosted - version: "8.0.0" + version: "7.3.2" built_collection: dependency: transitive description: @@ -186,10 +186,10 @@ packages: dependency: transitive description: name: collection - sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.19.0" + version: "1.18.0" convert: dependency: transitive description: @@ -266,10 +266,10 @@ packages: dependency: transitive description: name: custom_lint_visitor - sha256: bfe9b7a09c4775a587b58d10ebb871d4fe618237639b1e84d5ec62d7dfef25f9 + sha256: "8aeb3b6ae2bb765e7716b93d1d10e8356d04e0ff6d7592de6ee04e0dd7d6587d" url: "https://pub.dev" source: hosted - version: "1.0.0+6.11.0" + version: "1.0.0+6.7.0" dart_style: dependency: transitive description: @@ -637,10 +637,10 @@ packages: dependency: transitive description: name: http_parser - sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" url: "https://pub.dev" source: hosted - version: "4.1.2" + version: "4.0.2" image: dependency: transitive description: @@ -781,18 +781,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.7" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "3.0.8" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: @@ -805,10 +805,10 @@ packages: dependency: transitive description: name: lints - sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 + sha256: "3315600f3fb3b135be672bf4a178c55f274bebe368325ae18462c89ac1e3b413" url: "https://pub.dev" source: hosted - version: "5.1.1" + version: "5.0.0" logging: dependency: transitive description: @@ -821,10 +821,10 @@ packages: dependency: transitive description: name: macros - sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" + sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" url: "https://pub.dev" source: hosted - version: "0.1.3-main.0" + version: "0.1.2-main.4" mailer: dependency: "direct main" description: @@ -1013,10 +1013,10 @@ packages: dependency: transitive description: name: pubspec_parse - sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" + sha256: "81876843eb50dc2e1e5b151792c9a985c5ed2536914115ed04e9c8528f6647b0" url: "https://pub.dev" source: hosted - version: "1.5.0" + version: "1.4.0" recase: dependency: transitive description: @@ -1164,10 +1164,10 @@ packages: dependency: transitive description: name: shelf - sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 url: "https://pub.dev" source: hosted - version: "1.4.2" + version: "1.4.1" shelf_web_socket: dependency: transitive description: @@ -1180,7 +1180,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.0" + version: "0.0.99" smart_api_client: dependency: "direct main" description: @@ -1224,10 +1224,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.11.1" state_notifier: dependency: transitive description: @@ -1256,7 +1256,7 @@ packages: dependency: transitive description: name: string_scanner - sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dev" source: hosted version: "1.3.0" @@ -1272,10 +1272,10 @@ packages: dependency: transitive description: name: test_api - sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.7.3" + version: "0.7.2" the_validator: dependency: "direct main" description: @@ -1400,10 +1400,10 @@ packages: dependency: transitive description: name: video_player_android - sha256: "7018dbcb395e2bca0b9a898e73989e67c0c4a5db269528e1b036ca38bcca0d0b" + sha256: "391e092ba4abe2f93b3e625bd6b6a6ec7d7414279462c1c0ee42b5ab8d0a0898" url: "https://pub.dev" source: hosted - version: "2.7.17" + version: "2.7.16" video_player_avfoundation: dependency: transitive description: @@ -1432,10 +1432,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.3.0" + version: "14.2.5" watcher: dependency: transitive description: @@ -1533,5 +1533,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.6.0 <4.0.0" - flutter: ">=3.27.0" + dart: ">=3.5.2 <4.0.0" + flutter: ">=3.24.0" diff --git a/pubspec.yaml b/pubspec.yaml index 3126af19..4ba75fd8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -80,6 +80,7 @@ dev_dependencies: # flutter_splash_screen: ^3.0.0 flutter: + generate: true uses-material-design: true assets: - assets/user_guide_videos/