From 7aaa4da771eb8b3c46e70855461a7d6ebcb1a5b1 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 13 Nov 2022 09:58:42 +0300 Subject: [PATCH 1/5] mark attendance counter & ios nfc fixed 1.0 --- ios/Runner.xcodeproj/project.pbxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 9daee21..43841a1 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -383,7 +383,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 3A359E86ZF; + DEVELOPMENT_TEAM = 99Z3UD3LJM; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Mohemm; @@ -520,7 +520,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 3A359E86ZF; + DEVELOPMENT_TEAM = 99Z3UD3LJM; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Mohemm; @@ -549,7 +549,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 3A359E86ZF; + DEVELOPMENT_TEAM = 99Z3UD3LJM; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Mohemm; From 5f525f16a07b8d3b85bb540a27bba3ee58aec2c7 Mon Sep 17 00:00:00 2001 From: "mirza.shafique" Date: Thu, 19 Jan 2023 09:04:18 +0300 Subject: [PATCH 2/5] local network test --- android/app/build.gradle | 2 +- android/app/src/main/AndroidManifest.xml | 2 +- lib/classes/consts.dart | 3 +- lib/ui/login/login_screen.dart | 39 ++++++++++++++++++++++-- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 9cd8b0e..7792554 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -44,7 +44,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.cloudSolutions.mohemmtest" + applicationId "hmg.cloudSolutions.mohem" minSdkVersion 21 targetSdkVersion 32 versionCode flutterVersionCode.toInteger() diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 30555e1..10d72b4 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -9,9 +9,9 @@ { isAppOpenBySystem = (ModalRoute.of(context)!.settings.arguments ?? true) as bool; if (!kReleaseMode) { // username.text = "15444"; // Maha User - // username.text = "15153"; // Tamer User - // password.text = "Abcd@1234"; + username.text = "15153"; // Tamer User + password.text = "Abcd@12345"; // username.text = "206535"; // Hashim User // password.text = "Namira786"; @@ -224,6 +225,14 @@ class _LoginScreenState extends State { Navigator.pushNamed(context, AppRoutes.forgotPassword); }), ), + 20.height, + DefaultButton( + "Connect HMG Network", + () async { + SystemChannels.textInput.invokeMethod('TextInput.hide'); + connectWithHmgNetwork(); + }, + ), ], ), ) @@ -239,4 +248,30 @@ class _LoginScreenState extends State { ), ); } + + void connectWithHmgNetwork() async { + try { + bool isConnected = await WiFiForIoTPlugin.connect("MOHEMM-CONNECT", password: "0987654321", joinOnce: Platform.isIOS ? false : true, security: NetworkSecurity.WPA, withInternet: false); + + if (isConnected) { + await WiFiForIoTPlugin.forceWifiUsage(true); + // if (Platform.isIOS) { + // await closeWifiRequest(); + // await Future.delayed(Duration(seconds: 6)); + // } else { + // await WiFiForIoTPlugin.forceWifiUsage(true); + // } + } + } catch (e) { + print("----------------o----"); + print(e); + } + } + + Future closeWifiRequest() async { + if (Platform.isAndroid) { + await WiFiForIoTPlugin.forceWifiUsage(false); + } + return await WiFiForIoTPlugin.disconnect(); + } } From f4b57a33f98117a1a233c1bc36a834b7c6e43344 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 19 Jan 2023 09:58:37 +0300 Subject: [PATCH 3/5] local internet connectivity fixed on ios --- pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 3167dcd..5e89df7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,7 +49,7 @@ dependencies: flutter_calendar_carousel: ^2.1.0 pie_chart: ^5.1.0 shared_preferences: ^2.0.12 - firebase_messaging: ^11.2.8 + firebase_messaging: ^14.2.1 shimmer: ^2.0.0 logger: ^1.1.0 flutter_countdown_timer: ^4.1.0 @@ -67,7 +67,7 @@ dependencies: month_year_picker: ^0.2.0+1 month_picker_dialog_2: 0.5.5 open_file: ^3.2.1 - wifi_iot: ^0.3.16 + wifi_iot: ^0.3.18 flutter_html: ^3.0.0-alpha.6 # flutter_barcode_scanner: ^2.0.0 qr_code_scanner: ^1.0.0 From e10ea6b02361e95ffb6e5447f557461e56fbbd55 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 19 Jan 2023 12:18:04 +0300 Subject: [PATCH 4/5] mark attendance session expire fixed --- lib/api/api_client.dart | 54 ++++++++++++-------- lib/app_state/app_state.dart | 2 +- lib/classes/consts.dart | 4 +- lib/ui/landing/today_attendance_screen2.dart | 24 ++++----- lib/ui/login/login_screen.dart | 14 ++--- lib/widgets/mark_attendance_widget.dart | 50 +++++++++--------- 6 files changed, 78 insertions(+), 70 deletions(-) diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index ff26054..da80da3 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -19,7 +19,11 @@ class APIError { APIError(this.errorCode, this.errorMessage, this.errorType); - Map toJson() => {'errorCode': errorCode, 'errorMessage': errorMessage, 'errorType': errorType,}; + Map toJson() => { + 'errorCode': errorCode, + 'errorMessage': errorMessage, + 'errorType': errorType, + }; @override String toString() { @@ -79,28 +83,34 @@ class ApiClient { print("body:$bodyJson"); } var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes, isFormData: isFormData); - // try { - if (!kReleaseMode) { - logger.i("res: " + response.body); - } - var jsonData = jsonDecode(response.body); - if (jsonData["IsAuthenticated"] != null) { - AppState().setIsAuthenticated = jsonData["IsAuthenticated"]; - } - if (jsonData["ErrorMessage"] == null) { - return factoryConstructor(jsonData); - } else { - APIError? apiError; - apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorEndUserMessage'], jsonData['ErrorType']); - throw APIException(APIException.BAD_REQUEST, error: apiError); + try { + if (!kReleaseMode) { + logger.i("res: " + response.body); + } + var jsonData = jsonDecode(response.body); + if (jsonData["MessageStatus"] == 2) { + AppState().setIsAuthenticated = false; + } + +// else if (jsonData["ErrorEndUserMessage"] != null && jsonData["ErrorEndUserMessage"].toString().contains("MBL-APP-375")) { +// print("Custom:${jsonData["ErrorEndUserMessage"]}"); +// AppState().setIsAuthenticated = false; +// } + + if (jsonData["ErrorMessage"] == null && jsonData["MessageStatus"] == 1) { + return factoryConstructor(jsonData); + } else { + APIError? apiError; + apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorEndUserMessage'], jsonData['ErrorType'] ?? 0); + throw APIException(APIException.BAD_REQUEST, error: apiError); + } + } catch (ex) { + if (ex is APIException) { + rethrow; + } else { + throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex); + } } - // } catch (ex) { - // if (ex is APIException) { - // rethrow; - // } else { - // throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex); - // } - // } } Future postJsonForResponse(String url, T jsonObject, diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index e43c774..1a69faa 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -70,7 +70,7 @@ class AppState { bool get getIsDemoMarathon => _isDemoMarathon; - final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 3.8, mobileType: Platform.isAndroid ? "android" : "ios"); + final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 3.9, mobileType: Platform.isAndroid ? "android" : "ios"); void setPostParamsInitConfig() { isAuthenticated = false; diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 0559996..96fd4b0 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -3,8 +3,8 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart'; class ApiConsts { //static String baseUrl = "http://10.200.204.20:2801/"; // Local server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server - static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server - // static String baseUrl = "https://hmgwebservices.com"; // Live server + // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server + static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrlServices = baseUrl + "/Services/"; // server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; diff --git a/lib/ui/landing/today_attendance_screen2.dart b/lib/ui/landing/today_attendance_screen2.dart index f0228eb..a72df34 100644 --- a/lib/ui/landing/today_attendance_screen2.dart +++ b/lib/ui/landing/today_attendance_screen2.dart @@ -50,23 +50,23 @@ class _TodayAttendanceScreenState extends State { icon: const Icon(Icons.arrow_back_ios, color: Colors.white), onPressed: () => Navigator.pop(context), ), - actions: [ - IconButton( - onPressed: () { - data.fetchAttendanceTracking(context); - }, - icon: const Icon( - Icons.ac_unit, - color: Colors.white, - ), - ) - ], + // actions: [ + // IconButton( + // onPressed: () { + // data.fetchAttendanceTracking(context); + // }, + // icon: const Icon( + // Icons.ac_unit, + // color: Colors.white, + // ), + // ) + // ], ), backgroundColor: MyColors.backgroundBlackColor, body: Consumer( builder: (context, model, child) { return (model.isAttendanceTrackingLoading - ? Center(child: CircularProgressIndicator()) + ? const Center(child: CircularProgressIndicator()) : Column( children: [ Container( diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index b933e88..66bccf3 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -226,13 +226,13 @@ class _LoginScreenState extends State { }), ), 20.height, - DefaultButton( - "Connect HMG Network", - () async { - SystemChannels.textInput.invokeMethod('TextInput.hide'); - connectWithHmgNetwork(); - }, - ), + // DefaultButton( + // "Connect HMG Network", + // () async { + // SystemChannels.textInput.invokeMethod('TextInput.hide'); + // connectWithHmgNetwork(); + // }, + // ), ], ), ) diff --git a/lib/widgets/mark_attendance_widget.dart b/lib/widgets/mark_attendance_widget.dart index dfe3b79..5a71152 100644 --- a/lib/widgets/mark_attendance_widget.dart +++ b/lib/widgets/mark_attendance_widget.dart @@ -12,6 +12,7 @@ import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/privilege_list_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/ui/dialogs/success_dialog.dart'; import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart'; @@ -47,7 +48,7 @@ class _MarkAttendanceWidgetState extends State { void checkAttendanceAvailability() async { bool isAvailable = await NfcManager.instance.isAvailable(); setState(() { - AppState().privilegeListModel!.forEach((element) { + AppState().privilegeListModel!.forEach((PrivilegeListModel element) { if (element.serviceName == "enableNFC") { if (isAvailable) if (element.previlege ?? false) isNfcEnabled = true; } else if (element.serviceName == "enableQR") { @@ -144,6 +145,7 @@ class _MarkAttendanceWidgetState extends State { Future performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { if (Platform.isIOS) { + Utils.readNFc(onRead: (String nfcId) async { Utils.showLoading(context); try { @@ -152,7 +154,7 @@ class _MarkAttendanceWidgetState extends State { Utils.hideLoading(context); showDialog( context: context, - builder: (cxt) => ConfirmDialog( + builder: (BuildContext cxt) => ConfirmDialog( message: g?.errorEndUserMessage ?? "Unexpected error occurred", onTap: () { Navigator.pop(context); @@ -172,9 +174,7 @@ class _MarkAttendanceWidgetState extends State { } } catch (ex) { Utils.hideLoading(context); - Utils.handleException(ex, context, (msg) { - Utils.confirmDialog(context, msg); - }); + Utils.handleException(ex, context, null); } }); } else { @@ -186,7 +186,7 @@ class _MarkAttendanceWidgetState extends State { Utils.hideLoading(context); showDialog( context: context, - builder: (cxt) => ConfirmDialog( + builder: (BuildContext cxt) => ConfirmDialog( message: g?.errorEndUserMessage ?? "Unexpected error occurred", onTap: () { Navigator.pop(context); @@ -206,7 +206,7 @@ class _MarkAttendanceWidgetState extends State { } catch (ex) { print(ex); Utils.hideLoading(context); - Utils.handleException(ex, context, (msg) { + Utils.handleException(ex, context, (String msg) { Utils.confirmDialog(context, msg); }); } @@ -219,19 +219,23 @@ class _MarkAttendanceWidgetState extends State { bool isConnected = await WiFiForIoTPlugin.connect(AppState().getMohemmWifiSSID ?? "", password: AppState().getMohemmWifiPassword ?? "", joinOnce: Platform.isIOS ? false : true, security: NetworkSecurity.WPA, withInternet: false); if (isConnected) { - if (Platform.isIOS) { - await closeWifiRequest(); - await Future.delayed(Duration(seconds: 6)); - } else { - await WiFiForIoTPlugin.forceWifiUsage(true); - } + // if (Platform.isIOS) { + // await closeWifiRequest(); + // await Future.delayed(Duration(seconds: 6)); + // } else { + // await WiFiForIoTPlugin.forceWifiUsage(true); + // } + await WiFiForIoTPlugin.forceWifiUsage(true); + await Future.delayed(const Duration(seconds: 6)); try { GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng); bool status = await model.fetchAttendanceTracking(context); Utils.hideLoading(context); - if (Platform.isAndroid) { - await closeWifiRequest(); - } + // if (Platform.isAndroid) { + // await closeWifiRequest(); + // } + + await closeWifiRequest(); showMDialog( context, backgroundColor: Colors.transparent, @@ -241,9 +245,7 @@ class _MarkAttendanceWidgetState extends State { } catch (ex) { await closeWifiRequest(); Utils.hideLoading(context); - Utils.handleException(ex, context, (msg) { - Utils.confirmDialog(context, msg); - }); + Utils.handleException(ex, context, null); } } else { Utils.hideLoading(context); @@ -261,7 +263,7 @@ class _MarkAttendanceWidgetState extends State { Future performQrCodeAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { var qrCodeValue = await Navigator.of(context).push( MaterialPageRoute( - builder: (context) => QrScannerDialog(), + builder: (BuildContext context) => QrScannerDialog(), ), ); if (qrCodeValue != null) { @@ -279,9 +281,7 @@ class _MarkAttendanceWidgetState extends State { } catch (ex) { print(ex); Utils.hideLoading(context); - Utils.handleException(ex, context, (msg) { - Utils.confirmDialog(context, msg); - }); + Utils.handleException(ex, context, null); } } } @@ -295,9 +295,7 @@ class _MarkAttendanceWidgetState extends State { } catch (ex) { print(ex); Utils.hideLoading(context); - Utils.handleException(ex, context, (msg) { - Utils.confirmDialog(context, msg); - }); + Utils.handleException(ex, context, null); } } From be58dfdee18b3ea56338cce32c2e95a700322a89 Mon Sep 17 00:00:00 2001 From: "mirza.shafique" Date: Tue, 24 Jan 2023 15:58:06 +0300 Subject: [PATCH 5/5] isAuthentication fixed in API Client --- lib/api/api_client.dart | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index da80da3..1a70428 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -92,10 +92,6 @@ class ApiClient { AppState().setIsAuthenticated = false; } -// else if (jsonData["ErrorEndUserMessage"] != null && jsonData["ErrorEndUserMessage"].toString().contains("MBL-APP-375")) { -// print("Custom:${jsonData["ErrorEndUserMessage"]}"); -// AppState().setIsAuthenticated = false; -// } if (jsonData["ErrorMessage"] == null && jsonData["MessageStatus"] == 1) { return factoryConstructor(jsonData);