|
|
|
@ -12,6 +12,7 @@ import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/generic_response_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/privilege_list_model.dart';
|
|
|
|
|
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/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
@ -47,7 +48,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
void checkAttendanceAvailability() async {
|
|
|
|
|
bool isAvailable = await NfcManager.instance.isAvailable();
|
|
|
|
|
setState(() {
|
|
|
|
|
AppState().privilegeListModel!.forEach((element) {
|
|
|
|
|
AppState().privilegeListModel!.forEach((PrivilegeListModel element) {
|
|
|
|
|
if (element.serviceName == "enableNFC") {
|
|
|
|
|
if (isAvailable) if (element.previlege ?? false) isNfcEnabled = true;
|
|
|
|
|
} else if (element.serviceName == "enableQR") {
|
|
|
|
@ -144,6 +145,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
|
|
|
|
|
Future<void> performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
|
|
|
|
|
Utils.readNFc(onRead: (String nfcId) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
@ -152,7 +154,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (cxt) => ConfirmDialog(
|
|
|
|
|
builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
|
message: g?.errorEndUserMessage ?? "Unexpected error occurred",
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
@ -172,9 +174,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
}
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.handleException(ex, context, (msg) {
|
|
|
|
|
Utils.confirmDialog(context, msg);
|
|
|
|
|
});
|
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
@ -186,7 +186,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (cxt) => ConfirmDialog(
|
|
|
|
|
builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
|
message: g?.errorEndUserMessage ?? "Unexpected error occurred",
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
@ -206,7 +206,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
print(ex);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.handleException(ex, context, (msg) {
|
|
|
|
|
Utils.handleException(ex, context, (String msg) {
|
|
|
|
|
Utils.confirmDialog(context, msg);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -219,19 +219,23 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
bool isConnected = await WiFiForIoTPlugin.connect(AppState().getMohemmWifiSSID ?? "",
|
|
|
|
|
password: AppState().getMohemmWifiPassword ?? "", joinOnce: Platform.isIOS ? false : true, security: NetworkSecurity.WPA, withInternet: false);
|
|
|
|
|
if (isConnected) {
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
await closeWifiRequest();
|
|
|
|
|
await Future.delayed(Duration(seconds: 6));
|
|
|
|
|
} else {
|
|
|
|
|
await WiFiForIoTPlugin.forceWifiUsage(true);
|
|
|
|
|
}
|
|
|
|
|
// if (Platform.isIOS) {
|
|
|
|
|
// await closeWifiRequest();
|
|
|
|
|
// await Future.delayed(Duration(seconds: 6));
|
|
|
|
|
// } else {
|
|
|
|
|
// await WiFiForIoTPlugin.forceWifiUsage(true);
|
|
|
|
|
// }
|
|
|
|
|
await WiFiForIoTPlugin.forceWifiUsage(true);
|
|
|
|
|
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);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
|
await closeWifiRequest();
|
|
|
|
|
}
|
|
|
|
|
// if (Platform.isAndroid) {
|
|
|
|
|
// await closeWifiRequest();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
await closeWifiRequest();
|
|
|
|
|
showMDialog(
|
|
|
|
|
context,
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
@ -241,9 +245,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
await closeWifiRequest();
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.handleException(ex, context, (msg) {
|
|
|
|
|
Utils.confirmDialog(context, msg);
|
|
|
|
|
});
|
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
@ -261,7 +263,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
Future<void> performQrCodeAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
|
var qrCodeValue = await Navigator.of(context).push(
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => QrScannerDialog(),
|
|
|
|
|
builder: (BuildContext context) => QrScannerDialog(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
if (qrCodeValue != null) {
|
|
|
|
@ -279,9 +281,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
print(ex);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.handleException(ex, context, (msg) {
|
|
|
|
|
Utils.confirmDialog(context, msg);
|
|
|
|
|
});
|
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -295,9 +295,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
print(ex);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.handleException(ex, context, (msg) {
|
|
|
|
|
Utils.confirmDialog(context, msg);
|
|
|
|
|
});
|
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|