NFC Attendance implement 1.3

merge-requests/1/merge
devmirza121 4 years ago
parent 35d683a8ae
commit eb3ddb3d9e

@ -79,7 +79,7 @@ class LoginApiClient {
Future<GenericResponseModel?> checkActivationCode(bool isDeviceNFC, String? mobileNumber, String activationCode, String? pUserName) async { Future<GenericResponseModel?> checkActivationCode(bool isDeviceNFC, String? mobileNumber, String activationCode, String? pUserName) async {
String url = "${ApiConsts.erpRest}CheckActivationCode"; String url = "${ApiConsts.erpRest}CheckActivationCode";
Map<String, dynamic> postParams = {"isDeviceNFC": isDeviceNFC, "MobileNumber": mobileNumber, "activationCode": activationCode, "P_USER_NAME": pUserName}; Map<String, dynamic> postParams = {"IsDeviceNFC": isDeviceNFC, "MobileNumber": mobileNumber, "activationCode": activationCode, "P_USER_NAME": pUserName};
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject((json) {
GenericResponseModel responseData = GenericResponseModel.fromJson(json); GenericResponseModel responseData = GenericResponseModel.fromJson(json);

@ -46,7 +46,7 @@ class _TodayAttendanceScreenState extends State<TodayAttendanceScreen> {
bool isAvailable = await NfcManager.instance.isAvailable(); bool isAvailable = await NfcManager.instance.isAvailable();
setState(() { setState(() {
AppState().privilegeListModel!.forEach((element) { AppState().privilegeListModel!.forEach((element) {
// Check availability print(element.serviceName.toString() + " " + element.previlege.toString()); // Check availability
if (isAvailable) if (element.serviceName == "enableNFC") { if (isAvailable) if (element.serviceName == "enableNFC") {
// if (element.previlege ?? false) // if (element.previlege ?? false)
isNfcEnabled = true; isNfcEnabled = true;
@ -190,21 +190,26 @@ class _TodayAttendanceScreenState extends State<TodayAttendanceScreen> {
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8),
children: <Widget>[ children: <Widget>[
attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () {
showNfcReader(context, onNcfScan: (String? nfcId) async { if (isNfcLocationEnabled) {
print(nfcId); print("nfc location enabled");
Utils.showLoading(context); } else {
try { print("nfc not location enabled");
GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? ""); }
bool status = await model.fetchAttendanceTracking(); // showNfcReader(context, onNcfScan: (String? nfcId) async {
Utils.hideLoading(context); // print(nfcId);
} catch (ex) { // Utils.showLoading(context);
print(ex); // try {
Utils.hideLoading(context); // GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? "");
Utils.handleException(ex, (msg) { // bool status = await model.fetchAttendanceTracking();
Utils.confirmDialog(context, msg); // Utils.hideLoading(context);
}); // } catch (ex) {
} // print(ex);
}); // Utils.hideLoading(context);
// Utils.handleException(ex, (msg) {
// Utils.confirmDialog(context, msg);
// });
// }
// });
// Location.getCurrentLocation((LatLng? latlng) { // Location.getCurrentLocation((LatLng? latlng) {
// print(latlng!.longitude.toString()); // print(latlng!.longitude.toString());
// }); // });

@ -130,6 +130,9 @@ class _LoginScreenState extends State<LoginScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
username.text = "15153"; username.text = "15153";
password.text = "Xy12345@"; password.text = "Xy12345@";
// username.text = "287742";
// password.text = "509@Shafi";
return Scaffold( return Scaffold(
body: Column( body: Column(
children: [ children: [

@ -666,7 +666,7 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
(value) async { (value) async {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(false, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName); GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(true, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW( GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "", AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0, genericResponseModel?.pSESSIONID ?? 0,
@ -682,6 +682,9 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
AppState().setPrivilegeListModel = genericResponseModel!.privilegeList ?? []; AppState().setPrivilegeListModel = genericResponseModel!.privilegeList ?? [];
AppState().setMemberInformationListModel = genericResponseModel.memberInformationList?.first; AppState().setMemberInformationListModel = genericResponseModel.memberInformationList?.first;
MemberInformationListModel.saveToPrefs(genericResponseModel.memberInformationList ?? []); MemberInformationListModel.saveToPrefs(genericResponseModel.memberInformationList ?? []);
genericResponseModel.privilegeList!.forEach((element) {
print(element.serviceName.toString() + " " + element.previlege.toString()); // Check availability
});
PrivilegeListModel.saveToPrefs(genericResponseModel.privilegeList ?? []); PrivilegeListModel.saveToPrefs(genericResponseModel.privilegeList ?? []);
Utils.saveStringFromPrefs(SharedPrefsConsts.username, AppState().getUserName!); Utils.saveStringFromPrefs(SharedPrefsConsts.username, AppState().getUserName!);
Utils.saveStringFromPrefs(SharedPrefsConsts.password, AppState().password!); Utils.saveStringFromPrefs(SharedPrefsConsts.password, AppState().password!);

Loading…
Cancel
Save