|
|
|
@ -157,7 +157,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
LocaleKeys.markAttendance.tr().toSectionHeading(),
|
|
|
|
LocaleKeys.markAttendance.tr().toSectionHeading(),
|
|
|
|
LocaleKeys.selectMethodOfAttendance.tr().toText11(color: const Color(0xff535353)),
|
|
|
|
LocaleKeys.selectMethodOfAttendance.tr().toText11(color: const Color(0xff535353)),
|
|
|
|
GridView(
|
|
|
|
GridView(
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
physics: const BouncingScrollPhysics(),
|
|
|
|
shrinkWrap: true,
|
|
|
|
shrinkWrap: true,
|
|
|
|
padding: const EdgeInsets.only(bottom: 0, top: 21),
|
|
|
|
padding: const EdgeInsets.only(bottom: 0, top: 21),
|
|
|
|
gridDelegate:
|
|
|
|
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") {
|
|
|
|
if (attendanceType == "NFC") {
|
|
|
|
performNfcAttendance(widget.model, lat: location.latitude.toString() ?? "", lng: location.longitude.toString() ?? "");
|
|
|
|
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;
|
|
|
|
requestCode = 0;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -506,7 +564,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
|
|
|
|
|
|
|
if (isConnected && AppState().isAuthenticated) {
|
|
|
|
if (isConnected && AppState().isAuthenticated) {
|
|
|
|
await WiFiForIoTPlugin.forceWifiUsage(true);
|
|
|
|
await WiFiForIoTPlugin.forceWifiUsage(true);
|
|
|
|
await Future.delayed(const Duration(seconds: 6));
|
|
|
|
// await Future.delayed(const Duration(seconds: 6));
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng);
|
|
|
|
GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng);
|
|
|
|
bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
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 {
|
|
|
|
Future<bool> closeWifiRequest() async {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
await WiFiForIoTPlugin.forceWifiUsage(false);
|
|
|
|
await WiFiForIoTPlugin.forceWifiUsage(false);
|
|
|
|
|