From b29284f59fd1fc4f6ef488590b47e76254ea24fd Mon Sep 17 00:00:00 2001 From: SikanderSaleem Date: Fri, 23 May 2025 11:38:59 +0300 Subject: [PATCH] changes for ios release --- .gitignore | 2 + ios/Podfile.lock | 4 +- ios/Runner/Info.plist | 28 ++++++-- ios/Runner/Runner.entitlements | 1 - .../firebase_notification_manger.dart | 30 ++++---- lib/dashboard_latest/dashboard_view.dart | 57 ++++++++------- .../swipe_module/utils/location_utils.dart | 69 ++++++++++++++----- .../utils/swipe_general_utils.dart | 30 ++++---- 8 files changed, 137 insertions(+), 84 deletions(-) diff --git a/.gitignore b/.gitignore index f90ad501..d7192f85 100644 --- a/.gitignore +++ b/.gitignore @@ -5,9 +5,11 @@ *.swp .DS_Store .atom/ +.build/ .buildlog/ .history .svn/ +.swiftpm/ migrate_working_dir/ # IntelliJ related diff --git a/ios/Podfile.lock b/ios/Podfile.lock index ffbf5eb6..64268431 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -332,7 +332,7 @@ SPEC CHECKSUMS: flutter_sound: dde9a913063b65a27ba8fdc2039036b99b136c79 flutter_sound_core: 0c6eb9d5268adc70ff159b3d65fd3d98a82d3a27 flutter_timezone: ffb07bdad3c6276af8dada0f11978d8a1f8a20bb - fluttertoast: 723e187574b149e68e63ca4d39b837586b903cfa + fluttertoast: e9a18c7be5413da53898f660530c56f35edfba9c FMDB: 728731dd336af3936ce00f91d9d8495f5718a0e6 geolocator_apple: 9bcea1918ff7f0062d98345d238ae12718acfbc1 GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7 @@ -368,4 +368,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: d8654c27146ad2b7c852fbdd93ef1a3785d9310b -COCOAPODS: 1.12.0 +COCOAPODS: 1.16.2 diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index ec6f8b03..d9114032 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -18,6 +18,14 @@ Atoms CFBundlePackageType APPL + NFCReaderUsageDescription + Allow permission to use NFC to mark attendance by swiping nfc card. + NSLocationAlwaysAndWhenInUseUsageDescription + This App requires access to your location to mark your attendance. + NSLocationAlwaysUsageDescription + This App requires access to your location to mark your attendance. + NSLocationWhenInUseUsageDescription + This App requires access to your location to mark your attendance. CFBundleShortVersionString $(FLUTTER_BUILD_NAME) CFBundleSignature @@ -47,11 +55,11 @@ NSSpeechRecognitionUsageDescription This app requires permission for Speech Recognition for speech to text functionality. NSCalendarsUsageDescription - Access most functions for calendar viewing and editing. - NSContactsUsageDescription - Access contacts for event attendee editing. - NSCalendarsFullAccessUsageDescription - Access most functions for calendar viewing and editing. + Access most functions for calendar viewing and editing. + NSContactsUsageDescription + Access contacts for event attendee editing. + NSCalendarsFullAccessUsageDescription + Access most functions for calendar viewing and editing. UIApplicationSupportsIndirectInputEvents UIBackgroundModes @@ -88,5 +96,15 @@ + NS + + com.apple.developer.nfc.readersession.felica.systemcodes + + 0000 + + com.apple.developer.nfc.readersession.formats + + TAG + diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements index 9a632605..6a908a89 100644 --- a/ios/Runner/Runner.entitlements +++ b/ios/Runner/Runner.entitlements @@ -10,7 +10,6 @@ com.apple.developer.nfc.readersession.formats - NDEF TAG inter-app-audio diff --git a/lib/controllers/notification/firebase_notification_manger.dart b/lib/controllers/notification/firebase_notification_manger.dart index 43dabb24..26fe0e69 100644 --- a/lib/controllers/notification/firebase_notification_manger.dart +++ b/lib/controllers/notification/firebase_notification_manger.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'dart:developer'; import 'dart:io'; import 'package:firebase_messaging/firebase_messaging.dart'; @@ -7,14 +6,11 @@ import 'package:flutter/material.dart'; import 'package:google_api_availability/google_api_availability.dart'; import 'package:huawei_push/huawei_push.dart' as h_push; import 'package:test_sa/controllers/notification/notification_manger.dart'; -import 'package:test_sa/extensions/widget_extensions.dart'; -import 'package:test_sa/models/all_requests_and_count_model.dart'; import 'package:test_sa/models/device/device_transfer.dart'; import 'package:test_sa/models/new_models/gas_refill_model.dart'; import 'package:test_sa/modules/cm_module/views/service_request_detail_main_view.dart'; import 'package:test_sa/modules/pm_module/ppm_wo/ppm_details_page.dart'; import 'package:test_sa/modules/pm_module/recurrent_wo/recurrent_work_order_view.dart'; -import 'package:test_sa/modules/tm_module/tasks_wo/task_request_detail_view.dart'; import 'package:test_sa/views/pages/device_transfer/device_transfer_details.dart'; import 'package:test_sa/views/pages/user/gas_refill/gas_refill_details.dart'; import 'package:test_sa/views/widgets/loaders/no_data_found.dart'; @@ -73,12 +69,16 @@ class FirebaseNotificationManger { } static Future isGoogleServicesAvailable() async { - GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability(); - String status = availability.toString().split('.').last; - if (status == "success") { - return true; + try { + GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability(); + String status = availability.toString().split('.').last; + if (status == "success") { + return true; + } + return false; + } catch (ex) { + return false; } - return false; } static void handleMessage(context, Map messageData) { @@ -95,11 +95,11 @@ class FirebaseNotificationManger { case 1: serviceClass = PpmDetailsPage(requestId: int.parse(messageData["requestNumber"].toString())); break; - //these three request are same corrective maintenance.... + //these three request are same corrective maintenance.... case 3: serviceClass = ServiceRequestDetailMain(requestId: messageData["requestNumber"] ?? ''); break; - case 8: + case 8: serviceClass = ServiceRequestDetailMain(requestId: messageData["requestNumber"] ?? ''); break; case 11: @@ -117,14 +117,14 @@ class FirebaseNotificationManger { break; case 12: serviceClass = RecurrentWorkOrderView(taskId: int.parse(messageData["requestNumber"].toString())); - //Didn't handle task request yet... + //Didn't handle task request yet... // case 6: // serviceClass = TaskRequestDetailsView( // taskId: int.parse(messageData["requestNumber"].toString()), // requestDetails: RequestsDetails(nameOfType: messageData["sourceName"], status: messageData["statusName"], priority: messageData["priorityName"], date: messageData["createdDate"])); // return; default: - serviceClass = const Scaffold(body: Center(child: NoDataFound())); + serviceClass = const Scaffold(body: Center(child: NoDataFound())); } // if (messageData["requestType"] == "Service request to engineer") { @@ -144,12 +144,12 @@ class FirebaseNotificationManger { // // } Navigator.of(context).push(MaterialPageRoute(builder: (_) => serviceClass!)); - } + } } static initialized(BuildContext context) async { //TOD0 add platform check here also - if (!(await isGoogleServicesAvailable())) { + if (!(await isGoogleServicesAvailable()) && Platform.isAndroid) { var initialNotification = await h_push.Push.getInitialNotification(); if (initialNotification != null) { Map remoteData = Map.from(initialNotification["extras"] as Map); diff --git a/lib/dashboard_latest/dashboard_view.dart b/lib/dashboard_latest/dashboard_view.dart index 15b8d82a..01ef9b67 100644 --- a/lib/dashboard_latest/dashboard_view.dart +++ b/lib/dashboard_latest/dashboard_view.dart @@ -84,8 +84,6 @@ class _DashboardViewState extends State { }); } - - void handleScroll() async { _scrollController = ScrollController(); _scrollController.addListener(() async { @@ -134,41 +132,40 @@ class _DashboardViewState extends State { ), ), ), - if (user!=null&&user.employeeIsHMG==false) + if (user != null && user.employeeIsHMG == false) Positioned( - right: 20.toScreenWidth , + right: 20.toScreenWidth, bottom: 20.toScreenHeight, child: GestureDetector( onTap: () async { - bool isNfcSupported = await NfcManager.instance.isAvailable(); + bool isNfcSupported = await NfcManager.instance.isAvailable(); SwipeGeneralUtils.instance.showSwipeTypeBottomSheetSheet(isNfcSupported: isNfcSupported); }, - child: CircularAnimatedContainer(child: Container( - width: 100.toScreenWidth, - height: 100.toScreenHeight, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: AppColor.white10, - border: Border.all(color: AppColor.primary10.withOpacity(0.5), width: 2), + child: CircularAnimatedContainer( + child: Container( + width: 100.toScreenWidth, + height: 100.toScreenHeight, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppColor.white10, + border: Border.all(color: AppColor.primary10.withOpacity(0.5), width: 2), + ), + child: Consumer(builder: (context, userProvider, child) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + 'swipe'.toSvgAsset(width: 32, height: 32), + 8.height, + Text( + ("${context.translation.checkIn}\n${userProvider.swipeTransactionModel.swipeTime != null ? SwipeGeneralUtils.instance.formatTimeOnly(userProvider.swipeTransactionModel.swipeTime!) : '--:--'}"), + style: AppTextStyles.bodyText2.copyWith(color: AppColor.white936, fontWeight: FontWeight.w500, fontFamily: "Poppins"), + ), + ], + ); + }), ), - child: Consumer( - builder: (context, userProvider,child) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - 'swipe'.toSvgAsset(width: 32, height: 32), - 8.height, - Text( - ("${context.translation.checkIn}\n${userProvider.swipeTransactionModel.swipeTime != null ? SwipeGeneralUtils.instance.formatTimeOnly(userProvider.swipeTransactionModel.swipeTime!) : '--:--'}"), - style: AppTextStyles.bodyText2.copyWith(color: AppColor.white936, fontWeight: FontWeight.w500, fontFamily: "Poppins"), - ), - - ], - ); - } - ), - ),), + ), ), ), ], diff --git a/lib/new_views/swipe_module/utils/location_utils.dart b/lib/new_views/swipe_module/utils/location_utils.dart index 8e02e3da..b3627cc3 100644 --- a/lib/new_views/swipe_module/utils/location_utils.dart +++ b/lib/new_views/swipe_module/utils/location_utils.dart @@ -22,7 +22,7 @@ class LocationUtilities { static bool _listeningSettingChange = true; - static void listenGPS({bool change = true, Function(bool) ?onChange}) async { + static void listenGPS({bool change = true, Function(bool)? onChange}) async { _listeningSettingChange = change; if (change == false) return; @@ -46,22 +46,59 @@ class LocationUtilities { } static void getCurrentLocation(Function(Position position, bool isMocked) callback, Function errorCallBack, BuildContext context) { - void done(Position position) { - //AppStorage.sp.saveLocation(position); + Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) { bool isMocked = position.isMocked; callback(position, isMocked); - } - - locationFun((granted) { - if (granted) { - Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((value) { - done(value); - }).catchError((err) { - errorCallBack(); - }); - } else { - // AppPermissions - } - }, context); + }).catchError((err) { + errorCallBack(); + }); + // return; + // Permission.location.isGranted.then((isGranted) { + // if (!isGranted) { + // Permission.location.request().then((granted) { + // print("granted:$granted"); + // if (granted == PermissionStatus.granted) { + // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) { + // bool isMocked = position.isMocked; + // callback(position, isMocked); + // }).catchError((err) { + // print("getCurrentPositionError:$err"); + // errorCallBack(); + // }); + // } else { + // errorCallBack(); + // } + // }); + // } else { + // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) { + // bool isMocked = position.isMocked; + // callback(position, isMocked); + // }).catchError((err) { + // print("getCurrentPositionError:$err"); + // errorCallBack(); + // }); + // } + // }); + // + // // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) { + // // bool isMocked = position.isMocked; + // // callback(position, isMocked); + // // }).catchError((err) { + // // print("getCurrentPositionError:$err"); + // // errorCallBack(); + // // }); + // + // // locationFun((granted) { + // // if (granted) { + // // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((value) { + // // done(value); + // // }).catchError((err) { + // // print("getCurrentPositionError:$err"); + // // errorCallBack(); + // // }); + // // } else { + // // // AppPermissions + // // } + // // }, context); } } diff --git a/lib/new_views/swipe_module/utils/swipe_general_utils.dart b/lib/new_views/swipe_module/utils/swipe_general_utils.dart index a26236a7..8f4f03ae 100644 --- a/lib/new_views/swipe_module/utils/swipe_general_utils.dart +++ b/lib/new_views/swipe_module/utils/swipe_general_utils.dart @@ -85,14 +85,14 @@ class SwipeGeneralUtils { ); } - void showErrorDialog({String ?message, required BuildContext context}) { + void showErrorDialog({String? message, required BuildContext context}) { showDialog( context: context, builder: (context) => ConfirmDialog(message: message, title: 'Error', onTap: () => Navigator.pop(context)), ); } - void showMDialog(context, {Widget ?child, Color? backgroundColor, bool isDismissable = true, bool isBusniessCard = false}) async { + void showMDialog(context, {Widget? child, Color? backgroundColor, bool isDismissable = true, bool isBusniessCard = false}) async { return showDialog( context: context, barrierDismissible: isDismissable, @@ -137,7 +137,7 @@ class SwipeGeneralUtils { } //huawei permission part.... - void getHuaweiCurrentLocation({SwipeTypeEnum ?attendanceType, required BuildContext context}) async { + void getHuaweiCurrentLocation({SwipeTypeEnum? attendanceType, required BuildContext context}) async { try { showLoading(context); FusedLocationProviderClient locationService = FusedLocationProviderClient()..initFusedLocationService(); @@ -153,7 +153,7 @@ class SwipeGeneralUtils { (Location location) async { hideLoading(context); await locationService.removeLocationUpdates(requestCode); - handleSwipeOperation(swipeType: attendanceType!, context: context, lat: location.latitude??0, long: location.longitude??0); + handleSwipeOperation(swipeType: attendanceType!, context: context, lat: location.latitude ?? 0, long: location.longitude ?? 0); requestCode = 0; _streamSubscription.cancel(); }, @@ -173,7 +173,7 @@ class SwipeGeneralUtils { return (result[Permission.location] == PermissionStatus.granted || result[Permission.locationAlways] == PermissionStatus.granted); } - void checkHuaweiLocationPermission({required SwipeTypeEnum attendanceType,required BuildContext context}) async { + void checkHuaweiLocationPermission({required SwipeTypeEnum attendanceType, required BuildContext context}) async { // Permission_Handler permissionHandler = PermissionHandler(); LocationUtilities.isEnabled((bool isEnabled) async { if (isEnabled) { @@ -231,7 +231,7 @@ class SwipeGeneralUtils { // } } - void handleSwipeOperation({required SwipeTypeEnum swipeType,required double lat,required double long,required BuildContext context}) { + void handleSwipeOperation({required SwipeTypeEnum swipeType, required double lat, required double long, required BuildContext context}) { switch (swipeType) { case SwipeTypeEnum.NFC: handleNfcAttendance(latitude: lat, longitude: long, context: context); @@ -249,7 +249,7 @@ class SwipeGeneralUtils { return DateFormat.Hms().format(dateTime); } - Future performQrCodeAttendance({double ?latitude, double? longitude,required BuildContext context}) async { + Future performQrCodeAttendance({double? latitude, double? longitude, required BuildContext context}) async { UserProvider userProvider = Provider.of(context, listen: false); String qrCodeValue = await Navigator.of(context).push( @@ -267,7 +267,7 @@ class SwipeGeneralUtils { ); await userProvider.makeSwipe(model: swipeModel).then((swipeResponse) { - if (swipeResponse.isSuccess==true) { + if (swipeResponse.isSuccess == true) { hideLoading(context); Navigator.pushNamed(context, SwipeSuccessView.routeName); } else { @@ -294,7 +294,7 @@ class SwipeGeneralUtils { } } - Future handleNfcAttendance({double ?latitude = 0, double? longitude = 0,required BuildContext context}) async { + Future handleNfcAttendance({double? latitude = 0, double? longitude = 0, required BuildContext context}) async { // UserProvider _userProvider = Provider.of(context,listen:false); if (Platform.isIOS) { @@ -310,8 +310,8 @@ class SwipeGeneralUtils { Future _processNfcAttendance( String nfcId, - double ?latitude, - double ?longitude, + double? latitude, + double? longitude, BuildContext context, ) async { showLoading(context); @@ -321,7 +321,7 @@ class SwipeGeneralUtils { final swipeResponse = await userProvider.makeSwipe(model: swipeModel); - if (swipeResponse.isSuccess==true) { + if (swipeResponse.isSuccess == true) { hideLoading(context); Navigator.pushNamed(context, SwipeSuccessView.routeName); } else { @@ -405,7 +405,7 @@ class SwipeGeneralUtils { }, context)); } if (kDebugMode) { - userProvider.user!.enableWifi!= true; + userProvider.user!.enableWifi != true; } if (userProvider.user!.enableWifi!) { @@ -448,7 +448,7 @@ class SwipeGeneralUtils { ); } - void readNFc({Function(String) ?onRead}) { + void readNFc({Function(String)? onRead}) { NfcManager.instance.startSession(onDiscovered: (NfcTag tag) async { MifareUltralight f; if (Platform.isAndroid) { @@ -497,7 +497,7 @@ class SwipeGeneralUtils { final swipeResponse = await userProvider.makeSwipe(model: swipeModel); await closeWifiRequest(); - if (swipeResponse.isSuccess==true) { + if (swipeResponse.isSuccess == true) { hideLoading(context); Navigator.pushNamed(context, SwipeSuccessView.routeName); } else {