Compare commits

..

No commits in common. '01a35adebc5f48f5df7d759f49b9d19e6544f74a' and 'a472fa773ccf5dd7387ab62ca896e0175b8b4523' have entirely different histories.

@ -104,7 +104,7 @@ class _NfcLayoutState extends State<NfcLayout> {
setState(() { setState(() {
_reading = true; _reading = true;
// mainWidget = doneNfc(); mainWidget = doneNfc();
}); });
Future.delayed(const Duration(seconds: 1), () async { Future.delayed(const Duration(seconds: 1), () async {
@ -138,18 +138,22 @@ class _NfcLayoutState extends State<NfcLayout> {
Widget scanNfc() { Widget scanNfc() {
return Container( return Container(
color: AppColor.background(context), color: AppColor.background(context),
key: const ValueKey(1), key: ValueKey(1),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
Text( Text(
"Ready To Scan", "Ready To Scan",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24, color: AppColor.headingTextColor(context)), style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 24,
color:AppColor.headingTextColor(context)
), ),
const SizedBox( ),
SizedBox(
height: 30, height: 30,
), ),
Image.asset( Image.asset(
@ -192,7 +196,7 @@ class _NfcLayoutState extends State<NfcLayout> {
child: const Text("CANCEL"), child: const Text("CANCEL"),
), ),
), ),
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
], ],
@ -207,14 +211,18 @@ class _NfcLayoutState extends State<NfcLayout> {
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
Text( Text(
"Successfully Scanned", "Successfully Scanned",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24, color: AppColor.headingTextColor(context)), style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 24,
color:AppColor.headingTextColor(context)
), ),
const SizedBox( ),
SizedBox(
height: 30, height: 30,
), ),
Image.asset( Image.asset(
@ -224,16 +232,16 @@ class _NfcLayoutState extends State<NfcLayout> {
width: double.infinity, width: double.infinity,
color: AppColor.iconColor(context), color: AppColor.iconColor(context),
), ),
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
const Text( Text(
"Approach an NFC Tag", "Approach an NFC Tag",
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
), ),
), ),
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
ButtonTheme( ButtonTheme(
@ -251,13 +259,10 @@ class _NfcLayoutState extends State<NfcLayout> {
// }, // },
onPressed: null, onPressed: null,
// elevation: 0, // elevation: 0,
child: Text( child: Text("DONE",style: TextStyle(color: context.isDark?AppColor.primary10:null),),
"DONE",
style: TextStyle(color: context.isDark ? AppColor.primary10 : null),
),
), ),
), ),
const SizedBox( SizedBox(
height: 30, height: 30,
), ),
], ],

@ -20,21 +20,6 @@ class LocationUtilities {
Geolocator.isLocationServiceEnabled().then((value) => callback(value)); Geolocator.isLocationServiceEnabled().then((value) => callback(value));
} }
static Future<bool> isEnabledAsync() async {
return await Geolocator.isLocationServiceEnabled();
}
static Future<bool> havePermissionAsync() async {
LocationPermission permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
}
return permission == LocationPermission.always ||
permission == LocationPermission.whileInUse;
}
static bool _listeningSettingChange = true; static bool _listeningSettingChange = true;
static void listenGPS({bool change = true, Function(bool)? onChange}) async { static void listenGPS({bool change = true, Function(bool)? onChange}) async {
@ -59,59 +44,42 @@ class LocationUtilities {
completion(isGranted); completion(isGranted);
}); });
} }
static Future<void> getCurrentLocation(
Function(Position position, bool isMocked) callback,
Function(String error) errorCallBack,
BuildContext context,
) async {
debugPrint("📍 Fetching current location...");
try {
final position = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high,
timeLimit: const Duration(seconds: 10),
);
debugPrint("✅ Location: ${position.latitude}, ${position.longitude}");
callback(position, position.isMocked); static void getCurrentLocation(Function(Position position, bool isMocked) callback, Function errorCallBack, BuildContext context) {
} catch (e) { Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
debugPrint("❌ Primary location failed: $e"); bool isMocked = position.isMocked;
try { callback(position, isMocked);
final lastPosition = await Geolocator.getLastKnownPosition(); }).catchError((err) {
if (lastPosition != null) { errorCallBack();
debugPrint("⚠️ Using last known location"); });
callback(lastPosition, lastPosition.isMocked); // return;
return; // Permission.location.isGranted.then((isGranted) {
} // if (!isGranted) {
} catch (fallbackError) { // Permission.location.request().then((granted) {
debugPrint("❌ Fallback failed: $fallbackError"); // print("granted:$granted");
} // if (granted == PermissionStatus.granted) {
String message = "Unable to determine your location"; // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
final error = e.toString().toLowerCase(); // bool isMocked = position.isMocked;
if (error.contains("timeout")) { // callback(position, isMocked);
message = "Location request timed out. Please try again."; // }).catchError((err) {
} else if (error.contains("denied")) { // print("getCurrentPositionError:$err");
message = "Location permission denied."; // errorCallBack();
} else if (error.contains("disabled")) { // });
message = "Location services are disabled."; // } else {
} // errorCallBack();
errorCallBack(message); // }
} // });
} // } else {
// static void getCurrentLocation(Function(Position position, bool isMocked) callback, Function errorCallBack, BuildContext context) {
// Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) { // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
// bool isMocked = position.isMocked; // bool isMocked = position.isMocked;
// callback(position, isMocked); // callback(position, isMocked);
// }).catchError((err) { // }).catchError((err) {
// print("getCurrentPositionError:$err");
// errorCallBack(); // 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) { // // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
// // bool isMocked = position.isMocked; // // bool isMocked = position.isMocked;
// // callback(position, isMocked); // // callback(position, isMocked);
@ -119,40 +87,18 @@ class LocationUtilities {
// // print("getCurrentPositionError:$err"); // // print("getCurrentPositionError:$err");
// // errorCallBack(); // // errorCallBack();
// // }); // // });
// // } else { //
// // errorCallBack(); // // locationFun((granted) {
// // } // // if (granted) {
// // }); // // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((value) {
// // } else { // // done(value);
// // Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium, timeLimit: const Duration(seconds: 5)).then((position) {
// // bool isMocked = position.isMocked;
// // callback(position, isMocked);
// // }).catchError((err) { // // }).catchError((err) {
// // print("getCurrentPositionError:$err"); // // print("getCurrentPositionError:$err");
// // errorCallBack(); // // errorCallBack();
// // }); // // });
// // } else {
// // // AppPermissions
// // } // // }
// // }); // // }, context);
// // }
// // // 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);
// }
} }

@ -40,7 +40,7 @@ class SwipeGeneralUtils {
static bool get isLoading => _isLoadingVisible; static bool get isLoading => _isLoadingVisible;
void markFakeAttendance(dynamic sourceName, String lat, String long, {required BuildContext context}) async { void markFakeAttendance(dynamic sourceName, String lat, String long, @required BuildContext context) async {
showLoading(context); showLoading(context);
try { try {
hideLoading(navigatorKey.currentState!.overlay!.context); hideLoading(navigatorKey.currentState!.overlay!.context);
@ -114,33 +114,20 @@ class SwipeGeneralUtils {
} }
Widget attendanceTypeCard(String title, String icon, bool isEnabled, VoidCallback onPress, BuildContext context) { Widget attendanceTypeCard(String title, String icon, bool isEnabled, VoidCallback onPress, BuildContext context) {
return Container( return Container(
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(12),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isEnabled color: isEnabled ?context.isDark ? AppColor.neutral60 : Colors.white : AppColor.background(context),
? context.isDark
? AppColor.neutral60
: Colors.white
: AppColor.background(context),
borderRadius: BorderRadius.circular(18), borderRadius: BorderRadius.circular(18),
border: Border.all(color: context.isDark ? AppColor.neutral60 : Colors.white70, width: 2), border: Border.all(color:context.isDark ? AppColor.neutral60 : Colors.white70 , width: 2),
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
icon.toSvgAsset( icon.toSvgAsset(color: isEnabled ?context.isDark ? AppColor.neutral30 : AppColor.neutral50 : Colors.grey.withOpacity(0.5)),
color: isEnabled title.heading5(context).custom(color: isEnabled ?context.isDark ? AppColor.neutral30 : AppColor.neutral50 : Colors.grey.withOpacity(0.5)),
? context.isDark
? AppColor.neutral30
: AppColor.neutral50
: Colors.grey.withOpacity(0.5)),
title.heading5(context).custom(
color: isEnabled
? context.isDark
? AppColor.neutral30
: AppColor.neutral50
: Colors.grey.withOpacity(0.5)),
], ],
), ),
).onPress( ).onPress(
@ -349,127 +336,49 @@ class SwipeGeneralUtils {
} }
} }
Future<void> handleSwipe({ void handleSwipe({required SwipeTypeEnum swipeType, required bool isEnable, required BuildContext context}) async {
required SwipeTypeEnum swipeType,
required bool isEnable,
required BuildContext context,
}) async {
try {
if (Platform.isAndroid && !(await isGoogleServicesAvailable())) { if (Platform.isAndroid && !(await isGoogleServicesAvailable())) {
checkHuaweiLocationPermission( checkHuaweiLocationPermission(attendanceType: swipeType, context: context);
attendanceType: swipeType, } else {
context: context, LocationUtilities.isEnabled((bool isEnabled) {
); if (isEnabled) {
return; LocationUtilities.havePermission((bool permission) {
} if (permission) {
// Check if location is enabled
final isEnabled = await LocationUtilities.isEnabledAsync();
if (!isEnabled) {
showInfoDialog(
message: "You need to enable location services to mark attendance",
onTap: () async => await Geolocator.openLocationSettings(),
);
return;
}
// Check permission
final hasPermission = await LocationUtilities.havePermissionAsync();
if (!hasPermission) {
showInfoDialog(
message: "You need to give location permission to mark attendance",
onTap: () async => await Geolocator.openAppSettings(),
);
return;
}
// Show loader
showLoading(context); showLoading(context);
LocationUtilities.getCurrentLocation(
// Get location
await LocationUtilities.getCurrentLocation(
(Position position, bool isMocked) { (Position position, bool isMocked) {
hideLoading(context);
if (isMocked) { if (isMocked) {
markFakeAttendance( hideLoading(context);
swipeType.name, markFakeAttendance(swipeType.name, position.latitude.toString() ?? "", position.longitude.toString() ?? "", context);
position.latitude.toString(),
position.longitude.toString(),
context: context,
);
} else { } else {
handleSwipeOperation( hideLoading(context);
swipeType: swipeType, handleSwipeOperation(swipeType: swipeType, lat: position.latitude, long: position.longitude, context: context);
lat: position.latitude,
long: position.longitude,
context: context,
);
} }
}, },
(String error) { () {
hideLoading(context); hideLoading(context);
confirmDialog(context, "Unable to determine your location, Please make sure that your location services are turned on & working.");
confirmDialog(
context,
error.isNotEmpty ? error : "Unable to determine your location. Please try again.",
);
}, },
context, context,
); );
} catch (e) { } else {
hideLoading(context); showInfoDialog(
confirmDialog( message: "You need to give location permission to mark attendance",
context, onTap: () async {
"Something went wrong. Please try again.", await Geolocator.openAppSettings();
); });
debugPrint("❌ handleSwipe error: $e"); }
});
} else {
showInfoDialog(
message: "You need to enable location services to mark attendance",
onTap: () async {
await Geolocator.openLocationSettings();
});
}
});
} }
} }
//older code..
// void handleSwipe({required SwipeTypeEnum swipeType, required bool isEnable, required BuildContext context}) async {
// if (Platform.isAndroid && !(await isGoogleServicesAvailable())) {
// checkHuaweiLocationPermission(attendanceType: swipeType, context: context);
// } else {
// LocationUtilities.isEnabled((bool isEnabled) {
// if (isEnabled) {
// LocationUtilities.havePermission((bool permission) {
// if (permission) {
// showLoading(context);
// LocationUtilities.getCurrentLocation(
// (Position position, bool isMocked) {
// if (isMocked) {
// hideLoading(context);
// markFakeAttendance(swipeType.name, position.latitude.toString() ?? "", position.longitude.toString() ?? "", context);
// } else {
// hideLoading(context);
// handleSwipeOperation(swipeType: swipeType, lat: position.latitude, long: position.longitude, context: context);
// }
// },
// () {
// hideLoading(context);
// confirmDialog(context, "Unable to determine your location, Please make sure that your location services are turned on & working.");
// },
// context,
// );
// } else {
// showInfoDialog(
// message: "You need to give location permission to mark attendance",
// onTap: () async {
// await Geolocator.openAppSettings();
// });
// }
// });
// } else {
// showInfoDialog(
// message: "You need to enable location services to mark attendance",
// onTap: () async {
// await Geolocator.openLocationSettings();
// });
// }
// });
// }
// }
void showInfoDialog({required String message, VoidCallback? onTap}) { void showInfoDialog({required String message, VoidCallback? onTap}) {
showDialog( showDialog(
@ -525,15 +434,16 @@ class SwipeGeneralUtils {
), ),
backgroundColor: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
clipBehavior: Clip.antiAliasWithSaveLayer, clipBehavior: Clip.antiAliasWithSaveLayer,
builder: (BuildContext context) => Padding( builder: (BuildContext context) =>Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom + MediaQuery.of(context).padding.bottom, bottom: MediaQuery.of(context).viewInsets.bottom +
MediaQuery.of(context).padding.bottom,
), ),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
context.translation.markAttendance.heading4(context).custom(color: context.isDark ? AppColor.white50 : AppColor.white936), context.translation.markAttendance.heading4(context).custom(color:context.isDark?AppColor.white50: AppColor.white936),
8.height, 8.height,
context.translation.selectMethodToMarkAttendance.bodyText2(context).custom(color: AppColor.neutral120), context.translation.selectMethodToMarkAttendance.bodyText2(context).custom(color: AppColor.neutral120),
12.height, 12.height,

@ -44,7 +44,11 @@ class _UpdateUserContactInfoBottomSheetState extends State<UpdateUserContactInfo
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom + MediaQuery.of(context).padding.bottom,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@ -123,6 +127,7 @@ class _UpdateUserContactInfoBottomSheetState extends State<UpdateUserContactInfo
}, },
), ),
], ],
),
); );
} }
} }

Loading…
Cancel
Save