location checkin added.

mohemm_poc
taha.alam 1 year ago
parent c72189bb6b
commit ac82706eaa

@ -157,7 +157,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
LocaleKeys.markAttendance.tr().toSectionHeading(),
LocaleKeys.selectMethodOfAttendance.tr().toText11(color: const Color(0xff535353)),
GridView(
physics: const NeverScrollableScrollPhysics(),
physics: const BouncingScrollPhysics(),
shrinkWrap: true,
padding: const EdgeInsets.only(bottom: 0, top: 21),
gridDelegate:
@ -324,6 +324,59 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
});
}
}),
attendanceMethod("Location" ,"assets/images/ic_qr.svg", true, () async {
if (AppState().getIsHuawei) {
checkHuaweiLocationPermission("location");
} else {
location.Location.isEnabled((bool isEnabled) {
if (isEnabled) {
location.Location.havePermission((bool permission) {
if (permission) {
Utils.showLoading(context);
location.Location.getCurrentLocation(
(Position position, bool isMocked) {
if (isMocked) {
Utils.hideLoading(context);
markFakeAttendance("location", position.latitude.toString() ?? "", position.longitude.toString() ?? "");
} else {
Utils.hideLoading(context);
performLocationAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? "");
}
},
() {
Utils.hideLoading(context);
Utils.confirmDialog(context, "Unable to determine your location, Please make sure that your location services are turned on & working.");
},
context,
);
} else {
showDialog(
context: context,
builder: (BuildContext cxt) => ConfirmDialog(
message: "You need to give location permission to mark attendance",
onTap: () async {
Navigator.pop(context);
await Geolocator.openAppSettings();
},
),
);
}
});
} else {
showDialog(
context: context,
builder: (BuildContext cxt) => ConfirmDialog(
message: "You need to enable location services to mark attendance",
onTap: () async {
Navigator.pop(context);
await Geolocator.openLocationSettings();
},
),
);
}
});
}
}),
],
)
],
@ -357,6 +410,11 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
if (attendanceType == "NFC") {
performNfcAttendance(widget.model, lat: location.latitude.toString() ?? "", lng: location.longitude.toString() ?? "");
}
if (attendanceType == "location") {
performLocationAttendance(widget.model, lat: location.latitude.toString() ?? "", lng: location.longitude.toString() ?? "");
}
requestCode = 0;
},
);
@ -506,7 +564,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
if (isConnected && AppState().isAuthenticated) {
await WiFiForIoTPlugin.forceWifiUsage(true);
await Future.delayed(const Duration(seconds: 6));
// 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);
@ -547,6 +605,37 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
}
}
Future<void> performLocationAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
Utils.showLoading(context);
try {
GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng);
Utils.hideLoading(context);
if (g?.messageStatus == 2) {
showDialog(
barrierDismissible: true,
context: context,
builder: (cxt) => ConfirmDialog(
message: g?.errorEndUserMessage ?? "",
onTap: () {
Navigator.pop(context);
},
onCloseTap: () {},
),
);
} else {
showMDialog(
context,
backgroundColor: Colors.transparent,
isDismissable: false,
child: SuccessDialog(widget.isFromDashboard),
);
}
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
Future<bool> closeWifiRequest() async {
if (Platform.isAndroid) {
await WiFiForIoTPlugin.forceWifiUsage(false);

@ -66,7 +66,7 @@ dependencies:
month_picker_dialog: ^2.12.0
# open_file: ^3.2.1
open_filex: ^4.4.0
wifi_iot: ^0.3.18
wifi_iot: ^0.3.19+1
flutter_html: ^3.0.0-alpha.6
# flutter_barcode_scanner: ^2.0.0
qr_code_scanner: ^1.0.1

Loading…
Cancel
Save