From 58b32005e9bcc3287b81e45691ec24ba3151b6a9 Mon Sep 17 00:00:00 2001 From: SurendarSuri30 Date: Thu, 6 Nov 2025 18:15:30 +0530 Subject: [PATCH] update mobile no and wellmess --- android/app/build.gradle | 4 +- ios/Podfile | 2 +- ios/Runner/AppDelegate.swift | 13 + ios/Runner/Base.lproj/LaunchScreen.storyboard | 25 + ios/Runner/Runner-Bridging-Header.h | 1 + lib/main.dart | 120 +- lib/pages/email_verify.dart | 140 +- lib/pages/login.dart | 4 +- lib/pages/postEnrollment/home.dart | 101 +- lib/pages/postEnrollment/policies.dart | 80 +- lib/pages/postEnrollment/profile.dart | 1253 ++++---- .../postEnrollment/service/api_service.dart | 48 + lib/pages/service/appVersionService.dart | 84 + .../service/common_update_mobile_dialog.dart | 105 + lib/pages/service/popup_helper.dart | 2 + lib/pages/verify.dart | 2570 ++++++++--------- macos/Flutter/GeneratedPluginRegistrant.swift | 8 - pubspec.yaml | 12 +- .../flutter/generated_plugin_registrant.cc | 6 - windows/flutter/generated_plugins.cmake | 2 - 20 files changed, 2457 insertions(+), 2123 deletions(-) create mode 100644 ios/Runner/AppDelegate.swift create mode 100644 ios/Runner/Base.lproj/LaunchScreen.storyboard create mode 100644 ios/Runner/Runner-Bridging-Header.h create mode 100644 lib/pages/service/appVersionService.dart create mode 100644 lib/pages/service/common_update_mobile_dialog.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index ea4764a..0926571 100755 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -19,12 +19,12 @@ if (project.hasProperty('google-services.json')) { def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { - flutterVersionCode = '39' + flutterVersionCode = '41' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { - flutterVersionName = '2.0.1' + flutterVersionName = '2.0.3' } def keystoreProperties = new Properties() diff --git a/ios/Podfile b/ios/Podfile index 2dbf7d7..c2c1dc5 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '13.0' +platform :ios, '14.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..b636303 --- /dev/null +++ b/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@main +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/ios/Runner/Base.lproj/LaunchScreen.storyboard b/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..4b40275 --- /dev/null +++ b/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Runner-Bridging-Header.h b/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/lib/main.dart b/lib/main.dart index 2d03313..8e4ee62 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,6 @@ -import 'package:firebase_app_check/firebase_app_check.dart'; -import 'package:firebase_core/firebase_core.dart'; -import 'package:firebase_messaging/firebase_messaging.dart'; +// import 'package:firebase_app_check/firebase_app_check.dart'; +// import 'package:firebase_core/firebase_core.dart'; +// import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:nhance_app_pwa/customAppBar/toastHelper.dart'; @@ -130,55 +130,55 @@ Future tokenRedirectLogic( return null; // no redirect } -Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { - await Firebase.initializeApp(); - print("Handling background message: ${message.messageId}"); -} +// Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { +// await Firebase.initializeApp(); +// print("Handling background message: ${message.messageId}"); +// } Future main() async { WidgetsFlutterBinding.ensureInitialized(); // final SharedPreferences prefs = await SharedPreferences.getInstance(); // prefs.clear(); - if (kIsWeb) { - await Firebase.initializeApp( - options: const FirebaseOptions( - // apiKey: 'AIzaSyC4yHbCX4mQu0jO81pJrDwxKLQlTQWofrc', - // appId: '1:1084115316849:android:68b14c4ff37f4bbc6c6bd0', - // messagingSenderId: '1084115316849', - // projectId: 'nhance-ee8d1' - apiKey: "AIzaSyC4yHbCX4mQu0jO81pJrDwxKLQlTQWofrc", - authDomain: "nhance-ee8d1.firebaseapp.com", - projectId: "nhance-ee8d1", - storageBucket: "nhance-ee8d1.firebasestorage.app", - messagingSenderId: "1084115316849", - appId: "1:1084115316849:web:8fc3b1c886349ae86c6bd0")); - } else { - await Firebase.initializeApp(); - await FirebaseAppCheck.instance.activate( - // webProvider: ReCaptchaV3Provider('recaptcha-v3-site-key'), - androidProvider: AndroidProvider.playIntegrity, - appleProvider: AppleProvider.appAttest, - ); - FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler); - - FirebaseMessaging messaging = FirebaseMessaging.instance; - // NotificationSettings settings = await messaging.requestPermission(); - NotificationSettings settings = - await FirebaseMessaging.instance.requestPermission( - alert: true, - badge: true, - sound: true, - ); - print('User granted permission: ${settings.authorizationStatus}'); - - FirebaseMessaging.onMessage.listen((RemoteMessage message) { - print('Foreground Message: ${message.notification?.title}'); - }); - - FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { - print('User tapped on notification'); - }); - } + // if (kIsWeb) { + // await Firebase.initializeApp( + // options: const FirebaseOptions( + // // apiKey: 'AIzaSyC4yHbCX4mQu0jO81pJrDwxKLQlTQWofrc', + // // appId: '1:1084115316849:android:68b14c4ff37f4bbc6c6bd0', + // // messagingSenderId: '1084115316849', + // // projectId: 'nhance-ee8d1' + // apiKey: "AIzaSyC4yHbCX4mQu0jO81pJrDwxKLQlTQWofrc", + // authDomain: "nhance-ee8d1.firebaseapp.com", + // projectId: "nhance-ee8d1", + // storageBucket: "nhance-ee8d1.firebasestorage.app", + // messagingSenderId: "1084115316849", + // appId: "1:1084115316849:web:8fc3b1c886349ae86c6bd0")); + // } else { + // await Firebase.initializeApp(); + // await FirebaseAppCheck.instance.activate( + // // webProvider: ReCaptchaV3Provider('recaptcha-v3-site-key'), + // androidProvider: AndroidProvider.playIntegrity, + // appleProvider: AppleProvider.appAttest, + // ); + // FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler); + // + // FirebaseMessaging messaging = FirebaseMessaging.instance; + // // NotificationSettings settings = await messaging.requestPermission(); + // NotificationSettings settings = + // await FirebaseMessaging.instance.requestPermission( + // alert: true, + // badge: true, + // sound: true, + // ); + // print('User granted permission: ${settings.authorizationStatus}'); + // + // FirebaseMessaging.onMessage.listen((RemoteMessage message) { + // print('Foreground Message: ${message.notification?.title}'); + // }); + // + // FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { + // print('User tapped on notification'); + // }); + // } await dotenv.load(fileName: Environment.fileName); @@ -194,19 +194,19 @@ Future main() async { routes: [ GoRoute(path: '/splash', builder: (context, state) => const SplashScreen()), GoRoute(path: '/login', builder: (context, state) => login()), - GoRoute( - path: '/verify', - builder: (context, state) { - final extras = state.extra as Map?; - - return MyVerify( - verificationId: extras?['verificationId'] ?? '', - mobileNumber: extras?['mobileNumber'] ?? '', - resendToken: extras?['resendToken'], - onResendCode: extras?['onResendCode'], - ); - }, - ), + // GoRoute( + // path: '/verify', + // builder: (context, state) { + // final extras = state.extra as Map?; + // + // return MyVerify( + // verificationId: extras?['verificationId'] ?? '', + // mobileNumber: extras?['mobileNumber'] ?? '', + // resendToken: extras?['resendToken'], + // onResendCode: extras?['onResendCode'], + // ); + // }, + // ), // GoRoute( // path: '/chatbot', // builder: (context, state) { diff --git a/lib/pages/email_verify.dart b/lib/pages/email_verify.dart index 195fa83..b0ac7e9 100755 --- a/lib/pages/email_verify.dart +++ b/lib/pages/email_verify.dart @@ -1,5 +1,5 @@ -import 'package:firebase_auth/firebase_auth.dart'; -import 'package:firebase_messaging/firebase_messaging.dart'; +// import 'package:firebase_auth/firebase_auth.dart'; +// import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; @@ -66,8 +66,8 @@ class _MyEmailVerifyState extends State { String? fcmToken; String? apnsToken; late String verificationId; - final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; - final FirebaseAuth _auth = FirebaseAuth.instance; + // final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; + // final FirebaseAuth _auth = FirebaseAuth.instance; bool _isLoading = false; late String _verificationId; @@ -88,56 +88,56 @@ class _MyEmailVerifyState extends State { super.dispose(); } - Future initNotification() async { - try { - // Request permission - NotificationSettings settings = - await _firebaseMessaging.requestPermission( - alert: true, - badge: true, - sound: true, - ); - print('🔔 Permission: ${settings.authorizationStatus}'); - - if (Platform.isIOS || Platform.isMacOS) { - // Get APNS token - apnsToken = await _firebaseMessaging.getAPNSToken(); - print('📱 APNS Token (iOS): $apnsToken'); - - // Retry if null - if (apnsToken == null) { - await Future.delayed(const Duration(seconds: 3)); - apnsToken = await _firebaseMessaging.getAPNSToken(); - print('🔁 Retried APNS Token: $apnsToken'); - } - - if (apnsToken != null) { - await sendDeviceToken(apnsToken!); - } - } else if (Platform.isAndroid) { - // Get FCM token - fcmToken = await _firebaseMessaging.getToken(); - print('🔥 FCM Token (Android): $fcmToken'); - - if (fcmToken != null) { - await sendDeviceToken(fcmToken!); - } - } - - // Background handler - FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); - - // Foreground listener - FirebaseMessaging.onMessage.listen((RemoteMessage message) { - print('💬 Message: ${message.notification?.title}'); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text(message.notification?.title ?? 'New Notification')), - ); - }); - } catch (e) { - print('❌ Notification init error: $e'); - } - } + // Future initNotification() async { + // try { + // // Request permission + // NotificationSettings settings = + // await _firebaseMessaging.requestPermission( + // alert: true, + // badge: true, + // sound: true, + // ); + // print('🔔 Permission: ${settings.authorizationStatus}'); + // + // if (Platform.isIOS || Platform.isMacOS) { + // // Get APNS token + // apnsToken = await _firebaseMessaging.getAPNSToken(); + // print('📱 APNS Token (iOS): $apnsToken'); + // + // // Retry if null + // if (apnsToken == null) { + // await Future.delayed(const Duration(seconds: 3)); + // apnsToken = await _firebaseMessaging.getAPNSToken(); + // print('🔁 Retried APNS Token: $apnsToken'); + // } + // + // if (apnsToken != null) { + // await sendDeviceToken(apnsToken!); + // } + // } else if (Platform.isAndroid) { + // // Get FCM token + // fcmToken = await _firebaseMessaging.getToken(); + // print('🔥 FCM Token (Android): $fcmToken'); + // + // if (fcmToken != null) { + // await sendDeviceToken(fcmToken!); + // } + // } + // + // // Background handler + // FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); + // + // // Foreground listener + // FirebaseMessaging.onMessage.listen((RemoteMessage message) { + // print('💬 Message: ${message.notification?.title}'); + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar(content: Text(message.notification?.title ?? 'New Notification')), + // ); + // }); + // } catch (e) { + // print('❌ Notification init error: $e'); + // } + // } // Future initNotification() async { // await _firebaseMessaging.requestPermission(); @@ -346,13 +346,13 @@ class _MyEmailVerifyState extends State { print('Successfully Login'); - loginUser( - gpaEmpName: session.gpaEmpName, - empPrimaryId: session.empPrimaryId, - empCodeString: session.empCodeString, - client_id: session.client_id, - empClientBranchId: session.empClientBranchId, - ); + // loginUser( + // gpaEmpName: session.gpaEmpName, + // empPrimaryId: session.empPrimaryId, + // empCodeString: session.empCodeString, + // client_id: session.client_id, + // empClientBranchId: session.empClientBranchId, + // ); // if (kIsWeb) { // html.window.localStorage['gpaEmpName'] = gpaEmpName; @@ -432,7 +432,7 @@ class _MyEmailVerifyState extends State { } else { prefs.setString('empEmailid', widget.value); } - await initNotification(); + // await initNotification(); checkLoginPin(context); } // } @@ -490,7 +490,7 @@ class _MyEmailVerifyState extends State { } else { prefs.setString('empEmailid', widget.value); } - await initNotification(); + // await initNotification(); checkLoginPin(context); } // } @@ -1241,10 +1241,10 @@ class _MyEmailVerifyState extends State { } // ✅ Must be outside any class — this fixes your error -@pragma('vm:entry-point') -Future firebaseMessagingBackgroundHandler(RemoteMessage message) async { - print('📨 Handling background message: ${message.messageId}'); - print('Title: ${message.notification?.title}'); - print('Body: ${message.notification?.body}'); - print('Data: ${message.data}'); -} \ No newline at end of file +// @pragma('vm:entry-point') +// Future firebaseMessagingBackgroundHandler(RemoteMessage message) async { +// print('📨 Handling background message: ${message.messageId}'); +// print('Title: ${message.notification?.title}'); +// print('Body: ${message.notification?.body}'); +// print('Data: ${message.data}'); +// } \ No newline at end of file diff --git a/lib/pages/login.dart b/lib/pages/login.dart index 609ca0c..1cd66e2 100755 --- a/lib/pages/login.dart +++ b/lib/pages/login.dart @@ -1,4 +1,4 @@ -import 'package:firebase_auth/firebase_auth.dart'; +// import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -33,7 +33,7 @@ class _loginState extends State { dynamic empMobileNo; dynamic empEmailid; - final FirebaseAuth _auth = FirebaseAuth.instance; + // final FirebaseAuth _auth = FirebaseAuth.instance; late String _verificationId; int? _resendToken; diff --git a/lib/pages/postEnrollment/home.dart b/lib/pages/postEnrollment/home.dart index 75db39e..d3e5cfc 100755 --- a/lib/pages/postEnrollment/home.dart +++ b/lib/pages/postEnrollment/home.dart @@ -123,31 +123,10 @@ class _HomeState extends State { - if (kIsWeb) { - openBotmanChat(); - - // setupBackButtonHandler(() { - // if (!_dialogShown) _showBackConfirmationDialog(); - // }); - - // Push a dummy state so back button triggers popstate instead of navigating - // html.window.history.pushState(null, 'home', html.window.location.href); - - // html.window.onPopState.listen((event) { - // if (!_dialogShown) { - // _showBackConfirmationDialog(); - // } - // // Re-push to prevent leaving - // html.window.history.pushState(null, 'home', html.window.location.href); - // }); - } - // if (Platform.isAndroid) { - // WebViewPlatform.instance = AndroidWebViewPlatform(); + // if (kIsWeb) { + // openBotmanChat(); // } - // _controller = WebViewController() - // ..setJavaScriptMode(JavaScriptMode.unrestricted) - // ..loadFlutterAsset('assets/botman_chat.html'); // or loadHtmlString } @override @@ -974,44 +953,44 @@ class _HomeState extends State { ), ), ]), - floatingActionButton: Responsive.isDesktop(context) - ? null - : FloatingActionButton( - // onPressed: () => push(chatbot()), - onPressed: () => { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => MyWebViewPage( - // url: 'https://venbait.in/nhance/dev/chatbot?employee_id=${empPrimaryId}&emp_code=${empCodeString}&origin=mob&name=${empName}&client_id=${client_id}&client_branch_id=${client_branch_id}', - // ), - // ), - // ) - // context.go( - // '/chatbot', - // extra: { - // 'client_branch_id': client_branch_id, - // 'empCodeString': empCodeString, - // 'empName': empName, - // 'empPrimaryId': empPrimaryId, - // 'client_id': client_id, - // }, - // ) - Navigator.push( - context, - // MaterialPageRoute(builder: (context) => const BotmanChatPage()), - MaterialPageRoute( - builder: (context) => ChatbotWebViewPage( - client_branch_id: client_branch_id, - empCodeString: empCodeString, - empName: empName, - empPrimaryId: empPrimaryId, - client_id: client_id, - )), - ) - }, - child: Icon(Icons.chat), - ), + // floatingActionButton: Responsive.isDesktop(context) + // ? null + // : FloatingActionButton( + // // onPressed: () => push(chatbot()), + // onPressed: () => { + // // Navigator.push( + // // context, + // // MaterialPageRoute( + // // builder: (context) => MyWebViewPage( + // // url: 'https://venbait.in/nhance/dev/chatbot?employee_id=${empPrimaryId}&emp_code=${empCodeString}&origin=mob&name=${empName}&client_id=${client_id}&client_branch_id=${client_branch_id}', + // // ), + // // ), + // // ) + // // context.go( + // // '/chatbot', + // // extra: { + // // 'client_branch_id': client_branch_id, + // // 'empCodeString': empCodeString, + // // 'empName': empName, + // // 'empPrimaryId': empPrimaryId, + // // 'client_id': client_id, + // // }, + // // ) + // Navigator.push( + // context, + // // MaterialPageRoute(builder: (context) => const BotmanChatPage()), + // MaterialPageRoute( + // builder: (context) => ChatbotWebViewPage( + // client_branch_id: client_branch_id, + // empCodeString: empCodeString, + // empName: empName, + // empPrimaryId: empPrimaryId, + // client_id: client_id, + // )), + // ) + // }, + // child: Icon(Icons.chat), + // ), floatingActionButtonLocation: Responsive.isDesktop(context) ? null : FloatingActionButtonLocation.miniEndFloat, diff --git a/lib/pages/postEnrollment/policies.dart b/lib/pages/postEnrollment/policies.dart index 9d118f0..14cf846 100755 --- a/lib/pages/postEnrollment/policies.dart +++ b/lib/pages/postEnrollment/policies.dart @@ -37,6 +37,9 @@ class _policiesState extends State { dynamic _token; dynamic empCodeString; dynamic empPrimaryId; + dynamic empName; + dynamic mobileNo; + dynamic client_branch_id; dynamic client_id; dynamic policyList; dynamic policyDataIsEmpty = 1; @@ -77,16 +80,49 @@ class _policiesState extends State { final SharedPreferences prefs = await SharedPreferences.getInstance(); if (token != null && token.isNotEmpty) { // Decode the JWT token received from the API response - Map? decodedToken = Jwt.parseJwt(token); - print(decodedToken); - empCodeString = prefs.getString('empCode'); - print(empCodeString); // Check if emp_code is correct - empPrimaryId = prefs.getString('empPrimaryId'); - client_id = prefs.getString('client_id'); - print(client_id); + mobileNo = session.mobileNo; + client_branch_id = session.empClientBranchId; + empCodeString = session.empCodeString; + empName = session.gpaEmpName; + print(empCodeString); // Check if emp_code is correct + empPrimaryId = session.empPrimaryId; + client_id = session.client_id; } } + Future getEcardDownload() async { + final clientPolicyID = widget.arguments?['client_policy_id']; + final policyNo = widget.arguments?['policy_no']; + final eCarDParams = { + 'id': empPrimaryId, + 'emp_code': empCodeString, + 'client_policy_id': clientPolicyID, + 'policy_no': policyNo + }; + final response = await apiService.getEcardRequest(eCarDParams); + print('check 1'); + final ecardDownloadUrl = response['data']['eCardDownload']; + final message = response['data']['message']; + if (ecardDownloadUrl != null) { + print('✅ Link: $ecardDownloadUrl'); + await _launchURL(ecardDownloadUrl,context); // Only launch if status is success + // ToastHelper.showSuccessToast(context, message); + } else { + print('❌ Error: $message'); + ToastHelper.showErrorToast(context, message); + } + } + + + Future _launchURL(String url, BuildContext context) async { + print('url $url'); + try { + final Uri uri = Uri.parse(url); + await launchUrl(uri, mode: LaunchMode.externalApplication); + } catch (e) { + print('Could not launch URL: $e'); + } + } String convertDateFormat(String date) { // Define input and output date formats @@ -111,19 +147,6 @@ class _policiesState extends State { } } -// Function to open URL in the default browser - Future _launchURL(String url) async { - final Uri uri = Uri.parse(url); // Parse the URL properly - print('_launchURL $uri'); - if (uri != null) { - print('If $uri'); - await launchUrl(uri, mode: LaunchMode.externalApplication); - } else { - print('else $uri'); - throw 'Could not launch $url'; - } - } - void _openUrl(String url) async { if (url.isNotEmpty && await canLaunch(url)) { await launch(url, @@ -270,14 +293,15 @@ class _policiesState extends State { : 180, child: TextButton( onPressed: () { - if (argumentsData['eCardDownload'] != - null) { - _launchURL( - argumentsData['eCardDownload']); - } else { - ToastHelper.showInfoToast( - context, 'Not Generated'); - } + getEcardDownload(); + // if (argumentsData['eCardDownload'] != + // null) { + // _launchURL( + // argumentsData['eCardDownload']); + // } else { + // ToastHelper.showInfoToast( + // context, 'Not Generated'); + // } }, style: TextButton.styleFrom( padding: EdgeInsets.only( diff --git a/lib/pages/postEnrollment/profile.dart b/lib/pages/postEnrollment/profile.dart index b2d5ecd..7f0eb07 100755 --- a/lib/pages/postEnrollment/profile.dart +++ b/lib/pages/postEnrollment/profile.dart @@ -21,6 +21,8 @@ import '../../models/platform_helper_mobile.dart' if (dart.library.html) '../../models/platform_helper_other.dart'; import '../service/TokenService.dart'; +import '../service/appVersionService.dart'; +import '../service/common_update_mobile_dialog.dart'; import '../service/data_manager.dart'; import '../service/popup_helper.dart'; import '../session/authenticationService.dart'; @@ -64,6 +66,8 @@ class _profileState extends State { dynamic client_branch_id; final dataManager = DataManager(); final session = SessionManager(); + String installedVersion = ""; + String? storeVersion = ""; void _onTabChanged(int index) { setState(() { @@ -76,6 +80,9 @@ class _profileState extends State { super.initState(); apiService = ApiService(context); // Initialize ApiService here _loadToken(); + if(!kIsWeb){ + loadVersionInfo(); + } } @override @@ -83,7 +90,17 @@ class _profileState extends State { super.dispose(); } + Future loadVersionInfo() async { + print('App version:}'); + installedVersion = await AppVersionService.getInstalledVersion(); + storeVersion = await AppVersionService.getLatestStoreVersion( + androidPackage: "nh.ind.nhance.benefits", // Android + iosAppId: "6744743638", // iOS App Store ID + ); + + setState(() {}); + } Future _getAppVersion() async { try { @@ -120,52 +137,51 @@ class _profileState extends State { } Future getSelfEmployeeProfile() async { - final selfDetails = dataManager.selfProfile; print('profile'); print(profile); - // if (client_id == null || empCodeString == null) { - // return; - // } - // setState(() { - // isLoading = true; - // }); - // print('check 1'); - // final response = await apiService.getSelfEmployeeProfileDetails( - // client_id!, empCodeString!, client_branch_id!); - // print('check 1'); - // if (response['status'] == 'success') { - // if (response.containsKey('data')) { - setState(() { - // dynamic selfDetails = response['data']; - // - print(selfDetails); - selfRelationship = selfDetails?['relationship']; - selfName = selfDetails?['name']; - selfMobile = selfDetails?['mobile']; - selfDesignation = selfDetails?['designation']; - selfDob = convertDate(selfDetails?['dob']); - selfDoj = convertDate(selfDetails?['doj']); - selfGender = selfDetails?['gender']; - selfEmailCorporate = selfDetails?['email_corporate']; - selfEmailPersonal = selfDetails?['email_personal']; - selfEmpCode = selfDetails?['emp_code']; - selfFamilyFloaterKey = selfDetails?['family_floater_key']; - // print(clientDetails); - selfEmpStatus = selfDetails?['emp_status']; - // isLoading = false; - }); - // final SharedPreferences prefs = await SharedPreferences.getInstance(); - // prefs.setString('selfEmpStatus', selfEmpStatus); - // } else { - // // Handle other status messages if needed - // // ToastHelper.showErrorToast( - // // context, 'API request failed with status: ${data['status']}'); - // print('API request failed with status: ${response['status']}'); - // } - // } else { - // print('API request failed with status: ${response['status']}'); - // } + // if (client_id == null || empCodeString == null) { + // return; + // } + // setState(() { + // isLoading = true; + // }); + // print('check 1'); + // final response = await apiService.getSelfEmployeeProfileDetails( + // client_id!, empCodeString!, client_branch_id!); + // print('check 1'); + // if (response['status'] == 'success') { + // if (response.containsKey('data')) { + setState(() { + // dynamic selfDetails = response['data']; + // + print(selfDetails); + selfRelationship = selfDetails?['relationship']; + selfName = selfDetails?['name']; + selfMobile = selfDetails?['mobile']; + selfDesignation = selfDetails?['designation']; + selfDob = convertDate(selfDetails?['dob']); + selfDoj = convertDate(selfDetails?['doj']); + selfGender = selfDetails?['gender']; + selfEmailCorporate = selfDetails?['email_corporate']; + selfEmailPersonal = selfDetails?['email_personal']; + selfEmpCode = selfDetails?['emp_code']; + selfFamilyFloaterKey = selfDetails?['family_floater_key']; + // print(clientDetails); + selfEmpStatus = selfDetails?['emp_status']; + // isLoading = false; + }); + // final SharedPreferences prefs = await SharedPreferences.getInstance(); + // prefs.setString('selfEmpStatus', selfEmpStatus); + // } else { + // // Handle other status messages if needed + // // ToastHelper.showErrorToast( + // // context, 'API request failed with status: ${data['status']}'); + // print('API request failed with status: ${response['status']}'); + // } + // } else { + // print('API request failed with status: ${response['status']}'); + // } } Future checkLoginPin() async { @@ -205,7 +221,8 @@ class _profileState extends State { prefs.setString('mpin', data['Mpin']); } if (data['is_biometric_enabled'] != null) { - prefs.setString('is_biometric_enabled', data['is_biometric_enabled']); + prefs.setString( + 'is_biometric_enabled', data['is_biometric_enabled']); } if (data['is_mpin_skipped'] != null) { prefs.setString('is_mpin_skipped', data['is_mpin_skipped']); @@ -223,7 +240,6 @@ class _profileState extends State { return null; } - Future logout(BuildContext context) async { // if (isMobilePlatform()) { final SharedPreferences prefs = await SharedPreferences.getInstance(); @@ -276,7 +292,6 @@ class _profileState extends State { context.go('/login'); } - // } else { // final prefs = await SharedPreferences.getInstance(); // await prefs.clear(); @@ -293,577 +308,631 @@ class _profileState extends State { context.pop(); }, child: Scaffold( - backgroundColor: Colors.white, - appBar: CustomAppBar(), - body: Stack(children: [ - SingleChildScrollView( - child: Container( - padding: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: MediaQuery.of(context).size.width * - 0.2, // 30% of screen width as horizontal padding - vertical: MediaQuery.of(context).size.height * - 0.03, // 5% of screen height as vertical padding - ) - : EdgeInsets.all(10), - color: Colors.white, - child: Column(children: [ - if (selfName != null) - Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, + backgroundColor: Colors.white, + appBar: CustomAppBar(), + body: Stack(children: [ + SingleChildScrollView( + child: Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.2, // 30% of screen width as horizontal padding + vertical: MediaQuery.of(context).size.height * + 0.03, // 5% of screen height as vertical padding + ) + : EdgeInsets.all(10), + color: Colors.white, + child: Column(children: [ + if (selfName != null) + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - context.pop(); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Icon( - Icons - .chevron_left, // Replace with your desired icon - color: Color(0xFF000000), - size: 30, - ), - ], - ), - ), - ), - Expanded( - flex: 11, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - // Adjust space between icon and text - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - selfName ?? '', - textAlign: TextAlign.center, - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight.w600, + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () { + context.pop(); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon( + Icons + .chevron_left, // Replace with your desired icon color: Color(0xFF000000), + size: 30, ), - ), - ], + ], + ), ), - ], - ), - ) - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - flex: 1, - child: Container( - alignment: Alignment.topLeft, - padding: EdgeInsets.only(top: 10, left: 10), - child: Text(''))), - Expanded( - flex: Responsive.isDesktop(context) ? 12 : 11, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - // Adjust space between icon and text - Column( + ), + Expanded( + flex: 11, + child: Row( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, children: [ - RichText( - text: TextSpan( - children: [ - TextSpan( - text: 'Emp: Id - ', - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight - .w600, // Bold style for "Emp: Id -" - color: Color(0xFF000000), - ), + // Adjust space between icon and text + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + selfName ?? '', + textAlign: TextAlign.center, + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Color(0xFF000000), ), - TextSpan( - text: selfEmpCode ?? '', - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight - .w400, // Normal style for the ID number - color: Color(0xFF747474), - ), - ), - ], - ), + ), + ], ), ], ), - ], - ), - ) + ) + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + flex: 1, + child: Container( + alignment: Alignment.topLeft, + padding: EdgeInsets.only(top: 10, left: 10), + child: Text(''))), + Expanded( + flex: Responsive.isDesktop(context) ? 12 : 11, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // Adjust space between icon and text + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + RichText( + text: TextSpan( + children: [ + TextSpan( + text: 'Emp: Id - ', + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight + .w600, // Bold style for "Emp: Id -" + color: Color(0xFF000000), + ), + ), + TextSpan( + text: selfEmpCode ?? '', + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight + .w400, // Normal style for the ID number + color: Color(0xFF747474), + ), + ), + ], + ), + ), + ], + ), + ], + ), + ) + ], + ), + // Add more rows as needed ], ), - // Add more rows as needed - ], - ), - ), - SizedBox(height: 15), - if (selfName != null) - Card( - elevation: 5, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(10), // Set the border radius here ), - child: Column(children: [ - Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), + SizedBox(height: 15), + if (selfName != null) + Card( + elevation: 5, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + 10), // Set the border radius here ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.all(30) - : EdgeInsets.all(15), child: Column(children: [ Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Color(0xFFBDBDBD), - width: 1.0, // Adjust the width as needed - ), - ), - ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 15, bottom: 15, left: 15, right: 15) - : EdgeInsets.only(top: 10, bottom: 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10) - : EdgeInsets.only( - top: 7, - bottom: 7, - left: 7, - right: 7), - child: Text( - 'Gender', - textAlign: TextAlign.start, - style: GoogleFonts.poppins( - fontSize: Responsive.isDesktop(context) - ? 16 - : 14, - color: Color(0xFF777777), - fontWeight: FontWeight.w500, - ), - ), - ), - ), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Text( - selfGender == 'M' ? 'Male' : 'Female', - textAlign: TextAlign.end, - style: GoogleFonts.poppins( - fontSize: Responsive.isDesktop(context) - ? 16 - : 16, - color: Color(0xFF2D5A82), - fontWeight: FontWeight.w400, - ), - ), - ), - ), - ], - )), - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Color(0xFFBDBDBD), - width: 1.0, // Adjust the width as needed - ), - ), - ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 15, bottom: 15, left: 15, right: 15) - : EdgeInsets.only(top: 10, bottom: 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10) - : EdgeInsets.only( - top: 7, - bottom: 7, - left: 7, - right: 7), - child: Text( - 'Date of birth', - textAlign: TextAlign.start, - style: GoogleFonts.poppins( - fontSize: Responsive.isDesktop(context) - ? 16 - : 14, - color: Color(0xFF777777), - fontWeight: FontWeight.w500, - ), - ), - ), - ), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Text( - selfDob ?? '', - textAlign: TextAlign.end, - style: GoogleFonts.poppins( - fontSize: Responsive.isDesktop(context) - ? 16 - : 16, - color: Color(0xFF2D5A82), - fontWeight: FontWeight.w400, - ), - ), - ), - ), - ], - )), - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Color(0xFFBDBDBD), - width: 1.0, // Adjust the width as needed - ), - ), - ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 15, bottom: 15, left: 15, right: 15) - : EdgeInsets.only(top: 10, bottom: 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10) - : EdgeInsets.only( - top: 7, - bottom: 7, - left: 7, - right: 7), - child: Text( - 'Phone No', - textAlign: TextAlign.start, - style: GoogleFonts.poppins( - fontSize: Responsive.isDesktop(context) - ? 16 - : 14, - color: Color(0xFF777777), - fontWeight: FontWeight.w500, - ), - ), - ), - ), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Text( - selfMobile ?? '', - textAlign: TextAlign.end, - style: GoogleFonts.poppins( - fontSize: Responsive.isDesktop(context) - ? 16 - : 16, - color: Color(0xFF2D5A82), - fontWeight: FontWeight.w400, - ), - ), - ), - ), - ], - )), - Container( - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 15, bottom: 15, left: 15, right: 15) - : EdgeInsets.only(top: 10, bottom: 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10) - : EdgeInsets.only( - top: 7, - bottom: 7, - left: 7, - right: 7), - child: Text( - 'Email id', - textAlign: TextAlign.start, - style: GoogleFonts.poppins( - fontSize: Responsive.isDesktop(context) - ? 16 - : 14, - color: Color(0xFF777777), - fontWeight: FontWeight.w500, - ), - ), - ), - ), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Text( - selfEmailCorporate ?? '', - textAlign: TextAlign.end, - style: GoogleFonts.poppins( - fontSize: Responsive.isDesktop(context) - ? 16 - : 16, - color: Color(0xFF2D5A82), - fontWeight: FontWeight.w400, - ), - ), - ), - ), - ], - )), - ]), - ) - ])), - SizedBox(height: 12), - if(Responsive.isMobile(context) || Responsive.isTablet(context)) - Container( - child: Row( - children: [ - Expanded( - flex: 12, - child: Container( - width: 150, - // height: Responsive.isDesktop(context) ? 150 : 100, - alignment: Alignment.center, - child: ElevatedButton( - onPressed: () { - print('changePin'); - context.go('/changePin'); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - // Adjust space between icon and text - Text( - 'Change Pin', - style: GoogleFonts.poppins( - color: Color(0xFFE26728)), - ), - ], + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), ), - style: ElevatedButton.styleFrom( - backgroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), - side: BorderSide(color: Color(0xFFE26728)), - ), - ), - ), - )), - ], - ), - ), - SizedBox(height: 10), - Container( - child: Row( - children: [ - Expanded( - flex: 12, - child: Container( - width: 150, - // height: Responsive.isDesktop(context) ? 150 : 100, - alignment: Alignment.center, - child: ElevatedButton( - onPressed: () { - logout(context); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.logout, - color: Color(0xFFE26728), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(15), + child: Column(children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Color(0xFFBDBDBD), + width: 1.0, // Adjust the width as needed + ), + ), + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, + bottom: 15, + left: 15, + right: 15) + : EdgeInsets.only(top: 10, bottom: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10) + : EdgeInsets.only( + top: 7, + bottom: 7, + left: 7, + right: 7), + child: Text( + 'Gender', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 16 + : 14, + color: Color(0xFF777777), + fontWeight: FontWeight.w500, + ), + ), + ), + ), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Text( + selfGender == 'M' ? 'Male' : 'Female', + textAlign: TextAlign.end, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 16 + : 16, + color: Color(0xFF2D5A82), + fontWeight: FontWeight.w400, + ), + ), + ), + ), + ], + )), + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Color(0xFFBDBDBD), + width: 1.0, // Adjust the width as needed + ), + ), + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, + bottom: 15, + left: 15, + right: 15) + : EdgeInsets.only(top: 10, bottom: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10) + : EdgeInsets.only( + top: 7, + bottom: 7, + left: 7, + right: 7), + child: Text( + 'Date of birth', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 16 + : 14, + color: Color(0xFF777777), + fontWeight: FontWeight.w500, + ), + ), + ), + ), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Text( + selfDob ?? '', + textAlign: TextAlign.end, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 16 + : 16, + color: Color(0xFF2D5A82), + fontWeight: FontWeight.w400, + ), + ), + ), + ), + ], + )), + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Color(0xFFBDBDBD), + width: 1.0, // Adjust the width as needed + ), + ), + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, + bottom: 15, + left: 15, + right: 15) + : EdgeInsets.only(top: 10, bottom: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 4, + child: Container( + alignment: Alignment.centerLeft, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10) + : EdgeInsets.only( + top: 7, + bottom: 7, + left: 7, + right: 7), + child: Text( + 'Phone No', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 16 + : 14, + color: Color(0xFF777777), + fontWeight: FontWeight.w500, + ), + ), + ), + ), + Expanded( + flex: 8, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () async { + // {"email_id":"example@mail.com","client_id":123,"new_mobile_number":"9876543210"} + final updatedNumber = await showUpdateMobileDialog(context, apiService, client_id, selfEmailCorporate, selfMobile); + if (updatedNumber != null && updatedNumber.isNotEmpty) { + setState(() => selfMobile = updatedNumber); + dataManager.loadSelfEmployeeProfile( + clientId: session.client_id!, + empCode: session.empCodeString!, + clientBranchId: session.empClientBranchId!, + ); + } + }, + child: const Icon( + Icons.edit, + size: 18, + color: Colors.blue, + ), + ), + ), + const SizedBox(width: 6), + Text( + selfMobile ?? '', + style: GoogleFonts.poppins( + fontSize: 16, + color: Color(0xFF2D5A82), + ), + ) + ], + ), + ) + ], + )), + Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, + bottom: 15, + left: 15, + right: 15) + : EdgeInsets.only(top: 10, bottom: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10) + : EdgeInsets.only( + top: 7, + bottom: 7, + left: 7, + right: 7), + child: Text( + 'Email id', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 16 + : 14, + color: Color(0xFF777777), + fontWeight: FontWeight.w500, + ), + ), + ), + ), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Text( + selfEmailCorporate ?? '', + textAlign: TextAlign.end, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 16 + : 16, + color: Color(0xFF2D5A82), + fontWeight: FontWeight.w400, + ), + ), + ), + ), + ], + )), + ]), + ) + ])), + SizedBox(height: 12), + if (Responsive.isMobile(context) || + Responsive.isTablet(context)) + Container( + child: Row( + children: [ + Expanded( + flex: 12, + child: Container( + width: 150, + // height: Responsive.isDesktop(context) ? 150 : 100, + alignment: Alignment.center, + child: ElevatedButton( + onPressed: () { + print('changePin'); + context.go('/changePin'); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // Adjust space between icon and text + Text( + 'Change Pin', + style: GoogleFonts.poppins( + color: Color(0xFFE26728)), + ), + ], + ), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + side: BorderSide(color: Color(0xFFE26728)), + ), + ), ), - SizedBox( - width: - 8), // Adjust space between icon and text - Text( - 'Logout', - style: GoogleFonts.poppins( - color: Color(0xFFE26728)), + )), + ], + ), + ), + SizedBox(height: 10), + Container( + child: Row( + children: [ + Expanded( + flex: 12, + child: Container( + width: 150, + // height: Responsive.isDesktop(context) ? 150 : 100, + alignment: Alignment.center, + child: ElevatedButton( + onPressed: () { + logout(context); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.logout, + color: Color(0xFFE26728), + ), + SizedBox( + width: + 8), // Adjust space between icon and text + Text( + 'Logout', + style: GoogleFonts.poppins( + color: Color(0xFFE26728)), + ), + ], + ), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + side: BorderSide(color: Color(0xFFE26728)), + ), ), - ], - ), - style: ElevatedButton.styleFrom( - backgroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), - side: BorderSide(color: Color(0xFFE26728)), ), - ), - ), - )), - ], - ), - ), - SizedBox(height: Responsive.isDesktop(context) ? 40 : 10), - Padding( - padding: const EdgeInsets.only(bottom: 16.0), - child: FutureBuilder( - future: _getAppVersion(), // Function to get the app version - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return Text( - 'Loading version...', + )), + ], + ), + ), + SizedBox(height: Responsive.isDesktop(context) ? 40 : 10), + if (Responsive.isDesktop(context)) + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: FutureBuilder( + future: _getAppVersion(), // Function to get the app version + builder: (context, snapshot) { + if (snapshot.connectionState == + ConnectionState.waiting) { + return Text( + 'Loading version...', + style: GoogleFonts.poppins( + fontSize: 12, color: Colors.grey), + textAlign: TextAlign.center, + ); + } else if (snapshot.hasError) { + return Text( + 'Error fetching version', + style: GoogleFonts.poppins( + fontSize: 12, color: Colors.red), + textAlign: TextAlign.center, + ); + } else { + return Text( + 'Version ${snapshot.data}', + style: GoogleFonts.poppins( + fontSize: 12, color: Colors.grey), + textAlign: TextAlign.center, + ); + } + }, + ), + ), + if (Responsive.isMobile(context) || + Responsive.isTablet(context)) + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: Text( + 'Version ${installedVersion}', style: GoogleFonts.poppins( fontSize: 12, color: Colors.grey), - textAlign: TextAlign.center, - ); - } else if (snapshot.hasError) { - return Text( - 'Error fetching version', - style: GoogleFonts.poppins( - fontSize: 12, color: Colors.red), textAlign: TextAlign.center, - ); - } else { - return Text( - 'Version ${snapshot.data}', - style: GoogleFonts.poppins( - fontSize: 12, color: Colors.grey), - textAlign: TextAlign.center, - ); - } - }, + )) + ]), + )), + if (isLoading) + Container( + color: Color(0x98FFFCE5), // Semi-transparent background + child: Center( + child: // Your GIF loader widget + Image.asset( + height: 60, + width: 60, + 'assets/nhance-loader.gif'), // Adjust path to your GIF loader + ), ), + if (Responsive.isDesktop(context)) + Align( + alignment: Alignment.bottomCenter, + child: Container( + width: double.infinity, // Make the footer full width + child: CustomFooter(), + ), ), ]), - )), - if (isLoading) - Container( - color: Color(0x98FFFCE5), // Semi-transparent background - child: Center( - child: // Your GIF loader widget - Image.asset( - height: 60, - width: 60, - 'assets/nhance-loader.gif'), // Adjust path to your GIF loader - ), - ), - if (Responsive.isDesktop(context)) - Align( - alignment: Alignment.bottomCenter, - child: Container( - width: double.infinity, // Make the footer full width - child: CustomFooter(), - ), - ), - ]), - // floatingActionButton: Responsive.isDesktop(context) - // ? null - // : FloatingActionButton( - // onPressed: () { - // Navigator.pushNamed(context, 'chatbot'); - // }, - // child: Icon(Icons.chat), - // ), - floatingActionButtonLocation: Responsive.isDesktop(context) - ? null - : FloatingActionButtonLocation.miniEndFloat, - bottomNavigationBar: Responsive.isDesktop(context) - ? null - : CustomBottomNavigationBar( - onTabChanged: (index) { - if (index == 0) { - context.push('/home'); - } else if (index == 1) { - context.push('/claims'); - } else if (index == 2) { - context.push('/profile'); - } else if (index == 3) { - context.push('/help'); - } else if (index == 4) { - // Wellness tab clicked → show popup - PopupHelper.showRedirectPopup( - context: context, - apiService: apiService, - empPrimaryId: session.empPrimaryId, - ); - } - }, - icons: [ - Icons.home_outlined, - Icons.sticky_note_2_outlined, - Icons.person_outline_outlined, - Icons.headset_mic_outlined, - Icons.health_and_safety_outlined, - ], - labels: [ - "Home", - "Claims", - "Profile", - "Help", - "Wellness", - ], - initialIndex: 2, // Initial index of the bottom navigation bar - ), - ) - ); + // floatingActionButton: Responsive.isDesktop(context) + // ? null + // : FloatingActionButton( + // onPressed: () { + // Navigator.pushNamed(context, 'chatbot'); + // }, + // child: Icon(Icons.chat), + // ), + floatingActionButtonLocation: Responsive.isDesktop(context) + ? null + : FloatingActionButtonLocation.miniEndFloat, + bottomNavigationBar: Responsive.isDesktop(context) + ? null + : CustomBottomNavigationBar( + onTabChanged: (index) { + if (index == 0) { + context.push('/home'); + } else if (index == 1) { + context.push('/claims'); + } else if (index == 2) { + context.push('/profile'); + } else if (index == 3) { + context.push('/help'); + } else if (index == 4) { + // Wellness tab clicked → show popup + PopupHelper.showRedirectPopup( + context: context, + apiService: apiService, + empPrimaryId: session.empPrimaryId, + ); + } + }, + icons: [ + Icons.home_outlined, + Icons.sticky_note_2_outlined, + Icons.person_outline_outlined, + Icons.headset_mic_outlined, + Icons.health_and_safety_outlined, + ], + labels: [ + "Home", + "Claims", + "Profile", + "Help", + "Wellness", + ], + initialIndex: 2, // Initial index of the bottom navigation bar + ), + )); } } diff --git a/lib/pages/postEnrollment/service/api_service.dart b/lib/pages/postEnrollment/service/api_service.dart index 7fa9408..81299ba 100755 --- a/lib/pages/postEnrollment/service/api_service.dart +++ b/lib/pages/postEnrollment/service/api_service.dart @@ -153,6 +153,46 @@ class ApiService { return response; } + Future> getEcardRequest(eCardParam) async { + print(_postToken); + if (_postToken == null) { + await _initializeToken(); + } + final url = Uri.parse('${Environment.apiUrl}ecardRequest'); + final headers = { + 'Authorization': 'Bearer $_postToken' ?? '', + 'Content-Type': 'application/json', // Ensure content type is JSON + }; + final jsonBody = jsonEncode(eCardParam); + // Send formDataJson as the body + final response = await _makePostRequestWithoutFormData(url,jsonBody, headers); + return response; + } + + Future updateMobileNumber(Map updateParam) async { + if (_postToken == null) { + await _initializeToken(); + } + + final url = Uri.parse('${Environment.apiUrl}updateMobileNumber'); + + final headers = { + 'Authorization': 'Bearer $_postToken', + 'Content-Type': 'application/json', + }; + + final jsonBody = jsonEncode(updateParam); + + final response = await _makePostRequestWithoutFormData( + url, + jsonBody, + headers, + ); + + return response['status'] == 'success'; + } + + Future> fetchDepartmentList(String clientId, String empCode) async { print(_postToken); if (_postToken == null) { @@ -282,6 +322,14 @@ class ApiService { return _handleResponse(response); } + Future> _makePostRequestWithoutFormData( + Uri url, String body, Map headers) async { + + final response = await http.post(url, headers: headers, body: body); + return _handleResponse(response); + } + + Future> _handleResponse(http.Response response) async { if (response.statusCode == 200) { return jsonDecode(response.body); diff --git a/lib/pages/service/appVersionService.dart b/lib/pages/service/appVersionService.dart new file mode 100644 index 0000000..371ef16 --- /dev/null +++ b/lib/pages/service/appVersionService.dart @@ -0,0 +1,84 @@ +import 'dart:convert'; +import 'dart:io'; +import 'package:flutter/foundation.dart'; +import 'package:package_info_plus/package_info_plus.dart'; +import 'package:http/http.dart' as http; + +class AppVersionService { + /// ✅ Get installed app version (Android + iOS) + static Future getInstalledVersion() async { + PackageInfo info = await PackageInfo.fromPlatform(); + return info.version; // Example: "1.9" + } + + /// ✅ Get App Store version (iOS) + static Future getAppStoreVersion(String appId) async { + final url = Uri.parse("https://itunes.apple.com/lookup?id=$appId"); + + final response = await http.get(url); + + if (response.statusCode == 200) { + final data = jsonDecode(response.body); + + if (data["resultCount"] > 0) { + return data["results"][0]["version"]; // Example: "1.9" + } + } + return null; + } + + /// ✅ Get Play Store version (Android) + /// NOTE: Play Store has no official API. This scrapes the HTML page. + static Future getPlayStoreVersion(String packageName) async { + print(Platform.isAndroid); + try { + print('Platform.isAndroid'); + final url = Uri.parse( + "https://play.google.com/store/apps/details?id=$packageName&hl=en&gl=US", + ); + print(url); + final response = await http.get(url); + print('Get Version Response $response'); + if (response.statusCode == 200) { + final html = response.body; + print('Get Version Response $html'); + // Android version usually appears near: "Current Version" + final versionRegEx = RegExp( + r'Current Version.*?<\/span>]*>(.*?)<\/span>', + caseSensitive: false, + dotAll: true, + ); + print('versionRegEx $versionRegEx'); + final match = versionRegEx.firstMatch(html); + print('match $match'); + if (match != null) { + return match.group(1)?.trim(); + } + } + } catch (e) { + debugPrint("Play Store error: $e"); + } + + return null; + } + + + /// ✅ Unified function to get latest store version based on platform + static Future getLatestStoreVersion({ + required String androidPackage, + required String iosAppId, + }) async { + if (kIsWeb) return null; + + if (Platform.isAndroid) { + print('Platform.isAndroid'); + return await getPlayStoreVersion(androidPackage); + } + + if (Platform.isIOS) { + return await getAppStoreVersion(iosAppId); + } + + return null; + } +} diff --git a/lib/pages/service/common_update_mobile_dialog.dart b/lib/pages/service/common_update_mobile_dialog.dart new file mode 100644 index 0000000..078c1e1 --- /dev/null +++ b/lib/pages/service/common_update_mobile_dialog.dart @@ -0,0 +1,105 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:http/http.dart' as http; + +import '../../customAppBar/toastHelper.dart'; +import '../../models/environment.dart'; +import '../postEnrollment/service/api_service.dart'; + +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'dart:convert'; +import 'package:http/http.dart' as http; + +Future showUpdateMobileDialog( + BuildContext context, + ApiService apiService, + String clientId, + String emailId, + String? currentMobile, + ) { + final controller = TextEditingController(text: currentMobile ?? ''); + bool isLoading = false; + + return showDialog( + context: context, + barrierDismissible: false, + builder: (context) { + return StatefulBuilder( + builder: (context, setState) { + return AlertDialog( + title: Text( + "Update Mobile Number", + style: GoogleFonts.poppins(fontWeight: FontWeight.w600), + ), + + content: TextField( + controller: controller, + keyboardType: TextInputType.phone, + decoration: const InputDecoration( + labelText: "Enter Mobile Number", + border: OutlineInputBorder(), + ), + ), + + actions: [ + // Cancel Button + ElevatedButton( + onPressed: () => Navigator.pop(context, null), + child: Text("Cancel", style: GoogleFonts.poppins(color: Colors.white)), + style: ElevatedButton.styleFrom(backgroundColor: Color(0xFFE26728)), + ), + + const SizedBox(width: 10), + + // Save Button + ElevatedButton( + onPressed: isLoading + ? null + : () async { + final newMobile = controller.text.trim(); + + if (newMobile.isEmpty) { + ToastHelper.showErrorToast(context, "Enter mobile number"); + return; + } + + setState(() => isLoading = true); + + final updateParam = { + "email_id": emailId, + "client_id": clientId, + "new_mobile_number": newMobile, + }; + + // ✅ Call API using apiService + bool success = await apiService.updateMobileNumber(updateParam); + + if (success) { + ToastHelper.showSuccessToast(context, "Mobile Number Updated"); + Navigator.pop(context, newMobile); + } else { + ToastHelper.showErrorToast(context, "Failed to update number"); + } + }, + child: isLoading + ? const SizedBox( + width: 18, + height: 18, + child: CircularProgressIndicator( + color: Colors.white, + strokeWidth: 2, + ), + ) + : Text("Save", style: GoogleFonts.poppins(color: Colors.white)), + style: ElevatedButton.styleFrom(backgroundColor: Color(0xFFE26728)), + ), + ], + ); + }, + ); + }, + ); +} diff --git a/lib/pages/service/popup_helper.dart b/lib/pages/service/popup_helper.dart index 7d86132..f30954c 100644 --- a/lib/pages/service/popup_helper.dart +++ b/lib/pages/service/popup_helper.dart @@ -30,6 +30,8 @@ class PopupHelper { // 🔹 Fetch link using API final response = await apiService.getWellnessLink(empPrimaryId); + print('Wellness response : $response'); + if (response['status'] == 'success') { wellnessURL = response['data']; } else if (response['status'] == 'failed') { diff --git a/lib/pages/verify.dart b/lib/pages/verify.dart index 853c41c..2e2faa7 100755 --- a/lib/pages/verify.dart +++ b/lib/pages/verify.dart @@ -1,1285 +1,1285 @@ -import 'package:firebase_auth/firebase_auth.dart'; -import 'package:firebase_messaging/firebase_messaging.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart'; -import 'package:nhance_app_pwa/pages/service/SessionManager.dart'; -import 'package:nhance_app_pwa/pages/service/TokenService.dart'; -import 'package:pinput/pinput.dart'; -import 'dart:async'; -import 'package:flutter/gestures.dart'; -import 'package:http/http.dart' as http; - -import 'dart:convert'; -import 'dart:io'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:jwt_decode/jwt_decode.dart'; - -import '../customAppBar/responsive.dart'; -import '../customAppBar/toastHelper.dart'; -import '../models/environment.dart'; -import '../models/platform_helper_mobile.dart' -if (dart.library.html) '../models/platform_helper_other.dart'; - -// import 'dart:html' as html; - -import '../pages/helpers/html_stub.dart' -if (dart.library.html) '../pages/helpers/html_web.dart'; - -class MyVerify extends StatefulWidget { - final String verificationId; - final String mobileNumber; - final int? resendToken; - final Function(String, int?) onResendCode; - - const MyVerify({ - Key? key, - required this.verificationId, - required this.mobileNumber, - required this.resendToken, - required this.onResendCode, - }) : super(key: key); - - @override - State createState() => _MyVerifyState(); -} - -class _MyVerifyState extends State { - TextEditingController countryController = TextEditingController(); - late ApiService apiService; - TextEditingController _otpController = TextEditingController(); - final _formKey = GlobalKey(); - late Timer _timer; - int _secondsRemaining = 60; - bool _isTimerRunning = false; - - dynamic enrollmentEmpClientBranchId; - dynamic enrollmentEmpCodeString; - dynamic enrollmentEmpPrimaryId; - dynamic enrollmentGpaEmpName; - dynamic enrollmentClient_id; - dynamic enrollmentEmp_status; - - dynamic empClientBranchId; - dynamic empCodeString; - dynamic empPrimaryId; - dynamic gpaEmpName; - dynamic client_id; - dynamic emp_status; - - dynamic _preToken; - dynamic _postToken; - dynamic clientName; - dynamic clientLogo; - - String? fcmToken; - String? apnsToken; - late String verificationId; - late String mobileNumber; - final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; - final FirebaseAuth _auth = FirebaseAuth.instance; - bool _isLoading = false; - dynamic empMobileNo; - dynamic empEmailid; - late SessionManager session; - - late String _verificationId; - - @override - void initState() { - super.initState(); - countryController.text = "+91"; - apiService = ApiService(context); - // checkTokenAvailability(); - verificationId = widget.verificationId; - mobileNumber = widget.mobileNumber; - print('Received verificationId: $verificationId'); - print('Received mobileNumber: $mobileNumber'); - if (verificationId.isEmpty) { - // Handle the case where verificationId is not provided - // Navigator.pop(context); - context.pop(); - } - startTimer(); - // Equivalent to componentDidMount - _auth.authStateChanges().listen((User? user) { - if (user != null) { - // If user is already signed in, log them out - logOutFirebase(); - } - }); - } - - void logOutFirebase() async { - await _auth.signOut(); - print('User signed out'); - } - - @override - void dispose() { - _timer.cancel(); - super.dispose(); - } - - - Future initNotification() async { - try { - // Request permission - NotificationSettings settings = - await _firebaseMessaging.requestPermission( - alert: true, - badge: true, - sound: true, - ); - print('🔔 Permission: ${settings.authorizationStatus}'); - - if (Platform.isIOS || Platform.isMacOS) { - // Get APNS token - apnsToken = await _firebaseMessaging.getAPNSToken(); - print('📱 APNS Token (iOS): $apnsToken'); - - // Retry if null - if (apnsToken == null) { - await Future.delayed(const Duration(seconds: 3)); - apnsToken = await _firebaseMessaging.getAPNSToken(); - print('🔁 Retried APNS Token: $apnsToken'); - } - - if (apnsToken != null) { - await sendDeviceToken(apnsToken!); - } - } else if (Platform.isAndroid) { - // Get FCM token - fcmToken = await _firebaseMessaging.getToken(); - print('🔥 FCM Token (Android): $fcmToken'); - - if (fcmToken != null) { - await sendDeviceToken(fcmToken!); - } - } - - // Background handler - FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); - - // Foreground listener - FirebaseMessaging.onMessage.listen((RemoteMessage message) { - print('💬 Message: ${message.notification?.title}'); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text(message.notification?.title ?? 'New Notification')), - ); - }); - } catch (e) { - print('❌ Notification init error: $e'); - } - } - - // Future initNotification() async { - // try { - // // await _firebaseMessaging.requestPermission(); - // fCMToken = await FirebaseMessaging.instance.getToken(); - // print('Token : $fCMToken'); - // - // if (fCMToken != null) { - // await sendDeviceToken(fCMToken); - // } - // } catch (e) { - // print("Error getting FCM Token: $e"); - // } - // } - - // Future handleBackgroundMessage(RemoteMessage message) async { - // print('Title ${message.notification?.title}'); - // print('Body ${message.notification?.body}'); - // print('Playload ${message.data}'); - // } - - Future sendDeviceToken(deviceToken) async { - // Retrieve the passed mobile number value - - try { - final response = await http.post( - Uri.parse(Environment.apiUrlEnrollment + 'storeFireBase'), - body: json - .encode({'mobile': mobileNumber, 'firebase_token': deviceToken}), - headers: { - HttpHeaders.contentTypeHeader: 'application/json', - 'Authorization': 'Bearer $_preToken', - }, - ); - - if (response.statusCode == 200) { - Map data = json.decode(response.body); - print('data: $data'); - String status = data['status']; - print(status); - if (status == 'success') { - print('Token Store Successfully'); - } else { - print('Please try again'); - } - } else { - throw Exception('Failed to store'); - } - } catch (e) { - print('Error: $e'); - } - } - - void startTimer() { - _isTimerRunning = true; - _timer = Timer.periodic(Duration(seconds: 1), (Timer timer) { - setState(() { - if (_secondsRemaining > 0) { - _secondsRemaining--; - } else { - _isTimerRunning = false; - _timer.cancel(); - } - }); - }); - } - - void generateToken(bool otpVerifyStatus) async { - try { - final response = await http.post( - Uri.parse(Environment.apiUrlEnrollment + 'getVerifiedUserData'), - body: json.encode({ - 'mobile_number': mobileNumber, - 'otp_verification': otpVerifyStatus - }), - headers: { - HttpHeaders.contentTypeHeader: 'application/json', - }, - ); - - if (response.statusCode == 200) { - setState(() { - _isLoading = false; - }); - Map data = json.decode(response.body); - print('data: $data'); - - // --- Extract tokens safely --- - String? preToken; - if (data['data'] is String) { - preToken = data['data']; - } - - String? postToken; - if (data['post_enrollment'] != null && data['post_enrollment']['data'] is String) { - postToken = data['post_enrollment']['data']; - } - - // Save tokens - await TokenService.saveTokens(preToken: preToken, postToken: postToken); - print('Tokens saved → preToken: $preToken, postToken: $postToken'); - - _preToken = preToken; - String status = data['status']; - - // Directly access the post_enrollment data - Map post = data['post_enrollment']; - print('post: $post'); - - _postToken = postToken; - String postStatus = post['status']; - - if (postStatus == 'success') { - setState(() { - _isLoading = false; - }); - postSuccessData(post, data); - } else if (status == 'success') { - setState(() { - _isLoading = false; - }); - enrollmentSuccessData(data); - } else { - setState(() { - _isLoading = false; - }); - final SharedPreferences prefs = await SharedPreferences.getInstance(); - prefs.clear(); - ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); - // Show a Snackbar if the OTP is invalid - print('Invalid OTP. Please try again'); - } - } else { - setState(() { - _isLoading = false; - }); - final SharedPreferences prefs = await SharedPreferences.getInstance(); - prefs.clear(); - ToastHelper.showWarningToast(context, 'Something went wrong'); - throw Exception('Failed to verify OTP'); - } - } catch (e) { - setState(() { - _isLoading = false; - }); - print('Error: $e'); - final SharedPreferences prefs = await SharedPreferences.getInstance(); - prefs.clear(); - ToastHelper.showWarningToast(context, 'Something went wrong'); - // Show a Snackbar if there's an error while verifying OTP - print('Failed to verify OTP. Please try again.'); - } - } - - void loginUser({ - required dynamic gpaEmpName, - required dynamic empPrimaryId, - required dynamic empCodeString, - required dynamic client_id, - required dynamic empClientBranchId, - }) { - HtmlHelper.saveLoginData({ - 'gpaEmpName': gpaEmpName, - 'empPrimaryId': empPrimaryId, - 'empCode': empCodeString, - 'client_id': client_id, - 'empClientBranchId': empClientBranchId, - }); - print('Successfully Login'); - } - - void postSuccessData(post, data) async { - String status = data['status']; - String postStatus = post['status']; - - if (postStatus == 'success') { - // final SharedPreferences prefs = await SharedPreferences.getInstance(); - // prefs.setString('_postToken', post['data']); - - await SessionManager().initializeFromPostToken(post['data']); - session = await SessionManager(); - // // Decode the JWT token received from the API response - // Map? decodedToken = Jwt.parseJwt(post['data']); - // print('decodedToken : $decodedToken'); - // empClientBranchId = decodedToken['client_branch_id']; - // prefs.setString('empClientBranchId', empClientBranchId); - // empCodeString = decodedToken['emp_code'].toString(); - // prefs.setString('empCode', empCodeString); - // empPrimaryId = decodedToken['id']; - // prefs.setString('empPrimaryId', empPrimaryId); - // gpaEmpName = decodedToken['name'].toString(); - // prefs.setString('gpaEmpName', gpaEmpName); - // client_id = decodedToken['client_id']; - // prefs.setString('client_id', client_id); - // emp_status = decodedToken['emp_status']; - // prefs.setString('emp_status', emp_status); - // getClientLogoAndDetails(); - - loginUser( - gpaEmpName: session.gpaEmpName, - empPrimaryId: session.empPrimaryId, - empCodeString: session.empCodeString, - client_id: session.client_id, - empClientBranchId: session.empClientBranchId, - ); - - // if (kIsWeb) { - // html.window.localStorage['gpaEmpName'] = gpaEmpName; - // html.window.localStorage['empPrimaryId'] = empPrimaryId; - // html.window.localStorage['empCode'] = empCodeString; - // html.window.localStorage['client_id'] = client_id; - // html.window.localStorage['empClientBranchId'] = empClientBranchId; - // - // // Dispatch a custom event with a message - // - // // 🌟 Dispatch event to notify JavaScript - // html.window.dispatchEvent( - // html.CustomEvent('userLoggedIn', detail: {'status': 'success'})); - // - // print("✅ User logged in! LocalStorage values set."); - // - // print('Successfully Login'); - // } - - // Redirect to another page - } - - if (status == 'success') { - // final SharedPreferences prefs = await SharedPreferences.getInstance(); - // prefs.setString('enrollToken', data['data']); - await SessionManager().initializeFromPreToken(data['data']); - // // Decode the JWT token received from the API response - // Map? decodedToken = Jwt.parseJwt(data['data']); - // print('decodedToken : $decodedToken'); - // enrollmentEmpClientBranchId = decodedToken['client_branch_id']; - // prefs.setString( - // 'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId); - // enrollmentEmpCodeString = decodedToken['emp_code'].toString(); - // prefs.setString('enrollmentEmpCodeString', enrollmentEmpCodeString); - // enrollmentEmpPrimaryId = decodedToken['id']; - // prefs.setString('enrollmentEmpPrimaryId', enrollmentEmpPrimaryId); - // enrollmentGpaEmpName = decodedToken['name'].toString(); - // prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName); - // enrollmentClient_id = decodedToken['client_id']; - // prefs.setString('enrollmentClient_id', enrollmentClient_id); - // enrollmentEmp_status = decodedToken['emp_status']; - // prefs.setString('enrollmentEmp_status', enrollmentEmp_status); - getClientLogoAndDetails(); - } - - // final SharedPreferences prefs = await SharedPreferences.getInstance(); - // final _postToken = prefs.getString('_postToken'); - // int skipStatus = prefs.getInt('skipStatus') ?? 1; - // final mpinText = prefs.getString('mpinText'); - // print(isMobilePlatform()); - if (isMobilePlatform()) { - // if (prefs.containsKey('mpin') && mpinText == 'Mpin - exist') { - if (_postToken != null && _postToken.isNotEmpty) { - final SharedPreferences prefs = await SharedPreferences.getInstance(); - await prefs.setString('empMobileNo', widget.mobileNumber); - await initNotification(); - checkLoginPin(context); - } - // } - } else { - if (_postToken != null && _postToken.isNotEmpty) { - ToastHelper.showSuccessToast(context, 'Successfully Login'); - // if (emp_status == 'enrolled' || emp_status == 'active') { - context.go('/home'); - // Navigator.pushReplacementNamed(context, 'home'); - // } else { - // Navigator.pushReplacementNamed(context, 'empDetails'); - // } - } - } - } - - void enrollmentSuccessData(data) async { - // final SharedPreferences prefs = await SharedPreferences.getInstance(); - // prefs.setString('enrollToken', data['data']); - - await SessionManager().initializeFromPreToken(data['data']); - - // // Decode the JWT token received from the API response - // Map? decodedToken = Jwt.parseJwt(data['data']); - // print('decodedToken : $decodedToken'); - // enrollmentEmpClientBranchId = decodedToken['client_branch_id']; - // prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId); - // enrollmentEmpCodeString = decodedToken['emp_code'].toString(); - // prefs.setString('enrollmentEmpCodeString', enrollmentEmpCodeString); - // enrollmentEmpPrimaryId = decodedToken['id']; - // prefs.setString('enrollmentEmpPrimaryId', enrollmentEmpPrimaryId); - // enrollmentGpaEmpName = decodedToken['name'].toString(); - // prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName); - // enrollmentClient_id = decodedToken['client_id']; - // prefs.setString('enrollmentClient_id', enrollmentClient_id); - // enrollmentEmp_status = decodedToken['emp_status']; - // prefs.setString('enrollmentEmp_status', enrollmentEmp_status); - getClientLogoAndDetails(); - - print('Successfully Login'); - - // Redirect to another page - // final enrollToken = prefs.getString('enrollToken'); - // int skipStatus = prefs.getInt('skipStatus') ?? 1; - // final mpinText = prefs.getString('mpinText'); - print(isMobilePlatform()); - if (isMobilePlatform()) { - // if (prefs.containsKey('mpin') && mpinText == 'Mpin - exist') { - if (_preToken != null && _preToken.isNotEmpty) { - final SharedPreferences prefs = await SharedPreferences.getInstance(); - prefs.setString('empMobileNo', widget.mobileNumber); - await initNotification(); - checkLoginPin(context); - } - // } - } else { - if (_preToken != null && _preToken.isNotEmpty) { - ToastHelper.showSuccessToast(context, 'Successfully Login'); - // if (emp_status == 'enrolled' || emp_status == 'active') { - // Navigator.pushReplacementNamed(context, 'home'); - // } else { - context.go('/empDetails'); - // Navigator.pushReplacementNamed(context, 'empDetails'); - // } - } - } - } - - void verifyOTP(String otp) async { - try { - // setState(() { - // _isLoading = true; - // }); - // Later, in verify screen: - SharedPreferences prefs = await SharedPreferences.getInstance(); - dynamic verificationId = prefs.getString('verificationId'); - - final credential = PhoneAuthProvider.credential( - verificationId: verificationId, // Make sure this is up-to-date - smsCode: otp, - ); - - print('credential $credential'); - - final userCredential = - await FirebaseAuth.instance.signInWithCredential(credential); - // await FirebaseAuth.instance.signInWithCredential(credential); - print('otp firebase check'); - - if (userCredential.user != null) { - print('otp firebase check done'); - bool otpVerifyStatus = true; - generateToken(otpVerifyStatus); - } else { - ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again.'); - } - - // await FirebaseAuth.instance.signInWithCredential(credential).then((userCredential) async { - // if (userCredential.user != null) { - // bool otpVerifyStatus = true; - // generateToken(otpVerifyStatus); - // } else { - // setState(() { - // _isLoading = false; - // }); - // ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); - // } - // }); - } on FirebaseAuthException catch (e) { - if (e.code == 'code-expired') { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('OTP expired. Please request a new one.'), - duration: Duration(seconds: 2), - ), - ); - ToastHelper.showErrorToast( - context, 'OTP expired. Please request a new one.'); - } else if (e.code == 'invalid-verification-code') { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Invalid OTP entered. Please try again.'), - duration: Duration(seconds: 2), - ), - ); - ToastHelper.showErrorToast( - context, 'Invalid OTP entered. Please try again.'); - } else if (e.code == 'session-expired') { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Session expired. Try restarting the verification.'), - duration: Duration(seconds: 2), - ), - ); - ToastHelper.showErrorToast( - context, 'Session expired. Try restarting the verification.'); - } else { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Error: ${e.message}'), - duration: Duration(seconds: 2), - ), - ); - ToastHelper.showErrorToast(context, 'Error: ${e.message}'); - } - } catch (e) { - // setState(() { - // _isLoading = false; - // }); - print('Error: $e'); - ToastHelper.showErrorToast( - context, 'Failed to verify OTP. Please try again.'); - } - } - - void _resendOTP() { - setState(() { - _secondsRemaining = 60; - _isTimerRunning = true; - }); - startTimer(); - widget.onResendCode(widget.mobileNumber, widget.resendToken); - } - - Future checkLoginPin(BuildContext context) async { - print('checkLoginPin'); - try { - final SharedPreferences prefs = await SharedPreferences.getInstance(); - empMobileNo = prefs.getString('empMobileNo'); - empEmailid = prefs.getString('empEmailid'); - print('empMobileNo $empMobileNo'); - print('empEmailid $empEmailid'); - // _preToken = prefs.getString('token'); - var params = {}; - if (empMobileNo != null && empMobileNo.isNotEmpty) { - params = {'mobile_number': empMobileNo}; - } else if (empEmailid != null && empEmailid.isNotEmpty) { - params = {'email_id': empEmailid}; - } - - final response = await http.post( - Uri.parse(Environment.apiUrlEnrollment + 'checkMpin'), - body: json.encode(params), - headers: { - HttpHeaders.contentTypeHeader: 'application/json', - }, - ); - - if (response.statusCode == 200) { - print('checkLoginPin $response'); - Map data = json.decode(response.body); - if (data['status'] == 'success') { - print('checkLoginPin success'); - if (data['data'] != null) { - prefs.setString('mpinText', data['data']); - } - - if (data['Mpin'] != null) { - prefs.setString('mpin', data['Mpin']); - } - - if (data['is_biometric_enabled'] != null) { - prefs.setString( - 'is_biometric_enabled', data['is_biometric_enabled']); - } - - if (data['is_mpin_skipped'] != null) { - prefs.setString('is_mpin_skipped', data['is_mpin_skipped']); - } - - if (_postToken != null && _postToken.isNotEmpty) { - ToastHelper.showSuccessToast(context, 'Successfully Login'); - context.go('/home'); - // Navigator.pushReplacementNamed(context, 'home'); - } else { - context.go('/empDetails'); - // Navigator.pushReplacementNamed(context, 'empDetails'); - } - - // if (data['is_mpin_skipped'] != null && - // data['is_mpin_skipped'] == '0') { - // context.go('/pinPage'); - // // Navigator.pushReplacementNamed(context, 'pinPage'); - // } else { - // if (_postToken != null && _postToken.isNotEmpty) { - // ToastHelper.showSuccessToast(context, 'Successfully Login'); - // context.go('/home'); - // // Navigator.pushReplacementNamed(context, 'home'); - // } else { - // context.go('/empDetails'); - // // Navigator.pushReplacementNamed(context, 'empDetails'); - // } - // } - } else { - context.go('/pinSettingPage'); - // Navigator.pushReplacementNamed(context, 'pinSettingPage'); - } - } else { - print('checkLoginPin Something went wrong'); - ToastHelper.showErrorToast(context, 'Something went wrong'); - throw Exception('Failed to verify pin number'); - } - } catch (e) { - ToastHelper.showErrorToast(context, 'Something went wrong'); - print('Error: $e'); - } - } - - Future getClientLogoAndDetails() async { - print('getClientLogoAndDetails'); - var url = Uri.parse(Environment.apiUrlEnrollment + 'getClientDetails?post_client_id=${session.client_id}&post_branch_id=${session.empClientBranchId}&pre_client_id=${session.enrollmentClient_id}&pre_branch_id=${session.enrollmentEmpClientBranchId}'); - try { - var response = await http.get( - url, - headers: { - 'Authorization': - 'Bearer $_preToken', // Add token to the Authorization header - }, - ); - if (response.statusCode == 200) { - // print('response.statusCode == 200'); - Map data = json.decode(response.body); - // print(data); - - if (data.containsKey('data')) { - dynamic clientDetails = data['data']; - final SharedPreferences prefs = await SharedPreferences.getInstance(); - prefs.setString('clientLogo', clientDetails['client']['client_logo']); - prefs.setString('clientName', clientDetails['client']['client_name']); - prefs.setString( - 'addon_subheading', clientDetails['client']['addon_subheading']); - setState(() { - // dynamic clientDetails = data['data']; - // print(clientDetails); - clientName = clientDetails['client']['client_name']; - print(clientName); - clientLogo = clientDetails['client']['client_logo']; - print(clientLogo); - }); - } else { - // Handle other status messages if needed - // ToastHelper.showErrorToast( - // context, 'API request failed with status: ${data['status']}'); - print('API request failed with status: ${data['status']}'); - } - } else { - // Handle other status codes - // ToastHelper.showErrorToast( - // context, 'Request failed with status: ${response.statusCode}'); - print('Request failed with status: ${response.statusCode}'); - } - } catch (e) { - // Handle exceptions - print('Exception occurred: $e'); - } - } - - @override - Widget build(BuildContext context) { - // Retrieve the passed mobile number value - // final String mobileNumber = - // ModalRoute.of(context)!.settings.arguments as String; - Size _size = MediaQuery.of(context).size; - EdgeInsets marginInsets = EdgeInsets.zero; - if (Responsive.isDesktop(context)) { - marginInsets = const EdgeInsets.only( - left: 0, - right: 0, - bottom: 0, - top: 0, - ); - } else if (Responsive.isMobile(context)) { - marginInsets = const EdgeInsets.only( - left: 25, // Example value for mobile - right: 25, // Example value for mobile - bottom: 0, // Example value for mobile - top: 0, // Example value for mobile - ); - } else if (Responsive.isTablet(context)) { - marginInsets = const EdgeInsets.only( - left: 25, // Example value for mobile - right: 25, // Example value for mobile - bottom: 0, // Example value for mobile - top: 0, // Example value for mobile - ); - } - final defaultPinTheme = PinTheme( - width: 56, - height: 56, - textStyle: TextStyle( - fontSize: 20, - color: Color.fromRGBO(30, 60, 87, 1), - fontWeight: FontWeight.w600, - ), - decoration: BoxDecoration( - border: Border.all(color: Color.fromRGBO(234, 239, 243, 1)), - borderRadius: BorderRadius.circular(20), - ), - ); - - final focusedPinTheme = defaultPinTheme.copyDecorationWith( - border: Border.all(color: Color.fromRGBO(114, 178, 238, 1)), - borderRadius: BorderRadius.circular(8), - ); - - final submittedPinTheme = defaultPinTheme.copyWith( - decoration: defaultPinTheme.decoration?.copyWith( - color: Color.fromRGBO(234, 239, 243, 1), - ), - ); - - return WillPopScope( - onWillPop: () async { - context.go('/login'); - // Navigator.pushReplacementNamed(context, 'login'); - return false; - }, - child: Scaffold( - body: SingleChildScrollView( - keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, - child: Container( - height: _size.height, - color: Colors.white, - child: Stack( - children: [ - Visibility( - visible: _size.width <= 1100, - child: ClipRRect( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(30), - bottomRight: Radius.circular(30), - ), - child: Container( - height: _size.height / 3, - width: double.infinity, - color: Color(0xFFFFFCE5), - child: Stack( - children: [ - Column( - children: [ - SizedBox( - height: _size.height / - 6.4), // Adjust the spacing between the rows - Row( - mainAxisAlignment: MainAxisAlignment - .center, // Align to the center - children: [ - Expanded( - flex: Responsive.isDesktop(context) - ? 10 - : 12, - child: Align( - alignment: Responsive.isDesktop(context) - ? Alignment.centerLeft - : Alignment.bottomCenter, - child: Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ), - ), - ), - if (!Responsive.isMobile(context) && - !Responsive.isTablet(context)) - Expanded( - flex: 2, - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - context.go('/hrLogin'); - // Navigator.pushNamed( - // context, 'hrLogin'); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align to the end (right) - children: [ - Text( - 'HR Login', - style: GoogleFonts.poppins( - color: Color( - 0xFF000000), // Text color - // Add other text styles as needed - ), - ), - SizedBox(width: 5), - Icon( - Icons - .east, // Icon for customer login - color: Colors - .black, // Adjust color as needed - ), - ], - ), - ), - ), - ), - ], - ), - ], - ), - ], - ), - ), - ), - ), - Container( - margin: marginInsets, - alignment: Alignment.bottomCenter, - child: SingleChildScrollView( - child: Form( - key: _formKey, - child: Column( - children: [ - Row( - children: [ - Expanded( - flex: _size.width < 1100 ? 6 : 12, - child: Container( - margin: _size.width > 1100 - ? EdgeInsets.only(left: 20, right: 20) - : EdgeInsets.only(left: 0, right: 0), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - if (!Responsive.isMobile(context) && - !Responsive.isTablet(context)) - Row( - children: [ - Expanded( - flex: 10, - child: Align( - alignment: Responsive - .isDesktop(context) - ? Alignment.centerLeft - : Alignment - .bottomCenter, // Align to the start - child: _size.width <= 1100 - ? Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ) - : _size.width > 1100 - ? Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ) - : Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ), - )), - ], - ), - SizedBox(height: 10), - // SizedBox( - // height: Responsive.isDesktop(context) - // ? _size.height * 0.1 - // : 10, - // ), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Text( - "Welcome to Nhance", - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: - "Please enter the one-time usage code sent to your mobile number $mobileNumber", - style: TextStyle( - fontSize: 12, - height: 1.5, - color: Color(0xFF000000)), - children: [ - TextSpan( - text: " (Change Number)", - style: TextStyle( - fontSize: 12, - color: Color( - 0xFFE26728)), // Change color as desired - recognizer: - TapGestureRecognizer() - ..onTap = () { - context.go('/login'); - // Navigator.pushNamed( - // context, 'login'); - }, - ), - ], - ), - ), - ), - SizedBox(height: 15), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: Pinput( - length: 6, - // defaultPinTheme: defaultPinTheme, - // focusedPinTheme: focusedPinTheme, - // submittedPinTheme: submittedPinTheme, - showCursor: true, - controller: _otpController, - ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align text to the right - children: [ - _isTimerRunning - ? Text( - "Resend OTP in $_secondsRemaining seconds", - style: - GoogleFonts.poppins( - color: - Colors.black), - ) - : InkWell( - onTap: () { - _resendOTP(); - }, - child: Text( - "Resend OTP", - style: - GoogleFonts.poppins( - color: Colors - .blue), - ), - ), - ], - ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: SizedBox( - width: double.infinity, - height: 45, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: - Color(0xFF00989E), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(10), - ), - ), - onPressed: () { - if (_formKey.currentState! - .validate()) { - _formKey.currentState! - .save(); // Save form fields before calling verifyOTP - verifyOTP( - _otpController.text); - } - }, - child: Text( - "Submit", - style: GoogleFonts.poppins( - color: Color(0xFFFFFFFF)), - ), - ), - ), - ), - // _size.width > 1100 - // ? Container( - // margin: EdgeInsets.symmetric( - // horizontal: 150), - // child: Column( - // children: [ - // SizedBox(height: 20), - // Text( - // "Benefits of Login", - // style: - // GoogleFonts.poppins( - // fontSize: 20, - // fontWeight: - // FontWeight.bold, - // ), - // ), - // SizedBox(height: 15), - // ], - // )) - // : SizedBox(), - // _size.width > 1100 - // ? Container( - // margin: EdgeInsets.symmetric( - // horizontal: 150), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment.center, - // children: [ - // Expanded( - // flex: 6, - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: 8), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment - // .center, - // children: [ - // Expanded( - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: - // 12), - // decoration: - // BoxDecoration( - // border: - // Border( - // right: - // BorderSide( - // width: 1, - // color: Colors - // .black, - // ), - // ), - // ), - // child: Column( - // children: [ - // Icon( - // Icons - // .policy, - // color: Color( - // 0xFFE26728)), - // SizedBox( - // height: - // 10), - // Text( - // "View Policy", - // style: GoogleFonts - // .poppins()), - // ], - // ), - // ), - // ), - // Expanded( - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: - // 12), - // child: Column( - // children: [ - // Icon( - // Icons - // .edit, - // color: Color( - // 0xFFE26728)), - // SizedBox( - // height: - // 10), - // Text( - // "Manage Claims", - // style: GoogleFonts - // .poppins()), - // ], - // ), - // ), - // ), - // ], - // ), - // ), - // ), - // ], - // ), - // ) - // : SizedBox( - // height: Responsive.isDesktop( - // context) - // ? _size.height * 0.1 - // : _size.height * 0.2, - // ), - SizedBox( - height: Responsive.isDesktop(context) - ? _size.height * 0.3 - : _size.height * 0.2, - ), - // SizedBox( - // height: _size.height * 0.1, - // ), - Container( - alignment: Alignment.bottomCenter, - padding: - EdgeInsets.symmetric(vertical: 8), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: - 'By continuing, you agree with our ', - style: GoogleFonts.poppins( - color: Colors.black, - fontSize: 9, - ), - children: [ - TextSpan( - text: 'privacy policy ', - style: GoogleFonts.poppins( - color: Color(0xFF00989E), - fontSize: 9, - ), - ), - TextSpan( - text: 'and ', - style: GoogleFonts.poppins( - color: Colors.black, - fontSize: 9, - ), - ), - TextSpan( - text: 'terms of use', - style: GoogleFonts.poppins( - color: Color(0xFF00989E), - fontSize: 9, - ), - ), - ], - ), - ), - ), - ], - ), - ), - ), - if (_size.width > 1100) - Expanded( - flex: _size.width < 1100 ? 6 : 12, - child: LayoutBuilder( - builder: (BuildContext context, - BoxConstraints constraints) { - if (constraints.maxWidth > 600) { - return Image.asset( - 'assets/login_web.jpg', - height: _size.height, - fit: BoxFit.cover, - ); - } else { - return SizedBox(); - } - }, - ), - ), - ], - ), - ], - ), - ), - ), - ), - ], - )), - ))); - } -} - -// ✅ Must be outside any class — this fixes your error -@pragma('vm:entry-point') -Future firebaseMessagingBackgroundHandler(RemoteMessage message) async { - print('📨 Handling background message: ${message.messageId}'); - print('Title: ${message.notification?.title}'); - print('Body: ${message.notification?.body}'); - print('Data: ${message.data}'); -} \ No newline at end of file +// import 'package:firebase_auth/firebase_auth.dart'; +// import 'package:firebase_messaging/firebase_messaging.dart'; +// import 'package:flutter/foundation.dart'; +// import 'package:flutter/material.dart'; +// import 'package:go_router/go_router.dart'; +// import 'package:google_fonts/google_fonts.dart'; +// import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart'; +// import 'package:nhance_app_pwa/pages/service/SessionManager.dart'; +// import 'package:nhance_app_pwa/pages/service/TokenService.dart'; +// import 'package:pinput/pinput.dart'; +// import 'dart:async'; +// import 'package:flutter/gestures.dart'; +// import 'package:http/http.dart' as http; +// +// import 'dart:convert'; +// import 'dart:io'; +// import 'package:shared_preferences/shared_preferences.dart'; +// import 'package:jwt_decode/jwt_decode.dart'; +// +// import '../customAppBar/responsive.dart'; +// import '../customAppBar/toastHelper.dart'; +// import '../models/environment.dart'; +// import '../models/platform_helper_mobile.dart' +// if (dart.library.html) '../models/platform_helper_other.dart'; +// +// // import 'dart:html' as html; +// +// import '../pages/helpers/html_stub.dart' +// if (dart.library.html) '../pages/helpers/html_web.dart'; +// +// class MyVerify extends StatefulWidget { +// final String verificationId; +// final String mobileNumber; +// final int? resendToken; +// final Function(String, int?) onResendCode; +// +// const MyVerify({ +// Key? key, +// required this.verificationId, +// required this.mobileNumber, +// required this.resendToken, +// required this.onResendCode, +// }) : super(key: key); +// +// @override +// State createState() => _MyVerifyState(); +// } +// +// class _MyVerifyState extends State { +// TextEditingController countryController = TextEditingController(); +// late ApiService apiService; +// TextEditingController _otpController = TextEditingController(); +// final _formKey = GlobalKey(); +// late Timer _timer; +// int _secondsRemaining = 60; +// bool _isTimerRunning = false; +// +// dynamic enrollmentEmpClientBranchId; +// dynamic enrollmentEmpCodeString; +// dynamic enrollmentEmpPrimaryId; +// dynamic enrollmentGpaEmpName; +// dynamic enrollmentClient_id; +// dynamic enrollmentEmp_status; +// +// dynamic empClientBranchId; +// dynamic empCodeString; +// dynamic empPrimaryId; +// dynamic gpaEmpName; +// dynamic client_id; +// dynamic emp_status; +// +// dynamic _preToken; +// dynamic _postToken; +// dynamic clientName; +// dynamic clientLogo; +// +// String? fcmToken; +// String? apnsToken; +// late String verificationId; +// late String mobileNumber; +// final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; +// final FirebaseAuth _auth = FirebaseAuth.instance; +// bool _isLoading = false; +// dynamic empMobileNo; +// dynamic empEmailid; +// late SessionManager session; +// +// late String _verificationId; +// +// @override +// void initState() { +// super.initState(); +// countryController.text = "+91"; +// apiService = ApiService(context); +// // checkTokenAvailability(); +// verificationId = widget.verificationId; +// mobileNumber = widget.mobileNumber; +// print('Received verificationId: $verificationId'); +// print('Received mobileNumber: $mobileNumber'); +// if (verificationId.isEmpty) { +// // Handle the case where verificationId is not provided +// // Navigator.pop(context); +// context.pop(); +// } +// startTimer(); +// // Equivalent to componentDidMount +// _auth.authStateChanges().listen((User? user) { +// if (user != null) { +// // If user is already signed in, log them out +// logOutFirebase(); +// } +// }); +// } +// +// void logOutFirebase() async { +// await _auth.signOut(); +// print('User signed out'); +// } +// +// @override +// void dispose() { +// _timer.cancel(); +// super.dispose(); +// } +// +// +// Future initNotification() async { +// try { +// // Request permission +// NotificationSettings settings = +// await _firebaseMessaging.requestPermission( +// alert: true, +// badge: true, +// sound: true, +// ); +// print('🔔 Permission: ${settings.authorizationStatus}'); +// +// if (Platform.isIOS || Platform.isMacOS) { +// // Get APNS token +// apnsToken = await _firebaseMessaging.getAPNSToken(); +// print('📱 APNS Token (iOS): $apnsToken'); +// +// // Retry if null +// if (apnsToken == null) { +// await Future.delayed(const Duration(seconds: 3)); +// apnsToken = await _firebaseMessaging.getAPNSToken(); +// print('🔁 Retried APNS Token: $apnsToken'); +// } +// +// if (apnsToken != null) { +// await sendDeviceToken(apnsToken!); +// } +// } else if (Platform.isAndroid) { +// // Get FCM token +// fcmToken = await _firebaseMessaging.getToken(); +// print('🔥 FCM Token (Android): $fcmToken'); +// +// if (fcmToken != null) { +// await sendDeviceToken(fcmToken!); +// } +// } +// +// // Background handler +// FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); +// +// // Foreground listener +// FirebaseMessaging.onMessage.listen((RemoteMessage message) { +// print('💬 Message: ${message.notification?.title}'); +// ScaffoldMessenger.of(context).showSnackBar( +// SnackBar(content: Text(message.notification?.title ?? 'New Notification')), +// ); +// }); +// } catch (e) { +// print('❌ Notification init error: $e'); +// } +// } +// +// // Future initNotification() async { +// // try { +// // // await _firebaseMessaging.requestPermission(); +// // fCMToken = await FirebaseMessaging.instance.getToken(); +// // print('Token : $fCMToken'); +// // +// // if (fCMToken != null) { +// // await sendDeviceToken(fCMToken); +// // } +// // } catch (e) { +// // print("Error getting FCM Token: $e"); +// // } +// // } +// +// // Future handleBackgroundMessage(RemoteMessage message) async { +// // print('Title ${message.notification?.title}'); +// // print('Body ${message.notification?.body}'); +// // print('Playload ${message.data}'); +// // } +// +// Future sendDeviceToken(deviceToken) async { +// // Retrieve the passed mobile number value +// +// try { +// final response = await http.post( +// Uri.parse(Environment.apiUrlEnrollment + 'storeFireBase'), +// body: json +// .encode({'mobile': mobileNumber, 'firebase_token': deviceToken}), +// headers: { +// HttpHeaders.contentTypeHeader: 'application/json', +// 'Authorization': 'Bearer $_preToken', +// }, +// ); +// +// if (response.statusCode == 200) { +// Map data = json.decode(response.body); +// print('data: $data'); +// String status = data['status']; +// print(status); +// if (status == 'success') { +// print('Token Store Successfully'); +// } else { +// print('Please try again'); +// } +// } else { +// throw Exception('Failed to store'); +// } +// } catch (e) { +// print('Error: $e'); +// } +// } +// +// void startTimer() { +// _isTimerRunning = true; +// _timer = Timer.periodic(Duration(seconds: 1), (Timer timer) { +// setState(() { +// if (_secondsRemaining > 0) { +// _secondsRemaining--; +// } else { +// _isTimerRunning = false; +// _timer.cancel(); +// } +// }); +// }); +// } +// +// void generateToken(bool otpVerifyStatus) async { +// try { +// final response = await http.post( +// Uri.parse(Environment.apiUrlEnrollment + 'getVerifiedUserData'), +// body: json.encode({ +// 'mobile_number': mobileNumber, +// 'otp_verification': otpVerifyStatus +// }), +// headers: { +// HttpHeaders.contentTypeHeader: 'application/json', +// }, +// ); +// +// if (response.statusCode == 200) { +// setState(() { +// _isLoading = false; +// }); +// Map data = json.decode(response.body); +// print('data: $data'); +// +// // --- Extract tokens safely --- +// String? preToken; +// if (data['data'] is String) { +// preToken = data['data']; +// } +// +// String? postToken; +// if (data['post_enrollment'] != null && data['post_enrollment']['data'] is String) { +// postToken = data['post_enrollment']['data']; +// } +// +// // Save tokens +// await TokenService.saveTokens(preToken: preToken, postToken: postToken); +// print('Tokens saved → preToken: $preToken, postToken: $postToken'); +// +// _preToken = preToken; +// String status = data['status']; +// +// // Directly access the post_enrollment data +// Map post = data['post_enrollment']; +// print('post: $post'); +// +// _postToken = postToken; +// String postStatus = post['status']; +// +// if (postStatus == 'success') { +// setState(() { +// _isLoading = false; +// }); +// postSuccessData(post, data); +// } else if (status == 'success') { +// setState(() { +// _isLoading = false; +// }); +// enrollmentSuccessData(data); +// } else { +// setState(() { +// _isLoading = false; +// }); +// final SharedPreferences prefs = await SharedPreferences.getInstance(); +// prefs.clear(); +// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); +// // Show a Snackbar if the OTP is invalid +// print('Invalid OTP. Please try again'); +// } +// } else { +// setState(() { +// _isLoading = false; +// }); +// final SharedPreferences prefs = await SharedPreferences.getInstance(); +// prefs.clear(); +// ToastHelper.showWarningToast(context, 'Something went wrong'); +// throw Exception('Failed to verify OTP'); +// } +// } catch (e) { +// setState(() { +// _isLoading = false; +// }); +// print('Error: $e'); +// final SharedPreferences prefs = await SharedPreferences.getInstance(); +// prefs.clear(); +// ToastHelper.showWarningToast(context, 'Something went wrong'); +// // Show a Snackbar if there's an error while verifying OTP +// print('Failed to verify OTP. Please try again.'); +// } +// } +// +// void loginUser({ +// required dynamic gpaEmpName, +// required dynamic empPrimaryId, +// required dynamic empCodeString, +// required dynamic client_id, +// required dynamic empClientBranchId, +// }) { +// HtmlHelper.saveLoginData({ +// 'gpaEmpName': gpaEmpName, +// 'empPrimaryId': empPrimaryId, +// 'empCode': empCodeString, +// 'client_id': client_id, +// 'empClientBranchId': empClientBranchId, +// }); +// print('Successfully Login'); +// } +// +// void postSuccessData(post, data) async { +// String status = data['status']; +// String postStatus = post['status']; +// +// if (postStatus == 'success') { +// // final SharedPreferences prefs = await SharedPreferences.getInstance(); +// // prefs.setString('_postToken', post['data']); +// +// await SessionManager().initializeFromPostToken(post['data']); +// session = await SessionManager(); +// // // Decode the JWT token received from the API response +// // Map? decodedToken = Jwt.parseJwt(post['data']); +// // print('decodedToken : $decodedToken'); +// // empClientBranchId = decodedToken['client_branch_id']; +// // prefs.setString('empClientBranchId', empClientBranchId); +// // empCodeString = decodedToken['emp_code'].toString(); +// // prefs.setString('empCode', empCodeString); +// // empPrimaryId = decodedToken['id']; +// // prefs.setString('empPrimaryId', empPrimaryId); +// // gpaEmpName = decodedToken['name'].toString(); +// // prefs.setString('gpaEmpName', gpaEmpName); +// // client_id = decodedToken['client_id']; +// // prefs.setString('client_id', client_id); +// // emp_status = decodedToken['emp_status']; +// // prefs.setString('emp_status', emp_status); +// // getClientLogoAndDetails(); +// +// loginUser( +// gpaEmpName: session.gpaEmpName, +// empPrimaryId: session.empPrimaryId, +// empCodeString: session.empCodeString, +// client_id: session.client_id, +// empClientBranchId: session.empClientBranchId, +// ); +// +// // if (kIsWeb) { +// // html.window.localStorage['gpaEmpName'] = gpaEmpName; +// // html.window.localStorage['empPrimaryId'] = empPrimaryId; +// // html.window.localStorage['empCode'] = empCodeString; +// // html.window.localStorage['client_id'] = client_id; +// // html.window.localStorage['empClientBranchId'] = empClientBranchId; +// // +// // // Dispatch a custom event with a message +// // +// // // 🌟 Dispatch event to notify JavaScript +// // html.window.dispatchEvent( +// // html.CustomEvent('userLoggedIn', detail: {'status': 'success'})); +// // +// // print("✅ User logged in! LocalStorage values set."); +// // +// // print('Successfully Login'); +// // } +// +// // Redirect to another page +// } +// +// if (status == 'success') { +// // final SharedPreferences prefs = await SharedPreferences.getInstance(); +// // prefs.setString('enrollToken', data['data']); +// await SessionManager().initializeFromPreToken(data['data']); +// // // Decode the JWT token received from the API response +// // Map? decodedToken = Jwt.parseJwt(data['data']); +// // print('decodedToken : $decodedToken'); +// // enrollmentEmpClientBranchId = decodedToken['client_branch_id']; +// // prefs.setString( +// // 'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId); +// // enrollmentEmpCodeString = decodedToken['emp_code'].toString(); +// // prefs.setString('enrollmentEmpCodeString', enrollmentEmpCodeString); +// // enrollmentEmpPrimaryId = decodedToken['id']; +// // prefs.setString('enrollmentEmpPrimaryId', enrollmentEmpPrimaryId); +// // enrollmentGpaEmpName = decodedToken['name'].toString(); +// // prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName); +// // enrollmentClient_id = decodedToken['client_id']; +// // prefs.setString('enrollmentClient_id', enrollmentClient_id); +// // enrollmentEmp_status = decodedToken['emp_status']; +// // prefs.setString('enrollmentEmp_status', enrollmentEmp_status); +// getClientLogoAndDetails(); +// } +// +// // final SharedPreferences prefs = await SharedPreferences.getInstance(); +// // final _postToken = prefs.getString('_postToken'); +// // int skipStatus = prefs.getInt('skipStatus') ?? 1; +// // final mpinText = prefs.getString('mpinText'); +// // print(isMobilePlatform()); +// if (isMobilePlatform()) { +// // if (prefs.containsKey('mpin') && mpinText == 'Mpin - exist') { +// if (_postToken != null && _postToken.isNotEmpty) { +// final SharedPreferences prefs = await SharedPreferences.getInstance(); +// await prefs.setString('empMobileNo', widget.mobileNumber); +// await initNotification(); +// checkLoginPin(context); +// } +// // } +// } else { +// if (_postToken != null && _postToken.isNotEmpty) { +// ToastHelper.showSuccessToast(context, 'Successfully Login'); +// // if (emp_status == 'enrolled' || emp_status == 'active') { +// context.go('/home'); +// // Navigator.pushReplacementNamed(context, 'home'); +// // } else { +// // Navigator.pushReplacementNamed(context, 'empDetails'); +// // } +// } +// } +// } +// +// void enrollmentSuccessData(data) async { +// // final SharedPreferences prefs = await SharedPreferences.getInstance(); +// // prefs.setString('enrollToken', data['data']); +// +// await SessionManager().initializeFromPreToken(data['data']); +// +// // // Decode the JWT token received from the API response +// // Map? decodedToken = Jwt.parseJwt(data['data']); +// // print('decodedToken : $decodedToken'); +// // enrollmentEmpClientBranchId = decodedToken['client_branch_id']; +// // prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId); +// // enrollmentEmpCodeString = decodedToken['emp_code'].toString(); +// // prefs.setString('enrollmentEmpCodeString', enrollmentEmpCodeString); +// // enrollmentEmpPrimaryId = decodedToken['id']; +// // prefs.setString('enrollmentEmpPrimaryId', enrollmentEmpPrimaryId); +// // enrollmentGpaEmpName = decodedToken['name'].toString(); +// // prefs.setString('enrollmentGpaEmpName', enrollmentGpaEmpName); +// // enrollmentClient_id = decodedToken['client_id']; +// // prefs.setString('enrollmentClient_id', enrollmentClient_id); +// // enrollmentEmp_status = decodedToken['emp_status']; +// // prefs.setString('enrollmentEmp_status', enrollmentEmp_status); +// getClientLogoAndDetails(); +// +// print('Successfully Login'); +// +// // Redirect to another page +// // final enrollToken = prefs.getString('enrollToken'); +// // int skipStatus = prefs.getInt('skipStatus') ?? 1; +// // final mpinText = prefs.getString('mpinText'); +// print(isMobilePlatform()); +// if (isMobilePlatform()) { +// // if (prefs.containsKey('mpin') && mpinText == 'Mpin - exist') { +// if (_preToken != null && _preToken.isNotEmpty) { +// final SharedPreferences prefs = await SharedPreferences.getInstance(); +// prefs.setString('empMobileNo', widget.mobileNumber); +// await initNotification(); +// checkLoginPin(context); +// } +// // } +// } else { +// if (_preToken != null && _preToken.isNotEmpty) { +// ToastHelper.showSuccessToast(context, 'Successfully Login'); +// // if (emp_status == 'enrolled' || emp_status == 'active') { +// // Navigator.pushReplacementNamed(context, 'home'); +// // } else { +// context.go('/empDetails'); +// // Navigator.pushReplacementNamed(context, 'empDetails'); +// // } +// } +// } +// } +// +// void verifyOTP(String otp) async { +// try { +// // setState(() { +// // _isLoading = true; +// // }); +// // Later, in verify screen: +// SharedPreferences prefs = await SharedPreferences.getInstance(); +// dynamic verificationId = prefs.getString('verificationId'); +// +// final credential = PhoneAuthProvider.credential( +// verificationId: verificationId, // Make sure this is up-to-date +// smsCode: otp, +// ); +// +// print('credential $credential'); +// +// final userCredential = +// await FirebaseAuth.instance.signInWithCredential(credential); +// // await FirebaseAuth.instance.signInWithCredential(credential); +// print('otp firebase check'); +// +// if (userCredential.user != null) { +// print('otp firebase check done'); +// bool otpVerifyStatus = true; +// generateToken(otpVerifyStatus); +// } else { +// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again.'); +// } +// +// // await FirebaseAuth.instance.signInWithCredential(credential).then((userCredential) async { +// // if (userCredential.user != null) { +// // bool otpVerifyStatus = true; +// // generateToken(otpVerifyStatus); +// // } else { +// // setState(() { +// // _isLoading = false; +// // }); +// // ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); +// // } +// // }); +// } on FirebaseAuthException catch (e) { +// if (e.code == 'code-expired') { +// ScaffoldMessenger.of(context).showSnackBar( +// SnackBar( +// content: Text('OTP expired. Please request a new one.'), +// duration: Duration(seconds: 2), +// ), +// ); +// ToastHelper.showErrorToast( +// context, 'OTP expired. Please request a new one.'); +// } else if (e.code == 'invalid-verification-code') { +// ScaffoldMessenger.of(context).showSnackBar( +// SnackBar( +// content: Text('Invalid OTP entered. Please try again.'), +// duration: Duration(seconds: 2), +// ), +// ); +// ToastHelper.showErrorToast( +// context, 'Invalid OTP entered. Please try again.'); +// } else if (e.code == 'session-expired') { +// ScaffoldMessenger.of(context).showSnackBar( +// SnackBar( +// content: Text('Session expired. Try restarting the verification.'), +// duration: Duration(seconds: 2), +// ), +// ); +// ToastHelper.showErrorToast( +// context, 'Session expired. Try restarting the verification.'); +// } else { +// ScaffoldMessenger.of(context).showSnackBar( +// SnackBar( +// content: Text('Error: ${e.message}'), +// duration: Duration(seconds: 2), +// ), +// ); +// ToastHelper.showErrorToast(context, 'Error: ${e.message}'); +// } +// } catch (e) { +// // setState(() { +// // _isLoading = false; +// // }); +// print('Error: $e'); +// ToastHelper.showErrorToast( +// context, 'Failed to verify OTP. Please try again.'); +// } +// } +// +// void _resendOTP() { +// setState(() { +// _secondsRemaining = 60; +// _isTimerRunning = true; +// }); +// startTimer(); +// widget.onResendCode(widget.mobileNumber, widget.resendToken); +// } +// +// Future checkLoginPin(BuildContext context) async { +// print('checkLoginPin'); +// try { +// final SharedPreferences prefs = await SharedPreferences.getInstance(); +// empMobileNo = prefs.getString('empMobileNo'); +// empEmailid = prefs.getString('empEmailid'); +// print('empMobileNo $empMobileNo'); +// print('empEmailid $empEmailid'); +// // _preToken = prefs.getString('token'); +// var params = {}; +// if (empMobileNo != null && empMobileNo.isNotEmpty) { +// params = {'mobile_number': empMobileNo}; +// } else if (empEmailid != null && empEmailid.isNotEmpty) { +// params = {'email_id': empEmailid}; +// } +// +// final response = await http.post( +// Uri.parse(Environment.apiUrlEnrollment + 'checkMpin'), +// body: json.encode(params), +// headers: { +// HttpHeaders.contentTypeHeader: 'application/json', +// }, +// ); +// +// if (response.statusCode == 200) { +// print('checkLoginPin $response'); +// Map data = json.decode(response.body); +// if (data['status'] == 'success') { +// print('checkLoginPin success'); +// if (data['data'] != null) { +// prefs.setString('mpinText', data['data']); +// } +// +// if (data['Mpin'] != null) { +// prefs.setString('mpin', data['Mpin']); +// } +// +// if (data['is_biometric_enabled'] != null) { +// prefs.setString( +// 'is_biometric_enabled', data['is_biometric_enabled']); +// } +// +// if (data['is_mpin_skipped'] != null) { +// prefs.setString('is_mpin_skipped', data['is_mpin_skipped']); +// } +// +// if (_postToken != null && _postToken.isNotEmpty) { +// ToastHelper.showSuccessToast(context, 'Successfully Login'); +// context.go('/home'); +// // Navigator.pushReplacementNamed(context, 'home'); +// } else { +// context.go('/empDetails'); +// // Navigator.pushReplacementNamed(context, 'empDetails'); +// } +// +// // if (data['is_mpin_skipped'] != null && +// // data['is_mpin_skipped'] == '0') { +// // context.go('/pinPage'); +// // // Navigator.pushReplacementNamed(context, 'pinPage'); +// // } else { +// // if (_postToken != null && _postToken.isNotEmpty) { +// // ToastHelper.showSuccessToast(context, 'Successfully Login'); +// // context.go('/home'); +// // // Navigator.pushReplacementNamed(context, 'home'); +// // } else { +// // context.go('/empDetails'); +// // // Navigator.pushReplacementNamed(context, 'empDetails'); +// // } +// // } +// } else { +// context.go('/pinSettingPage'); +// // Navigator.pushReplacementNamed(context, 'pinSettingPage'); +// } +// } else { +// print('checkLoginPin Something went wrong'); +// ToastHelper.showErrorToast(context, 'Something went wrong'); +// throw Exception('Failed to verify pin number'); +// } +// } catch (e) { +// ToastHelper.showErrorToast(context, 'Something went wrong'); +// print('Error: $e'); +// } +// } +// +// Future getClientLogoAndDetails() async { +// print('getClientLogoAndDetails'); +// var url = Uri.parse(Environment.apiUrlEnrollment + 'getClientDetails?post_client_id=${session.client_id}&post_branch_id=${session.empClientBranchId}&pre_client_id=${session.enrollmentClient_id}&pre_branch_id=${session.enrollmentEmpClientBranchId}'); +// try { +// var response = await http.get( +// url, +// headers: { +// 'Authorization': +// 'Bearer $_preToken', // Add token to the Authorization header +// }, +// ); +// if (response.statusCode == 200) { +// // print('response.statusCode == 200'); +// Map data = json.decode(response.body); +// // print(data); +// +// if (data.containsKey('data')) { +// dynamic clientDetails = data['data']; +// final SharedPreferences prefs = await SharedPreferences.getInstance(); +// prefs.setString('clientLogo', clientDetails['client']['client_logo']); +// prefs.setString('clientName', clientDetails['client']['client_name']); +// prefs.setString( +// 'addon_subheading', clientDetails['client']['addon_subheading']); +// setState(() { +// // dynamic clientDetails = data['data']; +// // print(clientDetails); +// clientName = clientDetails['client']['client_name']; +// print(clientName); +// clientLogo = clientDetails['client']['client_logo']; +// print(clientLogo); +// }); +// } else { +// // Handle other status messages if needed +// // ToastHelper.showErrorToast( +// // context, 'API request failed with status: ${data['status']}'); +// print('API request failed with status: ${data['status']}'); +// } +// } else { +// // Handle other status codes +// // ToastHelper.showErrorToast( +// // context, 'Request failed with status: ${response.statusCode}'); +// print('Request failed with status: ${response.statusCode}'); +// } +// } catch (e) { +// // Handle exceptions +// print('Exception occurred: $e'); +// } +// } +// +// @override +// Widget build(BuildContext context) { +// // Retrieve the passed mobile number value +// // final String mobileNumber = +// // ModalRoute.of(context)!.settings.arguments as String; +// Size _size = MediaQuery.of(context).size; +// EdgeInsets marginInsets = EdgeInsets.zero; +// if (Responsive.isDesktop(context)) { +// marginInsets = const EdgeInsets.only( +// left: 0, +// right: 0, +// bottom: 0, +// top: 0, +// ); +// } else if (Responsive.isMobile(context)) { +// marginInsets = const EdgeInsets.only( +// left: 25, // Example value for mobile +// right: 25, // Example value for mobile +// bottom: 0, // Example value for mobile +// top: 0, // Example value for mobile +// ); +// } else if (Responsive.isTablet(context)) { +// marginInsets = const EdgeInsets.only( +// left: 25, // Example value for mobile +// right: 25, // Example value for mobile +// bottom: 0, // Example value for mobile +// top: 0, // Example value for mobile +// ); +// } +// final defaultPinTheme = PinTheme( +// width: 56, +// height: 56, +// textStyle: TextStyle( +// fontSize: 20, +// color: Color.fromRGBO(30, 60, 87, 1), +// fontWeight: FontWeight.w600, +// ), +// decoration: BoxDecoration( +// border: Border.all(color: Color.fromRGBO(234, 239, 243, 1)), +// borderRadius: BorderRadius.circular(20), +// ), +// ); +// +// final focusedPinTheme = defaultPinTheme.copyDecorationWith( +// border: Border.all(color: Color.fromRGBO(114, 178, 238, 1)), +// borderRadius: BorderRadius.circular(8), +// ); +// +// final submittedPinTheme = defaultPinTheme.copyWith( +// decoration: defaultPinTheme.decoration?.copyWith( +// color: Color.fromRGBO(234, 239, 243, 1), +// ), +// ); +// +// return WillPopScope( +// onWillPop: () async { +// context.go('/login'); +// // Navigator.pushReplacementNamed(context, 'login'); +// return false; +// }, +// child: Scaffold( +// body: SingleChildScrollView( +// keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, +// child: Container( +// height: _size.height, +// color: Colors.white, +// child: Stack( +// children: [ +// Visibility( +// visible: _size.width <= 1100, +// child: ClipRRect( +// borderRadius: BorderRadius.only( +// bottomLeft: Radius.circular(30), +// bottomRight: Radius.circular(30), +// ), +// child: Container( +// height: _size.height / 3, +// width: double.infinity, +// color: Color(0xFFFFFCE5), +// child: Stack( +// children: [ +// Column( +// children: [ +// SizedBox( +// height: _size.height / +// 6.4), // Adjust the spacing between the rows +// Row( +// mainAxisAlignment: MainAxisAlignment +// .center, // Align to the center +// children: [ +// Expanded( +// flex: Responsive.isDesktop(context) +// ? 10 +// : 12, +// child: Align( +// alignment: Responsive.isDesktop(context) +// ? Alignment.centerLeft +// : Alignment.bottomCenter, +// child: Image.asset( +// 'assets/nhance_app_logo.png', +// width: 150, +// height: 150, +// ), +// ), +// ), +// if (!Responsive.isMobile(context) && +// !Responsive.isTablet(context)) +// Expanded( +// flex: 2, +// child: MouseRegion( +// cursor: SystemMouseCursors.click, +// child: GestureDetector( +// onTap: () { +// context.go('/hrLogin'); +// // Navigator.pushNamed( +// // context, 'hrLogin'); +// }, +// child: Row( +// mainAxisAlignment: MainAxisAlignment +// .end, // Align to the end (right) +// children: [ +// Text( +// 'HR Login', +// style: GoogleFonts.poppins( +// color: Color( +// 0xFF000000), // Text color +// // Add other text styles as needed +// ), +// ), +// SizedBox(width: 5), +// Icon( +// Icons +// .east, // Icon for customer login +// color: Colors +// .black, // Adjust color as needed +// ), +// ], +// ), +// ), +// ), +// ), +// ], +// ), +// ], +// ), +// ], +// ), +// ), +// ), +// ), +// Container( +// margin: marginInsets, +// alignment: Alignment.bottomCenter, +// child: SingleChildScrollView( +// child: Form( +// key: _formKey, +// child: Column( +// children: [ +// Row( +// children: [ +// Expanded( +// flex: _size.width < 1100 ? 6 : 12, +// child: Container( +// margin: _size.width > 1100 +// ? EdgeInsets.only(left: 20, right: 20) +// : EdgeInsets.only(left: 0, right: 0), +// child: Column( +// mainAxisAlignment: +// MainAxisAlignment.center, +// children: [ +// if (!Responsive.isMobile(context) && +// !Responsive.isTablet(context)) +// Row( +// children: [ +// Expanded( +// flex: 10, +// child: Align( +// alignment: Responsive +// .isDesktop(context) +// ? Alignment.centerLeft +// : Alignment +// .bottomCenter, // Align to the start +// child: _size.width <= 1100 +// ? Image.asset( +// 'assets/nhance_app_logo.png', +// width: 150, +// height: 150, +// ) +// : _size.width > 1100 +// ? Image.asset( +// 'assets/nhance_app_logo.png', +// width: 150, +// height: 150, +// ) +// : Image.asset( +// 'assets/nhance_app_logo.png', +// width: 150, +// height: 150, +// ), +// )), +// ], +// ), +// SizedBox(height: 10), +// // SizedBox( +// // height: Responsive.isDesktop(context) +// // ? _size.height * 0.1 +// // : 10, +// // ), +// Container( +// margin: Responsive.isDesktop(context) +// ? EdgeInsets.symmetric( +// horizontal: 150) +// : EdgeInsets.symmetric( +// horizontal: 0), +// child: Row( +// mainAxisAlignment: +// MainAxisAlignment.center, +// children: [ +// Text( +// "Welcome to Nhance", +// style: GoogleFonts.poppins( +// fontSize: 16, +// fontWeight: FontWeight.bold, +// ), +// ), +// ], +// ), +// ), +// SizedBox(height: 10), +// Container( +// margin: Responsive.isDesktop(context) +// ? EdgeInsets.symmetric( +// horizontal: 150) +// : EdgeInsets.symmetric( +// horizontal: 0), +// child: RichText( +// textAlign: TextAlign.center, +// text: TextSpan( +// text: +// "Please enter the one-time usage code sent to your mobile number $mobileNumber", +// style: TextStyle( +// fontSize: 12, +// height: 1.5, +// color: Color(0xFF000000)), +// children: [ +// TextSpan( +// text: " (Change Number)", +// style: TextStyle( +// fontSize: 12, +// color: Color( +// 0xFFE26728)), // Change color as desired +// recognizer: +// TapGestureRecognizer() +// ..onTap = () { +// context.go('/login'); +// // Navigator.pushNamed( +// // context, 'login'); +// }, +// ), +// ], +// ), +// ), +// ), +// SizedBox(height: 15), +// Container( +// margin: Responsive.isDesktop(context) +// ? EdgeInsets.symmetric( +// horizontal: 150) +// : EdgeInsets.symmetric( +// horizontal: 0), +// child: Pinput( +// length: 6, +// // defaultPinTheme: defaultPinTheme, +// // focusedPinTheme: focusedPinTheme, +// // submittedPinTheme: submittedPinTheme, +// showCursor: true, +// controller: _otpController, +// ), +// ), +// SizedBox(height: 10), +// Container( +// margin: Responsive.isDesktop(context) +// ? EdgeInsets.symmetric( +// horizontal: 150) +// : EdgeInsets.symmetric( +// horizontal: 0), +// child: Row( +// mainAxisAlignment: MainAxisAlignment +// .end, // Align text to the right +// children: [ +// _isTimerRunning +// ? Text( +// "Resend OTP in $_secondsRemaining seconds", +// style: +// GoogleFonts.poppins( +// color: +// Colors.black), +// ) +// : InkWell( +// onTap: () { +// _resendOTP(); +// }, +// child: Text( +// "Resend OTP", +// style: +// GoogleFonts.poppins( +// color: Colors +// .blue), +// ), +// ), +// ], +// ), +// ), +// SizedBox(height: 10), +// Container( +// margin: Responsive.isDesktop(context) +// ? EdgeInsets.symmetric( +// horizontal: 150) +// : EdgeInsets.symmetric( +// horizontal: 0), +// child: SizedBox( +// width: double.infinity, +// height: 45, +// child: ElevatedButton( +// style: ElevatedButton.styleFrom( +// backgroundColor: +// Color(0xFF00989E), +// shape: RoundedRectangleBorder( +// borderRadius: +// BorderRadius.circular(10), +// ), +// ), +// onPressed: () { +// if (_formKey.currentState! +// .validate()) { +// _formKey.currentState! +// .save(); // Save form fields before calling verifyOTP +// verifyOTP( +// _otpController.text); +// } +// }, +// child: Text( +// "Submit", +// style: GoogleFonts.poppins( +// color: Color(0xFFFFFFFF)), +// ), +// ), +// ), +// ), +// // _size.width > 1100 +// // ? Container( +// // margin: EdgeInsets.symmetric( +// // horizontal: 150), +// // child: Column( +// // children: [ +// // SizedBox(height: 20), +// // Text( +// // "Benefits of Login", +// // style: +// // GoogleFonts.poppins( +// // fontSize: 20, +// // fontWeight: +// // FontWeight.bold, +// // ), +// // ), +// // SizedBox(height: 15), +// // ], +// // )) +// // : SizedBox(), +// // _size.width > 1100 +// // ? Container( +// // margin: EdgeInsets.symmetric( +// // horizontal: 150), +// // child: Row( +// // mainAxisAlignment: +// // MainAxisAlignment.center, +// // children: [ +// // Expanded( +// // flex: 6, +// // child: Container( +// // padding: EdgeInsets +// // .symmetric( +// // vertical: 8), +// // child: Row( +// // mainAxisAlignment: +// // MainAxisAlignment +// // .center, +// // children: [ +// // Expanded( +// // child: Container( +// // padding: EdgeInsets +// // .symmetric( +// // vertical: +// // 12), +// // decoration: +// // BoxDecoration( +// // border: +// // Border( +// // right: +// // BorderSide( +// // width: 1, +// // color: Colors +// // .black, +// // ), +// // ), +// // ), +// // child: Column( +// // children: [ +// // Icon( +// // Icons +// // .policy, +// // color: Color( +// // 0xFFE26728)), +// // SizedBox( +// // height: +// // 10), +// // Text( +// // "View Policy", +// // style: GoogleFonts +// // .poppins()), +// // ], +// // ), +// // ), +// // ), +// // Expanded( +// // child: Container( +// // padding: EdgeInsets +// // .symmetric( +// // vertical: +// // 12), +// // child: Column( +// // children: [ +// // Icon( +// // Icons +// // .edit, +// // color: Color( +// // 0xFFE26728)), +// // SizedBox( +// // height: +// // 10), +// // Text( +// // "Manage Claims", +// // style: GoogleFonts +// // .poppins()), +// // ], +// // ), +// // ), +// // ), +// // ], +// // ), +// // ), +// // ), +// // ], +// // ), +// // ) +// // : SizedBox( +// // height: Responsive.isDesktop( +// // context) +// // ? _size.height * 0.1 +// // : _size.height * 0.2, +// // ), +// SizedBox( +// height: Responsive.isDesktop(context) +// ? _size.height * 0.3 +// : _size.height * 0.2, +// ), +// // SizedBox( +// // height: _size.height * 0.1, +// // ), +// Container( +// alignment: Alignment.bottomCenter, +// padding: +// EdgeInsets.symmetric(vertical: 8), +// child: RichText( +// textAlign: TextAlign.center, +// text: TextSpan( +// text: +// 'By continuing, you agree with our ', +// style: GoogleFonts.poppins( +// color: Colors.black, +// fontSize: 9, +// ), +// children: [ +// TextSpan( +// text: 'privacy policy ', +// style: GoogleFonts.poppins( +// color: Color(0xFF00989E), +// fontSize: 9, +// ), +// ), +// TextSpan( +// text: 'and ', +// style: GoogleFonts.poppins( +// color: Colors.black, +// fontSize: 9, +// ), +// ), +// TextSpan( +// text: 'terms of use', +// style: GoogleFonts.poppins( +// color: Color(0xFF00989E), +// fontSize: 9, +// ), +// ), +// ], +// ), +// ), +// ), +// ], +// ), +// ), +// ), +// if (_size.width > 1100) +// Expanded( +// flex: _size.width < 1100 ? 6 : 12, +// child: LayoutBuilder( +// builder: (BuildContext context, +// BoxConstraints constraints) { +// if (constraints.maxWidth > 600) { +// return Image.asset( +// 'assets/login_web.jpg', +// height: _size.height, +// fit: BoxFit.cover, +// ); +// } else { +// return SizedBox(); +// } +// }, +// ), +// ), +// ], +// ), +// ], +// ), +// ), +// ), +// ), +// ], +// )), +// ))); +// } +// } +// +// // ✅ Must be outside any class — this fixes your error +// @pragma('vm:entry-point') +// Future firebaseMessagingBackgroundHandler(RemoteMessage message) async { +// print('📨 Handling background message: ${message.messageId}'); +// print('Title: ${message.notification?.title}'); +// print('Body: ${message.notification?.body}'); +// print('Data: ${message.data}'); +// } \ No newline at end of file diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index b4b39ca..5a09cb9 100755 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,10 +7,6 @@ import Foundation import file_picker import file_selector_macos -import firebase_app_check -import firebase_auth -import firebase_core -import firebase_messaging import flutter_inappwebview_macos import flutter_secure_storage_macos import google_sign_in_ios @@ -26,10 +22,6 @@ import webview_flutter_wkwebview func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) - FLTFirebaseAppCheckPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAppCheckPlugin")) - FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) - FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) - FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin")) InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin")) FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin")) diff --git a/pubspec.yaml b/pubspec.yaml index 7f19508..c10d151 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,8 +17,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. #version: 1.0.32+32 -#version: 1.0.20+21 -version: 2.0.1+39 +version: 1.0.20+23 +#version: 2.0.3+41 environment: sdk: '>=3.3.3 <4.0.0' @@ -51,13 +51,13 @@ dependencies: url_launcher: ^6.2.6 flutter_svg: ^2.0.10+1 dash_chat_2: ^0.0.21 - firebase_messaging: ^16.0.3 +# firebase_messaging: ^16.0.3 local_auth: ^3.0.0 google_sign_in: ^7.2.0 dio: ^5.7.0 - firebase_core: ^4.2.0 - firebase_auth: ^6.1.1 - firebase_app_check: ^0.4.1+1 +# firebase_core: ^4.2.0 +# firebase_auth: ^6.1.1 +# firebase_app_check: ^0.4.1+2 package_info_plus: ^9.0.0 webview_flutter: ^4.13.0 webview_flutter_android: ^4.7.0 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index b9c472b..06dd00e 100755 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,8 +7,6 @@ #include "generated_plugin_registrant.h" #include -#include -#include #include #include #include @@ -17,10 +15,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { FileSelectorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorWindows")); - FirebaseAuthPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); - FirebaseCorePluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi")); FlutterSecureStorageWindowsPluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index a4ba2cc..442dfbc 100755 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,8 +4,6 @@ list(APPEND FLUTTER_PLUGIN_LIST file_selector_windows - firebase_auth - firebase_core flutter_inappwebview_windows flutter_secure_storage_windows local_auth_windows