|
|
|
|
@ -1,34 +1,25 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
import 'package:geolocator/geolocator.dart';
|
|
|
|
|
import 'package:huawei_location/huawei_location.dart';
|
|
|
|
|
// import 'package:mohem_flutter_app/widgets/nfc/nfc_reader_sheet.dart';
|
|
|
|
|
// import 'package:mohem_flutter_app/widgets/qr_scanner_dialog.dart';
|
|
|
|
|
import 'package:nfc_manager/nfc_manager.dart';
|
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/dashboard_latest/dashboard_provider.dart';
|
|
|
|
|
// import 'package:platform_device_id/platform_device_id.dart';
|
|
|
|
|
import 'package:test_sa/dashboard_latest/widgets/app_bar_widget.dart';
|
|
|
|
|
import 'package:test_sa/extensions/enum_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/helper/utils.dart';
|
|
|
|
|
import 'package:test_sa/models/enums/swipe_type.dart';
|
|
|
|
|
import 'package:test_sa/models/lookup.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/swipe_model.dart';
|
|
|
|
|
import 'package:test_sa/nfc/nfc_reader_sheet.dart';
|
|
|
|
|
// import 'package:mohem_flutter_app/api/dashboard_api_client.dart';
|
|
|
|
|
// import 'package:mohem_flutter_app/app_state/app_state.dart';
|
|
|
|
|
// import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
|
// import 'package:mohem_flutter_app/classes/utils.dart';
|
|
|
|
|
// 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';
|
|
|
|
|
// import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart';im
|
|
|
|
|
|
|
|
|
|
import 'package:test_sa/utilities/Location.dart' as location;
|
|
|
|
|
import 'package:test_sa/views/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/dialogs/success_dialog.dart';
|
|
|
|
|
@ -174,7 +165,10 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
gridDelegate:
|
|
|
|
|
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: (MediaQuery.of(context).size.width < 550) ? 3 : 5, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8),
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
attendanceMethod("NFC", Icons.nfc, isNfcEnabled, () {
|
|
|
|
|
attendanceMethod(SwipeTypeEnum.NFC.name, Icons.nfc, true, () {
|
|
|
|
|
log('i am here...nfc');
|
|
|
|
|
handleSwipe(swipeType: SwipeTypeEnum.NFC, isEnable: true);
|
|
|
|
|
return;
|
|
|
|
|
// if (AppState().getIsHuawei) {
|
|
|
|
|
if (false) {
|
|
|
|
|
checkHuaweiLocationPermission("NFC");
|
|
|
|
|
@ -284,7 +278,9 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
// if (isQrEnabled) //todo
|
|
|
|
|
attendanceMethod("QR", Icons.qr_code_2, isQrEnabled, () async {
|
|
|
|
|
attendanceMethod(SwipeTypeEnum.QR.name, Icons.qr_code_2, true, () async {
|
|
|
|
|
handleSwipe(swipeType: SwipeTypeEnum.QR, isEnable: true);
|
|
|
|
|
return;
|
|
|
|
|
// if (AppState().getIsHuawei) {
|
|
|
|
|
if (false) {
|
|
|
|
|
checkHuaweiLocationPermission("QR");
|
|
|
|
|
@ -345,6 +341,77 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleSwipe({required SwipeTypeEnum swipeType,required bool isEnable,}){
|
|
|
|
|
log('handle swipe value is ${swipeType.name}');
|
|
|
|
|
// if (AppState().getIsHuawei) {
|
|
|
|
|
if (false) {
|
|
|
|
|
checkHuaweiLocationPermission("NFC");
|
|
|
|
|
} 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(swipeType.name, position.latitude.toString() ?? "", position.longitude.toString() ?? "");
|
|
|
|
|
} else {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
//todo performNfcAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? "");
|
|
|
|
|
handleSwipeOperation(swipeType: swipeType,lat: position.latitude,lang: position.longitude);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
() {
|
|
|
|
|
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();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleSwipeOperation({required SwipeTypeEnum swipeType,double ?lat, double ?lang}){
|
|
|
|
|
switch(swipeType){
|
|
|
|
|
case SwipeTypeEnum.NFC:
|
|
|
|
|
handleNfcAttendance(latitude: lat,longitude: lang);
|
|
|
|
|
return;
|
|
|
|
|
case SwipeTypeEnum.QR:
|
|
|
|
|
performQrCodeAttendance(latitude: lat,longitude: lang);
|
|
|
|
|
return;
|
|
|
|
|
case SwipeTypeEnum.Wifi:
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getHuaweiCurrentLocation(String attendanceType) async {
|
|
|
|
|
try {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
@ -399,93 +466,198 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }).catchError((error) {
|
|
|
|
|
// print("HUAWEI LOCATION getLastLocation ERROR!!!!!");
|
|
|
|
|
// print(error);
|
|
|
|
|
// log("HUAWEI LOCATION getLastLocation ERROR!!!!!");
|
|
|
|
|
// log(error);
|
|
|
|
|
// });
|
|
|
|
|
// }).catchError((error) {
|
|
|
|
|
// print("HUAWEI LOCATION checkLocationSettings ERROR!!!!!");
|
|
|
|
|
// print(error);
|
|
|
|
|
// log("HUAWEI LOCATION checkLocationSettings ERROR!!!!!");
|
|
|
|
|
// log(error);
|
|
|
|
|
// if (error.code == "LOCATION_SETTINGS_NOT_AVAILABLE") {
|
|
|
|
|
// // Location service not enabled.
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
} catch (error) {
|
|
|
|
|
print("HUAWEI LOCATION ERROR!!!!!");
|
|
|
|
|
print(error);
|
|
|
|
|
log("HUAWEI LOCATION ERROR!!!!!");
|
|
|
|
|
log('$error');
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
// Utils.handleException(error, context, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// 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 {
|
|
|
|
|
// GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId, isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng);
|
|
|
|
|
// if (g?.messageStatus != 1) {
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// showDialog(
|
|
|
|
|
// context: context,
|
|
|
|
|
// builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
|
// message: g?.errorEndUserMessage ?? "Unexpected error occurred",
|
|
|
|
|
// onTap: () {
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// } else {
|
|
|
|
|
// bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
|
// if (Platform.isIOS) await Future.delayed(const Duration(seconds: 3));
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// showMDialog(
|
|
|
|
|
// context,
|
|
|
|
|
// backgroundColor: Colors.transparent,
|
|
|
|
|
// isDismissable: true,
|
|
|
|
|
// child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// } catch (ex) {
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// Utils.handleException(ex, context, null);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// showNfcReader(context, onNcfScan: (String? nfcId) async {
|
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
|
// try {
|
|
|
|
|
// GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? "", isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng);
|
|
|
|
|
// if (g?.messageStatus != 1) {
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// showDialog(
|
|
|
|
|
// context: context,
|
|
|
|
|
// builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
|
// message: g?.errorEndUserMessage ?? "Unexpected error occurred",
|
|
|
|
|
// onTap: () {
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// } else {
|
|
|
|
|
// bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// showMDialog(
|
|
|
|
|
// context,
|
|
|
|
|
// backgroundColor: Colors.transparent,
|
|
|
|
|
// isDismissable: false,
|
|
|
|
|
// child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// } catch (ex) {
|
|
|
|
|
// print(ex);
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// // Utils.handleException(ex, context, (String msg) {
|
|
|
|
|
// // Utils.confirmDialog(context, msg);
|
|
|
|
|
// // });
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Future<void> handleNfcAttendance({double? latitude = 0, double? longitude = 0}) async {
|
|
|
|
|
final dashBoardProvider = Provider.of<DashBoardProvider>(context, listen: false);
|
|
|
|
|
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
Utils.readNFc(onRead: (String nfcId) async {
|
|
|
|
|
await _processNfcAttendance(dashBoardProvider, nfcId, latitude, longitude);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
showNfcReader(context, onNcfScan: (String? nfcId) async {
|
|
|
|
|
await _processNfcAttendance(dashBoardProvider, nfcId ?? '', latitude, longitude);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _processNfcAttendance(
|
|
|
|
|
DashBoardProvider dashBoardProvider,
|
|
|
|
|
String nfcId,
|
|
|
|
|
double? latitude,
|
|
|
|
|
double? longitude,
|
|
|
|
|
) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
final swipeModel = Swipe(
|
|
|
|
|
swipeTypeValue: SwipeTypeEnum.NFC.getIntFromSwipeTypeEnum(),
|
|
|
|
|
value: nfcId,
|
|
|
|
|
latitude: latitude,
|
|
|
|
|
longitude: longitude,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final swipeResponse = await dashBoardProvider.makeSwipe(model: swipeModel);
|
|
|
|
|
log('swipe response i got is ${swipeResponse.toJson()}');
|
|
|
|
|
|
|
|
|
|
if (swipeResponse.responseCode != 1) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
_showErrorDialog(swipeResponse.message ?? "Unexpected error occurred");
|
|
|
|
|
} else {
|
|
|
|
|
final isSuccess = swipeResponse.data;
|
|
|
|
|
log('nfc swipe response is ${isSuccess}');
|
|
|
|
|
if (Platform.isIOS) await Future.delayed(const Duration(seconds: 3));
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
_showSuccessDialog();
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
// Uncomment below line for error handling if needed
|
|
|
|
|
// Utils.handleException(error, context, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _showErrorDialog(String message) {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (context) => ConfirmDialog(
|
|
|
|
|
message: message,
|
|
|
|
|
onTap: () => Navigator.pop(context),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _showSuccessDialog() {
|
|
|
|
|
showMDialog(
|
|
|
|
|
context,
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
isDismissable: true,
|
|
|
|
|
child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//older code....
|
|
|
|
|
Future<void> performNfcAttendance({double? lat = 0, double ?lng = 0}) async {
|
|
|
|
|
DashBoardProvider dashBoardProvider = Provider.of<DashBoardProvider>(context,listen:false);
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
Utils.readNFc(onRead: (String nfcId) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
SwipeModel? swipeResponse = await dashBoardProvider.makeSwipe(model: Swipe(swipeTypeValue: SwipeTypeEnum.NFC.getIntFromSwipeTypeEnum(), value: '', latitude: lat, longitude: lng));
|
|
|
|
|
if (swipeResponse.responseCode != 1) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
|
message: swipeResponse.message ?? "Unexpected error occurred",
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
bool status = swipeResponse.data;
|
|
|
|
|
if (Platform.isIOS) await Future.delayed(const Duration(seconds: 3));
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
showMDialog(
|
|
|
|
|
context,
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
isDismissable: true,
|
|
|
|
|
child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
// Utils.handleException(ex, context, null);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
showNfcReader(context, onNcfScan: (String? nfcId) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
SwipeModel? swipeResponse = await dashBoardProvider.makeSwipe(model: Swipe(swipeTypeValue: SwipeTypeEnum.NFC.getIntFromSwipeTypeEnum(), value: nfcId??'', latitude: lat, longitude: lng));
|
|
|
|
|
log('api response i got is ${swipeResponse.toJson()}');
|
|
|
|
|
if (swipeResponse.responseCode != 1) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
|
message: swipeResponse.message ?? "Unexpected error occurred",
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
bool status = swipeResponse.data; //use this status to get transactions.
|
|
|
|
|
if (Platform.isIOS) await Future.delayed(const Duration(seconds: 3));
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
showMDialog(
|
|
|
|
|
context,
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
isDismissable: true,
|
|
|
|
|
child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
// Utils.handleException(ex, context, null);
|
|
|
|
|
}
|
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
|
// try {
|
|
|
|
|
// GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? "", isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng);
|
|
|
|
|
// if (g?.messageStatus != 1) {
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// showDialog(
|
|
|
|
|
// context: context,
|
|
|
|
|
// builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
|
// message: g?.errorEndUserMessage ?? "Unexpected error occurred",
|
|
|
|
|
// onTap: () {
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// } else {
|
|
|
|
|
// bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// showMDialog(
|
|
|
|
|
// context,
|
|
|
|
|
// backgroundColor: Colors.transparent,
|
|
|
|
|
// isDismissable: false,
|
|
|
|
|
// child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// } catch (ex) {
|
|
|
|
|
// log(ex);
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// // Utils.handleException(ex, context, (String msg) {
|
|
|
|
|
// // Utils.confirmDialog(context, msg);
|
|
|
|
|
// // });
|
|
|
|
|
// }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void showMDialog(context, {Widget? child, Color? backgroundColor, bool isDismissable = true, bool isBusniessCard = false}) async {
|
|
|
|
|
return showDialog(
|
|
|
|
|
@ -520,12 +692,14 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// Future<void> performWifiAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
|
// if (Platform.isAndroid) {
|
|
|
|
|
// if (!(await checkSession())) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//TODO need to confirm ....
|
|
|
|
|
// Future<void> performWifiAttendance({double? latitude, double? lng}) async {
|
|
|
|
|
// // if (Platform.isAndroid) {
|
|
|
|
|
// // if (!(await checkSession())) {
|
|
|
|
|
// // return;
|
|
|
|
|
// // }
|
|
|
|
|
// // }
|
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
|
// bool isConnected = await WiFiForIoTPlugin.connect(AppState().getMohemmWifiSSID ?? "",
|
|
|
|
|
// password: AppState().getMohemmWifiPassword ?? "", joinOnce: Platform.isIOS ? false : true, security: NetworkSecurity.WPA, withInternet: false);
|
|
|
|
|
@ -588,54 +762,65 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
return await WiFiForIoTPlugin.disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Future<void> performQrCodeAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
|
// var qrCodeValue = await Navigator.of(context).push(
|
|
|
|
|
// MaterialPageRoute(
|
|
|
|
|
// builder: (BuildContext context) => QrScannerDialog(),
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// if (qrCodeValue != null) {
|
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
|
// try {
|
|
|
|
|
// GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 1, isGpsRequired: isQrLocationEnabled, lat: lat, long: lng, QRValue: qrCodeValue);
|
|
|
|
|
// bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
|
// 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: true,
|
|
|
|
|
// child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// } catch (ex) {
|
|
|
|
|
// print(ex);
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// Utils.handleException(ex, context, null);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
Future<void> performQrCodeAttendance( {double ? latitude , double ?longitude}) async {
|
|
|
|
|
DashBoardProvider dashBoardProvider = Provider.of<DashBoardProvider>(context,listen: false);
|
|
|
|
|
var qrCodeValue = await Navigator.of(context).push(
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (BuildContext context) => QrScannerDialog(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
if (qrCodeValue != null) {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
final swipeModel = Swipe(
|
|
|
|
|
swipeTypeValue: SwipeTypeEnum.QR.getIntFromSwipeTypeEnum(),
|
|
|
|
|
value: qrCodeValue,
|
|
|
|
|
latitude: latitude,
|
|
|
|
|
longitude: longitude,
|
|
|
|
|
);
|
|
|
|
|
log('model i got to scan qr is ${swipeModel.toJson()}');
|
|
|
|
|
final swipeResponse = await dashBoardProvider.makeSwipe(model: swipeModel);
|
|
|
|
|
log('response of swipe is ${swipeResponse.toJson()}');
|
|
|
|
|
|
|
|
|
|
bool status = await swipeResponse.data;
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
if (swipeResponse.responseCode == 2) {
|
|
|
|
|
showDialog(
|
|
|
|
|
barrierDismissible: true,
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (cxt) => ConfirmDialog(
|
|
|
|
|
message: swipeResponse.message ?? "",
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
onCloseTap: () {},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
showMDialog(
|
|
|
|
|
context,
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
isDismissable: true,
|
|
|
|
|
child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
log('$ex');
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
//this need to confirm where it comes..
|
|
|
|
|
// Utils.handleException(ex, context, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void markFakeAttendance(String sourceName, String lat, String long) async {
|
|
|
|
|
void markFakeAttendance(dynamic sourceName, String lat, String long) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
// await DashboardApiClient().markFakeLocation(sourceName: sourceName, lat: lat, long: long);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.confirmDialog(context, "LocaleKeys.fakeLocation.tr()");
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
print(ex);
|
|
|
|
|
log('$ex');
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
//Utils.handleException(ex, context, null);
|
|
|
|
|
}
|
|
|
|
|
@ -651,8 +836,11 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
begin: Alignment.topRight,
|
|
|
|
|
end: Alignment.bottomLeft,
|
|
|
|
|
colors: [
|
|
|
|
|
//MyColors.gradiantEndColor,
|
|
|
|
|
// MyColors.gradiantStartColor,
|
|
|
|
|
//ToDo set Colors according to design provided by designer...
|
|
|
|
|
Colors.blue,
|
|
|
|
|
Colors.green,
|
|
|
|
|
// AppColor.gradiantEndColor,
|
|
|
|
|
// MyColors.gradiantStartColor,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
@ -670,6 +858,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
),
|
|
|
|
|
).onPress(
|
|
|
|
|
() {
|
|
|
|
|
log('isEnabled is ${!isEnabled}');
|
|
|
|
|
if (!isEnabled) return;
|
|
|
|
|
onPress();
|
|
|
|
|
},
|
|
|
|
|
|