Updates & fixes

development_haroon_merge_aamir
haroon amjad 2 years ago
parent 1a8db3b0ee
commit e39526b5eb

@ -90,7 +90,7 @@ class AppState {
String get getHuaweiPushToken => _huaweiPushToken; String get getHuaweiPushToken => _huaweiPushToken;
final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 4.9, mobileType: Platform.isAndroid ? "android" : "ios"); final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 5.0, mobileType: Platform.isAndroid ? "android" : "ios");
void setPostParamsInitConfig() { void setPostParamsInitConfig() {
isAuthenticated = false; isAuthenticated = false;

@ -109,7 +109,10 @@ class AppNotifications {
debugPrint("HUAWEI PUSH TOKEN: $_huaweiToken"); debugPrint("HUAWEI PUSH TOKEN: $_huaweiToken");
} }
void _onTokenError(Object error) {} void _onTokenError(Object error) {
debugPrint("HUAWEI PUSH TOKEN ERROR: $error");
Utils.hideLoading(context);
}
Future<void> initTokenStream(Function loginCallback) async { Future<void> initTokenStream(Function loginCallback) async {
huawei_push.Push.getTokenStream.listen(_onTokenEvent, onError: _onTokenError).onData((data) { huawei_push.Push.getTokenStream.listen(_onTokenEvent, onError: _onTokenError).onData((data) {

@ -10,6 +10,4 @@ extension IntExtensions on int {
Widget get divider => Divider(height: toDouble(), thickness: toDouble(), color: MyColors.lightGreyEFColor); Widget get divider => Divider(height: toDouble(), thickness: toDouble(), color: MyColors.lightGreyEFColor);
Widget get makeItSquare => SizedBox(width: toDouble(), height: toDouble()); Widget get makeItSquare => SizedBox(width: toDouble(), height: toDouble());
} }

@ -103,6 +103,7 @@ class _LoginScreenState extends State<LoginScreen> {
try { try {
if (!(await Utils.isGoogleServicesAvailable())) { if (!(await Utils.isGoogleServicesAvailable())) {
print("HUAWEI APPPP GALLERYYYY!!!!"); print("HUAWEI APPPP GALLERYYYY!!!!");
AppNotifications().init(firebaseToken, context);
AppState().setIsHuawei = true; AppState().setIsHuawei = true;
AppNotifications().initHuaweiPush(checkLoginInfo); AppNotifications().initHuaweiPush(checkLoginInfo);
} else { } else {

@ -47,15 +47,6 @@ class Location {
Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((value) { Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((value) {
done(value); done(value);
}); });
// Geolocator.getLastKnownPosition(forceAndroidLocationManager: true).then((value) {
// if (value == null) {
// Geolocator.getCurrentPosition().then((value) {
// done(value);
// });
// } else {
// done(value);
// }
// });
} else { } else {
// AppPermissions // AppPermissions
} }

@ -1,13 +1,11 @@
import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:huawei_location/location/fused_location_provider_client.dart'; import 'package:huawei_location/huawei_location.dart';
import 'package:huawei_location/location/location_request.dart';
import 'package:huawei_location/location/location_settings_request.dart';
import 'package:huawei_location/permission/permission_handler.dart';
import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; import 'package:mohem_flutter_app/api/dashboard_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/colors.dart';
@ -21,7 +19,7 @@ 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/ui/dialogs/success_dialog.dart';
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart'; import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart'; import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart';
import 'package:mohem_flutter_app/widgets/location/Location.dart'; import 'package:mohem_flutter_app/widgets/location/Location.dart' as location;
import 'package:mohem_flutter_app/widgets/nfc/nfc_reader_sheet.dart'; import 'package:mohem_flutter_app/widgets/nfc/nfc_reader_sheet.dart';
import 'package:mohem_flutter_app/widgets/qr_scanner_dialog.dart'; import 'package:mohem_flutter_app/widgets/qr_scanner_dialog.dart';
import 'package:nfc_manager/nfc_manager.dart'; import 'package:nfc_manager/nfc_manager.dart';
@ -75,26 +73,61 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
} }
void checkHuaweiLocationPermission(String attendanceType) async { void checkHuaweiLocationPermission(String attendanceType) async {
PermissionHandler permissionHandler = PermissionHandler(); // Permission_Handler permissionHandler = PermissionHandler();
location.Location.isEnabled((bool isEnabled) async {
if (await permissionHandler.hasLocationPermission()) { if (isEnabled) {
getHuaweiCurrentLocation(attendanceType); location.Location.havePermission((bool permission) async {
} else { if (permission) {
bool has = await requestPermissions(); getHuaweiCurrentLocation(attendanceType);
if (has) { } else {
getHuaweiCurrentLocation(attendanceType); bool has = await requestPermissions();
if (has) {
getHuaweiCurrentLocation(attendanceType);
} else {
showDialog(
context: context,
builder: (BuildContext cxt) => ConfirmDialog(
message: "You need to give location permission to mark attendance",
onTap: () {
Navigator.pop(context);
},
),
);
}
}
});
} else { } else {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext cxt) => ConfirmDialog( builder: (BuildContext cxt) => ConfirmDialog(
message: "You need to give location permission to mark attendance", message: "You need to enable location services to mark attendance",
onTap: () { onTap: () async {
Navigator.pop(context); Navigator.pop(context);
await Geolocator.openLocationSettings();
}, },
), ),
); );
} }
} });
// if (await permissionHandler.hasLocationPermission()) {
// getHuaweiCurrentLocation(attendanceType);
// } else {
// bool has = await requestPermissions();
// if (has) {
// getHuaweiCurrentLocation(attendanceType);
// } else {
// showDialog(
// context: context,
// builder: (BuildContext cxt) => ConfirmDialog(
// message: "You need to give location permission to mark attendance",
// onTap: () {
// Navigator.pop(context);
// },
// ),
// );
// }
// }
} }
Future<bool> requestPermissions() async { Future<bool> requestPermissions() async {
@ -134,11 +167,11 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
if (AppState().getIsHuawei) { if (AppState().getIsHuawei) {
checkHuaweiLocationPermission("NFC"); checkHuaweiLocationPermission("NFC");
} else { } else {
Location.isEnabled((bool isEnabled) { location.Location.isEnabled((bool isEnabled) {
if (isEnabled) { if (isEnabled) {
Location.havePermission((bool permission) { location.Location.havePermission((bool permission) {
if (permission) { if (permission) {
Location.getCurrentLocation( location.Location.getCurrentLocation(
(Position position, bool isMocked) { (Position position, bool isMocked) {
if (isMocked) { if (isMocked) {
markFakeAttendance("NFC", position.latitude.toString() ?? "", position.longitude.toString() ?? ""); markFakeAttendance("NFC", position.latitude.toString() ?? "", position.longitude.toString() ?? "");
@ -181,11 +214,11 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
if (AppState().getIsHuawei) { if (AppState().getIsHuawei) {
checkHuaweiLocationPermission("WIFI"); checkHuaweiLocationPermission("WIFI");
} else { } else {
Location.isEnabled((bool isEnabled) { location.Location.isEnabled((bool isEnabled) {
if (isEnabled) { if (isEnabled) {
Location.havePermission((bool permission) { location.Location.havePermission((bool permission) {
if (permission) { if (permission) {
Location.getCurrentLocation( location.Location.getCurrentLocation(
(Position position, bool isMocked) { (Position position, bool isMocked) {
if (isMocked) { if (isMocked) {
markFakeAttendance("WIFI", position.latitude.toString() ?? "", position.longitude.toString() ?? ""); markFakeAttendance("WIFI", position.latitude.toString() ?? "", position.longitude.toString() ?? "");
@ -228,11 +261,11 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
if (AppState().getIsHuawei) { if (AppState().getIsHuawei) {
checkHuaweiLocationPermission("QR"); checkHuaweiLocationPermission("QR");
} else { } else {
Location.isEnabled((bool isEnabled) { location.Location.isEnabled((bool isEnabled) {
if (isEnabled) { if (isEnabled) {
Location.havePermission((bool permission) { location.Location.havePermission((bool permission) {
if (permission) { if (permission) {
Location.getCurrentLocation( location.Location.getCurrentLocation(
(Position position, bool isMocked) { (Position position, bool isMocked) {
if (isMocked) { if (isMocked) {
markFakeAttendance("QR", position.latitude.toString() ?? "", position.longitude.toString() ?? ""); markFakeAttendance("QR", position.latitude.toString() ?? "", position.longitude.toString() ?? "");
@ -277,49 +310,70 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
); );
} }
void getHuaweiCurrentLocation(String attendanceType) { void getHuaweiCurrentLocation(String attendanceType) async {
try { try {
Utils.showLoading(context);
FusedLocationProviderClient locationService = FusedLocationProviderClient(); FusedLocationProviderClient locationService = FusedLocationProviderClient();
LocationRequest locationRequest = LocationRequest(); LocationRequest locationRequest = LocationRequest();
locationRequest.priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY; locationRequest.priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
locationRequest.interval = 1000; locationRequest.interval = 500;
List<LocationRequest> locationRequestList = <LocationRequest>[locationRequest]; List<LocationRequest> locationRequestList = <LocationRequest>[locationRequest];
LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList); LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList);
locationService.checkLocationSettings(locationSettingsRequest).then((settings) async { late StreamSubscription<Location> _streamSubscription;
await locationService.getLastLocation().then((value) { int requestCode = (await (locationService.requestLocationUpdates(locationRequest)))!;
if (value.latitude == null || value.longitude == null) {
showDialog( _streamSubscription = locationService.onLocationData!.listen(
context: context, (Location location) async {
builder: (BuildContext cxt) => ConfirmDialog( Utils.hideLoading(context);
message: "Unable to get your location, Please check your location settings & try again.", await locationService.removeLocationUpdates(requestCode);
onTap: () { if (attendanceType == "QR") {
Navigator.pop(context); performQrCodeAttendance(widget.model, lat: location.latitude.toString() ?? "", lng: location.longitude.toString() ?? "");
},
),
);
} 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) { if (attendanceType == "WIFI") {
print("HUAWEI LOCATION getLastLocation ERROR!!!!!"); performWifiAttendance(widget.model, lat: location.latitude.toString() ?? "", lng: location.longitude.toString() ?? "");
print(error); }
}); if (attendanceType == "NFC") {
}).catchError((error) { performNfcAttendance(widget.model, lat: location.latitude.toString() ?? "", lng: location.longitude.toString() ?? "");
print("HUAWEI LOCATION checkLocationSettings ERROR!!!!!"); }
print(error); requestCode = 0;
if (error.code == "LOCATION_SETTINGS_NOT_AVAILABLE") { },
// Location service not enabled. );
}
}); // 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.
// }
// });
} catch (error) { } catch (error) {
print("HUAWEI LOCATION ERROR!!!!!"); print("HUAWEI LOCATION ERROR!!!!!");
print(error); print(error);

@ -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. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 3.2.93+300032 version: 3.2.991+300039
environment: environment:
sdk: ">=2.16.0 <3.0.0" sdk: ">=2.16.0 <3.0.0"
@ -46,7 +46,7 @@ dependencies:
local_auth: ^1.1.9 local_auth: ^1.1.9
fluttertoast: ^8.0.8 fluttertoast: ^8.0.8
syncfusion_flutter_calendar: ^19.4.48 syncfusion_flutter_calendar: ^19.4.48
# flutter_calendar_carousel: ^2.1.0 # flutter_calendar_carousel: ^2.1.0
pie_chart: ^5.1.0 pie_chart: ^5.1.0
shared_preferences: ^2.0.12 shared_preferences: ^2.0.12
firebase_messaging: ^13.0.4 firebase_messaging: ^13.0.4
@ -54,9 +54,9 @@ dependencies:
logger: ^1.1.0 logger: ^1.1.0
flutter_countdown_timer: ^4.1.0 flutter_countdown_timer: ^4.1.0
nfc_manager: ^3.2.0 nfc_manager: ^3.2.0
# uuid: ^3.0.6 # uuid: ^3.0.6
# device_info_plus: ^4.0.0 # device_info_plus: ^4.0.0
# android_id: ^0.1.3+1 # android_id: ^0.1.3+1
platform_device_id: ^1.0.1 platform_device_id: ^1.0.1
image_picker: ^0.8.5+3 image_picker: ^0.8.5+3
file_picker: ^4.6.1 file_picker: ^4.6.1
@ -66,21 +66,21 @@ dependencies:
open_file: ^3.2.1 open_file: ^3.2.1
wifi_iot: ^0.3.18 wifi_iot: ^0.3.18
flutter_html: ^3.0.0-alpha.6 flutter_html: ^3.0.0-alpha.6
# flutter_barcode_scanner: ^2.0.0 # flutter_barcode_scanner: ^2.0.0
qr_code_scanner: ^1.0.1 qr_code_scanner: ^1.0.1
# qr_flutter: ^4.0.0 # qr_flutter: ^4.0.0
url_launcher: ^6.0.15 url_launcher: ^6.0.15
share: 2.0.4 share: 2.0.4
flutter_rating_bar: ^4.0.1 flutter_rating_bar: ^4.0.1
auto_size_text: ^3.0.0 auto_size_text: ^3.0.0
pull_to_refresh: ^2.0.0 pull_to_refresh: ^2.0.0
# lottie json animations # lottie json animations
lottie: any lottie: any
# Marathon Card Swipe # Marathon Card Swipe
appinio_swiper: ^1.1.1 appinio_swiper: ^1.1.1
expandable: ^5.0.1 expandable: ^5.0.1
# networkImage # networkImage
cached_network_image: ^3.2.2 cached_network_image: ^3.2.2
#Chat #Chat
@ -101,12 +101,13 @@ dependencies:
video_player: ^2.5.1 video_player: ^2.5.1
just_audio: ^0.9.30 just_audio: ^0.9.30
# safe_device: ^1.1.2 # safe_device: ^1.1.2
flutter_layout_grid: ^2.0.1 flutter_layout_grid: ^2.0.1
#Huawei Dependencies #Huawei Dependencies
# huawei_hmsavailability: ^6.6.0+300 # huawei_hmsavailability: ^6.6.0+300
huawei_location: 6.0.0+302 # huawei_location: 6.0.0+302
huawei_location: ^6.11.0+301
huawei_push: ^6.7.0+300 huawei_push: ^6.7.0+300
firebase_crashlytics: ^2.9.0 firebase_crashlytics: ^2.9.0
@ -114,7 +115,7 @@ dependencies:
carousel_slider: ^4.2.1 carousel_slider: ^4.2.1
#Huawei Specified #Huawei Specified
# store_checker: ^1.1.0 # store_checker: ^1.1.0
google_api_availability: ^3.0.1 google_api_availability: ^3.0.1

Loading…
Cancel
Save