|
|
|
@ -85,14 +85,14 @@ class SwipeGeneralUtils {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void showErrorDialog({String ?message, required BuildContext context}) {
|
|
|
|
void showErrorDialog({String? message, required BuildContext context}) {
|
|
|
|
showDialog(
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
builder: (context) => ConfirmDialog(message: message, title: 'Error', onTap: () => Navigator.pop(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(
|
|
|
|
return showDialog(
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: isDismissable,
|
|
|
|
barrierDismissible: isDismissable,
|
|
|
|
@ -137,7 +137,7 @@ class SwipeGeneralUtils {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//huawei permission part....
|
|
|
|
//huawei permission part....
|
|
|
|
void getHuaweiCurrentLocation({SwipeTypeEnum ?attendanceType, required BuildContext context}) async {
|
|
|
|
void getHuaweiCurrentLocation({SwipeTypeEnum? attendanceType, required BuildContext context}) async {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
showLoading(context);
|
|
|
|
showLoading(context);
|
|
|
|
FusedLocationProviderClient locationService = FusedLocationProviderClient()..initFusedLocationService();
|
|
|
|
FusedLocationProviderClient locationService = FusedLocationProviderClient()..initFusedLocationService();
|
|
|
|
@ -153,7 +153,7 @@ class SwipeGeneralUtils {
|
|
|
|
(Location location) async {
|
|
|
|
(Location location) async {
|
|
|
|
hideLoading(context);
|
|
|
|
hideLoading(context);
|
|
|
|
await locationService.removeLocationUpdates(requestCode);
|
|
|
|
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;
|
|
|
|
requestCode = 0;
|
|
|
|
_streamSubscription.cancel();
|
|
|
|
_streamSubscription.cancel();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -173,7 +173,7 @@ class SwipeGeneralUtils {
|
|
|
|
return (result[Permission.location] == PermissionStatus.granted || result[Permission.locationAlways] == PermissionStatus.granted);
|
|
|
|
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();
|
|
|
|
// Permission_Handler permissionHandler = PermissionHandler();
|
|
|
|
LocationUtilities.isEnabled((bool isEnabled) async {
|
|
|
|
LocationUtilities.isEnabled((bool isEnabled) async {
|
|
|
|
if (isEnabled) {
|
|
|
|
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) {
|
|
|
|
switch (swipeType) {
|
|
|
|
case SwipeTypeEnum.NFC:
|
|
|
|
case SwipeTypeEnum.NFC:
|
|
|
|
handleNfcAttendance(latitude: lat, longitude: long, context: context);
|
|
|
|
handleNfcAttendance(latitude: lat, longitude: long, context: context);
|
|
|
|
@ -249,7 +249,7 @@ class SwipeGeneralUtils {
|
|
|
|
return DateFormat.Hms().format(dateTime);
|
|
|
|
return DateFormat.Hms().format(dateTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> performQrCodeAttendance({double ?latitude, double? longitude,required BuildContext context}) async {
|
|
|
|
Future<void> performQrCodeAttendance({double? latitude, double? longitude, required BuildContext context}) async {
|
|
|
|
UserProvider userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
UserProvider userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
|
|
|
|
|
|
|
|
String qrCodeValue = await Navigator.of(context).push(
|
|
|
|
String qrCodeValue = await Navigator.of(context).push(
|
|
|
|
@ -267,7 +267,7 @@ class SwipeGeneralUtils {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
await userProvider.makeSwipe(model: swipeModel).then((swipeResponse) {
|
|
|
|
await userProvider.makeSwipe(model: swipeModel).then((swipeResponse) {
|
|
|
|
if (swipeResponse.isSuccess==true) {
|
|
|
|
if (swipeResponse.isSuccess == true) {
|
|
|
|
hideLoading(context);
|
|
|
|
hideLoading(context);
|
|
|
|
Navigator.pushNamed(context, SwipeSuccessView.routeName);
|
|
|
|
Navigator.pushNamed(context, SwipeSuccessView.routeName);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -294,7 +294,7 @@ class SwipeGeneralUtils {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> handleNfcAttendance({double ?latitude = 0, double? longitude = 0,required BuildContext context}) async {
|
|
|
|
Future<void> handleNfcAttendance({double? latitude = 0, double? longitude = 0, required BuildContext context}) async {
|
|
|
|
// UserProvider _userProvider = Provider.of<UserProvider>(context,listen:false);
|
|
|
|
// UserProvider _userProvider = Provider.of<UserProvider>(context,listen:false);
|
|
|
|
|
|
|
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
@ -310,8 +310,8 @@ class SwipeGeneralUtils {
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _processNfcAttendance(
|
|
|
|
Future<void> _processNfcAttendance(
|
|
|
|
String nfcId,
|
|
|
|
String nfcId,
|
|
|
|
double ?latitude,
|
|
|
|
double? latitude,
|
|
|
|
double ?longitude,
|
|
|
|
double? longitude,
|
|
|
|
BuildContext context,
|
|
|
|
BuildContext context,
|
|
|
|
) async {
|
|
|
|
) async {
|
|
|
|
showLoading(context);
|
|
|
|
showLoading(context);
|
|
|
|
@ -321,7 +321,7 @@ class SwipeGeneralUtils {
|
|
|
|
|
|
|
|
|
|
|
|
final swipeResponse = await userProvider.makeSwipe(model: swipeModel);
|
|
|
|
final swipeResponse = await userProvider.makeSwipe(model: swipeModel);
|
|
|
|
|
|
|
|
|
|
|
|
if (swipeResponse.isSuccess==true) {
|
|
|
|
if (swipeResponse.isSuccess == true) {
|
|
|
|
hideLoading(context);
|
|
|
|
hideLoading(context);
|
|
|
|
Navigator.pushNamed(context, SwipeSuccessView.routeName);
|
|
|
|
Navigator.pushNamed(context, SwipeSuccessView.routeName);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -405,7 +405,7 @@ class SwipeGeneralUtils {
|
|
|
|
}, context));
|
|
|
|
}, context));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (kDebugMode) {
|
|
|
|
if (kDebugMode) {
|
|
|
|
userProvider.user!.enableWifi!= true;
|
|
|
|
userProvider.user!.enableWifi != true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (userProvider.user!.enableWifi!) {
|
|
|
|
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 {
|
|
|
|
NfcManager.instance.startSession(onDiscovered: (NfcTag tag) async {
|
|
|
|
MifareUltralight f;
|
|
|
|
MifareUltralight f;
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
@ -497,7 +497,7 @@ class SwipeGeneralUtils {
|
|
|
|
|
|
|
|
|
|
|
|
final swipeResponse = await userProvider.makeSwipe(model: swipeModel);
|
|
|
|
final swipeResponse = await userProvider.makeSwipe(model: swipeModel);
|
|
|
|
await closeWifiRequest();
|
|
|
|
await closeWifiRequest();
|
|
|
|
if (swipeResponse.isSuccess==true) {
|
|
|
|
if (swipeResponse.isSuccess == true) {
|
|
|
|
hideLoading(context);
|
|
|
|
hideLoading(context);
|
|
|
|
Navigator.pushNamed(context, SwipeSuccessView.routeName);
|
|
|
|
Navigator.pushNamed(context, SwipeSuccessView.routeName);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|