From 06c832a24988558a333ca100846a3cc642586ef6 Mon Sep 17 00:00:00 2001 From: Kalonkarthik Date: Wed, 4 Jun 2025 13:59:48 +0530 Subject: [PATCH] share content --- .firebase/hosting.cHVibGlj.cache | 7 +- .firebaserc | 2 +- android/app/src/main/AndroidManifest.xml | 55 +- firebase.json | 13 +- .../Screens/charts/screens/chart_screen.dart | 2 +- public/.well-known/5-3share complete.txt | 1752 ----------------- public/.well-known/assetlinks.json | 2 +- public/.well-known/deeplink.txt | 49 - public/index.html | 20 +- pubspec.lock | 74 +- 10 files changed, 78 insertions(+), 1898 deletions(-) delete mode 100644 public/.well-known/5-3share complete.txt delete mode 100644 public/.well-known/deeplink.txt diff --git a/.firebase/hosting.cHVibGlj.cache b/.firebase/hosting.cHVibGlj.cache index c96fa28d..790b4dea 100644 --- a/.firebase/hosting.cHVibGlj.cache +++ b/.firebase/hosting.cHVibGlj.cache @@ -1,4 +1,3 @@ -index.html,1740467251291,3094e9e392638f12a83064c2bd3eb47179fc87830e120211fee9bbaca8521153 -404.html,1740467250990,762bf484ba67404bd1a3b181546ea28d60dfddf18e9dd4795d8d25bcf3c1a890 -.well-known/deeplink.txt,1740662700011,8b3c4be59000686b807f432cf2d226e993bab79debd39d5a091bffc403537a89 -.well-known/assetlinks.json,1739864133103,9b1de4b52760425f3607c90e639af0c72594c3d2fa92b0865360ccdc0b6303ff +index.html,1749016928549,c42b806930f499518bfbe07c7c4475c3facaf88ae99e2bf699ae2c7432968ca9 +404.html,1749016923653,762bf484ba67404bd1a3b181546ea28d60dfddf18e9dd4795d8d25bcf3c1a890 +.well-known/assetlinks.json,1749020217418,2cbceb7922baa8574ba7b3ddb959273603d28e7729c277783cc7715f9e18110b diff --git a/.firebaserc b/.firebaserc index f4483484..60bb850a 100644 --- a/.firebaserc +++ b/.firebaserc @@ -1,5 +1,5 @@ { "projects": { - "default": "fcsc-da580" + "default": "fcsc-a161c" } } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 264ff252..c9e894b9 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -7,62 +7,33 @@ android:name="${applicationName}" android:icon="@mipmap/ic_launcher"> - - + + - - + + - + - + - - - - - - - - - - - - - - - - - + + + shareCurrentPage(BuildContext context, bool isSharing) async { isSharing = true; try { final String currentRoute = GoRouterState.of(context).uri.toString(); - final String baseAppLink = 'https://www.fcsc.com'; + final String baseAppLink = 'https://fcsc-a161c.web.app'; final String shareLink = '$baseAppLink$currentRoute'; final String shareText = 'Check this out!\n\n$shareLink'; print('Generated Share Link: $shareLink'); diff --git a/public/.well-known/5-3share complete.txt b/public/.well-known/5-3share complete.txt deleted file mode 100644 index ac3b4cfd..00000000 --- a/public/.well-known/5-3share complete.txt +++ /dev/null @@ -1,1752 +0,0 @@ -sessioncheck -import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; -import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; -import 'package:uae_stat/domain/entities/session_entity.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class SessionCheckScreen extends StatefulWidget { - @override - _SessionCheckScreenState createState() => _SessionCheckScreenState(); -} - -class _SessionCheckScreenState extends State { - final PAuthRepo _authRepo = PAuthRepo(); - - String get playStoreUrl => "https://play.google.com/store/apps/details?id=ae.gov.fcsc.frontend"; - - @override - void initState() { - super.initState(); - WidgetsBinding.instance.addPostFrameCallback((_) { - _checkSession(); - }); - } - - Future _checkSession() async { - await Future.delayed(Duration(seconds: 2)); // Optional splash delay - final SessionEntity? session = await _authRepo.fetchLocallyStored(); - final GoRouterState state = GoRouterState.of(context); - final String? intendedPath = state.uri.toString().isNotEmpty && state.uri.path != '/' - ? state.uri.path - : null; - - print('fetchLocallyStored $session'); - print('navigating to intended path: $intendedPath'); - - // First if: Check if app data exists (indicating app setup) - if (session != null) { - // Second if: Check if user is logged in (session is valid) - if (session.freshness != SessionFreshness.expired) { - // User is logged in, check for shared intent path - if (intendedPath != null) { - print('navigating to intended path: $intendedPath'); - if (mounted) { - context.go(intendedPath); - } - } else { - print('myhomepage'); - if (mounted) { - context.go('/myhomepage'); // Redirect to home - } - } - } else { - // User is not logged in, redirect to login with intended path if present - print('session expired, redirecting to login'); - if (mounted) { - context.go('/login', extra: intendedPath != null ? {'intendedPath': intendedPath} : null); - } - } - } else { - // No session data, redirect to Play Store - print('no session data, redirecting to play store'); - if (mounted) { - _redirectToPlayStore(); - } - } - } - - Future _redirectToPlayStore() async { - final Uri url = Uri.parse(playStoreUrl); - - if (await canLaunchUrl(url)) { - await launchUrl(url, mode: LaunchMode.externalApplication); - } - } - - @override - Widget build(BuildContext context) { - return SizedBox.shrink(); - } -} - - -// import 'dart:math'; -// -// import 'package:flutter/material.dart'; -// import 'package:go_router/go_router.dart'; -// import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -// import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; -// import 'package:url_launcher/url_launcher.dart'; -// -// class AuthRepository { -// final FlutterSecureStorage _secureStorage = const FlutterSecureStorage(); -// -// Future fetchLocallyStored() async { -// return await _secureStorage.read(key: "FlutterSecureStorage.session"); -// } -// } -// -// class SessionCheckScreen extends StatefulWidget { -// const SessionCheckScreen({Key? key}) : super(key: key); -// -// @override -// _SessionCheckScreenState createState() => _SessionCheckScreenState(); -// } -// -// class _SessionCheckScreenState extends State { -// final PAuthRepo _pAuthRepo = PAuthRepo(); -// final AuthRepository _authRepo = AuthRepository(); -// final String playStoreUrl = "https://play.google.com/store/apps/details?id=ae.gov.fcsc.frontend"; -// -// @override -// void initState() { -// super.initState(); -// WidgetsBinding.instance.addPostFrameCallback((_) { -// _checkSessionAndHandleLink(); -// }); -// } -// -// Future _checkSessionAndHandleLink() async { -// try { -// final session = await _authRepo.fetchLocallyStored(); -// -// // Check if user is not logged in -// if (session == null || session.isEmpty) { -// _handleUnauthenticatedUser(); -// return; -// } -// -// // User is authenticated, process the shared link -// final GoRouterState state = GoRouterState.of(context); -// final String? sharedLink = state.uri.toString().isNotEmpty && state.uri.path != '/' -// ? state.uri.toString() -// : null; -// -// print(sharedLink); -// -// if (sharedLink != null) { -// // Validate if the link is a valid app route -// final Uri parsedUri = Uri.parse(sharedLink); -// final String path = parsedUri.path; -// -// if (mounted) { -// GoRouter.of(context).go(path); -// } -// } else { -// // Default route for authenticated users with no specific link -// if (mounted) { -// GoRouter.of(context).go('/myhomepage'); -// } -// } -// } catch (e) { -// print("Error processing link: $e"); -// _handleUnauthenticatedUser(); -// } -// } -// -// void _handleUnauthenticatedUser() { -// final GoRouterState state = GoRouterState.of(context); -// final String? sharedLink = state.uri.toString().isNotEmpty && state.uri.path != '/' -// ? state.uri.toString() -// : null; -// -// if (sharedLink != null) { -// // Store the intended destination and redirect to login -// if (mounted) { -// GoRouter.of(context).go('/login', extra: {'redirectTo': sharedLink}); -// } -// } else { -// // No specific link, just go to login -// if (mounted) { -// GoRouter.of(context).go('/login'); -// } -// } -// } -// -// Future _redirectToPlayStore() async { -// final Uri url = Uri.parse(playStoreUrl); -// -// if (await canLaunchUrl(url)) { -// await launchUrl(url, mode: LaunchMode.externalApplication); -// } -// } -// -// @override -// Widget build(BuildContext context) { -// return const Scaffold( -// body: Center( -// child: CircularProgressIndicator(), -// ), -// ); -// } -// } -// -// // import 'package:flutter/material.dart'; -// // import 'package:go_router/go_router.dart'; -// // import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -// // import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; -// // import 'package:url_launcher/url_launcher.dart'; -// // -// // class AuthRepository { -// // final FlutterSecureStorage _secureStorage = const FlutterSecureStorage(); -// // -// // Future fetchLocallyStored() async { -// // return await _secureStorage.read(key: "FlutterSecureStorage.session"); -// // } -// // } -// // -// // class SessionCheckScreen extends StatefulWidget { -// // const SessionCheckScreen({Key? key}) : super(key: key); -// // -// // @override -// // _SessionCheckScreenState createState() => _SessionCheckScreenState(); -// // } -// // -// // class _SessionCheckScreenState extends State { -// // final PAuthRepo _pAuthRepo = PAuthRepo(); -// // final AuthRepository _authRepo = AuthRepository(); -// // final String playStoreUrl = "https://play.google.com/store/apps/details?id=ae.gov.fcsc.frontend"; -// // -// // @override -// // void initState() { -// // super.initState(); -// // WidgetsBinding.instance.addPostFrameCallback((_) { -// // _checkSessionAndHandleLink(); -// // }); -// // } -// // -// // Future _checkSessionAndHandleLink() async { -// // try { -// // final session = await _authRepo.fetchLocallyStored(); -// // -// // // Check if user is not logged in -// // if (session == null || session.isEmpty) { -// // _handleUnauthenticatedUser(); -// // return; -// // } -// // -// // // User is authenticated, process the shared link -// // final GoRouterState state = GoRouterState.of(context); -// // final String? sharedLink = state.uri.toString().isNotEmpty && state.uri.path != '/' -// // ? state.uri.toString() -// // : null; -// // -// // if (sharedLink != null) { -// // // Validate if the link is a valid app route -// // final Uri parsedUri = Uri.parse(sharedLink); -// // final String path = parsedUri.path; -// // -// // if (mounted) { -// // GoRouter.of(context).go(path); -// // } -// // } else { -// // // Default route for authenticated users with no specific link -// // if (mounted) { -// // GoRouter.of(context).go('/myhomepage'); -// // } -// // } -// // } catch (e) { -// // print("Error processing link: $e"); -// // _handleUnauthenticatedUser(); -// // } -// // } -// // -// // void _handleUnauthenticatedUser() { -// // final GoRouterState state = GoRouterState.of(context); -// // final String? sharedLink = state.uri.toString().isNotEmpty && state.uri.path != '/' -// // ? state.uri.toString() -// // : null; -// // -// // if (sharedLink != null) { -// // // Store the intended destination and redirect to login -// // if (mounted) { -// // GoRouter.of(context).go('/login', extra: {'redirectTo': sharedLink}); -// // } -// // } else { -// // // No specific link, just go to login -// // if (mounted) { -// // GoRouter.of(context).go('/login'); -// // } -// // } -// // } -// // -// // Future _redirectToPlayStore() async { -// // final Uri url = Uri.parse(playStoreUrl); -// // -// // if (await canLaunchUrl(url)) { -// // await launchUrl(url, mode: LaunchMode.externalApplication); -// // } -// // } -// // -// // @override -// // Widget build(BuildContext context) { -// // return const Scaffold( -// // body: Center( -// // child: CircularProgressIndicator(), -// // ), -// // ); -// // } -// // } - - - - -loginroute - -import 'dart:convert'; - -import 'package:external_repos/external_repos.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -import 'package:go_router/go_router.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:the_validator/the_validator.dart'; -import 'package:uae_stat/config/my_theme.dart'; -import 'package:uae_stat/domain/use_cases/auth_use_case.dart'; -import 'package:uae_stat/domain/use_cases/language.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/presentation/Screens/demo_home.dart'; -import 'package:uae_stat/presentation/components/dialogs.dart'; -import 'package:uae_stat/presentation/components/lang_toggle.dart'; -import 'package:uae_stat/presentation/components/my_bottom_nav_bar.dart'; -import 'package:uae_stat/presentation/components/space.dart'; -import 'package:uae_stat/presentation/components/themed_text_field.dart'; -import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart'; -import 'package:http/http.dart' as http; -import '../../Screens/auth_verification/registration.dart'; -import 'package:pocketbase/pocketbase.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:uae_stat/config/api_config.dart'; - - -import '../../components/indicators/locale_provider.dart'; -import '../../components/my_toggle.dart'; - -class LoginRoute extends HookConsumerWidget { - // final pb = PocketBase('https://pb.venbait.in'); - final pb = PocketBase(apiUrl); - final FlutterSecureStorage _secureStorage = const FlutterSecureStorage(); - // final _pb = PocketBase('http://127.0.0.1:8090'); - // final bool isLoginScreen; // Pass `true` if this is the login screen - // LoginRoute({Key? key, required this.isLoginScreen}) : super(key: key); - LoginRoute({super.key}); - dynamic userData; - String? role; - int? loginCount; - - static final formKey = GlobalKey(); - - Future profileStatus(String userId) async { - try { - // Authenticate admin - final adminAuth = await pb.admins.authWithPassword( - 'pb@venbainfotech.com', - 'pb@venbainfotech.com', - ); - final String adminToken = adminAuth.token; - print('adminToken: $adminToken'); - - // Fetch user details - final userDetailsResponse = await pb.collection('users').getOne( - userId, - headers: { - 'Authorization': 'Bearer $adminToken', - }, - ); - - print('userDetailsLogin: $userDetailsResponse'); - - // Check if user is verified - role = userDetailsResponse.data['role']; - final bool? isVerified = userDetailsResponse.data['verified']; - final bool? isUserMailVerified = - userDetailsResponse.data['user_mail_verify']; - - // Check admin and email verification statuses - if (isVerified == false) { - throw Exception('Admin not approved'); - } - if (isUserMailVerified == false) { - throw Exception('Email not verified'); - } - userData = userDetailsResponse; - // Check if 'is_profile_completed' is true - final bool isProfileCompleted = - userDetailsResponse.data['is_profile_completed'] ?? false; - - return isProfileCompleted; - } catch (e) { - print('Error fetching user details: $e'); - rethrow; - } - } - - Future saveUserId(String userId, count) async { - print(count); - final prefs = await SharedPreferences.getInstance(); - await prefs.setString('userId', userId); // Save userId locally - await prefs.setString('login_count', count.toString()); - } - - // Future authenticateAndStoreData() async { - // try { - // // Perform authentication - // final authData = await pb - // .collection("users") - // .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com'); - // - // // Check if authentication is successful - // if (pb.authStore.isValid) { - // print("Authentication successful!"); - // print("Token: ${pb.authStore.token}"); - // // print("User ID: ${pb.authStore.record.id}"); - // - // // Store the token and user ID in local storage - // await _secureStorage.write( - // key: "FlutterSecureStorage.session", value: pb.authStore.token); - // // await _secureStorage.write( - // // key: "FlutterSecureStorage.userId", value: pb.authStore.record.id); - // - // print("Session and User ID stored in local storage."); - // } else { - // print("Authentication failed."); - // } - // } catch (e) { - // print("Error during authentication: $e"); - // } - // } - - @override - Widget build(BuildContext context, WidgetRef ref) { - final hasValidated = useState(false); - final locale = ref.watch(localeProvider); - final emailCtl = useTextEditingController(); - final pwCtl = useTextEditingController(); - final forgotPwBtn = TextButton( - onPressed: () async { - final forgotPwFormKey = GlobalKey(); - final email = await showDialog( - context: context, - builder: (dialogCtx) => SizedBox( - // width: 850, // Increase dialog width - child: AlertDialog( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20), // Rounded corners - ), - elevation: 10, - shadowColor: Colors.black12, - title: Text( - context.translate( - 'Reset Password', - 'إعادة تعيين كلمة المرور', - ), - style: TextStyle( - fontSize: locale?.languageCode == 'ar' ? 18 : 20, - color: Color(0xFF898C81), - fontWeight: FontWeight.w600), - ), - content: Form( - key: forgotPwFormKey, - child: TextFormField( - validator: FieldValidator.email(), - controller: emailCtl, - decoration: InputDecoration( - labelText: context.translate( - 'Email address', - 'عنوان البريد الإلكتروني', - ), - labelStyle: TextStyle( - fontSize: locale?.languageCode == 'ar' ? 13 : 16, - color: Color(0xFF898C81), // For label text color - // fontWeight: FontWeight.w600, - ), - ), - ), - ), - actions: [ - TextButton( - onPressed: Navigator.of(dialogCtx, rootNavigator: true).pop, - style: TextButton.styleFrom( - // backgroundColor: Colors.white, // Background color - foregroundColor: Color(0xFF92722A), // Font (text) color - side: BorderSide( - color: Color(0xFF92722A)), // Border outline color - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(8), // Optional: Rounded corners - ), - padding: EdgeInsets.symmetric( - horizontal: 16, vertical: 12), // Optional: Padding - ), - child: Text( - context.translate( - 'Return', - 'يعود', - ), - ), - ), - ElevatedButton( - onPressed: () { - final isValid = forgotPwFormKey.currentState!.validate(); - if (!isValid) return; - Navigator.of(dialogCtx, rootNavigator: true).pop( - emailCtl.text, - ); - }, - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF92722A), - foregroundColor: Colors.white, - padding: EdgeInsets.symmetric( - horizontal: 15, vertical: 15), // Optional: Adjusts size - shape: RoundedRectangleBorder( - // Optional: Adds rounded corners - borderRadius: BorderRadius.circular(12), - ), - ), - child: Text( - context.translate( - 'Send Reset Email', - 'إرسال إعادة تعيين البريد الإلكتروني', - ), - ), - ), - ], - ), - ), - ); - if (email == null) return; - if (!context.mounted) return; - await context.loaderWithErrorDialog( - () => ref - .read( - authUseCaseProvider.notifier, - ) - .requestPwReset(email), - ); - if (!context.mounted) return; - - context.simpleDialog( - title: context.translate( - 'Success!', - 'نجاح', - ), - content: context.translate( - 'An email has been sent to $email with further details.', - 'تم إرسال بريد إلكتروني إلى $email يتضمن المزيد من التفاصيل.', - ), - ); - - }, - style: TextButton.styleFrom( - padding: EdgeInsets.zero, - // maximumSize: Size.zero, - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - visualDensity: VisualDensity.compact, - overlayColor: Colors.white - ), - child: Text( - context.translate( - 'Forgot Password?', - 'هل نسيت كلمة السر؟', - ), - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'Roboto', - ), - fontWeight: FontWeight.bold, - fontSize: locale?.languageCode == 'ar' ? 12 : 14, - color: Color(0xFF985400), - ), - ), - ); - final loginBtn = SizedBox( - width: double.infinity, - child: ElevatedButton( - onPressed: () async { - hasValidated.value=true; - final isValid = formKey.currentState!.validate(); - if (!isValid) return; - final session = await context.loaderWithErrorDialog( - () => ref - .read( - authUseCaseProvider.notifier, - ) - .login( - emailCtl.text, - pwCtl.text, - ), - errorDialogBuilder: ( - error, [ - StackTrace? stackTrace, - ]) { - if (error == LoginError.invalidEmailPw) { - return context.simpleDialog( - title: context.translate( - 'Incorrect Credentials', - 'أوراق غير صحيحة', - ), - content: context.translate( - 'Your email or password is invalid. Please try again.', - 'بريدك الإلكتروني أو كلمة المرور غير صالحة. حاول مرة اخرى.', - ), - ); - } - // if (error == LoginError.emailAddressNotVerified) { - // return context.simpleDialog( - // title: context.translate( - // 'Verification Error', - // 'خطأ التحقق', - // ), - // content: context.translate( - // '${emailCtl.text} is not a verified email address. Please check your email for a verification link.', - // '${emailCtl.text} ليس عنوان بريد إلكتروني تم التحقق منه. يرجى التحقق من بريدك الإلكتروني للحصول على رابط التحقق.', - // ), - // extraAction: ElevatedButton( - // onPressed: () async { - // Navigator.of( - // context, - // rootNavigator: true, - // ).pop(); - // await context.loaderWithErrorDialog( - // () => ref - // .read(authUseCaseProvider.notifier) - // .requestVerificationEmail(emailCtl.text), - // ); - // if (!context.mounted) return; - // context.simpleDialog( - // title: 'Email Re-sent', - // content: - // 'We\'ve sent you the verification email at ${emailCtl.text} again.', - // ); - // }, - // child: Text( - // context.translate( - // 'I did not receive an email', - // 'لم أتلق بريدًا إلكترونيًا', - // ), - // ), - // ), - // ); - // } - return context.simpleDialog(); - }, - ); - - if (!context.mounted || session == null) return; - final userId = session.id; - if (userId.isNotEmpty) { - final url = - // Uri.parse("https://pb.venbait.in/api/login_success?id=$userId"); - Uri.parse('$apiUrl/api/login_success?id=$userId'); - - try { - final response = await http.get(url); - - if (response.statusCode == 200) { - print("Login success API call successful: ${response.body}"); - final count = jsonDecode(response.body); - loginCount = - count["login_count"]; // Directly assign it as an int - print(loginCount); - } else { - print( - "Failed to call login success API. Status code: ${response.statusCode}"); - } - } catch (e) { - print("Error calling login success API: $e"); - } - - await saveUserId(userId, loginCount); - } - try { - final bool isProfileComplete = await profileStatus(userId); - print("Is Profile Complete: $isProfileComplete"); - - // Extract intendedPath from query parameters (if coming from redirect) - final String? intendedPath = GoRouterState.of(context).uri.queryParameters['intendedPath']; - print("Extracted intendedPath after login: $intendedPath"); - - if (!context.mounted) return; - - if (isProfileComplete) { - print('Redirecting to Home / Intended Path'); - context.go(intendedPath ?? '/myhomepage'); - } else { - print('Redirecting to Profile Setup'); - if (userId.isNotEmpty) { - context.go('/profile/$userId'); - } else { - print('Error: userId is null or empty.'); - } - } - } catch (e) { - // Handle specific errors based on their message - if (e.toString().contains('Admin not approved')) { - context.simpleDialog( - title: context.translate( - 'Admin Approval Required', 'موافقة المسؤول مطلوبة'), - content: context.translate( - 'Your account has not been approved by the admin.', - 'لم تتم الموافقة على حسابك من قبل المسؤول.', - ), - ); - } else if (e.toString().contains('Email not verified')) { - context.simpleDialog( - title: context.translate( - 'Email Not Verified', 'البريد الإلكتروني غير مُحقق'), - content: context.translate( - 'Your email address is not verified. Please check your email.', - 'عنوان بريدك الإلكتروني غير مُحقق. يرجى التحقق من بريدك الإلكتروني.', - ), - ); - } else { - print('Unexpected error: $e'); - } - } - - // context.go('/${context.language}/${BottomNavBarItem.home.routePath}'); - }, - style: ButtonStyle( - shape: WidgetStatePropertyAll( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - ), - padding: const WidgetStatePropertyAll( - EdgeInsets.symmetric(vertical: 10.5), - ), - textStyle: WidgetStatePropertyAll( - TextStyle( - fontFamily: context.translate( - 'Roboto', - 'Roboto', - ), - fontSize: locale?.languageCode == 'ar' ? 14 : 16, - fontWeight: FontWeight.w600, - ), - ), - backgroundColor: WidgetStatePropertyAll( - MyTheme.topicColor(IndicatorTopic.social), - ), - // surfaceTintColor: MaterialStatePropertyAll( - // MyTheme.economy[800], - // ), - foregroundColor: const WidgetStatePropertyAll( - Colors.white, - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - context.translate( - 'Login', - 'تسجيل الدخول', - ), - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'Roboto', - ), - fontSize: locale?.languageCode == 'ar' ? 12: 18, - fontWeight: FontWeight.w500, - ), - ), - 6.horizontalSpace, - const Icon( - Icons.chevron_right_outlined, - color: Colors.white, // Set your desired color here - ) - ], - ), - ), - ); - final form = Form( - key: formKey, - child: Column( - children: [ - ThemedFormField( - hintText: context.translate( - 'Email', - 'بريد إلكتروني', - ), - - validator: (value) { - final emailRegex = - r'^[a-zA-Z0-9àèìòùÀÈÌÒÙéàç~!#$%^&*()_+=-{}|;,.?<>]+@[a-zA-Z0-9àèìòùÀÈÌÒÙéàç~!#$%^&*()_+=-{}|;,.?<>]+\.[a-zA-Z]{2,}$'; - if (value == null || value.isEmpty) { - return context.translate('Required', 'مطلوب'); - } - else if (!RegExp(emailRegex).hasMatch(value)) { - return AppLocalizations.of(context)!.invalid_email; - } return null; - }, - imgPath: MiscIconAssetPath.person, - controller: emailCtl, - ), - 15.verticalSpace, - ThemedFormField( - validator: (text) { - if (text == null || text.isEmpty) { - return context.translate('Required', 'مطلوب'); - } else if (text.length < 8) { - return AppLocalizations.of(context)!.only8charac; - } - return FieldValidator.password(minLength: 8)(text); - }, - hintText: context.translate( - 'Password', - 'كلمة المرور', - ), - imgPath: MiscIconAssetPath.lock, - controller: pwCtl, - isObscurable: true, - ), - // 6.verticalSpace, - Padding( - padding: EdgeInsets.zero, - child: Align( - alignment: AlignmentDirectional.topEnd, - child: forgotPwBtn, - ), - ), - 10.verticalSpace, - loginBtn, - ], - ), - ); - final helloAndPleaseLoginTexts = Column( - children: [ - Text( - context.translate( - 'Hello Again!', - 'مرحبا مجددا!', - ), - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'Roboto', - ), - fontSize: locale?.languageCode == 'ar' ? 38 : 40, - fontWeight: FontWeight.w300, - ), - ), - 10.verticalSpace, - Text( - context.translate( - 'Please login to access \n UAE’s key official statistics', - 'يرجى تسجيل الدخول للوصول إلى الإحصاءات الرسمية الرئيسية لدولة الإمارات العربية المتحدة', - ), - textAlign: TextAlign.center, - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'Roboto', - ), - fontSize: context.translate(18.0, 14.0), - color: const Color(0xff898C81), - fontWeight: FontWeight.w600, - ), - ), - ], - ); - final dontHaveAnAccountRegisterBtn = TextButton( - onPressed: () => {context.push('/register')}, - child: Text.rich( - textAlign: TextAlign.center, - TextSpan( - style: TextStyle( - fontFamily: context.translate( - 'Roboto', - 'Roboto', - ), - fontSize: locale?.languageCode == 'ar' ? 12 : 14, - fontWeight: FontWeight.bold, - ), - children: [ - TextSpan( - text: context.translate( - 'Don\'t have an account? ', - 'ليس لديك حساب؟', - ), - style: TextStyle( - fontSize: locale?.languageCode == 'ar' ? 12 : 14, - color: Color(0xff898C81), - ), - ), - const TextSpan( - text: ' ', - ), - TextSpan( - text: context.translate( - 'Register Now', - 'سجل الان', - ), - style: TextStyle( - fontSize: locale?.languageCode == 'ar' ? 12 : 14, - color: Color(0xFF985400), - ), - ), - ], - ), - ), - ); - // final continueAsGuestBtn = SizedBox( - // width: double.infinity, - // child: ElevatedButton( - // onPressed: () async { - // final prefs = await SharedPreferences.getInstance(); - // prefs.clear(); - // final userId = 'guest'; - // if (userId.isNotEmpty) { - // await saveUserId(userId); - // } - // context.go('/myhomepage'); - // //context.go('/${context.language}/${BottomNavBarItem.home.routePath}'), - // }, - // //context.go('/${context.language}/${BottomNavBarItem.home.routePath}'), - // style: ButtonStyle( - // shape: WidgetStatePropertyAll( - // RoundedRectangleBorder( - // borderRadius: BorderRadius.circular(10), - // ), - // ), - // padding: const WidgetStatePropertyAll( - // EdgeInsets.symmetric(vertical: 10.5), - // ), - // textStyle: WidgetStatePropertyAll( - // TextStyle( - // fontFamily: context.translate( - // 'Roboto', - // 'NotoKufi', - // ), - // fontSize: 16, - // fontWeight: FontWeight.w600, - // ), - // ), - // backgroundColor: WidgetStatePropertyAll( - // MyTheme.topicColor(IndicatorTopic.environment), - // ), - // foregroundColor: const WidgetStatePropertyAll( - // Colors.white, - // ), - // ), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.center, - // children: [ - // Text( - // context.translate( - // 'Continue as Guest', - // 'استمر كضيف', - // ), - // ), - // 6.horizontalSpace, - // const Icon(Icons.chevron_right_outlined), - // ], - // ), - // ), - // ); - final fcscBanner = Image.asset( - BannerAssetPath.fcsc, - height: 40, - ); - final screenWidth = MediaQuery.of(context).size.width; - final listViewHorizontalPadding = - screenWidth < 700 ? 30 : 30 + (screenWidth - 700) / 2; - final scaffoldBody = SingleChildScrollView( - child: Column( - children:[ - Padding( - padding: EdgeInsets.all(16), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - 3.verticalSpace, - Align( - alignment: AlignmentDirectional.topEnd, - child: MyToggle( - isOn: locale?.languageCode == 'en', - knobTextWhenOn: 'ع', - knobTextWhenOff: 'EN', - pathColorWhenOn: Colors.grey.shade300, - pathColorWhenOff: Colors.grey.shade300, - onTap: () { - final formState = formKey.currentState; - ref.read(localeProvider.notifier).toggleLocale(); - Future.delayed(Duration(milliseconds: 100), () { - if (hasValidated.value && formState?.validate() == false) { - formState?.validate(); - } - }); - }, - ), - ), - 34.verticalSpace, - helloAndPleaseLoginTexts, - 40.verticalSpace, - form, - 15.verticalSpace, - dontHaveAnAccountRegisterBtn, - // continueAsGuestBtn, - // Spacer(), - 15.verticalSpace, - fcscBanner, - ], - ), - ) - ] - ), - ); - // final bgScaffold = Scaffold( - // backgroundColor: Colors.white, - // body: SafeArea(child: scaffoldBody), - // ); - // return bgScaffold; - return PopScope( - canPop: false, // Allow back navigation only if not login screen - onPopInvokedWithResult: (didPop, result) { - if (didPop) return; - SystemNavigator.pop(); - // _showExitConfirmation(context); // Show exit confirmation dialog - }, - child: Scaffold( - backgroundColor: Colors.white, - body: SafeArea(child: scaffoldBody), - ), - ); - } -//when the pop up need un comment the code -// void _showExitConfirmation(BuildContext context) { -// showDialog( -// context: context, -// builder: (context) => AlertDialog( -// title: Text( context.translate( -// 'Exit App', -// 'الخروج من التطبيق', -// ),style: TextStyle(color: Color(0xFF898C81),fontWeight: FontWeight.w700),), -// content: Text( context.translate( -// 'Are you sure you want to exit?', -// 'هل أنت متأكد أنك تريد الخروج؟', -// ), -// style: TextStyle(color:Color(0xFF898C81)), -// ), -// actions: [ -// TextButton( -// onPressed: () => Navigator.of(context).pop(), // Close dialog -// style: TextButton.styleFrom( -// foregroundColor: Color(0xFFAA8E83), // Background color -// // backgroundColor: Colors.white, // Font (text) color -// side: BorderSide( -// // color: Color(0xFF92722A)), // Border outline color -// color: Color(0xFFAA8E83)), // Border outline color -// shape: RoundedRectangleBorder( -// borderRadius: -// BorderRadius.circular(8), // Optional: Rounded corners -// ), -// padding: EdgeInsets.symmetric( -// horizontal: 16, vertical: 12), // Optional: Padding -// ), -// child: Text( context.translate( -// 'Cancel', -// 'إلغاء', -// ),), -// ), -// TextButton( -// onPressed: () => SystemNavigator.pop(), // Exit the app -// style: TextButton.styleFrom( -// backgroundColor: Color(0xFFAA8E83), // Background color -// foregroundColor: Colors.white, // Font (text) color -// side: BorderSide( -// // color: Color(0xFF92722A)), // Border outline color -// color: Color(0xFFAA8E83)), // Border outline color -// shape: RoundedRectangleBorder( -// borderRadius: -// BorderRadius.circular(8), // Optional: Rounded corners -// ), -// padding: EdgeInsets.symmetric( -// horizontal: 16, vertical: 12), // Optional: Padding -// ), -// child: Text( context.translate( -// 'Exit', -// 'خروج', -// ),), -// ), -// ], -// ), -// ); -// } -} - -murouter -// import 'package:external_repos/external_repos.dart'; -// import 'package:flutter/material.dart'; -// import 'package:flutter_localizations/flutter_localizations.dart'; -// import 'package:go_router/go_router.dart'; -// import 'package:riverpod_annotation/riverpod_annotation.dart'; -// import 'package:uae_stat/domain/use_cases/auth_use_case.dart'; -// import 'package:uae_stat/domain/use_cases/language.dart'; -// import 'package:uae_stat/domain/use_cases/preferences_use_case.dart'; -// import 'package:uae_stat/infrastructure/services/packages/go_router.dart'; -// import 'package:uae_stat/presentation/components/logged_in_home_scaffold.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/auth_routes/login_route.dart'; -// import 'package:uae_stat/presentation/routes/auth_routes/register_route.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/competitiveness_flow/report_flow/list_reports_route.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/competitiveness_flow/report_flow/report_route.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/country_profile_flow/country_statistics_route.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/country_profile_flow/list_countries_route.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/list_uae_numbers_route.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_aircraft_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_gdp_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_hotels_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_inflation_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_trade_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/_area_of_national_reserves_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/_oil_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/_water_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/electricity_consumption_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/electricity_production_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_general_education_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_higher_education_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_hospitals_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_labor_force_body.dart'; -// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_population_body.dart'; -// import 'package:uae_stat/presentation/routes/drawer_routes/feedback_route.dart'; -// import 'package:uae_stat/presentation/routes/drawer_routes/manage_user_router.dart'; -// import 'package:uae_stat/presentation/routes/drawer_routes/my_favorites_route.dart'; -// import 'package:uae_stat/presentation/routes/drawer_routes/privacy_policy_route.dart'; -// import 'package:uae_stat/presentation/routes/drawer_routes/profile/reset_pw_route.dart'; -// -// import '../presentation/routes/drawer_routes/profile/profile_route.dart'; -// -// part 'my_router.g.dart'; -// -// class _MyRouter { -// const _MyRouter({ -// required this.isLoggedIn, -// }); -// -// final bool isLoggedIn; -// -// static FutureOr rootRedirect( -// BuildContext context, -// GoRouterState state, -// ) { -// final defaultLanguage = PreferencesUseCase.defaultPrefs.language.name; -// if (state.fullPath == '/') { -// return '/$defaultLanguage/home'; -// } -// final currentLocale = state.pathParameters['locale']; -// if (currentLocale == null) { -// return '$defaultLanguage/${state.pathWithParameters}'; -// } -// return null; -// } -// -// Iterable get authRoutes => [ -// GoRoute( -// path: 'Profile', -// redirect: (context, state) => -// isLoggedIn ? null : '${context.language.name}/profile', -// builder: (context, state) => const ProfileRoute(), -// ), -// GoRoute( -// path: 'login', -// redirect: (context, state) => -// isLoggedIn ? '${context.language.name}/profile' : null, -// builder: (context, state) => const ProfileRoute(), -// //builder: (context, state) => const LoginRoute(), -// ), -// // GoRoute( -// // path: 'register', -// // redirect: (context, state) => -// // isLoggedIn ? '${context.language.name}/profile' : null, -// // builder: (context, state) => const RegisterRoute(), -// // ), -// ]; -// -// static final Iterable bottomBarRoutes = BottomNavBarItem.values.map( -// (e) => switch (e) { -// BottomNavBarItem.home => GoRoute( -// path: e.routePath, -// pageBuilder: (context, state) => const NoTransitionPage( -// child: HomeRoute(), -// ), -// ), -// BottomNavBarItem.uaeNumbers => GoRoute( -// path: e.routePath, -// pageBuilder: (context, state) => const NoTransitionPage( -// child: ListUAENumbersRoute(), -// ), -// routes: [ -// ...IndicatorEnum.values.map( -// (ie) => GoRoute( -// path: ie.name, -// builder: (context, state) => switch (ie) { -// // environment -// IndicatorEnum.nationalReservesArea => -// const AreaOfNationalReservesBody(), -// IndicatorEnum.crudeOilProduction => const OilBody(), -// IndicatorEnum.exportOilQuantity => const OilBody(), -// IndicatorEnum.electricityProduction => -// const ElectricityProductionBody(), -// IndicatorEnum.electricityConsumption => -// const ElectricityConsumptionBody(), -// IndicatorEnum.desalinatedWaterProduction => const WaterBody(), -// IndicatorEnum.municipalWaste => throw UnimplementedError(), -// // trade -// IndicatorEnum.inflationRate => const InflationBody(), -// IndicatorEnum.gdpConstant => const GdpBody(), -// IndicatorEnum.gdpGrowthConstant => const GdpBody(), -// IndicatorEnum.aircraftMovement => const AircraftBody(), -// IndicatorEnum.tradeValue => const TradeBody(), -// IndicatorEnum.hotelGuests => const HotelsBody(), -// // social -// IndicatorEnum.studentsGeneral => const GeneralEducationBody(), -// IndicatorEnum.studentsHigher => const HigherEducationBody(), -// IndicatorEnum.hospitalsGovernment => const HospitalsBody(), -// IndicatorEnum.hospitalsPrivate => const HospitalsBody(), -// IndicatorEnum.laborForce => const LaborForceBody(), -// IndicatorEnum.population => const PopulationBody(), -// }, -// ), -// ), -// ], -// ), -// BottomNavBarItem.competitiveness => GoRoute( -// path: e.routePath, -// pageBuilder: (context, state) => const NoTransitionPage( -// child: ListReportsRoute(), -// ), -// routes: [ -// GoRoute( -// path: ':reportCode', -// builder: (context, state) => ReportRoute( -// reportCode: state.pathParameters['reportCode'] as String, -// ), -// ), -// ], -// ), -// BottomNavBarItem.countryStatistics => GoRoute( -// path: e.routePath, -// pageBuilder: (context, state) => const NoTransitionPage( -// child: ListCountriesRoute(), -// ), -// routes: [ -// GoRoute( -// path: ':alpha2CountryCode', -// redirect: (context, state) { -// final code = state.pathParameters['alpha2CountryCode']; -// if (code == null) return 'country-profile'; -// return null; -// }, -// builder: (context, state) { -// final alpha2Code = state.pathParameters['alpha2CountryCode']!; -// final country = ISOCountry.fromAlpha2(alpha2Code); -// return CountryProfileRoute(country: country); -// }, -// ), -// ], -// ), -// }, -// ); -// -// Iterable get _drawerRoutes => [ -// GoRoute( -// path: 'profile', -// redirect: (context, state) { -// if (isLoggedIn) return null; -// return '/${context.language.name}/login'; -// }, -// pageBuilder: (context, state) => const NoTransitionPage( -// child: ProfileRoute(), -// ), -// routes: [ -// GoRoute( -// path: 'reset-pw', -// builder: (context, state) => const ResetPwRoute(), -// ), -// ], -// ), -// ...DrawerItems.values.map( -// (e) => GoRoute( -// path: e.routePath, -// pageBuilder: (context, state) => NoTransitionPage( -// child: switch (e) { -// DrawerItems.favorites => const MyFavoritesRoute(), -// //DrawerItems.feedback => const FeedbackRoute(), -// DrawerItems.feedback => FeedbackForm(), -// DrawerItems.privacyPolicy => const PrivacyPolicyRoute(), -// DrawerItems.manageuser => ManageUserRouter() -// // DrawerItems.userGuide => const NotificationsRoute(), -// // DrawerItems.notifications => const UserGuideRoute(), -// }, -// ), -// ), -// ), -// ]; -// // -// ShellRoute get inAppRoutes => ShellRoute( -// builder: (context, state, child) => LoggedInHomeScaffold( -// body: child, -// ), -// routes: [ -// ...bottomBarRoutes, -// ..._drawerRoutes, -// ], -// ); -// } -// // -// String? _pathCache; -// -// @riverpod -// Future router(RouterRef ref) async { -// final routerKey = GlobalKey( -// debugLabel: 'routerKey', -// ); -// final isLoggedIn = await ref.watch( -// authUseCaseProvider.future.select( -// (session) async => (await session) != null, -// ), -// ); -// final language = await ref.watch( -// preferencesUseCaseProvider.future.select( -// (asyncPrefs) async => (await asyncPrefs).language, -// ), -// ); -// final myRouter = _MyRouter( -// isLoggedIn: isLoggedIn, -// ); -// final router = GoRouter( -// navigatorKey: routerKey, -// initialLocation: _pathCache ?? '/$language/home', -// routes: [ -// GoRoute( -// redirect: _MyRouter.rootRedirect, -// path: '/:locale', -// routes: [ -// myRouter.inAppRoutes, -// // ...myRouter.authRoutes, -// ] -// .map( -// (e) => ShellRoute( -// builder: (context, state, child) { -// final goRouterState = GoRouterState.of(context); -// final locale = goRouterState.pathParameters['locale']!; -// final language = LanguageLocale.fromName(locale); -// return Localizations.override( -// context: context, -// delegates: GlobalMaterialLocalizations.delegates, -// locale: Locale( -// switch (language) { -// LanguageLocale.enUS => 'en', -// LanguageLocale.arAE => 'ar', -// }, -// ), -// child: Directionality( -// textDirection: switch (language) { -// LanguageLocale.enUS => TextDirection.ltr, -// LanguageLocale.arAE => TextDirection.rtl, -// }, -// child: child, -// ), -// ); -// }, -// routes: [e], -// ), -// ) -// .toList(), -// ), -// ], -// ); -// ref.onDispose( -// () { -// _pathCache = -// ref.state.valueOrNull?.routeInformationProvider.value.uri.toString(); -// router.dispose(); -// }, -// ); -// -// return router; -// } - -import 'dart:convert'; - -import 'package:flutter/material.dart'; -import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -import 'package:go_router/go_router.dart'; -import 'package:uae_stat/config/sessionCheckScreen.dart'; -import 'package:uae_stat/domain/entities/session_entity.dart'; -import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; -import 'package:uae_stat/presentation/Screens/Bottom%20Navigation%20Pages/UAE_Numbers/Social/marriages.dart'; -import 'package:uae_stat/presentation/Screens/auth_verification/privacy_policy.dart'; -import 'package:uae_stat/presentation/Screens/auth_verification/registration.dart'; -import 'package:uae_stat/presentation/Screens/auth_verification/terms&conditions.dart'; -import 'package:uae_stat/presentation/Screens/charts/chart.dart'; -import 'package:uae_stat/presentation/Screens/charts/screens/chart_screen.dart'; -import 'package:uae_stat/presentation/Screens/demo_home2.dart'; -import 'package:uae_stat/presentation/Screens/online_offline_verification/internet_check.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/contactUs.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/AboutTheApp/AboutFCSC.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/AboutTheApp/getStarted.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/KeyFeatures/AppFeatures.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/KeyFeatures/ChangeMyPassword.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/KeyFeatures/EditMyProfile.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/KeyFeatures/howUseTheApp.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/KeyFeatures/purpose.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/KeyFeatures/stayUpdate.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/KeyFeatures/useTheApp.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/aboutApp.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/userguide.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; - -import 'package:uae_stat/presentation/Screens/Bottom Navigation Pages/UAE_Numbers/uae_numbers.dart'; -import 'package:uae_stat/presentation/Screens/Bottom Navigation Pages/Competitiveness/competitiveness.dart'; -import 'package:uae_stat/presentation/Screens/Bottom Navigation Pages/Country_Profile/country_profile.dart'; - -import '../domain/use_cases/preferences_use_case.dart'; -import '../presentation/Screens/auth_verification/changepassword.dart'; -import '../presentation/Screens/auth_verification/confirm_password.dart'; -import '../presentation/Screens/auth_verification/create_new_pw.dart'; -import '../presentation/Screens/auth_verification/otp_verification.dart'; -import '../presentation/Screens/demo_home.dart'; -import '../presentation/Screens/profilepage.dart'; -import '../presentation/routes/auth_routes/login_route.dart'; -import '../presentation/routes/bottom_bar_routes/tab_routes/home_route.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/bookmark.dart'; -import '../presentation/routes/drawer_routes/Drawer Items/edit_profile.dart'; -import '../presentation/routes/drawer_routes/Drawer Items/feedback.dart'; -import '../presentation/routes/drawer_routes/Drawer Items/user_guide/faq_page.dart'; -import '../presentation/routes/drawer_routes/Drawer Items/user_guide/features.dart'; -import '../presentation/routes/drawer_routes/Drawer Items/manage_users.dart'; - -final FlutterSecureStorage _secureStorage = const FlutterSecureStorage(); - -// Future _checkSession() async { -// print('_checkSession'); -// await Future.delayed(Duration(seconds: 2)); // Optional splash effect -// -// String? sessionToken = -// await _secureStorage.read(key: "FlutterSecureStorage.session"); -// print('sessionToken $sessionToken'); -// -// if (sessionToken != null && sessionToken.isNotEmpty) { -// print('_checkSession home'); -// return "/myhomepage"; // Redirect to home page if session is valid -// } else { -// print('_checkSession login'); -// return "/login"; // Redirect to login page if session is invalid -// } -// } - -final GoRouter router = GoRouter( - initialLocation: '/', - routes: [ - GoRoute( - path: '/', - //builder: (context, state) => MyHomePage(), - builder: (context, state) => SessionCheckScreen(), - - ), - // GoRoute( - // path: '/', - // redirect: (context, state) async => await _checkSession(), - // ), - GoRoute( - path: '/internetcheck', - builder: (context, state) => InternetCheck(), - ), - GoRoute( - path: '/login', - builder: (context, state) => LoginRoute(), - //builder: (context, state) => LoginRoute(), - ), - GoRoute( - path: '/myhomepage', - builder: (context, state) => MyHomePage(), - ), - GoRoute( - path: '/register', - builder: (context, state) => RegisterScreen(), - ), - // GoRoute( - // path: '/DemoHome/:dataSets', - // builder: (context, state) { - // final dataSets = state.pathParameters['dataSets']!; - // print('Router $dataSets'); - // return ChartPage(dataSets: dataSets); - // }, - // ), - // GoRoute( - // path: '/Chart/:dataSets', - // builder: (context, state) { - // final dataSets = state.pathParameters['dataSets']!; - // print('Router $dataSets'); - // return ChartScreen(dataSets: dataSets); - // }, - // ), - GoRoute( - path: '/chartScreen/:dataSets', - builder: (context, state) { - // Retrieve path parameter - final dataSets = state.pathParameters['dataSets']!; - // Retrieve query parameter - final bgColor = state.uri.queryParameters['bgColor'] ?? - '0xFFFFFFFF'; // Default white - final mainTopic = state.uri.queryParameters['mainTopic'] ?? ''; - final title = state.uri.queryParameters['title'] ?? ''; - final key = state.uri.queryParameters['key'] ?? ''; - final kpi = state.uri.queryParameters['kpi'] ?? ''; // Get kpi - - // Parse filter_data as a JSON list - // Parse filter_data as a JSON list - List> filterData = []; - - if (state.uri.queryParameters.containsKey('filter_data') && - state.uri.queryParameters['filter_data']!.isNotEmpty) { - try { - filterData = List>.from( - jsonDecode(state.uri.queryParameters['filter_data']!) - ); - } catch (e) { - print('Error parsing filter_data: $e'); - filterData = []; // Assign an empty list to prevent null issues - } - } else { - filterData = []; // Ensure it's a valid list - } - - - - print('Router dataSets: $dataSets'); - print('Router bgColor: $bgColor'); - print('Router mainTopic: $mainTopic'); - print('Router title: $title'); - print('Router filter: $filterData'); - - // Pass both values to the screen - return ChartScreen1( - dataSets: dataSets, - bgColor: bgColor, - mainTopic: mainTopic, - title: title, - keyParam: key, - kpi: kpi, - filter_data: filterData, - ); - }, - ), - GoRoute( - path: '/mailverification', - builder: (context, state) => EmailVerificationScreen( - email: '', - userId: '', - otp: '', - otpId: '', - sendVerificationCode: (String) {}, - ), - ), - GoRoute( - path: '/changepassword/:userId', - builder: (context, state) { - final userId = state.pathParameters['userId']!; - return Changepassword(userId: userId); - }, - ), - GoRoute( - path: '/createNewPw/:userId/:email', - builder: (context, state) { - final userId = state.pathParameters['userId']!; - final email = state.pathParameters['email']!; - final key = state.uri.queryParameters['key'] ?? ''; - - return CreateNewPw(userId: userId, email: email, keyParam: key); - }, - ), - GoRoute( - path: '/confirmpasswd', - builder: (context, state) => ConfirmPassword( - email: '', - userId: '', - ), - ), - GoRoute( - path: '/terms&conditions', - builder: (context, state) => TermsOfUse(), - //builder: (context, state) => LoginRoute(), - ), - GoRoute( - path: '/privacy_policy', - builder: (context, state) => PrivacyPolicy(), - //builder: (context, state) => LoginRoute(), - ), - -// Drawer Routers - GoRoute( - path: '/feedback', - builder: (context, state) => FeedbackForm(), - ), - //Sub route - GoRoute( - path: '/profile/:userId', - builder: (context, state) { - final userId = state.pathParameters['userId']!; - return ProfileScreen(userId: userId); - }, - ), - GoRoute( - path: '/notification', - builder: (context, state) { - // final userId = state.pathParameters['userId']!; - return NotificationPage(); - }, - ), - GoRoute( - path: '/user-guide', - builder: (context, state) => Userguide(), - routes: [ - GoRoute( - path: '/features', - name: 'features', - builder: (context, state) => UsingFeatures(), - routes: [ - GoRoute( - path: 'whoUseApp', - name: 'whoUseApp', - builder: (context, state) => WhoUseTheApp(), - ), - GoRoute( - path: 'howUseApp', - name: 'howUseApp', - builder: (context, state) => HowUseTheApp(), - ), - GoRoute( - path: 'purpose', - name: 'purpose', - builder: (context, state) => Purpose(), - ), - GoRoute( - path: 'stayUpdated', - name: 'stayUpdated', - builder: (context, state) => StayUpdate(), - ), - GoRoute( - path: 'changeMyPassword', - name: 'changeMyPassword', - builder: (context, state) => ChangeMyPassword(), - ), - GoRoute( - path: 'appFeatures', - name: 'appFeatures', - builder: (context, state) => AppFeatures(), - ), - GoRoute( - path: 'editMyProfile', - name: 'editMyProfile', - builder: (context, state) => EditMyProfile(), - ), - ], - ), - GoRoute( - path: 'aboutApp', - builder: (context, state) => aboutTheApp(), - routes: [ - GoRoute( - path: 'aboutFCSC', - name: 'aboutFCSC', - builder: (context, state) => aboutFCSC(), - ), - GoRoute( - path: 'getStarted', - name: 'getStarted', - builder: (context, state) => GetStarted(), - ), - ]), - GoRoute( - path: '/faq', - name: 'faq', - builder: (context, state) => FAQPage(), - ), - ], - ), - // GoRoute( - // path: '/manageuser', - // builder: (context, state) { - // // Retrieve the title from extra or query params - // final title = state.extra as String? ?? 'Manage users'; - // return ManageUserRouter(title: title); - // }, - // ), - GoRoute( - path: '/editProfile', - builder: (context, state) => EditProfile(), - ), - GoRoute( - path: '/bookmark', - builder: (context, state) => BookMark(), - ), - GoRoute( - path: '/manageuser', - builder: (context, state) => ManageUserRouter(), - ), - - // Bottom Navigation Routes - // GoRoute( - // path: '/uaenumbers', - // builder: (context, state) => UaeNumbers(), - // ), - GoRoute(path: '/uaenumbers', builder: (context, state) => UaeNumbers()), - - GoRoute( - path: '/competitiveness', - builder: (context, state) => Competitiveness(), - ), - - GoRoute( - path: '/countryprofile', - builder: (context, state) => CountryProfile(), - ), - - GoRoute( - path: '/marriages', - builder: (context, state) => Marriages(), - ), - - GoRoute( - path: '/contact', - builder: (context, state) => Contact(), - ), - ], - redirect: (context, state) async { - if (state.uri.path == '/SessionCheckScreen' || state.uri.path == '/login') { - return null; - } - - final session = await PAuthRepo().fetchLocallyStored(); - - if (session == null || session.freshness == SessionFreshness.expired) { - print('Session expired, redirecting to login with intendedPath: ${state.uri.path}'); - return '/login${state.uri.path != '/' ? '?intendedPath=${state.uri.path}' : ''}'; - } - return null; - } -); diff --git a/public/.well-known/assetlinks.json b/public/.well-known/assetlinks.json index ee5c2795..845e5770 100644 --- a/public/.well-known/assetlinks.json +++ b/public/.well-known/assetlinks.json @@ -5,7 +5,7 @@ "namespace": "android_app", "package_name": "ae.gov.fcsc.frontend", "sha256_cert_fingerprints": [ - "E0:B4:6F:B9:8B:96:66:5B:EC:14:98:53:07:01:D4:DF:39:24:E8:1F:CD:A2:9E:E4:77:66:E0:B4:5B:C2:E0:94" + "8E:D9:A0:F3:32:A7:5A:65:5B:F5:3B:57:76:39:2F:F8:1D:B1:8D:68:64:69:2D:0F:18:73:0D:02:39:7C:2E:E6" ] } } diff --git a/public/.well-known/deeplink.txt b/public/.well-known/deeplink.txt deleted file mode 100644 index 6d200b20..00000000 --- a/public/.well-known/deeplink.txt +++ /dev/null @@ -1,49 +0,0 @@ -Future _checkUserLoginStatus() async { - try { - await Future.delayed(const Duration(seconds: 1)); - log('Checking login status...'); - final session = await _authRepo.fetchLocallyStored(); - return session != null; - } catch (e) { - log('Error checking login status: $e'); - return false; - } -} - -Future _redirectToLogin(String redirectPath) async { - if (mounted) { - GoRouter.of(context).push('/login?redirect=$redirectPath'); - } -} - -Future _handleDeepLink(BuildContext context) async { - final GoRouterState state = GoRouterState.of(context); - final String? deepLink = state.uri.toString().isNotEmpty && state.uri.path != '/' ? state.uri.toString() : null; - - if (deepLink == null) { - log('No deep link detected.'); - return; - } - - log('Received deep link: $deepLink'); - final String path = Uri.parse(deepLink).path; - - final bool isLoggedIn = await _checkUserLoginStatus(); - if (!isLoggedIn) { - log('User not logged in. Redirecting to login.'); - await _redirectToLogin(path); - return; - } - - // If logged in, proceed to the shared page - if (mounted) { - log('User is logged in. Navigating to $path'); - GoRouter.of(context).go(path); - } -} - -@override -Widget build(BuildContext context) { - return widget.child; -} -} diff --git a/public/index.html b/public/index.html index c78755d8..248ff1af 100644 --- a/public/index.html +++ b/public/index.html @@ -6,17 +6,17 @@ Welcome to Firebase Hosting - + - - - - - - - - - + + + + + + + + +