From 7d0c5598a0102eceebe78dd55b4df8d1632fe985 Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Mon, 20 Feb 2023 17:23:52 +0300 Subject: [PATCH 1/8] QuickFix --- lib/ui/marathon/marathon_provider.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ui/marathon/marathon_provider.dart b/lib/ui/marathon/marathon_provider.dart index 65b9353..908a8c0 100644 --- a/lib/ui/marathon/marathon_provider.dart +++ b/lib/ui/marathon/marathon_provider.dart @@ -279,8 +279,8 @@ class MarathonProvider extends ChangeNotifier { oneSec, (Timer timer) async { if (totalSecondsToWaitForWinner == 1) { - await callGetSelectedWinnersApi().whenComplete(() => updateQuestionCardStatus(QuestionCardStatus.winnerFound)); timer.cancel(); + await callGetSelectedWinnersApi().whenComplete(() => updateQuestionCardStatus(QuestionCardStatus.winnerFound)); return; } else if (totalSecondsToWaitForWinner == 15) { totalSecondsToWaitForWinner--; @@ -353,12 +353,15 @@ class MarathonProvider extends ChangeNotifier { gapTimeImage = currentQuestion.gapImage; gapTimeText = currentQuestion.gapText; gapTimeType = currentQuestion.gapType; + + startTimerForQuestion(); + updateCardData(); if (Utils.isLoading) { Utils.hideLoading(AppRoutes.navigatorKey.currentContext!); } - startTimerForQuestion(); - updateCardData(); - totalMarathoners = await MarathonApiClient().getMarathonersCount(marathonId: marathonDetailModel.id!); + if (!AppState().getIsDemoMarathon) { + totalMarathoners = await MarathonApiClient().getMarathonersCount(marathonId: marathonDetailModel.id!); + } Navigator.pushReplacementNamed(AppRoutes.navigatorKey.currentContext!, AppRoutes.marathonScreen); } else { currentQuestion = AppState().getIsDemoMarathon From 8439b587591775c028bd067cae280b6334649dd5 Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Thu, 23 Feb 2023 17:22:54 +0300 Subject: [PATCH 2/8] Added Huawei Checks --- lib/app_state/app_state.dart | 2 +- lib/classes/notifications.dart | 23 ++++++++++++----------- lib/classes/utils.dart | 23 ++++++++++++++++++++++- lib/ui/login/login_screen.dart | 16 +++++++++------- pubspec.yaml | 6 +++++- 5 files changed, 49 insertions(+), 21 deletions(-) diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index 2395bc1..cbdcdd9 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -88,7 +88,7 @@ class AppState { String get getHuaweiPushToken => _huaweiPushToken; - final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 4.3, mobileType: Platform.isAndroid ? "android" : "ios"); + final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 4.4, mobileType: Platform.isAndroid ? "android" : "ios"); void setPostParamsInitConfig() { isAuthenticated = false; diff --git a/lib/classes/notifications.dart b/lib/classes/notifications.dart index f714662..fe50455 100644 --- a/lib/classes/notifications.dart +++ b/lib/classes/notifications.dart @@ -4,7 +4,7 @@ import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; -import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; +// import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; import 'package:huawei_push/huawei_push.dart' as huawei_push; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; @@ -19,7 +19,7 @@ class AppNotifications { factory AppNotifications() => _instance; - late HmsApiAvailability hmsApiAvailability; + // late HmsApiAvailability hmsApiAvailability; String _huaweiToken = ''; @@ -40,9 +40,9 @@ class AppNotifications { } void init(String? firebaseToken) async { - if (Platform.isAndroid) { - hmsApiAvailability = HmsApiAvailability(); - } + // if (Platform.isAndroid) { + // hmsApiAvailability = HmsApiAvailability(); + // } await requestPermissions(); AppState().setDeviceToken = firebaseToken; @@ -68,9 +68,10 @@ class AppNotifications { }); if (Platform.isAndroid) { - await hmsApiAvailability.isHMSAvailable().then((value) async { - if (value == 0) { - huawei_push.Push.enableLogger(); + // await hmsApiAvailability.isHMSAvailable().then((value) async { + if (await Utils.isAppInstalledFromHuawei() && !(await Utils.isGoogleServicesAvailable()) ) { + + huawei_push.Push.enableLogger(); var result = await huawei_push.Push.setAutoInitEnabled(true); huawei_push.Push.onNotificationOpenedApp.listen((message) { @@ -81,9 +82,9 @@ class AppNotifications { // newMessage(toFirebaseRemoteMessage(message)); }, onError: (e) => print(e.toString())); } - }).catchError((err) { - print(err); - }); + // }).catchError((err) { + // print(err); + // }); } } diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 076e8ab..0b3f8df 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -7,6 +7,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:fluttertoast/fluttertoast.dart'; +import 'package:google_api_availability/google_api_availability.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/config/routes.dart'; @@ -20,6 +21,7 @@ import 'package:mohem_flutter_app/widgets/loading_dialog.dart'; import 'package:nfc_manager/nfc_manager.dart'; import 'package:nfc_manager/platform_tags.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:store_checker/store_checker.dart'; // ignore_for_file: avoid_annotating_with_dynamic @@ -226,7 +228,6 @@ class Utils { return BoxDecoration( color: background, border: Border.all( - width: 1, // color: background // <--- border width here ), @@ -391,4 +392,24 @@ class Utils { print(err); }); } + + //HUAWEI DECISION MAKING + + static Future isAppInstalledFromHuawei() async { + Source installationSource = await StoreChecker.getSource; + + if (installationSource == Source.IS_INSTALLED_FROM_HUAWEI_APP_GALLERY) { + return true; + } + return false; + } + + static Future isGoogleServicesAvailable() async { + GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability(); + String status = availability.toString().split('.').last; + if (status == "success") { + return true; + } + return false; + } } diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index 1eab45c..a9b7bf2 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -5,11 +5,10 @@ import 'package:easy_localization/src/public_ext.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; +// import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; import 'package:mohem_flutter_app/api/login_api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; @@ -59,12 +58,12 @@ class _LoginScreenState extends State { bool isOnExternalStorage = false; bool isDevelopmentModeEnable = false; - late HmsApiAvailability hmsApiAvailability; + // late HmsApiAvailability hmsApiAvailability; @override void initState() { super.initState(); - hmsApiAvailability = HmsApiAvailability(); + // hmsApiAvailability = HmsApiAvailability(); // checkFirebaseToken(); // if (kReleaseMode) { // checkDeviceSafety(); @@ -92,6 +91,9 @@ class _LoginScreenState extends State { super.dispose(); } + + + String? firebaseToken; GetMobileLoginInfoListModel? loginInfo; @@ -100,8 +102,8 @@ class _LoginScreenState extends State { Utils.showLoading(context); if (Platform.isAndroid) { try { - await hmsApiAvailability.isHMSAvailable().then((value) async { - if (value == 0) { + // await hmsApiAvailability.isHMSAvailable().then((value) async { + if (await Utils.isAppInstalledFromHuawei() && !(await Utils.isGoogleServicesAvailable()) ) { AppState().setIsHuawei = true; AppNotifications().initHuaweiPush(checkLoginInfo); } else { @@ -112,7 +114,7 @@ class _LoginScreenState extends State { checkLoginInfo(); await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); } - }); + // }); } catch (ex) {} } else { await Firebase.initializeApp(); diff --git a/pubspec.yaml b/pubspec.yaml index 138fb63..0445b36 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -102,7 +102,7 @@ dependencies: flutter_layout_grid: ^2.0.1 #Huawei Dependencies - huawei_hmsavailability: ^6.6.0+300 +# huawei_hmsavailability: ^6.6.0+300 huawei_location: 6.0.0+302 huawei_push: ^6.7.0+300 firebase_crashlytics: ^2.9.0 @@ -110,6 +110,10 @@ dependencies: #Items for sale Image Carousel Slider carousel_slider: ^4.2.1 + #Huawei Specified + store_checker: ^1.1.0 + google_api_availability: ^3.0.1 + dependency_overrides: firebase_core_platform_interface: 4.5.1 From 601a0cdbfde45c9f197c54781292942998fa91b1 Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Sun, 26 Feb 2023 10:50:17 +0300 Subject: [PATCH 3/8] Added test Dialog for Huawei --- lib/classes/utils.dart | 5 +++++ lib/extensions/string_extensions.dart | 5 +++-- lib/ui/landing/dashboard_screen.dart | 25 ++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 0b3f8df..5d44ab8 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -404,6 +404,11 @@ class Utils { return false; } + static Future getInstallationSource() async { + Source installationSource = await StoreChecker.getSource; + return installationSource.toString().split(".")[1]; + } + static Future isGoogleServicesAvailable() async { GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability(); String status = availability.toString().split('.').last; diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index b9e1acd..45cfc05 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -22,7 +22,7 @@ extension TrimString on String { } } -String displayLocalizedContent({required bool isPhoneLangArabic,required int selectedLanguage,required String englishContent,required String arabicContent}) { +String displayLocalizedContent({required bool isPhoneLangArabic, required int selectedLanguage, required String englishContent, required String arabicContent}) { if (selectedLanguage == 1) { return englishContent; } else if (selectedLanguage == 2) { @@ -122,9 +122,10 @@ extension EmailValidator on String { decoration: isUnderLine ? TextDecoration.underline : null), ); - Widget toText16({Color? color, bool isUnderLine = false, bool isBold = false, int? maxlines, double? height}) => Text( + Widget toText16({Color? color, bool isUnderLine = false, bool isBold = false, int? maxlines, double? height, bool isCentered = false}) => Text( this, maxLines: maxlines, + textAlign: isCentered ? TextAlign.center : null, style: TextStyle( color: color ?? MyColors.darkTextColor, fontSize: 16, diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 1de8913..ea317d7 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -25,6 +25,7 @@ import 'package:mohem_flutter_app/ui/landing/widget/services_widget.dart'; import 'package:mohem_flutter_app/ui/marathon/marathon_provider.dart'; import 'package:mohem_flutter_app/ui/marathon/widgets/marathon_banner.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; +import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart'; import 'package:mohem_flutter_app/widgets/mark_attendance_widget.dart'; import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; import 'package:mohem_flutter_app/widgets/shimmer/offers_shimmer_widget.dart'; @@ -142,7 +143,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb data.fetchMenuEntries(); data.getCategoryOffersListAPI(context); marathonProvider.getMarathonDetailsFromApi(); - if(isFromInit) { + if (isFromInit) { checkERMChannel(); } if (!cProvider.disbaleChatForThisUser && !isFromInit) checkHubCon(); @@ -287,9 +288,27 @@ class _DashboardScreenState extends State with WidgetsBindingOb children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ LocaleKeys.welcomeBack.tr().toText14(color: MyColors.grey77Color), - (AppState().memberInformationList!.eMPLOYEENAME ?? "").toText24(isBold: true), + (AppState().memberInformationList!.eMPLOYEENAME ?? "").toText24(isBold: true).onPress(() async { + return showMDialog( + context, + backgroundColor: Colors.transparent, + isDismissable: true, + child: SizedBox( + width: MediaQuery.of(context).size.width / 2.2, + height: MediaQuery.of(context).size.width / 2.2, + child: Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25.0), + ), + child: Center( + child: "This app is installed from ${await Utils.getInstallationSource()}".toText16(isCentered: true), + ), + ), + ), + ); + }), 16.height, Row( children: [ From 990b830bfa9f507d74b645fcc3354e1a9b98b052 Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Sun, 26 Feb 2023 11:38:12 +0300 Subject: [PATCH 4/8] Added test Dialog for Huawei --- lib/classes/notifications.dart | 2 +- lib/ui/login/login_screen.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/classes/notifications.dart b/lib/classes/notifications.dart index fe50455..52bfd10 100644 --- a/lib/classes/notifications.dart +++ b/lib/classes/notifications.dart @@ -69,7 +69,7 @@ class AppNotifications { if (Platform.isAndroid) { // await hmsApiAvailability.isHMSAvailable().then((value) async { - if (await Utils.isAppInstalledFromHuawei() && !(await Utils.isGoogleServicesAvailable()) ) { + if (await Utils.isAppInstalledFromHuawei()) { huawei_push.Push.enableLogger(); var result = await huawei_push.Push.setAutoInitEnabled(true); diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index a9b7bf2..31cf19c 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -103,7 +103,7 @@ class _LoginScreenState extends State { if (Platform.isAndroid) { try { // await hmsApiAvailability.isHMSAvailable().then((value) async { - if (await Utils.isAppInstalledFromHuawei() && !(await Utils.isGoogleServicesAvailable()) ) { + if (await Utils.isAppInstalledFromHuawei() ) { AppState().setIsHuawei = true; AppNotifications().initHuaweiPush(checkLoginInfo); } else { From 8f1c223469dd2147722c14ffcf19b783c7b89554 Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Sun, 26 Feb 2023 11:41:53 +0300 Subject: [PATCH 5/8] removed google api availability --- lib/classes/utils.dart | 17 ++++++++--------- pubspec.yaml | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 5d44ab8..7d6903b 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -7,7 +7,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:fluttertoast/fluttertoast.dart'; -import 'package:google_api_availability/google_api_availability.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/config/routes.dart'; @@ -409,12 +408,12 @@ class Utils { return installationSource.toString().split(".")[1]; } - static Future isGoogleServicesAvailable() async { - GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability(); - String status = availability.toString().split('.').last; - if (status == "success") { - return true; - } - return false; - } + // static Future isGoogleServicesAvailable() async { + // GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability(); + // String status = availability.toString().split('.').last; + // if (status == "success") { + // return true; + // } + // return false; + // } } diff --git a/pubspec.yaml b/pubspec.yaml index 0445b36..7f88a34 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -112,7 +112,7 @@ dependencies: #Huawei Specified store_checker: ^1.1.0 - google_api_availability: ^3.0.1 +# google_api_availability: ^3.0.1 dependency_overrides: From 72501fd0d9bc7264a481e9b649b8ea84e73ce0cc Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 26 Feb 2023 11:46:24 +0300 Subject: [PATCH 6/8] ITG Ads fix --- lib/api/dashboard_api_client.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index 5126f6d..96dc988 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -204,6 +204,7 @@ Future setAdvertisementViewed(String masterID, int advertisementId) async { Map postParams = { "ItgNotificationMasterId": masterID, + "EmployeeNumber": AppState().memberInformationList!.eMPLOYEENUMBER.toString(), "ItgAdvertisement": {"advertisementId": advertisementId, "acknowledgment": true} //Mobile Id }; postParams.addAll(AppState().postParamsJson); From 4bac19f9b8569f3e08257ddbb5cb136bbc898f1e Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 26 Feb 2023 17:17:15 +0300 Subject: [PATCH 7/8] Platform ID & Huawei fixes --- lib/api/dashboard_api_client.dart | 6 +- lib/classes/utils.dart | 18 +++--- lib/ui/login/login_screen.dart | 5 +- lib/widgets/mark_attendance_widget.dart | 75 ++++++++++++++----------- pubspec.yaml | 9 ++- 5 files changed, 66 insertions(+), 47 deletions(-) diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index 96dc988..7555dc6 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -5,6 +5,7 @@ import 'package:mohem_flutter_app/api/api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/classes/date_uitl.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/models/dashboard/get_accrual_balances_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; @@ -12,6 +13,7 @@ import 'package:mohem_flutter_app/models/dashboard/list_menu.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/itg/itg_main_response.dart'; import 'package:mohem_flutter_app/models/itg/itg_response_model.dart'; +import 'package:platform_device_id/platform_device_id.dart'; import 'package:uuid/uuid.dart'; class DashboardApiClient { @@ -107,11 +109,11 @@ class DashboardApiClient { //Mark Attendance Future markAttendance({String lat = "0", String? long = "0", required int pointType, String nfcValue = "", bool isGpsRequired = false, String QRValue = ""}) async { String url = "${ApiConsts.swpRest}AuthenticateAndSwipeUserSupportNFC"; - var uuid = Uuid(); + // var uuid = Uuid(); // Generate a v4 (random) id Map postParams = { - "UID": uuid.v4(), //Mobile Id + "UID": await PlatformDeviceId.getDeviceId, //uuid.v4(), //Mobile Id "Latitude": lat, "Longitude": long, "QRValue": QRValue, diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 7d6903b..fb8e90f 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -7,6 +7,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:fluttertoast/fluttertoast.dart'; +import 'package:google_api_availability/google_api_availability.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/config/routes.dart'; @@ -393,7 +394,6 @@ class Utils { } //HUAWEI DECISION MAKING - static Future isAppInstalledFromHuawei() async { Source installationSource = await StoreChecker.getSource; @@ -408,12 +408,12 @@ class Utils { return installationSource.toString().split(".")[1]; } - // static Future isGoogleServicesAvailable() async { - // GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability(); - // String status = availability.toString().split('.').last; - // if (status == "success") { - // return true; - // } - // return false; - // } + static Future isGoogleServicesAvailable() async { + GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability(); + String status = availability.toString().split('.').last; + if (status == "success") { + return true; + } + return false; + } } diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index 31cf19c..2e14cab 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -103,10 +103,13 @@ class _LoginScreenState extends State { if (Platform.isAndroid) { try { // await hmsApiAvailability.isHMSAvailable().then((value) async { - if (await Utils.isAppInstalledFromHuawei() ) { + // if (await Utils.isAppInstalledFromHuawei() && !(await Utils.isGoogleServicesAvailable())) { + if (!(await Utils.isGoogleServicesAvailable())) { + print("HUAWEI APPPP GALLERYYYY!!!!"); AppState().setIsHuawei = true; AppNotifications().initHuaweiPush(checkLoginInfo); } else { + print("GOOGLE PLAY STOREEEE!!!!"); await Firebase.initializeApp(); _firebaseMessaging = FirebaseMessaging.instance; firebaseToken = await _firebaseMessaging.getToken(); diff --git a/lib/widgets/mark_attendance_widget.dart b/lib/widgets/mark_attendance_widget.dart index 7c7e672..2ffa961 100644 --- a/lib/widgets/mark_attendance_widget.dart +++ b/lib/widgets/mark_attendance_widget.dart @@ -192,42 +192,53 @@ class _MarkAttendanceWidgetState extends State { } void getHuaweiCurrentLocation(String attendanceType) { - FusedLocationProviderClient locationService = FusedLocationProviderClient(); - LocationRequest locationRequest = LocationRequest(); - locationRequest.priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY; - locationRequest.interval = 1000; - List locationRequestList = [locationRequest]; - LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList); + try { + FusedLocationProviderClient locationService = FusedLocationProviderClient(); + LocationRequest locationRequest = LocationRequest(); + locationRequest.priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY; + locationRequest.interval = 1000; + List locationRequestList = [locationRequest]; + LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList); - locationService.checkLocationSettings(locationSettingsRequest).then((settings) async { - await locationService.getLastLocation().then((value) { - if (value.latitude == null || value.longitude == null) { - showDialog( - context: context, - builder: (BuildContext cxt) => ConfirmDialog( - message: "Unable to get your location, Please check your location settings & try again.", - onTap: () { - Navigator.pop(context); - }, - ), - ); - } else { - if (attendanceType == "QR") { - performQrCodeAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); - } - if (attendanceType == "WIFI") { - performWifiAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); - } - if (attendanceType == "NFC") { - performNfcAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); + locationService.checkLocationSettings(locationSettingsRequest).then((settings) async { + await locationService.getLastLocation().then((value) { + if (value.latitude == null || value.longitude == null) { + showDialog( + context: context, + builder: (BuildContext cxt) => ConfirmDialog( + message: "Unable to get your location, Please check your location settings & try again.", + onTap: () { + Navigator.pop(context); + }, + ), + ); + } else { + if (attendanceType == "QR") { + performQrCodeAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); + } + if (attendanceType == "WIFI") { + performWifiAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); + } + if (attendanceType == "NFC") { + performNfcAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); + } } + }).catchError((error) { + print("HUAWEI LOCATION getLastLocation ERROR!!!!!"); + print(error); + }); + }).catchError((error) { + print("HUAWEI LOCATION checkLocationSettings ERROR!!!!!"); + print(error); + if (error.code == "LOCATION_SETTINGS_NOT_AVAILABLE") { + // Location service not enabled. } }); - }).catchError((error) { - if (error.code == "LOCATION_SETTINGS_NOT_AVAILABLE") { - // Location service not enabled. - } - }); + } catch(error) { + print("HUAWEI LOCATION ERROR!!!!!"); + print(error); + } + } Future performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async { diff --git a/pubspec.yaml b/pubspec.yaml index 7f88a34..fc040a7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 3.2.8+300028 +version: 3.2.91+300030 environment: sdk: ">=2.16.0 <3.0.0" @@ -54,7 +54,10 @@ dependencies: logger: ^1.1.0 flutter_countdown_timer: ^4.1.0 nfc_manager: ^3.2.0 - uuid: ^3.0.6 +# uuid: ^3.0.6 +# device_info_plus: ^4.0.0 +# android_id: ^0.1.3+1 + platform_device_id: ^1.0.1 image_picker: ^0.8.5+3 file_picker: ^4.6.1 geolocator: ^9.0.2 @@ -112,7 +115,7 @@ dependencies: #Huawei Specified store_checker: ^1.1.0 -# google_api_availability: ^3.0.1 + google_api_availability: ^3.0.1 dependency_overrides: From 379015ca6cc336f8c21513a9bd142b41919c5e72 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 26 Feb 2023 17:33:18 +0300 Subject: [PATCH 8/8] chat privilege added --- lib/ui/landing/dashboard_screen.dart | 102 +++++++++------------------ 1 file changed, 35 insertions(+), 67 deletions(-) diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index ea317d7..38644fe 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -17,6 +17,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/offers_and_discounts/get_offers_list.dart'; +import 'package:mohem_flutter_app/models/privilege_list_model.dart'; import 'package:mohem_flutter_app/provider/chat_provider_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/ui/landing/widget/app_drawer.dart'; @@ -62,7 +63,9 @@ class _DashboardScreenState extends State with WidgetsBindingOb data = Provider.of(context, listen: false); marathonProvider = Provider.of(context, listen: false); cProvider = Provider.of(context, listen: false); - _bHubCon(); + if (checkIfPrivilegedForChat()) { + _bHubCon(); + } _onRefresh(true); }); } @@ -166,15 +169,6 @@ class _DashboardScreenState extends State with WidgetsBindingOb "masterId": val.result!.data!.notificationMasterId, "advertisement": value.mohemmItgResponseItem!.result!.data!.advertisement, }); - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (BuildContext context) => ITGAdsScreen( - // addMasterId: val.result!.data!.notificationMasterId!, - // advertisement: value.mohemmItgResponseItem!.result!.data!.advertisement!, - // ), - // ), - // ); } } }, @@ -188,46 +182,6 @@ class _DashboardScreenState extends State with WidgetsBindingOb Widget build(BuildContext context) { return Scaffold( key: _scaffoldState, - // appBar: AppBar( - // actions: [ - // IconButton( - // onPressed: () { - // data.getITGNotification().then((val) { - // if (val!.result!.data != null) { - // print("-------------------- Survey ----------------------------"); - // if (val.result!.data!.notificationType == "Survey") { - // Navigator.pushNamed(context, AppRoutes.survey, arguments: val.result!.data); - // } else { - // print("------------------------------------------- Ads --------------------"); - // DashboardApiClient().getAdvertisementDetail(val.result!.data!.notificationMasterId ?? "").then( - // (value) { - // if (value!.mohemmItgResponseItem!.statusCode == 200) { - // if (value.mohemmItgResponseItem!.result!.data != null) { - // Navigator.pushNamed(context, AppRoutes.advertisement, arguments: { - // "masterId": val.result!.data!.notificationMasterId, - // "advertisement": value.mohemmItgResponseItem!.result!.data!.advertisement, - // }); - // - // // Navigator.push( - // // context, - // // MaterialPageRoute( - // // builder: (BuildContext context) => ITGAdsScreen( - // // addMasterId: val.result!.data!.notificationMasterId!, - // // advertisement: value.mohemmItgResponseItem!.result!.data!.advertisement!, - // // ), - // // ), - // // ); - // } - // } - // }, - // ); - // } - // } - // }); - // }, - // icon: Icon(Icons.add)) - // ], - // ), body: Column( children: [ Row( @@ -614,24 +568,28 @@ class _DashboardScreenState extends State with WidgetsBindingOb children: [ SvgPicture.asset( "assets/icons/chat/chat.svg", - color: currentIndex == 4 - ? MyColors.grey3AColor - : cProvider.disbaleChatForThisUser - ? MyColors.lightGreyE3Color - : MyColors.grey98Color, + color: !checkIfPrivilegedForChat() + ? MyColors.lightGreyE3Color + : currentIndex == 4 + ? MyColors.grey3AColor + : cProvider.disbaleChatForThisUser + ? MyColors.lightGreyE3Color + : MyColors.grey98Color, ).paddingAll(4), Consumer( builder: (BuildContext cxt, ChatProviderModel data, Widget? child) { - return Positioned( - right: 0, - top: 0, - child: Container( - padding: const EdgeInsets.only(left: 4, right: 4), - alignment: Alignment.center, - decoration: BoxDecoration(color: cProvider.disbaleChatForThisUser ? MyColors.pinkDarkColor : MyColors.redColor, borderRadius: BorderRadius.circular(17)), - child: data.chatUConvCounter.toString().toText10(color: Colors.white), - ), - ); + return !checkIfPrivilegedForChat() + ? const SizedBox() + : Positioned( + right: 0, + top: 0, + child: Container( + padding: const EdgeInsets.only(left: 4, right: 4), + alignment: Alignment.center, + decoration: BoxDecoration(color: cProvider.disbaleChatForThisUser ? MyColors.pinkDarkColor : MyColors.redColor, borderRadius: BorderRadius.circular(17)), + child: data.chatUConvCounter.toString().toText10(color: Colors.white), + ), + ); }, ), ], @@ -655,7 +613,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb } else if (index == 3) { Navigator.pushNamed(context, AppRoutes.itemsForSale); } else if (index == 4) { - if (!cProvider.disbaleChatForThisUser) { + if (!cProvider.disbaleChatForThisUser && checkIfPrivilegedForChat()) { Navigator.pushNamed(context, AppRoutes.chat); } } @@ -680,7 +638,17 @@ class _DashboardScreenState extends State with WidgetsBindingOb } } }); - Navigator.pushNamed(context, AppRoutes.offersAndDiscountsDetails, arguments: getOffersDetailList); } + + bool checkIfPrivilegedForChat() { + for (PrivilegeListModel element in AppState().privilegeListModel!) { + if (element.serviceName?.toLowerCase() == "chat") { + if (element.previlege != null) { + return element.previlege!; + } + } + } + return false; + } }