diff --git a/lib/config/sessionCheckScreen.dart b/lib/config/sessionCheckScreen.dart index 70d00557..25eaa96c 100644 --- a/lib/config/sessionCheckScreen.dart +++ b/lib/config/sessionCheckScreen.dart @@ -4,6 +4,8 @@ import 'package:go_router/go_router.dart'; import 'package:pocketbase/pocketbase.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:uae_stat/config/api_config.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; +import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; import 'package:uae_stat/domain/entities/session_entity.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; @@ -38,11 +40,25 @@ class _SessionCheckScreenState extends ConsumerState { final userId = prefs.getString('userId'); // Authenticate admin d - final adminAuth = await pb.admins.authWithPassword( - 'pb@venbainfotech.com', - 'pb@venbainfotech.com', + // final adminAuth = await pb.admins.authWithPassword( + // 'pb@venbainfotech.com', + // 'pb@venbainfotech.com', + // ); + + final auth = ref.watch(authProvider); + + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + + // final String adminToken = adminAuth.token; + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, ); - final String adminToken = adminAuth.token; print('adminToken: $adminToken'); // Fetch user details @@ -147,9 +163,10 @@ class SplashScreen extends StatelessWidget { color: isDark ? null : Colors.white, image: isDark ? DecorationImage( - image: AssetImage('assets/splash_screen/background_splash_dark.png'), // 🔄 Add this background for dark mode - fit: BoxFit.cover, - ) + image: AssetImage( + 'assets/splash_screen/background_splash_dark.png'), // 🔄 Add this background for dark mode + fit: BoxFit.cover, + ) : null, ), child: Center( @@ -180,7 +197,7 @@ class SplashScreen extends StatelessWidget { fontFamily: 'NotoKufi', ), ), - ], + ], ), ), ], @@ -191,7 +208,6 @@ class SplashScreen extends StatelessWidget { } } - // import 'dart:math'; // // import 'package:flutter/material.dart'; diff --git a/lib/config/theme/auth_provider.dart b/lib/config/theme/auth_provider.dart new file mode 100644 index 00000000..a3ee4891 --- /dev/null +++ b/lib/config/theme/auth_provider.dart @@ -0,0 +1,62 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +class AuthState { + final String email; + final String password; + + // AuthState({ + // this.email = 'kannan@sightspectrum.com', // default value + // this.password = '1DgZ_we3k5UuCZiF9wziwECQzQo1YNRQ', // default value + // }); + + AuthState({ + this.email = "pb@venbainfotech.com", // default value + this.password = "pb@venbainfotech.com", // default value + }); + + // AuthState({ + // this.email = 'sangeethae9919@gmail.com', // default value + // this.password = 'Sang@123', // default value + // }); +} + +final authProvider = StateProvider((ref) => AuthState()); + +// --------------------- Dynamic USER Email and Password + +// final adminAuth = await PocketBaseService.users.authWithPassword( +// 'user1@gmail.com', +// 'tes@123', +// ); + +// +// /// Holds login credentials +// class AuthState { +// final String? email; +// final String? password; +// +// const AuthState({this.email, this.password}); +// +// AuthState copyWith({String? email, String? password}) { +// return AuthState( +// email: email ?? this.email, +// password: password ?? this.password, +// ); +// } +// } +// +// class AuthNotifier extends StateNotifier { +// AuthNotifier() : super(const AuthState()); +// +// void setCredentials(String email, String password) { +// state = AuthState(email: email, password: password); +// } +// +// void clearCredentials() { +// state = const AuthState(); +// } +// } +// +// final authProvider = StateNotifierProvider((ref) { +// return AuthNotifier(); +// }); diff --git a/lib/config/theme/service.dart b/lib/config/theme/service.dart index 72cd7c80..a5675fd6 100644 --- a/lib/config/theme/service.dart +++ b/lib/config/theme/service.dart @@ -1,8 +1,11 @@ import 'dart:convert'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:http/http.dart' as http; import 'package:pocketbase/pocketbase.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:uae_stat/config/api_config.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; +import 'package:uae_stat/infrastructure/services/pocketbase_service.dart'; class ThemeBaseService { final pb = PocketBase(apiUrl); @@ -38,14 +41,40 @@ class ThemeBaseService { // // } // } - Future getUserTheme(String userId) async { + Future getAdminToken({ + required String email, + required String password, + }) async { + print("ADminTOKEN"); + try { + final adminAuth = await pb.admins.authWithPassword(email, password); + return adminAuth.token; // return only the token + } catch (e) { + throw Exception("Admin auth failed: $e"); + } + } + + Future getUserTheme(String userId, WidgetRef ref) async { print('getUserTheme'); final url = "${pb.baseUrl}/api/collections/users/records/$userId"; + // final adminAuth = await pb.admins.authWithPassword( + // 'pb@venbainfotech.com', + // 'pb@venbainfotech.com', + // ); + + final auth = ref.watch(authProvider); + final adminAuth = await pb.admins.authWithPassword( - 'pb@venbainfotech.com', - 'pb@venbainfotech.com', + auth.email, + auth.password, ); + + // final adminAuth = await PocketBaseService.users.authWithPassword( + // 'sangeethae9919@gmail.com', + // 'Sang@123', + // ); + final String adminToken = adminAuth.token; print('adminToken: $adminToken'); final response = await http.get( @@ -71,13 +100,21 @@ class ThemeBaseService { } } - Future updateUserTheme(String userId, String theme) async { + Future updateUserTheme( + String userId, String theme, WidgetRef ref) async { print('updateUserTheme'); // Authenticate admin d final url = "${pb.baseUrl}/api/collections/users/records/$userId"; + // final adminAuth = await pb.admins.authWithPassword( + // 'pb@venbainfotech.com', + // 'pb@venbainfotech.com', + // ); + + final auth = ref.watch(authProvider); + final adminAuth = await pb.admins.authWithPassword( - 'pb@venbainfotech.com', - 'pb@venbainfotech.com', + auth.email, + auth.password, ); final String adminToken = adminAuth.token; print('adminToken: $adminToken'); diff --git a/lib/config/toggle_lang_service.dart b/lib/config/toggle_lang_service.dart index 23eb4017..010c38f6 100644 --- a/lib/config/toggle_lang_service.dart +++ b/lib/config/toggle_lang_service.dart @@ -1,11 +1,15 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:pocketbase/pocketbase.dart'; import 'package:uae_stat/config/api_config.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; +import 'package:uae_stat/config/theme/service.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; class UserService { final _pb = PocketBase(apiUrl); - Future updateLanguage(String localeCode) async { + Future updateLanguage(String localeCode, WidgetRef ref) async { try { final prefs = await SharedPreferences.getInstance(); final userId = prefs.getString('userId'); @@ -14,9 +18,22 @@ class UserService { throw Exception('User ID not found'); } // Authenticate as admin - final adminAuth = await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); - final token = adminAuth.token; + // final adminAuth = await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + + final auth = ref.watch(authProvider); + + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // final token = adminAuth.token; + + final themeService = ThemeBaseService(); + final token = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); final headers = { 'Authorization': 'Bearer $token', diff --git a/lib/domain/use_cases/auth_use_case.dart b/lib/domain/use_cases/auth_use_case.dart index c1a9db59..319f0dc1 100644 --- a/lib/domain/use_cases/auth_use_case.dart +++ b/lib/domain/use_cases/auth_use_case.dart @@ -57,6 +57,7 @@ class AuthUseCase extends _$AuthUseCase { } Future login(String email, String pw) async { + print("Auth_use_case_1"); final session = await _repo.login(email, pw); final localPrefs = await getIt.call().get(); if (localPrefs != null) { @@ -76,9 +77,9 @@ class AuthUseCase extends _$AuthUseCase { final localPrefs = await getIt.call().get(); if (localPrefs != null) { await getIt.call().syncPreferences( - localPrefs, - id: session.id, - ); + localPrefs, + id: session.id, + ); } state = AsyncData(session); return session; // Return the session with user details. diff --git a/lib/infrastructure/data/p_auth_repo.dart b/lib/infrastructure/data/p_auth_repo.dart index 8ee8f054..92343da5 100644 --- a/lib/infrastructure/data/p_auth_repo.dart +++ b/lib/infrastructure/data/p_auth_repo.dart @@ -48,6 +48,8 @@ class PAuthRepo implements TAuthRepo { @override Future login(String email, String pw) async { late final RecordAuth user; + print('P_auth_repo_2'); + try { user = await PocketBaseService.users.authWithPassword( email, @@ -90,7 +92,6 @@ class PAuthRepo implements TAuthRepo { return se; } - @override Future logout() { PocketBaseService.authStore.clear(); diff --git a/lib/infrastructure/services/pocketbase_service.dart b/lib/infrastructure/services/pocketbase_service.dart index 017137df..477e0e14 100644 --- a/lib/infrastructure/services/pocketbase_service.dart +++ b/lib/infrastructure/services/pocketbase_service.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:pocketbase/pocketbase.dart'; import 'package:uae_stat/config/api_config.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; abstract class PocketBaseService { static const _host = apiUrl; diff --git a/lib/presentation/Screens/auth_verification/create_new_pw.dart b/lib/presentation/Screens/auth_verification/create_new_pw.dart index 92d12609..a33ef3ff 100644 --- a/lib/presentation/Screens/auth_verification/create_new_pw.dart +++ b/lib/presentation/Screens/auth_verification/create_new_pw.dart @@ -7,6 +7,8 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:uae_stat/config/api_config.dart'; import 'package:uae_stat/config/connectivity_provider.dart'; import 'package:uae_stat/config/my_router.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; +import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; @@ -18,6 +20,7 @@ import 'package:uae_stat/presentation/components/my_toggle.dart'; import 'package:uae_stat/presentation/components/space.dart'; import 'package:uae_stat/l10n/app_localizations.dart'; import 'package:uae_stat/config/my_theme.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; class CreateNewPw extends ConsumerStatefulWidget { final String userId; @@ -146,9 +149,22 @@ class _CreateNewPwState extends ConsumerState { isLoading = true; }); // Authenticate as admin - final adminAuth = await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); - final token = adminAuth.token; + // final adminAuth = await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + + final auth = ref.watch(authProvider); + + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // final token = adminAuth.token; + + final themeService = ThemeBaseService(); + final token = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); final headers = { 'Authorization': 'Bearer $token', diff --git a/lib/presentation/Screens/auth_verification/forgot_password.dart b/lib/presentation/Screens/auth_verification/forgot_password.dart index 0d0a934e..fd2f5cb9 100644 --- a/lib/presentation/Screens/auth_verification/forgot_password.dart +++ b/lib/presentation/Screens/auth_verification/forgot_password.dart @@ -7,6 +7,8 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:uae_stat/config/api_config.dart'; import 'package:uae_stat/config/connectivity_provider.dart'; import 'package:uae_stat/config/my_router.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; +import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; @@ -18,6 +20,7 @@ import 'package:uae_stat/presentation/components/indicators/locale_provider.dart import 'package:uae_stat/presentation/components/my_toggle.dart'; import 'package:uae_stat/presentation/components/space.dart'; import 'package:uae_stat/config/my_theme.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; class ForgotPassword extends ConsumerStatefulWidget { final String email; @@ -174,9 +177,23 @@ class _ForgotPasswordState extends ConsumerState { isLoading = true; }); // Authenticate as admin - final adminAuth = await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); - final token = adminAuth.token; + // final adminAuth = await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + + final auth = ref.watch(authProvider); + + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // + // final token = adminAuth.token; + + final themeService = ThemeBaseService(); + final token = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); final headers = { 'Authorization': 'Bearer $token', diff --git a/lib/presentation/Screens/charts/screens/chart_screen.dart b/lib/presentation/Screens/charts/screens/chart_screen.dart index aba69d31..5c53c988 100644 --- a/lib/presentation/Screens/charts/screens/chart_screen.dart +++ b/lib/presentation/Screens/charts/screens/chart_screen.dart @@ -13,6 +13,8 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:tutorial_coach_mark/tutorial_coach_mark.dart'; import 'package:uae_stat/config/api_config.dart'; import 'package:uae_stat/config/connectivity_provider.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; +import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:uae_stat/config/toast_util.dart'; import 'package:uae_stat/config/toggle_lang_service.dart'; @@ -23,6 +25,7 @@ import 'package:uae_stat/presentation/Screens/charts/widgets/chart_widget.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; import 'package:uae_stat/presentation/components/my_toggle.dart'; import 'package:uae_stat/l10n/app_localizations.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; import 'package:uae_stat/presentation/Screens/app_tour/Target_content.dart'; import '../filters/search_filter_helper.dart'; @@ -140,12 +143,24 @@ class _ChartScreen1State extends ConsumerState { final prefs = await SharedPreferences.getInstance(); final userID = prefs.getString('userId'); try { - final adminAuth = await _pb.admins.authWithPassword( - 'pb@venbainfotech.com', - 'pb@venbainfotech.com', - ); + // final adminAuth = await _pb.admins.authWithPassword( + // 'pb@venbainfotech.com', + // 'pb@venbainfotech.com', + // ); - final adminToken = adminAuth.token; + final auth = ref.watch(authProvider); + + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // final adminToken = adminAuth.token; + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); final result = await _pb.collection('bookmark').getList( filter: "user_id = '${userID}' && dataset = '${widget.dataSets}'", @@ -170,8 +185,15 @@ class _ChartScreen1State extends ConsumerState { final prefs = await SharedPreferences.getInstance(); final userID = prefs.getString('userId'); try { - final adminAuth = await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + // final adminAuth = await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + + final auth = ref.watch(authProvider); + + final adminAuth = await pb.admins.authWithPassword( + auth.email, + auth.password, + ); final adminToken = adminAuth.token; final response = await _pb.collection('bookmark').create(body: { 'user_id': userID, @@ -2398,7 +2420,7 @@ class _ChartScreen1State extends ConsumerState { isLoading = true; print('isLoadingref $isLoading'); }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); // fetchChartData(widget.dataSets, localeCode); print('Saving currentTab: $tabWiseKpi before locale change'); diff --git a/lib/presentation/Screens/charts/services/api_service.dart b/lib/presentation/Screens/charts/services/api_service.dart index ba67a80e..c19fb933 100644 --- a/lib/presentation/Screens/charts/services/api_service.dart +++ b/lib/presentation/Screens/charts/services/api_service.dart @@ -16,7 +16,7 @@ class ApiService { static const String baseUrl = '$apiUrl/api/getDataSet'; Future> fetchChartData(String dataSets, locale, kpi, - List> filterData,themeMode) async { + List> filterData, themeMode) async { List isChartData = []; List nonChartData = []; List originalChartsData = []; @@ -35,7 +35,7 @@ class ApiService { 'kpi': kpi.isNotEmpty ? kpi : null, // Avoid sending empty kpi 'filter_data': filterData.isNotEmpty ? filterData : [], // Avoid empty list - 'color_mode' : themeMode, + 'color_mode': themeMode, }; // final url = Uri.https('$baseUrl?dataset=$dataSets&language=$locale'); @@ -46,7 +46,10 @@ class ApiService { try { final response = await http.post( url, - headers: {'Content-Type': 'application/json'}, + headers: { + 'Content-Type': 'application/json', + 'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A' + }, body: jsonEncode(requestBody), ); diff --git a/lib/presentation/Screens/profilepage.dart b/lib/presentation/Screens/profilepage.dart index 99ac1286..930deba0 100644 --- a/lib/presentation/Screens/profilepage.dart +++ b/lib/presentation/Screens/profilepage.dart @@ -16,13 +16,16 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:uae_stat/config/api_config.dart'; import 'package:uae_stat/config/connectivity_provider.dart'; import 'package:uae_stat/config/my_theme.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; +import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/misc_icon_asset_path.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; import 'package:uae_stat/presentation/components/my_toggle.dart'; - import 'package:uae_stat/l10n/app_localizations.dart'; +import 'package:uae_stat/l10n/app_localizations.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; class ProfileScreen extends ConsumerStatefulWidget { final String userId; // Add this field to hold the user ID @@ -162,9 +165,23 @@ class _ProfileScreenState extends ConsumerState { Future _fetchUserData() async { try { - final adminAuth = await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); - final adminToken = adminAuth.token; + // final adminAuth = await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + + final auth = ref.watch(authProvider); + + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // + // final adminToken = adminAuth.token; + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); print('adminToken- ${adminToken}'); final userDetailsResponse = await _pb.collection('users').getOne( widget.userId, @@ -201,10 +218,10 @@ class _ProfileScreenState extends ConsumerState { _isLoading = true; // Start loading }); final XFile? pickedFile = - await _picker.pickImage(source: ImageSource.gallery); + await _picker.pickImage(source: ImageSource.gallery); if (pickedFile != null) { final String fileExtension = - pickedFile.path.split('.').last.toLowerCase(); + pickedFile.path.split('.').last.toLowerCase(); if (fileExtension == 'jpg' || fileExtension == 'jpeg' || fileExtension == 'png' || @@ -217,13 +234,13 @@ class _ProfileScreenState extends ConsumerState { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - 'Please select a JPG, JPEG, or PNG file.', - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - )), - )), + 'Please select a JPG, JPEG, or PNG file.', + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + )), + )), ); } } @@ -358,7 +375,7 @@ class _ProfileScreenState extends ConsumerState { // Create a multipart request final uri = - Uri.parse('${_pb.baseUrl}/api/collections/users/records/$userID'); + Uri.parse('${_pb.baseUrl}/api/collections/users/records/$userID'); final request = http.MultipartRequest('PATCH', uri); // Add other fields @@ -384,13 +401,13 @@ class _ProfileScreenState extends ConsumerState { print(response); ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text( - AppLocalizations.of(context)!.profile_updated_successfully, - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - )), - ))); + AppLocalizations.of(context)!.profile_updated_successfully, + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + )), + ))); // **Set Default Locale in Provider** print('_selectedLanguage $_selectedLanguage'); preferredLang = _selectedLanguage == 'English' ? 'en' : 'ar'; @@ -411,14 +428,14 @@ class _ProfileScreenState extends ConsumerState { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - context.translate("Failed to update profile: $error", - '$error فشل في تحديث الملف الشخصي: '), - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - )), - )), + context.translate("Failed to update profile: $error", + '$error فشل في تحديث الملف الشخصي: '), + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + )), + )), ); } } @@ -685,7 +702,7 @@ class _ProfileScreenState extends ConsumerState { backgroundImage: _profileImage != null ? FileImage(_profileImage!) : AssetImage("assets/edit_profile/profile.png") - as ImageProvider, + as ImageProvider, child: Align( alignment: Alignment.bottomRight, child: GestureDetector( @@ -709,7 +726,7 @@ class _ProfileScreenState extends ConsumerState { child: CircularProgressIndicator( strokeWidth: 2, valueColor: - AlwaysStoppedAnimation(Colors.grey), + AlwaysStoppedAnimation(Colors.grey), ), ), ], @@ -983,7 +1000,7 @@ class _ProfileScreenState extends ConsumerState { 'NotoKufi', ), color: - isDarkTheme ? Colors.white : Color(0xFFC3C6CB), + isDarkTheme ? Colors.white : Color(0xFFC3C6CB), // color: Color(0xFFB68A34), fontSize: 14, ), @@ -992,11 +1009,11 @@ class _ProfileScreenState extends ConsumerState { width: 45, padding: EdgeInsets.only(right: 1), alignment: - Alignment.center, // Center the icon vertically + Alignment.center, // Center the icon vertically child: Icon( Icons.keyboard_arrow_down_sharp, color: - _isHoveringDate ? Colors.black : Colors.grey, + _isHoveringDate ? Colors.black : Colors.grey, ), ), ), @@ -1086,27 +1103,27 @@ class _ProfileScreenState extends ConsumerState { : Colors.grey), items: _countries .map((item) => DropdownMenuItem( - value: item, - child: SizedBox( - width: double.infinity, - child: Text( - // item.nameEN, - context.translate( - item.nameEN, item.nameAR), - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - // color: Colors.red - color: - isDarkTheme ? Colors.white : null, - ), - ), - ), - )) + value: item, + child: SizedBox( + width: double.infinity, + child: Text( + // item.nameEN, + context.translate( + item.nameEN, item.nameAR), + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + // color: Colors.red + color: + isDarkTheme ? Colors.white : null, + ), + ), + ), + )) .toList(), onChanged: (ISOCountry? newValue) { setState(() { @@ -1250,18 +1267,18 @@ class _ProfileScreenState extends ConsumerState { : Colors.grey), items: preferred_language .map((item) => DropdownMenuItem( - value: item, - child: Text( - item, - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - color: isDarkTheme ? Colors.white : null, - ), - ), - )) + value: item, + child: Text( + item, + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + color: isDarkTheme ? Colors.white : null, + ), + ), + )) .toList(), onChanged: (String? newValue) { setState(() { @@ -1312,7 +1329,7 @@ class _ProfileScreenState extends ConsumerState { color: isDarkTheme ? Colors.white : Color( - 0xFF898C81), // Change to your desired color + 0xFF898C81), // Change to your desired color ), children: [ TextSpan( @@ -1351,7 +1368,7 @@ class _ProfileScreenState extends ConsumerState { color: isDarkTheme ? Colors.white : Color( - 0xFF898C81), // Change to your desired color + 0xFF898C81), // Change to your desired color ), ), TextSpan( @@ -1390,7 +1407,7 @@ class _ProfileScreenState extends ConsumerState { color: isDarkTheme ? Colors.white : Color( - 0xFF898C81), // Change to your desired color + 0xFF898C81), // Change to your desired color ), ), ], @@ -1426,34 +1443,34 @@ class _ProfileScreenState extends ConsumerState { ], ), SizedBox(height: 20), - if(isOAuthLogin != 1) - Center( - child: GestureDetector( - onTap: () { - final userId = widget.userId; - final email = _emailController.text; + if (isOAuthLogin != 1) + Center( + child: GestureDetector( + onTap: () { + final userId = widget.userId; + final email = _emailController.text; - context.push('/createNewPw/$userId/$email'); - }, - child: Text( - AppLocalizations.of(context)!.change_password, - style: TextStyle( - // color: Color(0xFF648CBA), - color: Color(0xFFB68A34), - // color: isDarkTheme - // ? Color(0xFF9EB3E4) - // : Color(0xFF985400), - fontSize: 14, - fontWeight: FontWeight.w700, - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', + context.push('/createNewPw/$userId/$email'); + }, + child: Text( + AppLocalizations.of(context)!.change_password, + style: TextStyle( + // color: Color(0xFF648CBA), + color: Color(0xFFB68A34), + // color: isDarkTheme + // ? Color(0xFF9EB3E4) + // : Color(0xFF985400), + fontSize: 14, + fontWeight: FontWeight.w700, + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + // decoration: TextDecoration.underline), ), - // decoration: TextDecoration.underline), ), ), ), - ), SizedBox(height: 20), // ElevatedButton.icon( ElevatedButton( @@ -1468,7 +1485,7 @@ class _ProfileScreenState extends ConsumerState { } else { setState(() { showError = - !isChecked; // Show error if the checkbox is not checked + !isChecked; // Show error if the checkbox is not checked }); } }, @@ -1484,7 +1501,7 @@ class _ProfileScreenState extends ConsumerState { ), child: Row( mainAxisAlignment: - MainAxisAlignment.center, // Center the content + MainAxisAlignment.center, // Center the content children: [ Text( AppLocalizations.of(context)!.save, @@ -1566,7 +1583,7 @@ class ConfirmationDialog extends ConsumerWidget { 'NotoKufi', ), color: - isDarkTheme ? Colors.white : null), // Bold for "name" + isDarkTheme ? Colors.white : null), // Bold for "name" ), TextSpan( text: context.translate(' or ', 'أو'), @@ -1612,11 +1629,11 @@ class ConfirmationDialog extends ConsumerWidget { }, style: OutlinedButton.styleFrom( side: BorderSide(color: Color(0xFFB68A34) - // color: - // isDarkTheme ? Color(0xFF7296BE) : Color(0xFF92722A) - // + // color: + // isDarkTheme ? Color(0xFF7296BE) : Color(0xFF92722A) + // - ), + ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(7)), ), // Set the border color here @@ -1666,4 +1683,4 @@ class ConfirmationDialog extends ConsumerWidget { ], ); } -} \ No newline at end of file +} diff --git a/lib/presentation/routes/auth_routes/login_route.dart b/lib/presentation/routes/auth_routes/login_route.dart index ee8bc43e..495737cb 100644 --- a/lib/presentation/routes/auth_routes/login_route.dart +++ b/lib/presentation/routes/auth_routes/login_route.dart @@ -17,6 +17,7 @@ import 'package:uae_stat/config/app_links_helper.dart'; import 'package:uae_stat/config/connectivity_provider.dart'; import 'package:uae_stat/config/my_theme.dart'; import 'package:uae_stat/config/theme/app_theme.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:uae_stat/domain/entities/session_entity.dart'; @@ -25,6 +26,7 @@ import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/banner_asset_path.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/misc_icon_asset_path.dart'; +import 'package:uae_stat/infrastructure/services/pocketbase_service.dart'; import 'package:uae_stat/l10n/app_localizations.dart'; import 'package:uae_stat/presentation/components/dialogs.dart'; import 'package:uae_stat/presentation/components/lang_toggle.dart'; @@ -60,13 +62,22 @@ class LoginRoute extends HookConsumerWidget { Future profileStatus(String userId, WidgetRef ref) async { try { // Authenticate admin - final adminAuth = await pb.admins.authWithPassword( - 'pb@venbainfotech.com', - 'pb@venbainfotech.com', - ); - final String adminToken = adminAuth.token; - print('adminToken: $adminToken'); + // final adminAuth = await pb.admins.authWithPassword( + // 'pb@venbainfotech.com', + // 'pb@venbainfotech.com', + // ); + final auth = ref.watch(authProvider); + // final adminToken = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); // Fetch user details final userDetailsResponse = await pb.collection('users').getOne( userId, @@ -125,7 +136,8 @@ class LoginRoute extends HookConsumerWidget { // print("FCM Token: $token"); // } - Future getDeviceToken(BuildContext context, String userId) async { + Future getDeviceToken( + BuildContext context, String userId, WidgetRef ref) async { try { // await _firebaseMessaging.requestPermission(); print("FCM Token Entry"); @@ -133,7 +145,7 @@ class LoginRoute extends HookConsumerWidget { print("FCM Token: $token"); if (token != null) { - await updateDeviceToken(userId, token); + await updateDeviceToken(userId, token, ref); // Automatically copy to clipboard // Clipboard.setData(ClipboardData(text: token)); @@ -172,14 +184,28 @@ class LoginRoute extends HookConsumerWidget { } } - Future updateDeviceToken(String userId, String token) async { + Future updateDeviceToken( + String userId, String token, WidgetRef ref) async { final url = "${pb.baseUrl}/api/collections/users/records/$userId"; try { // Authenticate admin (Persist session globally instead) - await pb.admins.authWithPassword( - 'pb@venbainfotech.com', - 'pb@venbainfotech.com', + // await pb.admins.authWithPassword( + // 'pb@venbainfotech.com', + // 'pb@venbainfotech.com', + // ); + + final auth = ref.watch(authProvider); + // + // await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, ); final response = await http.patch( @@ -209,7 +235,8 @@ class LoginRoute extends HookConsumerWidget { Uri.parse("${pb.baseUrl}api/auth/request-password-reset?email=$email"); try { - final response = await http.get(url); + final response = await http + .get(url, headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); final body = json.decode(response.body); if (response.statusCode == 200) { return body['status'] ?? 'Reset link sent successfully.'; @@ -322,7 +349,7 @@ class LoginRoute extends HookConsumerWidget { Future initializeTheme( BuildContext context, WidgetRef ref, String userId) async { final themeService = ThemeBaseService(); - final theme = await themeService.getUserTheme(userId); // e.g., "dark" + final theme = await themeService.getUserTheme(userId, ref); // e.g., "dark" final platformBrightness = MediaQuery.of(context).platformBrightness; ref .read(themeProvider.notifier) @@ -360,7 +387,7 @@ class LoginRoute extends HookConsumerWidget { print("Email: ${loginCount}"); await loginCountApi(userId!); - await updateOAuthUserDetails(userId!, metaDetails); + await updateOAuthUserDetails(userId!, metaDetails, ref); // await saveUserId(userId!, loginCount); // await getDeviceToken(context, userId); await initializeTheme(context, ref, userId); @@ -429,11 +456,11 @@ class LoginRoute extends HookConsumerWidget { Future loginCountApi(String userId) async { if (userId.isNotEmpty) { - final url = - Uri.parse('$apiUrl/api/login_success?id=$userId'); + final url = Uri.parse('$apiUrl/api/login_success?id=$userId'); try { - final response = await http.get(url); + final response = await http + .get(url, headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { print("Login success API call successful: ${response.body}"); @@ -452,7 +479,8 @@ class LoginRoute extends HookConsumerWidget { } } - Future updateOAuthUserDetails(String userId, metaDetails) async { + Future updateOAuthUserDetails( + String userId, metaDetails, WidgetRef ref) async { final url = "${pb.baseUrl}/api/collections/users/records/$userId"; try { @@ -461,7 +489,18 @@ class LoginRoute extends HookConsumerWidget { // 'pb@venbainfotech.com', // 'pb@venbainfotech.com', // ); + final auth = ref.watch(authProvider); + // await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); final userDetails = metaDetails['rawUser']; print('oauthDetails $userDetails'); @@ -894,14 +933,35 @@ class LoginRoute extends HookConsumerWidget { if (!context.mounted || session == null) return; final userId = session.id; if (userId.isNotEmpty) { - final url = - Uri.parse('$apiUrl/api/login_success?id=$userId'); + print('EMAIL - $email '); + print('PASSWORD - ${pwCtl.text}'); + + // USE Dynamic USER EMail and Password + + // var password = pwCtl.text; + + // Save to AuthProvider + // ref.read(authProvider.notifier).setCredentials(email, password); + + // final session = await context.loaderWithErrorDialog( + // () => + // ref.read(authUseCaseProvider.notifier).login(email, password), + // ); + // + // final auth = ref.watch(authProvider); + // + // print("EMAIL - ${auth.email}"); + // print("PASSWORD - ${auth.password}"); + + final url = Uri.parse('${apiUrl}api/login_success?id=$userId'); try { - final response = await http.get(url); + final response = await http.get(url, + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { print("Login success API call successful: ${response.body}"); + print("LOginBtn"); final count = jsonDecode(response.body); loginCount = count["login_count"]; // Directly assign it as an int @@ -915,7 +975,7 @@ class LoginRoute extends HookConsumerWidget { } await saveUserId(userId, loginCount); - await getDeviceToken(context, userId); + await getDeviceToken(context, userId, ref); await initializeTheme(context, ref, userId); } try { diff --git a/lib/presentation/routes/bottom_bar_routes/tab_routes/UAE_Numbers/uae_numbers.dart b/lib/presentation/routes/bottom_bar_routes/tab_routes/UAE_Numbers/uae_numbers.dart index 9c9dcf52..6f22eb90 100644 --- a/lib/presentation/routes/bottom_bar_routes/tab_routes/UAE_Numbers/uae_numbers.dart +++ b/lib/presentation/routes/bottom_bar_routes/tab_routes/UAE_Numbers/uae_numbers.dart @@ -116,8 +116,9 @@ class _UaenumberWidgetState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -208,7 +209,7 @@ class _UaenumberWidgetState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/bottom_bar_routes/tab_routes/home/home_route.dart b/lib/presentation/routes/bottom_bar_routes/tab_routes/home/home_route.dart index b5e7bc16..0a12fe7a 100644 --- a/lib/presentation/routes/bottom_bar_routes/tab_routes/home/home_route.dart +++ b/lib/presentation/routes/bottom_bar_routes/tab_routes/home/home_route.dart @@ -1016,11 +1016,12 @@ class EconomyStatsState extends ConsumerState { // } // } - Future fetchData(locale,themeMode) async { + Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getHomePageData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { data = json.decode(response.body); @@ -1072,7 +1073,7 @@ class EconomyStatsState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart b/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart index e94d28ac..af5ce7b4 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart @@ -6,6 +6,9 @@ import 'package:flutter_svg/svg.dart'; import 'package:go_router/go_router.dart'; import 'package:dio/dio.dart'; import 'package:http/http.dart' as http; +import 'package:uae_stat/config/theme/auth_provider.dart'; +import 'package:uae_stat/config/theme/service.dart'; +import 'package:uae_stat/infrastructure/services/pocketbase_service.dart'; import 'package:uae_stat/l10n/app_localizations.dart'; import 'package:pocketbase/pocketbase.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -18,6 +21,7 @@ import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/bookmark_ import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/uae_numbers_asset_path.dart'; // import 'package:uae_stat/l10n/app_localizations.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; class BookMark extends ConsumerStatefulWidget { @@ -69,8 +73,9 @@ class _BookMarkState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -129,6 +134,9 @@ class _BookMarkState extends ConsumerState { 'language': locale, 'color_mode': themeMode }, + options: Options( + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}, + ), ); if (response.statusCode == 200 && response.data != null) { @@ -243,9 +251,28 @@ class _BookMarkState extends ConsumerState { setState(() { isLoading = true; }); - final adminAuth = await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); - final adminToken = adminAuth.token; + // final adminAuth = await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + + final auth = ref.watch(authProvider); + + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // + // + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); + print('adminTokenETRE1- '); + + // final adminToken = adminAuth.token; + + print('adminTokenETRE- $adminToken'); await _pb.collection('bookmark').delete(bookmarkId!, headers: { 'Authorization': adminToken, @@ -271,9 +298,9 @@ class _BookMarkState extends ConsumerState { AppLocalizations.of(context)!.removed_from_Bookmark, style: TextStyle( fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - )), + 'Roboto', + 'NotoKufi', + )), ), duration: Duration(seconds: 2), ), @@ -390,7 +417,7 @@ class _BookMarkState extends ConsumerState { foregroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: - BorderRadius.circular(10.0), // Set text color + BorderRadius.circular(10.0), // Set text color ), ), child: Text( @@ -426,7 +453,7 @@ class _BookMarkState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || @@ -486,11 +513,11 @@ class _BookMarkState extends ConsumerState { ]; List> bookmarks = - dataList.where((item) => item['isBookmark'] == true).toList(); + dataList.where((item) => item['isBookmark'] == true).toList(); List> filteredBookmarks = dataList.where((bookmark) { String mainTopic = bookmark['main_topic'].toString().trim().toLowerCase(); String selectedTabTitle = - tabs[selectedTabIndex]['title'].toString().trim().toLowerCase(); + tabs[selectedTabIndex]['title'].toString().trim().toLowerCase(); // Debugging prints print( @@ -521,220 +548,220 @@ class _BookMarkState extends ConsumerState { ), body: isLoading ? Container( - color: isDarkTheme ? Color(0xFF111111) : Colors.white, + color: isDarkTheme ? Color(0xFF111111) : Colors.white, // color: Color(0x98FFFCE5), // Semi-transparent background - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - margin: EdgeInsets.symmetric( - horizontal: 40), // Left & Right space - child: LinearProgressIndicator( - minHeight: 5, // Adjust thickness - backgroundColor: - Colors.grey[100], // Optional: Background color - valueColor: AlwaysStoppedAnimation( - Color(0xFFAA8E83)), // Loader color + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.symmetric( + horizontal: 40), // Left & Right space + child: LinearProgressIndicator( + minHeight: 5, // Adjust thickness + backgroundColor: + Colors.grey[100], // Optional: Background color + valueColor: AlwaysStoppedAnimation( + Color(0xFFAA8E83)), // Loader color + ), + ), + ], ), - ), - ], - ), - ) + ) : Column( - children: [ - TabBarHeader( - tabs: tabs, - selectedIndex: selectedTabIndex, - onTabSelected: (index) { - setState(() { - selectedTabIndex = index; - }); - }, - isDarkTheme: isDarkTheme), - Expanded( - child: selectedTabIndex == 0 - ? (bookmarks.isNotEmpty - ? SingleChildScrollView( - child: Container( - padding: const EdgeInsets.all(13.0), - child: Column( - children: List.generate( - transformedList.length, (i) { - final mainTopic = transformedList[i]; - print('oustside1 $mainTopic'); - final list = List.from( - mainTopic['SubTopic'] ?? []); - print('oustside2 $list'); - return CustomExpandableTile( - index: i, - isExpanded: expandedIndex == i, - onTap: (int index) { - // 🔹 Expecting an index - setState(() { - expandedIndex = - (expandedIndex == index) - ? null - : index; - }); - }, - title: mainTopic['main_topic'] ?? - 'No Topic', - childWidget: Container( - decoration: BoxDecoration( - color: isDarkTheme - ? Color(0xFF111111) - : Colors.white, - // borderRadius: BorderRadius.all(Radius.circular(20)) - ), - padding: const EdgeInsets.symmetric( - vertical: 16), - child: GridView.builder( - shrinkWrap: true, - physics: - NeverScrollableScrollPhysics(), - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 10.0, - mainAxisSpacing: 10.0, - mainAxisExtent: 100, - ), - itemCount: list.length, - itemBuilder: (context, index) { - return _buildBoxes( - mainTopic['SubTopic'][index], - context, - mainTopic['valueColor'], - isDarkTheme); - }, - ), - ), - filteredBookmarks: List.from( - mainTopic['SubTopic'] ?? []), - titleBackgroundColor: - mainTopic['valueColor'], - // Ensure it's a new list - isDarkTheme: isDarkTheme, - ); - }), - ), - ), - ) - : Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon(Icons.info_outline, - size: 100, color: Colors.grey[400]), - SizedBox(height: 16), - Text( - context.translate('No BookMark Added', - 'لم يتم إضافة أي علامة مرجعية'), - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - fontSize: 16, - color: Colors.grey), - ), - ], - ), - )) - : filteredBookmarks.isEmpty - ? Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon(Icons.info_outline, - size: 100, color: Colors.grey[400]), - SizedBox(height: 16), - Text( - context.translate('No BookMark Added', - 'لم يتم إضافة أي علامة مرجعية'), - style: TextStyle( - fontSize: 16, - color: Colors.grey, - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - ), - ), - ], - ), - ) - : Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - margin: const EdgeInsets.all(8.0), - child: Column( - children: [ - Container( - decoration: BoxDecoration( - color: tabs[selectedTabIndex] - ['color'], - borderRadius: BorderRadius.only( - topLeft: Radius.circular(20), - topRight: Radius.circular(20)) - - // borderRadius: BorderRadius.all( - // Radius.circular(35)) - - ), - padding: const EdgeInsets.only( - left: 16, - bottom: 5, - top: 5, - right: 10), - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Text( - tabs[selectedTabIndex] - ['titleUpper'], - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', + children: [ + TabBarHeader( + tabs: tabs, + selectedIndex: selectedTabIndex, + onTabSelected: (index) { + setState(() { + selectedTabIndex = index; + }); + }, + isDarkTheme: isDarkTheme), + Expanded( + child: selectedTabIndex == 0 + ? (bookmarks.isNotEmpty + ? SingleChildScrollView( + child: Container( + padding: const EdgeInsets.all(13.0), + child: Column( + children: List.generate( + transformedList.length, (i) { + final mainTopic = transformedList[i]; + print('oustside1 $mainTopic'); + final list = List.from( + mainTopic['SubTopic'] ?? []); + print('oustside2 $list'); + return CustomExpandableTile( + index: i, + isExpanded: expandedIndex == i, + onTap: (int index) { + // 🔹 Expecting an index + setState(() { + expandedIndex = + (expandedIndex == index) + ? null + : index; + }); + }, + title: mainTopic['main_topic'] ?? + 'No Topic', + childWidget: Container( + decoration: BoxDecoration( + color: isDarkTheme + ? Color(0xFF111111) + : Colors.white, + // borderRadius: BorderRadius.all(Radius.circular(20)) + ), + padding: const EdgeInsets.symmetric( + vertical: 16), + child: GridView.builder( + shrinkWrap: true, + physics: + NeverScrollableScrollPhysics(), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 10.0, + mainAxisSpacing: 10.0, + mainAxisExtent: 100, + ), + itemCount: list.length, + itemBuilder: (context, index) { + return _buildBoxes( + mainTopic['SubTopic'][index], + context, + mainTopic['valueColor'], + isDarkTheme); + }, + ), + ), + filteredBookmarks: List.from( + mainTopic['SubTopic'] ?? []), + titleBackgroundColor: + mainTopic['valueColor'], + // Ensure it's a new list + isDarkTheme: isDarkTheme, + ); + }), + ), + ), + ) + : Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.info_outline, + size: 100, color: Colors.grey[400]), + SizedBox(height: 16), + Text( + context.translate('No BookMark Added', + 'لم يتم إضافة أي علامة مرجعية'), + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + fontSize: 16, + color: Colors.grey), + ), + ], + ), + )) + : filteredBookmarks.isEmpty + ? Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.info_outline, + size: 100, color: Colors.grey[400]), + SizedBox(height: 16), + Text( + context.translate('No BookMark Added', + 'لم يتم إضافة أي علامة مرجعية'), + style: TextStyle( + fontSize: 16, + color: Colors.grey, + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + ), + ), + ], + ), + ) + : Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + margin: const EdgeInsets.all(8.0), + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: tabs[selectedTabIndex] + ['color'], + borderRadius: BorderRadius.only( + topLeft: Radius.circular(20), + topRight: Radius.circular(20)) + + // borderRadius: BorderRadius.all( + // Radius.circular(35)) + + ), + padding: const EdgeInsets.only( + left: 16, + bottom: 5, + top: 5, + right: 10), + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text( + tabs[selectedTabIndex] + ['titleUpper'], + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + color: Colors.white, + fontWeight: FontWeight.w600, + fontSize: 20, + ), + ), + ], + ), + ), + SizedBox( + height: 20, + ), + Expanded( + child: GridView.builder( + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 10.0, + mainAxisSpacing: 10.0, + mainAxisExtent: 100, + ), + itemCount: filteredBookmarks.length, + itemBuilder: (context, index) { + return _buildBox( + filteredBookmarks[index], + context, + isDarkTheme); + }, + ), + ), + ], + ), ), - color: Colors.white, - fontWeight: FontWeight.w600, - fontSize: 20, ), - ), - ], - ), - ), - SizedBox( - height: 20, - ), - Expanded( - child: GridView.builder( - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 10.0, - mainAxisSpacing: 10.0, - mainAxisExtent: 100, - ), - itemCount: filteredBookmarks.length, - itemBuilder: (context, index) { - return _buildBox( - filteredBookmarks[index], - context, - isDarkTheme); - }, - ), - ), - ], ), - ), + ], ), - ), - ], - ), ), ); } @@ -856,11 +883,11 @@ class _BookMarkState extends ConsumerState { } Widget _buildBoxes( - Map data, - BuildContext context, - Color styleColor, - bool isDarkTheme, - ) { + Map data, + BuildContext context, + Color styleColor, + bool isDarkTheme, + ) { // Color borderColor = data['valueColor']; print('inside function $data'); return GestureDetector( @@ -973,9 +1000,9 @@ class TabBarHeader extends StatelessWidget { TabBarHeader( {required this.tabs, - required this.selectedIndex, - required this.onTabSelected, - required this.isDarkTheme}); + required this.selectedIndex, + required this.onTabSelected, + required this.isDarkTheme}); @override Widget build(BuildContext context) { @@ -995,7 +1022,7 @@ class TabBarHeader extends StatelessWidget { onPressed: () => onTabSelected(index), style: ButtonStyle( foregroundColor: - MaterialStateProperty.resolveWith((states) { + MaterialStateProperty.resolveWith((states) { return selectedIndex == index ? entry.value['color'] : Color(0xFF898C81); @@ -1078,7 +1105,7 @@ class _CustomExpandableTileState extends State { color: widget.isDarkTheme ? Color(0xFF111111) : Colors - .white, // Ensuring the background outside the rounded container is white + .white, // Ensuring the background outside the rounded container is white ), child: Container( decoration: BoxDecoration( @@ -1086,8 +1113,8 @@ class _CustomExpandableTileState extends State { borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20)) - // borderRadius: BorderRadius.all(Radius.circular(35)) - ), + // borderRadius: BorderRadius.all(Radius.circular(35)) + ), padding: const EdgeInsets.only( left: 16, bottom: 5, top: 5, right: 10), child: Row( @@ -1128,9 +1155,9 @@ class _CustomExpandableTileState extends State { // height: widget.isExpanded ? myheight * 0.4 : 0, child: widget.isExpanded ? SingleChildScrollView( - child: Column( - children: [ - widget.childWidget, + child: Column( + children: [ + widget.childWidget, // Container( // decoration: BoxDecoration( // color: Colors.white, @@ -1153,9 +1180,9 @@ class _CustomExpandableTileState extends State { // }, // ), // ), - ], - ), - ) + ], + ), + ) : null, ), ), @@ -1163,4 +1190,4 @@ class _CustomExpandableTileState extends State { ), ); } -} \ No newline at end of file +} diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart b/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart index 29242495..bc5a59e2 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart @@ -53,8 +53,11 @@ class _ContactState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse( + baseUrl + '?language=$locale&color_mode=$themeMode', + ), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -87,7 +90,7 @@ class _ContactState extends ConsumerState { ref.listen(localeProvider, (previous, next) async { final localeCode = next?.languageCode ?? 'en'; // Default to 'en' if null - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); }); ref.listen(localeProvider, (previous, next) async { @@ -95,7 +98,7 @@ class _ContactState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && 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 230d4fdd..42a0e87e 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart @@ -17,11 +17,14 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:uae_stat/config/api_config.dart'; import 'package:uae_stat/config/connectivity_provider.dart'; import 'package:uae_stat/config/my_theme.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; +import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:uae_stat/config/toggle_lang_service.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/misc_icon_asset_path.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; import 'package:uae_stat/l10n/app_localizations.dart'; @@ -182,9 +185,22 @@ class _EditProfileState extends ConsumerState { Future _fetchUserData() async { try { print('EDIT PROFILE isPageLoad'); - final adminAuth = await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); - final adminToken = adminAuth.token; + // final adminAuth = await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + + final auth = ref.watch(authProvider); + + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // final adminToken = adminAuth.token; + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); print('adminToken- $adminToken'); final userDetailsResponse = await _pb.collection('users').getOne( userId, @@ -207,9 +223,9 @@ class _EditProfileState extends ConsumerState { // _selectedCountry = userDetailsResponse.data['country_region'] ?? ''; final countryName = - (userDetailsResponse.data['country_region'] ?? '').toLowerCase(); + (userDetailsResponse.data['country_region'] ?? '').toLowerCase(); _selectedCountry = ISOCountry.values.firstWhere( - (e) => e.nameEN.toLowerCase() == countryName, + (e) => e.nameEN.toLowerCase() == countryName, orElse: () => ISOCountry.numeric784, // fallback to UAE ); @@ -237,7 +253,7 @@ class _EditProfileState extends ConsumerState { if (avatarFilename.isNotEmpty && recordId.isNotEmpty) { _avatarUrl = - '$apiUrl/api/files/$collectionId/$recordId/$avatarFilename'; + '$apiUrl/api/files/$collectionId/$recordId/$avatarFilename'; } else { _avatarUrl = ''; // Reset to default or empty } @@ -270,14 +286,14 @@ class _EditProfileState extends ConsumerState { // await Future.delayed(Duration(seconds: 8)); // Example delay final XFile? pickedFile = - await _picker.pickImage(source: ImageSource.gallery); + await _picker.pickImage(source: ImageSource.gallery); if (pickedFile != null) { setState(() { isLoader = true; // Start loading }); print(pickedFile); final String fileExtension = - pickedFile.path.split('.').last.toLowerCase(); + pickedFile.path.split('.').last.toLowerCase(); print('fileExtension $fileExtension'); if (fileExtension == 'jpg' || fileExtension == 'jpeg' || @@ -291,14 +307,14 @@ class _EditProfileState extends ConsumerState { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - context.translate('Please select a JPG, JPEG, or PNG file.', - 'يرجى تحديد ملف بصيغة JPG أو JPEG أو PNG.'), - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - )), - )), + context.translate('Please select a JPG, JPEG, or PNG file.', + 'يرجى تحديد ملف بصيغة JPG أو JPEG أو PNG.'), + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + )), + )), ); } } @@ -414,7 +430,7 @@ class _EditProfileState extends ConsumerState { // Create a multipart request final uri = - Uri.parse('${_pb.baseUrl}/api/collections/users/records/$userID'); + Uri.parse('${_pb.baseUrl}/api/collections/users/records/$userID'); final request = http.MultipartRequest('PATCH', uri); // Add fields to the request @@ -462,13 +478,13 @@ class _EditProfileState extends ConsumerState { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context)!.profile_updated_successfully, - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - )), - )), + AppLocalizations.of(context)!.profile_updated_successfully, + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + )), + )), ); }); @@ -484,9 +500,9 @@ class _EditProfileState extends ConsumerState { 'Failed to update profile: ${response.statusCode}', style: TextStyle( fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - )), + 'Roboto', + 'NotoKufi', + )), ), ), ); @@ -498,13 +514,13 @@ class _EditProfileState extends ConsumerState { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - 'Failed to update profile: $error', - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - )), - )), + 'Failed to update profile: $error', + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + )), + )), ); } } else { @@ -556,7 +572,7 @@ class _EditProfileState extends ConsumerState { ref.listen(localeProvider, (previous, next) async { final localeCode = next?.languageCode ?? 'en'; // Default to 'en' if null - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); setState(() { isLoader = true; }); @@ -599,933 +615,934 @@ class _EditProfileState extends ConsumerState { ), body: isLoader ? Container( - color: Color(0x98FFFCE5), // Semi-transparent background - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - margin: EdgeInsets.symmetric( - horizontal: 40), // Left & Right space - child: LinearProgressIndicator( - minHeight: 5, // Adjust thickness - backgroundColor: - Colors.grey[100], // Optional: Background color - valueColor: AlwaysStoppedAnimation( - Color(0xFFAA8E83)), // Loader color + color: Color(0x98FFFCE5), // Semi-transparent background + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.symmetric( + horizontal: 40), // Left & Right space + child: LinearProgressIndicator( + minHeight: 5, // Adjust thickness + backgroundColor: + Colors.grey[100], // Optional: Background color + valueColor: AlwaysStoppedAnimation( + Color(0xFFAA8E83)), // Loader color + ), + ), + ], ), - ), - ], - ), - ) + ) : Container( - color: isDarkTheme ? Color(0xFF111111) : null, - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.only( - left: 10.0, right: 10.0, top: 3.0), - child: Column( - children: [ - SingleChildScrollView( - child: Form( - key: _formKey, - child: Padding( - // padding: const EdgeInsets.all(20.0), - padding: const EdgeInsets.only( - top: 20.0, - bottom: 20.0, - left: 25, - right: 25), - child: Column( - children: [ - // CircleAvatar( - // radius: 50, - // backgroundImage: _profileImage != null - // ? FileImage( - // _profileImage!) // If a local file is selected - // : _avatarUrl.isNotEmpty - // ? NetworkImage(_avatarUrl) // Load from URL - // : AssetImage( - // "assets/edit_profile/profile.png") - // as ImageProvider, - // - // //backgroundImage: NetworkImage(_avatarUrl) as ImageProvider, - // - // child: - // Align( - // alignment: Alignment.bottomRight, - // child: GestureDetector( - // onTap: _pickImage, // Call `_pickImage` on tap - // child: CircleAvatar( - // radius: 15, - // backgroundColor: Colors.white, - // child: Icon( - // Icons.camera_alt, - // size: 15, - // color: Colors.grey, - // ), - // ), - // ), - // ), - // ), - - // Stack( - // alignment: Alignment.center, - // children: [ - // // FutureBuilder to load the image - // FutureBuilder( - // future: _loadProfileImage(), - // builder: (context, snapshot) { - // if (snapshot.connectionState == ConnectionState.waiting) { - // // While the image is loading, show a progress indicator - // return CircleAvatar( - // radius: 50, - // child: CircularProgressIndicator(), - // ); - // } else if (snapshot.hasError || snapshot.data == null) { - // // If there's an error or no image, show an error icon - // return CircleAvatar( - // radius: 50, - // child: CircularProgressIndicator(), - // ); - // } else { - // // Display the loaded image - // return CircleAvatar( - // radius: 50, - // backgroundImage: snapshot.data, - // child: Align( - // alignment: Alignment.bottomRight, - // child: GestureDetector( - // onTap: _pickImage, - // child: CircleAvatar( - // radius: 15, - // backgroundColor: Colors.white, - // child: Icon( - // Icons.camera_alt, - // size: 15, - // color: Colors.grey, - // ), - // ), - // ), - // ), - // ); - // } - // }, - // ), - // ], - // ), - - Stack( - alignment: Alignment.center, - children: [ - CircleAvatar( - radius: 50, - backgroundImage: _profileImage != - null - ? FileImage( - _profileImage!) // If a local file is selected - : _avatarUrl.isNotEmpty - ? NetworkImage( - _avatarUrl) // Load from URL - : AssetImage( - 'assets/edit_profile/profile.jpg') - as ImageProvider, - child: _avatarUrl.isNotEmpty - ? FutureBuilder( - future: - _loadImage(_avatarUrl), - builder: - (context, snapshot) { - if (snapshot - .connectionState == - ConnectionState - .waiting) { - return Center( - child: - CircularProgressIndicator(), - ); - } else if (snapshot - .hasError) { - return Center( - child: - Icon(Icons.error), - ); - } else { - return Align( - alignment: Alignment - .bottomRight, - child: - GestureDetector( - onTap: - _pickImage, // Call `_pickImage` on tap - child: CircleAvatar( - radius: 15, - backgroundColor: - Colors.white, - child: Icon( - Icons - .camera_alt, - size: 15, - color: - Colors.grey, - ), - ), - ), - ); - } - }, - ) - : Align( - alignment: - Alignment.bottomRight, - child: GestureDetector( - onTap: - _pickImage, // Call `_pickImage` on tap - child: CircleAvatar( - radius: 15, - backgroundColor: - Colors.white, - child: Icon( - Icons.camera_alt, - size: 15, - color: Colors.grey, - ), - ), - ), - ), - ), - ], - ), - - SizedBox(height: 20), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Text( - AppLocalizations.of(context)! - .register_name, - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.grey, - ), - ), - ], - ), - SizedBox(height: 10), - TextFormField( - controller: _usernameController, - focusNode: _focusNodes[0], - decoration: InputDecoration( - // hintText: _showHints[0] ? 'Mohammad Hassan' : null, - hintStyle: TextStyle( - color: Colors.grey, - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - ), - border: OutlineInputBorder( - borderRadius: - BorderRadius.circular(8), - ), - enabled: false, - ), - ), - SizedBox(height: 10), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Text( - AppLocalizations.of(context)! - .email_id, - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.grey, - ), - ), - ], - ), - SizedBox(height: 10), - TextFormField( - controller: _emailController, - focusNode: _focusNodes[1], - decoration: InputDecoration( - // hintText: _showHints[1]? 'mohammad.hassan@fcsc.gov.ae': null, - border: OutlineInputBorder( - borderRadius: - BorderRadius.circular(8), - ), - enabled: false, - ), - ), - SizedBox(height: 10), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Text( - AppLocalizations.of(context)! - .full_name, - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.grey, - ), - ), - ], - ), - SizedBox(height: 10), - TextFormField( - enabled: false, - validator: (value) { - if (value == null || value.isEmpty) { - return context.translate( - 'Required', 'مطلوب'); - } - - //RegExp(r"^[a-zA-Z\s]+$"); - final nameRegex = RegExp( - r"^[a-zA-Z0-9'\-\u0627\u0639~\u00C0-\u00FF\s]+$", - ); - if (!nameRegex.hasMatch(value)) { - return AppLocalizations.of(context)! - .invalid_characters; - } - return null; - }, - controller: _fullNameController, - focusNode: _focusNodes[2], - decoration: InputDecoration( - // hintText: _showHints[2] ? 'Mohammad' : null, - hintStyle: TextStyle( - color: Colors.grey, - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - ), - border: OutlineInputBorder( - borderRadius: - BorderRadius.circular(8), - ), - // counterText: '', - enabled: !_isProfileCompleted, - ), - // maxLength: - // 40, // Set the maximum length to 20 characters - // maxLengthEnforcement: - // MaxLengthEnforcement.enforced, - ), - SizedBox(height: 10), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Text( - AppLocalizations.of(context)!.dob, - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.grey, - ), - ), - ], - ), - SizedBox(height: 10), - TextFormField( - controller: _dateController, - focusNode: _focusNodes[3], - decoration: InputDecoration( - border: OutlineInputBorder( - borderRadius: - BorderRadius.circular(8), - ), - // hintText: _showHints[3] ? 'Select your Date of Birth' : null, - hintStyle: TextStyle( - color: Colors.grey, - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - ), - suffixIcon: Container( - width: 45, - padding: EdgeInsets.only(right: 1), - alignment: Alignment - .center, // Center the icon vertically - child: Icon( - Icons.keyboard_arrow_down_sharp, - color: Colors.grey, - ), - ), - enabled: !_isProfileCompleted, - ), - readOnly: true, - onTap: _pickDate, - validator: _validateDob, - ), - SizedBox(height: 10), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Text( - AppLocalizations.of(context)! - .region, - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - fontSize: 16, - fontWeight: FontWeight.w500, - ), - ), - ], - ), - SizedBox(height: 10), - MouseRegion( - onEnter: (_) => setState( - () => _isHoveringDropdown = true), - onExit: (_) => setState( - () => _isHoveringDropdown = false), - - child: - DropdownButtonFormField( - isExpanded: true, - value: - _selectedCountry, // ISOCountry type - decoration: InputDecoration( - enabledBorder: OutlineInputBorder( - borderRadius: - BorderRadius.circular(10), - borderSide: BorderSide( - color: Color(0xFFB68A34), - width: 1, - ), - ), - border: OutlineInputBorder( - borderRadius: - BorderRadius.circular(8), - borderSide: BorderSide( - color: Color(0xFFB68A34)), - ), - labelText: context.translate( - 'Select', 'اختيار'), - ), - icon: Icon( - Icons.keyboard_arrow_down_sharp, - color: _isHoveringPreferredLang - ? Colors.black - : Colors.grey, - ), - items: _countries.map((country) { - return DropdownMenuItem( - value: country, - child: SizedBox( - width: double.infinity, - child: Text( - context.translate( - country.nameEN, - country.nameAR), - overflow: - TextOverflow.ellipsis, - maxLines: 1, - style: TextStyle( - fontFamily: - context.translate( - 'Roboto', - 'NotoKufi'), - color: isDarkTheme - ? Colors.white - : null, - ), - ), - ), - ); - }).toList(), - onChanged: (ISOCountry? newCountry) { - setState(() { - _selectedCountry = newCountry; - }); - }, - validator: (value) { - if (value == null) - return context.translate( - 'Please select a country', - 'يرجى اختيار دولة'); - return null; - }, - ), - - // child: DropdownButtonFormField( - // style: TextStyle( - // fontFamily: context.translate( - // 'Roboto', - // 'NotoKufi', - // ), - // fontSize: 16, - // fontWeight: FontWeight.normal, - // // color: Color(0xFF544C4C), - // color: isDarkTheme - // ? Colors.white - // : Color(0xFFC3C6CB), - // ), - // value: _selectedCountry, - // decoration: InputDecoration( - // enabledBorder: OutlineInputBorder( - // borderRadius: - // BorderRadius.circular(10), - // borderSide: BorderSide( - // color: Color(0xFFB68A34), - // // color: MyTheme.topicColor( - // // IndicatorTopic - // // .economy) - // // .shade400, - // width: 1), // Enabled border - // ), - // border: OutlineInputBorder( - // borderSide: BorderSide( - // // color: Color(0xFF7296BE), - // color: Color(0xFFB68A34), - // ), - // borderRadius: - // BorderRadius.circular(8), - // ), - // labelText: 'Select', - // ), - // icon: Icon( - // Icons.keyboard_arrow_down_sharp, - // color: _isHoveringDropdown - // ? isDarkTheme - // ? Colors.white - // : Colors.black - // : Colors.grey), - // items: _countries - // .map( - // (item) => - // DropdownMenuItem( - // value: item, - // child: Text( - // item, - // style: TextStyle( - // fontFamily: - // context.translate( - // 'Roboto', - // 'NotoKufi', - // )), - // ), - // ), - // ) - // .toList(), - // onChanged: (String? newValue) { - // setState(() { - // _selectedCountry = newValue; - // }); - // }, - // validator: _validateDropdown, - // ), - ), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Text( - AppLocalizations.of(context)! - .preferredLang, - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - fontSize: 16, - fontWeight: FontWeight.w500), - ), - ], - ), - SizedBox(height: 10), - MouseRegion( - onEnter: (_) => setState(() => - _isHoveringPreferredLang = true), - onExit: (_) => setState(() => - _isHoveringPreferredLang = false), - child: DropdownButtonFormField( - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - fontSize: 16, - fontWeight: FontWeight.normal, - // color: Color(0xFF544C4C), - color: isDarkTheme - ? Colors.white - : Color(0xFFC3C6CB), - ), - value: _selectedLanguage, - decoration: InputDecoration( - enabledBorder: OutlineInputBorder( - borderRadius: - BorderRadius.circular(10), - borderSide: BorderSide( - color: Color(0xFFB68A34), - // color: MyTheme.topicColor( - // IndicatorTopic - // .economy) - // .shade400, - width: 1), // Enabled border - ), - border: OutlineInputBorder( - borderSide: BorderSide( - color: Color(0xFFB68A34), - // color: Color(0xFF7296BE), - ), - borderRadius: - BorderRadius.circular(8), - ), - labelText: 'Select', - ), - icon: Icon( - Icons.keyboard_arrow_down_sharp, - color: _isHoveringPreferredLang - ? Colors.black - : Colors.grey), - items: preferred_language - .map( - (item) => - DropdownMenuItem( - value: item, - child: Text( - item, - style: TextStyle( - fontFamily: - context.translate( - 'Roboto', - 'NotoKufi', - )), - ), - ), - ) - .toList(), - onChanged: (String? newValue) { - setState(() { - _selectedLanguage = newValue; - changedPreferredLanguage = 1; - }); - }, - validator: _validatePreferredLang, - ), - ), - - SizedBox(height: 20), - if (!_isProfileCompleted) // Conditional rendering - Column( - crossAxisAlignment: - CrossAxisAlignment.start, + color: isDarkTheme ? Color(0xFF111111) : null, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.only( + left: 10.0, right: 10.0, top: 3.0), + child: Column( + children: [ + SingleChildScrollView( + child: Form( + key: _formKey, + child: Padding( + // padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.only( + top: 20.0, + bottom: 20.0, + left: 25, + right: 25), + child: Column( children: [ - Row( - children: [ - Checkbox( - value: isChecked, - onChanged: (value) { - setState(() { - isChecked = - value ?? false; - showError = false; - }); - }, - side: BorderSide( - color: showError - ? Color(0xFFb22222) - : MyTheme.topicColor( - IndicatorTopic - .economy) - .shade400, - width: 1.5, - ), - ), - Expanded( - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - SizedBox(height: 10), - Text.rich( - TextSpan( - text: AppLocalizations - .of(context)! - .agree, - style: TextStyle( - fontFamily: context - .translate( - 'Roboto', - 'NotoKufi', - ), - color: - Colors.black), - children: [ - TextSpan( - text: AppLocalizations - .of( - context, - )! - .terms_conditions, - style: TextStyle( - fontFamily: context - .translate( - 'Roboto', - 'NotoKufi', - ), - // color: Colors.blue, - // color: Color( - // 0xFF648CBA), - // - color: Color( - 0xFFB68A34), - decoration: - TextDecoration - .underline, - ), - recognizer: TapGestureRecognizer() - ..onTap = () => - context.push( - '/termsandconditions'), - ), - TextSpan( - text: - AppLocalizations - .of( - context, - )! - .t_and, - style: TextStyle( - fontFamily: context - .translate( - 'Roboto', - 'NotoKufi', - ), - color: Colors - .black, - ), - ), - TextSpan( - text: AppLocalizations - .of( - context, - )! - .privacy_policy, - style: TextStyle( - fontFamily: context - .translate( - 'Roboto', - 'NotoKufi', - ), - // color: Colors.blue, - color: Color( - 0xFFB68A34), + // CircleAvatar( + // radius: 50, + // backgroundImage: _profileImage != null + // ? FileImage( + // _profileImage!) // If a local file is selected + // : _avatarUrl.isNotEmpty + // ? NetworkImage(_avatarUrl) // Load from URL + // : AssetImage( + // "assets/edit_profile/profile.png") + // as ImageProvider, + // + // //backgroundImage: NetworkImage(_avatarUrl) as ImageProvider, + // + // child: + // Align( + // alignment: Alignment.bottomRight, + // child: GestureDetector( + // onTap: _pickImage, // Call `_pickImage` on tap + // child: CircleAvatar( + // radius: 15, + // backgroundColor: Colors.white, + // child: Icon( + // Icons.camera_alt, + // size: 15, + // color: Colors.grey, + // ), + // ), + // ), + // ), + // ), - // color: Color( - // 0xFF648CBA), - decoration: - TextDecoration - .underline, - ), - recognizer: TapGestureRecognizer() - ..onTap = () => - context.push( - '/privacy_policy'), - ), - TextSpan( - text: AppLocalizations - .of( - context, - )! - .conditions, - style: TextStyle( - fontFamily: context - .translate( - 'Roboto', - 'NotoKufi', + // Stack( + // alignment: Alignment.center, + // children: [ + // // FutureBuilder to load the image + // FutureBuilder( + // future: _loadProfileImage(), + // builder: (context, snapshot) { + // if (snapshot.connectionState == ConnectionState.waiting) { + // // While the image is loading, show a progress indicator + // return CircleAvatar( + // radius: 50, + // child: CircularProgressIndicator(), + // ); + // } else if (snapshot.hasError || snapshot.data == null) { + // // If there's an error or no image, show an error icon + // return CircleAvatar( + // radius: 50, + // child: CircularProgressIndicator(), + // ); + // } else { + // // Display the loaded image + // return CircleAvatar( + // radius: 50, + // backgroundImage: snapshot.data, + // child: Align( + // alignment: Alignment.bottomRight, + // child: GestureDetector( + // onTap: _pickImage, + // child: CircleAvatar( + // radius: 15, + // backgroundColor: Colors.white, + // child: Icon( + // Icons.camera_alt, + // size: 15, + // color: Colors.grey, + // ), + // ), + // ), + // ), + // ); + // } + // }, + // ), + // ], + // ), + + Stack( + alignment: Alignment.center, + children: [ + CircleAvatar( + radius: 50, + backgroundImage: _profileImage != + null + ? FileImage( + _profileImage!) // If a local file is selected + : _avatarUrl.isNotEmpty + ? NetworkImage( + _avatarUrl) // Load from URL + : AssetImage( + 'assets/edit_profile/profile.jpg') + as ImageProvider, + child: _avatarUrl.isNotEmpty + ? FutureBuilder( + future: + _loadImage(_avatarUrl), + builder: + (context, snapshot) { + if (snapshot + .connectionState == + ConnectionState + .waiting) { + return Center( + child: + CircularProgressIndicator(), + ); + } else if (snapshot + .hasError) { + return Center( + child: + Icon(Icons.error), + ); + } else { + return Align( + alignment: Alignment + .bottomRight, + child: + GestureDetector( + onTap: + _pickImage, // Call `_pickImage` on tap + child: CircleAvatar( + radius: 15, + backgroundColor: + Colors.white, + child: Icon( + Icons + .camera_alt, + size: 15, + color: + Colors.grey, + ), + ), ), - color: Colors - .black, + ); + } + }, + ) + : Align( + alignment: + Alignment.bottomRight, + child: GestureDetector( + onTap: + _pickImage, // Call `_pickImage` on tap + child: CircleAvatar( + radius: 15, + backgroundColor: + Colors.white, + child: Icon( + Icons.camera_alt, + size: 15, + color: Colors.grey, ), ), - ], + ), ), - textAlign: - TextAlign.start, - maxLines: 2, - overflow: TextOverflow - .visible, - softWrap: true, - ), - ], + ), + ], + ), + + SizedBox(height: 20), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text( + AppLocalizations.of(context)! + .register_name, + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.grey, ), ), ], ), - if (showError) - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Padding( - padding: - const EdgeInsets.only( - left: 10.0), - child: Text( - 'Please agree to terms and conditions', - style: TextStyle( - fontFamily: + SizedBox(height: 10), + TextFormField( + controller: _usernameController, + focusNode: _focusNodes[0], + decoration: InputDecoration( + // hintText: _showHints[0] ? 'Mohammad Hassan' : null, + hintStyle: TextStyle( + color: Colors.grey, + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + ), + border: OutlineInputBorder( + borderRadius: + BorderRadius.circular(8), + ), + enabled: false, + ), + ), + SizedBox(height: 10), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text( + AppLocalizations.of(context)! + .email_id, + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.grey, + ), + ), + ], + ), + SizedBox(height: 10), + TextFormField( + controller: _emailController, + focusNode: _focusNodes[1], + decoration: InputDecoration( + // hintText: _showHints[1]? 'mohammad.hassan@fcsc.gov.ae': null, + border: OutlineInputBorder( + borderRadius: + BorderRadius.circular(8), + ), + enabled: false, + ), + ), + SizedBox(height: 10), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text( + AppLocalizations.of(context)! + .full_name, + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.grey, + ), + ), + ], + ), + SizedBox(height: 10), + TextFormField( + enabled: false, + validator: (value) { + if (value == null || value.isEmpty) { + return context.translate( + 'Required', 'مطلوب'); + } + + //RegExp(r"^[a-zA-Z\s]+$"); + final nameRegex = RegExp( + r"^[a-zA-Z0-9'\-\u0627\u0639~\u00C0-\u00FF\s]+$", + ); + if (!nameRegex.hasMatch(value)) { + return AppLocalizations.of(context)! + .invalid_characters; + } + return null; + }, + controller: _fullNameController, + focusNode: _focusNodes[2], + decoration: InputDecoration( + // hintText: _showHints[2] ? 'Mohammad' : null, + hintStyle: TextStyle( + color: Colors.grey, + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + ), + border: OutlineInputBorder( + borderRadius: + BorderRadius.circular(8), + ), + // counterText: '', + enabled: !_isProfileCompleted, + ), + // maxLength: + // 40, // Set the maximum length to 20 characters + // maxLengthEnforcement: + // MaxLengthEnforcement.enforced, + ), + SizedBox(height: 10), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text( + AppLocalizations.of(context)!.dob, + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.grey, + ), + ), + ], + ), + SizedBox(height: 10), + TextFormField( + controller: _dateController, + focusNode: _focusNodes[3], + decoration: InputDecoration( + border: OutlineInputBorder( + borderRadius: + BorderRadius.circular(8), + ), + // hintText: _showHints[3] ? 'Select your Date of Birth' : null, + hintStyle: TextStyle( + color: Colors.grey, + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + ), + suffixIcon: Container( + width: 45, + padding: EdgeInsets.only(right: 1), + alignment: Alignment + .center, // Center the icon vertically + child: Icon( + Icons.keyboard_arrow_down_sharp, + color: Colors.grey, + ), + ), + enabled: !_isProfileCompleted, + ), + readOnly: true, + onTap: _pickDate, + validator: _validateDob, + ), + SizedBox(height: 10), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text( + AppLocalizations.of(context)! + .region, + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + SizedBox(height: 10), + MouseRegion( + onEnter: (_) => setState( + () => _isHoveringDropdown = true), + onExit: (_) => setState( + () => _isHoveringDropdown = false), + + child: + DropdownButtonFormField( + isExpanded: true, + value: + _selectedCountry, // ISOCountry type + decoration: InputDecoration( + enabledBorder: OutlineInputBorder( + borderRadius: + BorderRadius.circular(10), + borderSide: BorderSide( + color: Color(0xFFB68A34), + width: 1, + ), + ), + border: OutlineInputBorder( + borderRadius: + BorderRadius.circular(8), + borderSide: BorderSide( + color: Color(0xFFB68A34)), + ), + labelText: context.translate( + 'Select', 'اختيار'), + ), + icon: Icon( + Icons.keyboard_arrow_down_sharp, + color: _isHoveringPreferredLang + ? Colors.black + : Colors.grey, + ), + items: _countries.map((country) { + return DropdownMenuItem( + value: country, + child: SizedBox( + width: double.infinity, + child: Text( context.translate( - 'Roboto', - 'NotoKufi', + country.nameEN, + country.nameAR), + overflow: + TextOverflow.ellipsis, + maxLines: 1, + style: TextStyle( + fontFamily: + context.translate( + 'Roboto', + 'NotoKufi'), + color: isDarkTheme + ? Colors.white + : null, ), - color: Colors.red[700], - fontSize: 12, + ), + ), + ); + }).toList(), + onChanged: (ISOCountry? newCountry) { + setState(() { + _selectedCountry = newCountry; + }); + }, + validator: (value) { + if (value == null) + return context.translate( + 'Please select a country', + 'يرجى اختيار دولة'); + return null; + }, + ), + + // child: DropdownButtonFormField( + // style: TextStyle( + // fontFamily: context.translate( + // 'Roboto', + // 'NotoKufi', + // ), + // fontSize: 16, + // fontWeight: FontWeight.normal, + // // color: Color(0xFF544C4C), + // color: isDarkTheme + // ? Colors.white + // : Color(0xFFC3C6CB), + // ), + // value: _selectedCountry, + // decoration: InputDecoration( + // enabledBorder: OutlineInputBorder( + // borderRadius: + // BorderRadius.circular(10), + // borderSide: BorderSide( + // color: Color(0xFFB68A34), + // // color: MyTheme.topicColor( + // // IndicatorTopic + // // .economy) + // // .shade400, + // width: 1), // Enabled border + // ), + // border: OutlineInputBorder( + // borderSide: BorderSide( + // // color: Color(0xFF7296BE), + // color: Color(0xFFB68A34), + // ), + // borderRadius: + // BorderRadius.circular(8), + // ), + // labelText: 'Select', + // ), + // icon: Icon( + // Icons.keyboard_arrow_down_sharp, + // color: _isHoveringDropdown + // ? isDarkTheme + // ? Colors.white + // : Colors.black + // : Colors.grey), + // items: _countries + // .map( + // (item) => + // DropdownMenuItem( + // value: item, + // child: Text( + // item, + // style: TextStyle( + // fontFamily: + // context.translate( + // 'Roboto', + // 'NotoKufi', + // )), + // ), + // ), + // ) + // .toList(), + // onChanged: (String? newValue) { + // setState(() { + // _selectedCountry = newValue; + // }); + // }, + // validator: _validateDropdown, + // ), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text( + AppLocalizations.of(context)! + .preferredLang, + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + fontSize: 16, + fontWeight: FontWeight.w500), + ), + ], + ), + SizedBox(height: 10), + MouseRegion( + onEnter: (_) => setState(() => + _isHoveringPreferredLang = true), + onExit: (_) => setState(() => + _isHoveringPreferredLang = false), + child: DropdownButtonFormField( + style: TextStyle( + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + fontSize: 16, + fontWeight: FontWeight.normal, + // color: Color(0xFF544C4C), + color: isDarkTheme + ? Colors.white + : Color(0xFFC3C6CB), + ), + value: _selectedLanguage, + decoration: InputDecoration( + enabledBorder: OutlineInputBorder( + borderRadius: + BorderRadius.circular(10), + borderSide: BorderSide( + color: Color(0xFFB68A34), + // color: MyTheme.topicColor( + // IndicatorTopic + // .economy) + // .shade400, + width: 1), // Enabled border + ), + border: OutlineInputBorder( + borderSide: BorderSide( + color: Color(0xFFB68A34), + // color: Color(0xFF7296BE), + ), + borderRadius: + BorderRadius.circular(8), + ), + labelText: 'Select', + ), + icon: Icon( + Icons.keyboard_arrow_down_sharp, + color: _isHoveringPreferredLang + ? Colors.black + : Colors.grey), + items: preferred_language + .map( + (item) => + DropdownMenuItem( + value: item, + child: Text( + item, + style: TextStyle( + fontFamily: + context.translate( + 'Roboto', + 'NotoKufi', + )), + ), + ), + ) + .toList(), + onChanged: (String? newValue) { + setState(() { + _selectedLanguage = newValue; + changedPreferredLanguage = 1; + }); + }, + validator: _validatePreferredLang, + ), + ), + + SizedBox(height: 20), + if (!_isProfileCompleted) // Conditional rendering + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + Checkbox( + value: isChecked, + onChanged: (value) { + setState(() { + isChecked = + value ?? false; + showError = false; + }); + }, + side: BorderSide( + color: showError + ? Color(0xFFb22222) + : MyTheme.topicColor( + IndicatorTopic + .economy) + .shade400, + width: 1.5, + ), + ), + Expanded( + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + SizedBox(height: 10), + Text.rich( + TextSpan( + text: AppLocalizations + .of(context)! + .agree, + style: TextStyle( + fontFamily: context + .translate( + 'Roboto', + 'NotoKufi', + ), + color: + Colors.black), + children: [ + TextSpan( + text: AppLocalizations + .of( + context, + )! + .terms_conditions, + style: TextStyle( + fontFamily: context + .translate( + 'Roboto', + 'NotoKufi', + ), + // color: Colors.blue, + // color: Color( + // 0xFF648CBA), + // + color: Color( + 0xFFB68A34), + decoration: + TextDecoration + .underline, + ), + recognizer: TapGestureRecognizer() + ..onTap = () => + context.push( + '/termsandconditions'), + ), + TextSpan( + text: + AppLocalizations + .of( + context, + )! + .t_and, + style: TextStyle( + fontFamily: context + .translate( + 'Roboto', + 'NotoKufi', + ), + color: Colors + .black, + ), + ), + TextSpan( + text: AppLocalizations + .of( + context, + )! + .privacy_policy, + style: TextStyle( + fontFamily: context + .translate( + 'Roboto', + 'NotoKufi', + ), + // color: Colors.blue, + color: Color( + 0xFFB68A34), + + // color: Color( + // 0xFF648CBA), + decoration: + TextDecoration + .underline, + ), + recognizer: TapGestureRecognizer() + ..onTap = () => + context.push( + '/privacy_policy'), + ), + TextSpan( + text: AppLocalizations + .of( + context, + )! + .conditions, + style: TextStyle( + fontFamily: context + .translate( + 'Roboto', + 'NotoKufi', + ), + color: Colors + .black, + ), + ), + ], + ), + textAlign: + TextAlign.start, + maxLines: 2, + overflow: TextOverflow + .visible, + softWrap: true, + ), + ], + ), + ), + ], + ), + if (showError) + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Padding( + padding: + const EdgeInsets.only( + left: 10.0), + child: Text( + 'Please agree to terms and conditions', + style: TextStyle( + fontFamily: + context.translate( + 'Roboto', + 'NotoKufi', + ), + color: Colors.red[700], + fontSize: 12, + ), + ), + ), + ], + ), + ], + ), + if (isOAuthLogin != 1) + Center( + child: GestureDetector( + onTap: () { + final email = + _emailController.text; + context.push( + '/createNewPw/$userId/$email?key=editProfile'); + }, + child: Text( + AppLocalizations.of(context)! + .change_password, + style: TextStyle( + // color: Color(0xFF648CBA), + // color: isDarkTheme + // ? Color(0xFF9EB3E4) + // : Color(0xFF985400), + color: Color(0xFFB68A34), + fontSize: 14, + fontWeight: FontWeight.w700, + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', + ), + // decoration: TextDecoration.underline + ), + ), + ), + ), + SizedBox(height: 20), + // ElevatedButton.icon( + // onPressed: () { + // showConfirmationDialog(context); + // }, + // icon: Icon( + // Icons.save, + // color: Colors.white, + // ), + // label: Text( + // AppLocalizations.of(context)!.save, + // style: TextStyle(color: Colors.white), + // ), + // style: ElevatedButton.styleFrom( + // backgroundColor: Color(0xFF92722A), + // minimumSize: Size(double.infinity, 50), + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(8), + // ), + // ), + // ), + ElevatedButton( + onPressed: () { + // if ((_formKey.currentState?.validate() ?? false) && (isChecked)) { + // _formKey.currentState?.save(); + showConfirmationDialog(context); + // } else { + // setState(() { + // showError = !isChecked; // Show error if the checkbox is not checked + // }); + // } + }, + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFB68A34), + + // backgroundColor: isDarkTheme + // ? Color(0xFF24B4FB) + // : Color(0xFF92722A), + minimumSize: + Size(double.infinity, 50), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(8), + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment + .center, // Center the content + children: [ + Text( + AppLocalizations.of(context)! + .save, + style: TextStyle( + color: Colors.white, + fontFamily: context.translate( + 'Roboto', + 'NotoKufi', ), ), ), + SizedBox( + width: + 8), // Add space between text and icon + Image.asset( + MiscIconAssetPath.save, + color: Colors.white, + width: 20, + height: 20, + ), ], ), + ) ], ), - if(isOAuthLogin != 1) - Center( - child: GestureDetector( - onTap: () { - final email = _emailController.text; - context.push( - '/createNewPw/$userId/$email?key=editProfile'); - }, - child: Text( - AppLocalizations.of(context)! - .change_password, - style: TextStyle( - // color: Color(0xFF648CBA), - // color: isDarkTheme - // ? Color(0xFF9EB3E4) - // : Color(0xFF985400), - color: Color(0xFFB68A34), - fontSize: 14, - fontWeight: FontWeight.w700, - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - // decoration: TextDecoration.underline - ), - ), - ), ), - SizedBox(height: 20), - // ElevatedButton.icon( - // onPressed: () { - // showConfirmationDialog(context); - // }, - // icon: Icon( - // Icons.save, - // color: Colors.white, - // ), - // label: Text( - // AppLocalizations.of(context)!.save, - // style: TextStyle(color: Colors.white), - // ), - // style: ElevatedButton.styleFrom( - // backgroundColor: Color(0xFF92722A), - // minimumSize: Size(double.infinity, 50), - // shape: RoundedRectangleBorder( - // borderRadius: BorderRadius.circular(8), - // ), - // ), - // ), - ElevatedButton( - onPressed: () { - // if ((_formKey.currentState?.validate() ?? false) && (isChecked)) { - // _formKey.currentState?.save(); - showConfirmationDialog(context); - // } else { - // setState(() { - // showError = !isChecked; // Show error if the checkbox is not checked - // }); - // } - }, - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFB68A34), - - // backgroundColor: isDarkTheme - // ? Color(0xFF24B4FB) - // : Color(0xFF92722A), - minimumSize: - Size(double.infinity, 50), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(8), - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment - .center, // Center the content - children: [ - Text( - AppLocalizations.of(context)! - .save, - style: TextStyle( - color: Colors.white, - fontFamily: context.translate( - 'Roboto', - 'NotoKufi', - ), - ), - ), - SizedBox( - width: - 8), // Add space between text and icon - Image.asset( - MiscIconAssetPath.save, - color: Colors.white, - width: 20, - height: 20, - ), - ], - ), - ) - ], + ), ), - ), + ], ), ), - ], - ), - ), - ), - ) + ), + ) - //bottomNavigationBar: MyBottomNavBar(), - )); + //bottomNavigationBar: MyBottomNavBar(), + )); } } @@ -1660,4 +1677,4 @@ class ConfirmationDialog extends StatelessWidget { ], ); } -} \ No newline at end of file +} diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart b/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart index c9b25489..c4cc77d0 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/feedback.dart @@ -7,6 +7,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; import 'package:intl/intl.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; +import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:pocketbase/pocketbase.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -17,12 +19,14 @@ import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/feedback_asset_path.dart'; import 'package:uae_stat/infrastructure/services/packages/go_router.dart'; +import 'package:uae_stat/infrastructure/services/pocketbase_service.dart'; import 'package:uae_stat/l10n/app_localizations.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; import 'package:uae_stat/presentation/components/my_drawer.dart'; import 'package:mailer/mailer.dart'; import 'package:mailer/smtp_server.dart'; import 'package:uae_stat/presentation/components/space.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; import '../../../../config/my_theme.dart'; import '../../../../domain/use_cases/preferences_use_case.dart'; @@ -145,8 +149,9 @@ class _FeedbackFormState extends ConsumerState Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -305,7 +310,7 @@ class _FeedbackFormState extends ConsumerState setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && @@ -1001,9 +1006,22 @@ class _FeedbackFormState extends ConsumerState }; try { - final adminAuth = await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); - final adminToken = adminAuth.token; + // final adminAuth = await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + final auth = ref.watch(authProvider); + + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // + // final adminToken = adminAuth.token; + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); final response = await _pb .collection('feedback') .create(body: feedbackData, headers: {'Authorization': adminToken}); 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 2a232ff3..557114c0 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart @@ -7,6 +7,7 @@ import 'package:pocketbase/pocketbase.dart'; import 'package:uae_stat/config/api_config.dart'; import 'package:uae_stat/config/connectivity_provider.dart'; import 'package:uae_stat/config/theme/app_theme.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:uae_stat/config/toggle_lang_service.dart'; @@ -16,6 +17,7 @@ import 'package:uae_stat/presentation/components/indicators/locale_provider.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/Drawer%20Items/notification/notification.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; import 'package:uae_stat/l10n/app_localizations.dart'; @@ -58,8 +60,21 @@ class _ManageUserRouterState extends ConsumerState { Future fetchUnverifiedUsers() async { try { - await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + // await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + + final auth = ref.watch(authProvider); + + // await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); final result = await _pb.collection('users').getFullList( filter: 'role="user"', ); @@ -348,7 +363,7 @@ class _ManageUserRouterState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart b/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart index 8d492356..015433f3 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart @@ -8,6 +8,8 @@ import 'package:pocketbase/pocketbase.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:uae_stat/config/api_config.dart'; import 'package:uae_stat/config/connectivity_provider.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; +import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/config/theme/theme_provider.dart'; import 'package:uae_stat/config/toggle_lang_service.dart'; import 'package:uae_stat/domain/use_cases/language.dart'; @@ -73,8 +75,9 @@ class _NotificationPageState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -130,9 +133,22 @@ class _NotificationPageState extends ConsumerState { try { String? fetchedUserId = await getUserId(); userID = fetchedUserId; - final adminAuth = await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); - final adminToken = adminAuth.token; + // final adminAuth = await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + + final auth = ref.watch(authProvider); + // + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // final adminToken = adminAuth.token; + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); print('adminToken- ${adminToken}'); final userDetailsResponse = await _pb.collection('users').getOne( fetchedUserId!, @@ -181,7 +197,8 @@ class _NotificationPageState extends ConsumerState { Future fetchNotifications(locale) async { final baseUrl = apiUrl + '/api/getNotification'; try { - final response = await http.get(Uri.parse('$baseUrl?language=$locale')); + final response = await http.get(Uri.parse('$baseUrl?language=$locale'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { final Map jsonResponse = @@ -238,7 +255,7 @@ class _NotificationPageState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && @@ -312,7 +329,6 @@ class _NotificationPageState extends ConsumerState { // }, // ]; - // Filter notifications based on the selected tab List> filteredNotifications = selectedTabIndex == 0 ? notifications @@ -467,8 +483,12 @@ class TabBarHeader extends StatelessWidget { foregroundColor: MaterialStateProperty.resolveWith((states) { return selectedIndex == index - ? isDarkTheme ? Color(0xFFFFFFFF) : Color(0xFFB68A34) - : isDarkTheme ? Color(0xFFBBBBBB) : Color(0xFF898C81); + ? isDarkTheme + ? Color(0xFFFFFFFF) + : Color(0xFFB68A34) + : isDarkTheme + ? Color(0xFFBBBBBB) + : Color(0xFF898C81); }), ), child: Text( @@ -502,7 +522,7 @@ class TabBarHeader extends StatelessWidget { } } -class NotificationTile extends StatelessWidget { +class NotificationTile extends ConsumerWidget { final String title; final String message; final String date; @@ -524,13 +544,13 @@ class NotificationTile extends StatelessWidget { }); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { bool isPushed = userReadedNotiOrNot.contains(id); print('isPushed $isPushed , $id'); return GestureDetector( onTap: () { - readedNotification(userID, id); + readedNotification(userID, id, ref); final encodedKey = Uri.encodeQueryComponent('notification'); context.go('/notification_details', extra: { 'title': title, @@ -553,12 +573,13 @@ class NotificationTile extends StatelessWidget { title: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: EdgeInsets.only(top: 4.0, right: 6), - child: isPushed - ? const Icon(Icons.circle, size: 8, color: Color(0xFFFF274E)) - : const Icon(Icons.circle, size: 8, color: Colors.transparent), - ), + Padding( + padding: EdgeInsets.only(top: 4.0, right: 6), + child: isPushed + ? const Icon(Icons.circle, size: 8, color: Color(0xFFFF274E)) + : const Icon(Icons.circle, + size: 8, color: Colors.transparent), + ), Expanded( child: Text( title, @@ -567,8 +588,12 @@ class NotificationTile extends StatelessWidget { fontWeight: FontWeight.bold, fontFamily: context.translate('Roboto', 'NotoKufi'), color: isPushed - ? (isDarkTheme ? Colors.white : Color(0xFF414042)) // dark title - : (isDarkTheme ? Color(0xFF999999) : Color(0x99414042)), // light grey title + ? (isDarkTheme + ? Colors.white + : Color(0xFF414042)) // dark title + : (isDarkTheme + ? Color(0xFF999999) + : Color(0x99414042)), // light grey title ), ), ), @@ -590,7 +615,8 @@ class NotificationTile extends StatelessWidget { // ), // ), subtitle: Padding( - padding: const EdgeInsets.only(left: 15), // 👈 set your desired left padding here + padding: const EdgeInsets.only( + left: 15), // 👈 set your desired left padding here child: Text( date, style: TextStyle( @@ -612,10 +638,24 @@ class NotificationTile extends StatelessWidget { } final pb = PocketBase(apiUrl); -Future readedNotification(String userId, String notificationId) async { - await pb.admins.authWithPassword( - 'pb@venbainfotech.com', - 'pb@venbainfotech.com', +Future readedNotification( + String userId, String notificationId, WidgetRef ref) async { + // await pb.admins.authWithPassword( + // 'pb@venbainfotech.com', + // 'pb@venbainfotech.com', + // ); + + final auth = ref.watch(authProvider); + + // await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, ); final url = @@ -627,6 +667,7 @@ Future readedNotification(String userId, String notificationId) async { headers: { 'Content-Type': 'application/json', // Add this 'Authorization': pb.authStore.token, // Correct way to send auth token + 'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A' }, ); diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification_details.dart b/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification_details.dart index 02976b85..3f038463 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification_details.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification_details.dart @@ -88,8 +88,9 @@ class _NotificationDetailsState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -113,8 +114,9 @@ class _NotificationDetailsState extends ConsumerState { notificationID = widget.id; final baseUrl = apiUrl + '/api/getNotification'; try { - final response = await http - .get(Uri.parse('$baseUrl?language=$locale&id=$notificationID')); + final response = await http.get( + Uri.parse('$baseUrl?language=$locale&id=$notificationID'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { final Map jsonResponse = @@ -167,7 +169,7 @@ class _NotificationDetailsState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); fetchNotifications(localeCode); }); @@ -176,7 +178,7 @@ class _NotificationDetailsState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/AboutFCSC.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/AboutFCSC.dart index 2cc8ae98..3c202ec5 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/AboutFCSC.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/AboutFCSC.dart @@ -49,8 +49,9 @@ class _aboutFCSCState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -77,7 +78,7 @@ class _aboutFCSCState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && @@ -163,20 +164,19 @@ class _aboutFCSCState extends ConsumerState { ), ), SizedBox( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height * 0.36, - child: - Image.asset( - isDarkTheme - ? 'assets/user_guide/aboutfcscdark.png' - : 'assets/user_guide/aboutfcsclight.png', - ) - // Image.asset( - // 'assets/user_guide/about fcsc dark.png', - // fit: BoxFit.contain, - // ), + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height * 0.36, + child: Image.asset( + isDarkTheme + ? 'assets/user_guide/aboutfcscdark.png' + : 'assets/user_guide/aboutfcsclight.png', + ) + // Image.asset( + // 'assets/user_guide/about fcsc dark.png', + // fit: BoxFit.contain, + // ), - ), + ), SizedBox( height: 5, ), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/getStarted.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/getStarted.dart index 66f031d6..00b3709d 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/getStarted.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/AboutTheApp/getStarted.dart @@ -49,8 +49,9 @@ class _GetStartedState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -77,7 +78,7 @@ class _GetStartedState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/AppFeatures.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/AppFeatures.dart index eb0e0eb0..e612784d 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/AppFeatures.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/AppFeatures.dart @@ -52,8 +52,9 @@ class _AppFeaturesState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -80,7 +81,7 @@ class _AppFeaturesState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/ChangeMyPassword.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/ChangeMyPassword.dart index 8480ad02..b71284fd 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/ChangeMyPassword.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/ChangeMyPassword.dart @@ -50,8 +50,9 @@ class _ChangeMyPasswordState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -78,7 +79,7 @@ class _ChangeMyPasswordState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/EditMyProfile.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/EditMyProfile.dart index 0eeee03c..7cf909ae 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/EditMyProfile.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/EditMyProfile.dart @@ -50,8 +50,9 @@ class _EditMyProfileState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -78,7 +79,7 @@ class _EditMyProfileState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/howUseTheApp.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/howUseTheApp.dart index b08ebc40..a8ee29c1 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/howUseTheApp.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/howUseTheApp.dart @@ -51,8 +51,9 @@ class _HowUseTheAppState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -79,7 +80,7 @@ class _HowUseTheAppState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/purpose.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/purpose.dart index b931c8b9..bf6f21be 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/purpose.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/purpose.dart @@ -53,8 +53,9 @@ class _PurposeState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -81,7 +82,7 @@ class _PurposeState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/stayUpdate.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/stayUpdate.dart index bb4c976a..74b6c07a 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/stayUpdate.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/stayUpdate.dart @@ -53,8 +53,9 @@ class _StayUpdateState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -81,7 +82,7 @@ class _StayUpdateState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/useTheApp.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/useTheApp.dart index f5b3294a..6171d413 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/useTheApp.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/KeyFeatures/useTheApp.dart @@ -52,8 +52,9 @@ class _WhoUseTheAppState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -80,7 +81,7 @@ class _WhoUseTheAppState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/aboutApp.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/aboutApp.dart index 48395222..17ea4825 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/aboutApp.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/aboutApp.dart @@ -52,8 +52,9 @@ class _aboutTheAppState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -80,7 +81,7 @@ class _aboutTheAppState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/faq_page.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/faq_page.dart index 6687ba59..d6fcb6b8 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/faq_page.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/faq_page.dart @@ -50,8 +50,9 @@ class _FAQPageState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -78,7 +79,7 @@ class _FAQPageState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/features.dart b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/features.dart index 263665c5..c903106d 100755 --- a/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/features.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/user_guide/features.dart @@ -53,8 +53,9 @@ class _UsingFeaturesState extends ConsumerState { Future fetchData(locale, themeMode) async { const baseUrl = '$apiUrl/api/getUAENumbersData'; try { - final response = await http - .get(Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode')); + final response = await http.get( + Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { setState(() { homePageData = (json.decode(response.body) as List) @@ -81,7 +82,7 @@ class _UsingFeaturesState extends ConsumerState { setState(() { isLoading = true; }); - await _userService.updateLanguage(localeCode); + await _userService.updateLanguage(localeCode, ref); final currentTheme = ref.read(themeProvider); final isDark = currentTheme == ThemeMode.dark || (currentTheme == ThemeMode.system && diff --git a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart index 9fb0dc70..50a585a7 100644 --- a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart +++ b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart @@ -15,6 +15,7 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:tutorial_coach_mark/tutorial_coach_mark.dart'; import 'package:uae_stat/config/injector.dart'; import 'package:uae_stat/config/theme/app_theme.dart'; +import 'package:uae_stat/config/theme/auth_provider.dart'; import 'package:uae_stat/config/theme/service.dart'; import 'package:uae_stat/config/theme/themeDialog.dart'; import 'package:uae_stat/config/theme/theme_provider.dart'; @@ -31,6 +32,7 @@ import 'package:uae_stat/presentation/Screens/app_tour/Target_content.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; import 'package:uae_stat/presentation/components/my_toggle.dart'; import 'package:uae_stat/config/api_config.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; final selectedIndexProvider = StateProvider((ref) => 0); @@ -134,7 +136,7 @@ class _BaseScaffoldState extends ConsumerState { void _calculatetooglePosition() { final RenderBox cardRenderBox = - toggleKey.currentContext!.findRenderObject() as RenderBox; + toggleKey.currentContext!.findRenderObject() as RenderBox; final Offset cardPosition = cardRenderBox.localToGlobal(Offset.zero); final Size cardSize = cardRenderBox.size; toggleHeight = cardSize.height; @@ -259,7 +261,7 @@ class _BaseScaffoldState extends ConsumerState { .state = true; ref .read(previousChartsTourProvider - .notifier) + .notifier) .state = false; context.go( '/chartScreen/marriages?bgColor=0xFFAA8E83&mainTopic=null&title=Marriages', @@ -292,7 +294,7 @@ class _BaseScaffoldState extends ConsumerState { .state = true; ref .read(previousChartsTourProvider - .notifier) + .notifier) .state = false; context.go( '/chartScreen/marriages?bgColor=0xFFAA8E83&mainTopic=اجتماعي&title=الزواج&key=home', @@ -584,9 +586,9 @@ class _BaseScaffoldState extends ConsumerState { ElevatedButton( onPressed: () async { final prefs = - await SharedPreferences.getInstance(); + await SharedPreferences.getInstance(); String? loginCount = - prefs.getString('login_count'); + prefs.getString('login_count'); if (loginCount == '1') { await prefs.setString('login_count', '2'); } @@ -596,10 +598,10 @@ class _BaseScaffoldState extends ConsumerState { .state = true; ref .read( - previousChartsTourProvider.notifier) + previousChartsTourProvider.notifier) .state = true; ref.read(homeTourProvider.notifier).state = - true; + true; ref .read(previousHomeTourProvider.notifier) .state = true; @@ -608,7 +610,7 @@ class _BaseScaffoldState extends ConsumerState { .state = true; ref .read(previousScaffoldTourProvider - .notifier) + .notifier) .state = true; tutorialCoachMark.finish(); }, @@ -699,10 +701,23 @@ class _BaseScaffoldState extends ConsumerState { Future _fetchUserData() async { try { - final adminAuth = await _pb.admins - .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); - final adminToken = adminAuth.token; + // final adminAuth = await _pb.admins + // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); + + final auth = ref.watch(authProvider); + + // final adminAuth = await pb.admins.authWithPassword( + // auth.email, + // auth.password, + // ); + // final adminToken = adminAuth.token; //print('adminToken- ${adminToken}'); + + final themeService = ThemeBaseService(); + final adminToken = await themeService.getAdminToken( + email: auth.email, + password: auth.password, + ); final userDetailsResponse = await _pb.collection('users').getOne( userId!, headers: { @@ -721,7 +736,7 @@ class _BaseScaffoldState extends ConsumerState { String collectionId = userDetailsResponse.data['collectionId'] ?? '_pb_users_auth_'; List userReadedNotification = - userDetailsResponse.data['pushed_notification']; + userDetailsResponse.data['pushed_notification']; // Convert to List userReadedNotiOrNot = List.from(userReadedNotification); @@ -749,11 +764,12 @@ class _BaseScaffoldState extends ConsumerState { Future fetchNotifications(locale) async { final baseUrl = apiUrl + '/api/getNotification'; try { - final response = await http.get(Uri.parse('$baseUrl?language=$locale')); + final response = await http.get(Uri.parse('$baseUrl?language=$locale'), + headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'}); if (response.statusCode == 200) { final Map jsonResponse = - jsonDecode(response.body); // Decode JSON + jsonDecode(response.body); // Decode JSON if (jsonResponse['message'] == 'Success') { setState(() { @@ -942,7 +958,7 @@ class _BaseScaffoldState extends ConsumerState { ? (platformBrightness == Brightness.dark ? 'dark' : 'light') : selectedTheme.name; - await ThemeBaseService().updateUserTheme(userId, themeToSend); + await ThemeBaseService().updateUserTheme(userId, themeToSend, ref); } } @@ -1012,12 +1028,12 @@ class _BaseScaffoldState extends ConsumerState { leadingWidth: widget.showBackButton ? mywidth * 0.18 : null, bottom: widget.showDivider ? PreferredSize( - preferredSize: Size.fromHeight(1), // Height of the line - child: Container( - color: widget.dividerColor, // Line color - height: 1, // Line thickness - ), - ) + preferredSize: Size.fromHeight(1), // Height of the line + child: Container( + color: widget.dividerColor, // Line color + height: 1, // Line thickness + ), + ) : null, // bottom: widget.showDivider @@ -1148,19 +1164,19 @@ class _BaseScaffoldState extends ConsumerState { child: ClipOval( child: _avatarUrl.isNotEmpty ? Image( - image: NetworkImage(_avatarUrl), - fit: BoxFit.cover, - width: double.infinity, - height: double.infinity, - ) + image: NetworkImage(_avatarUrl), + fit: BoxFit.cover, + width: double.infinity, + height: double.infinity, + ) : Image( - image: AssetImage( - 'assets/edit_profile/profile.jpg', - ), - fit: BoxFit.cover, - width: double.infinity, - height: double.infinity, - ), + image: AssetImage( + 'assets/edit_profile/profile.jpg', + ), + fit: BoxFit.cover, + width: double.infinity, + height: double.infinity, + ), ), //child: Image(image: AssetImage('assets/edit_profile/profile.png')) ), @@ -1217,8 +1233,8 @@ class _BaseScaffoldState extends ConsumerState { 'Loading...', // Shows full email on hover child: SizedBox( width: MediaQuery.of(context) - .size - .width * + .size + .width * 0.6, // Adjust width as needed child: Text( userEmail ?? 'Loading...', @@ -1263,7 +1279,7 @@ class _BaseScaffoldState extends ConsumerState { ), ), trailing: - _buildNotificationBadge(count: notificationCount), + _buildNotificationBadge(count: notificationCount), onTap: () => _navigateTo(context, '/notification'), ), ListTile( @@ -1395,7 +1411,8 @@ class _BaseScaffoldState extends ConsumerState { ), ), ), - onTap: () => _showLogoutConfirmationDialog(context,isDarkTheme), + onTap: () => + _showLogoutConfirmationDialog(context, isDarkTheme), ), if (userId == 'guest') ListTile( @@ -1740,7 +1757,7 @@ Future logout(BuildContext context) async { context.go('/login'); // Redirect to login after logout } -void _showLogoutConfirmationDialog(BuildContext context,isDarkTheme) { +void _showLogoutConfirmationDialog(BuildContext context, isDarkTheme) { double myheight = MediaQuery.of(context).size.height; showDialog( context: context, @@ -1787,7 +1804,7 @@ void _showLogoutConfirmationDialog(BuildContext context,isDarkTheme) { children: [ SizedBox( width: - MediaQuery.of(context).size.width * 0.3, // Set button width + MediaQuery.of(context).size.width * 0.3, // Set button width child: TextButton( onPressed: () => Navigator.pop(dialogContext), style: TextButton.styleFrom( @@ -1815,7 +1832,7 @@ void _showLogoutConfirmationDialog(BuildContext context,isDarkTheme) { SizedBox(width: 16), SizedBox( width: - MediaQuery.of(context).size.width * 0.3, // Set button width + MediaQuery.of(context).size.width * 0.3, // Set button width child: TextButton( onPressed: () => logout(context), style: TextButton.styleFrom( @@ -1849,4 +1866,4 @@ void _showLogoutConfirmationDialog(BuildContext context,isDarkTheme) { ], ), ); -} \ No newline at end of file +}