From a9772440349981477c0c39d46beb0e538d2706cb Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 31 Dec 2024 10:49:22 +0300 Subject: [PATCH] swipe improvements. --- lib/extensions/context_extension.dart | 10 +- .../forget_passwod_verify_otp.dart | 48 +- .../reset_password_view.dart | 25 +- lib/new_views/pages/land_page/land_page.dart | 17 +- lib/new_views/pages/login_page.dart | 37 +- .../swipe_module/dialoge/confirm_dialog.dart | 1 - .../swipe_module/mark_attendance_widget.dart | 1604 ++++++++--------- .../swipe_module/swipe_success_view.dart | 39 +- .../utils/swipe_general_utils.dart | 37 +- 9 files changed, 883 insertions(+), 935 deletions(-) diff --git a/lib/extensions/context_extension.dart b/lib/extensions/context_extension.dart index 44f1fb9b..b5de20c0 100644 --- a/lib/extensions/context_extension.dart +++ b/lib/extensions/context_extension.dart @@ -1,7 +1,7 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; +import 'package:test_sa/new_views/swipe_module/dialoge/confirm_dialog.dart'; import '../controllers/providers/settings/setting_provider.dart'; @@ -13,4 +13,12 @@ extension BuildContextExtension on BuildContext { bool get isDark => Provider.of(this).theme == "dark"; bool get isAr => Provider.of(this).language == "ar"; + + void showConfirmDialog(String message, {String title, VoidCallback onTap}) => showDialog( + context: this, + builder: (BuildContext cxt) => ConfirmDialog( + message: message, + onTap: onTap, + ), + ); } diff --git a/lib/new_views/forget_password_module/forget_passwod_verify_otp.dart b/lib/new_views/forget_password_module/forget_passwod_verify_otp.dart index 7f25d7b0..8ce50955 100644 --- a/lib/new_views/forget_password_module/forget_passwod_verify_otp.dart +++ b/lib/new_views/forget_password_module/forget_passwod_verify_otp.dart @@ -128,6 +128,7 @@ // } import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:pinput/pinput.dart'; import 'package:provider/provider.dart'; @@ -136,16 +137,16 @@ import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; +import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/forget_password_module/models/general_response_model.dart'; -import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/forget_password_module/reset_password_view.dart'; class ForgetPasswordVerifyOtpView extends StatefulWidget { static const String routeName = "/verify_otp"; String employeeId = ''; - ForgetPasswordVerifyOtpView({Key key,this.employeeId}) : super(key: key); + ForgetPasswordVerifyOtpView({Key key, this.employeeId}) : super(key: key); @override State createState() => _ForgetPasswordVerifyOtpViewState(); @@ -153,7 +154,7 @@ class ForgetPasswordVerifyOtpView extends StatefulWidget { class _ForgetPasswordVerifyOtpViewState extends State { String otp = ''; - Timer _timer; + Timer _timer; int _remainingSeconds = 180; // 3 minutes in seconds @override @@ -225,9 +226,9 @@ class _ForgetPasswordVerifyOtpViewState extends State(context, listen: false); - String employeeId = widget.employeeId; - GeneralResponseModel response = await _userProvider.sendForgetPasswordOtp( - context: context, - employeeId: employeeId, - ); - print('Response of send OTP: ${response.toJson()}'); - - // Restart the timer - _startTimer(); - } + UserProvider _userProvider = Provider.of(context, listen: false); + String employeeId = widget.employeeId; + GeneralResponseModel response = await _userProvider.sendForgetPasswordOtp( + context: context, + employeeId: employeeId, + ); + print('Response of send OTP: ${response.toJson()}'); + _startTimer(); + } : null, child: Text( 'Resend', style: TextStyle( - color: _remainingSeconds == 0 ? AppColor.primary40 : AppColor.white10, + color: _remainingSeconds == 0 ? AppColor.blueStatus(context) : AppColor.white10, fontWeight: FontWeight.w500, fontSize: 16.toScreenWidth, decorationColor: AppColor.primary30, @@ -264,8 +263,6 @@ class _ForgetPasswordVerifyOtpViewState extends State(context, listen: false); GeneralResponseModel generalResponseModel = await _userProvider.forgetPasswordValidateOtp( context: context, - employeeId:widget.employeeId, + employeeId: widget.employeeId, otp: otp, ); if (generalResponseModel.isSuccess) { @@ -294,7 +292,3 @@ class _ForgetPasswordVerifyOtpViewState extends State { UserProvider _userProvider; - bool _passwordVisible =false; - bool _confirmPasswordVisible =false; + bool _passwordVisible = false; + bool _confirmPasswordVisible = false; final GlobalKey _formKey = GlobalKey(); @@ -44,11 +44,9 @@ class _ResetPasswordViewState extends State { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ - context.translation.resetPassword.heading2(context).custom(color: AppColor.neutral80, fontWeight: FontWeight.w500), 8.height, context.translation.pleaseEnterTheNewPassword.bodyText2(context).custom(color: AppColor.white20, fontWeight: FontWeight.w500), - 32.height, AppTextFormField( initialValue: _userProvider.newPassword, @@ -59,9 +57,7 @@ class _ResetPasswordViewState extends State { suffixIcon: IconButton( icon: Icon( // Based on passwordVisible state choose the icon - _passwordVisible - ? Icons.visibility - : Icons.visibility_off, + _passwordVisible ? Icons.visibility : Icons.visibility_off, color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, ), onPressed: () { @@ -92,9 +88,7 @@ class _ResetPasswordViewState extends State { suffixIcon: IconButton( icon: Icon( // Based on passwordVisible state choose the icon - _confirmPasswordVisible - ? Icons.visibility - : Icons.visibility_off, + _confirmPasswordVisible ? Icons.visibility : Icons.visibility_off, color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, ), onPressed: () { @@ -110,7 +104,6 @@ class _ResetPasswordViewState extends State { ], ), ).center.expanded, - ], ).paddingOnly(start: 16, end: 16, bottom: 24, top: 24), ), @@ -127,8 +120,8 @@ class _ResetPasswordViewState extends State { password: _userProvider.newPassword, confirmPassword: _userProvider.confirmPassword, userId: _userProvider.verifyOtpModel.userId, token: _userProvider.verifyOtpModel.token); GeneralResponseModel generalResponseModel = await _userProvider.updateNewPassword(context: context, updatePasswordModel: updatePasswordModel); if (generalResponseModel.isSuccess) { - _userProvider.newPassword=''; - _userProvider.confirmPassword=''; + _userProvider.newPassword = ''; + _userProvider.confirmPassword = ''; Navigator.of(context).pushNamedAndRemoveUntil(LoginPage.routeName, (routes) => true); } } diff --git a/lib/new_views/pages/land_page/land_page.dart b/lib/new_views/pages/land_page/land_page.dart index 30e3a0f1..ef0df1d6 100644 --- a/lib/new_views/pages/land_page/land_page.dart +++ b/lib/new_views/pages/land_page/land_page.dart @@ -1,5 +1,4 @@ import 'dart:io'; -import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:nfc_manager/nfc_manager.dart'; @@ -178,15 +177,6 @@ class _LandPageState extends State { }, ), ), - Visibility( - visible: !userProvider.isUserConfirmSwipe && userProvider.user != null && !userProvider.user.employeeIsHMG, - child: BackdropFilter( - filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), - child: Container( - color: Colors.black.withOpacity(0.2), // Optional tint effect - ), - ), - ), if (userProvider.user != null && !userProvider.user.employeeIsHMG) Positioned( right: _userProvider.user.type == UsersTypes.engineer ? 20.toScreenWidth : null, @@ -213,7 +203,12 @@ class _LandPageState extends State { 8.height, Text( ("${context.translation.checkIn}\n${userProvider.swipeTransactionModel != null && userProvider.swipeTransactionModel.swipeTime != null ? SwipeGeneralUtils.formatTimeOnly(userProvider.swipeTransactionModel.swipeTime) : '--:--'}"), - style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral80, fontWeight: FontWeight.w500, fontFamily: "Poppins"), + textAlign: TextAlign.center, + style: AppTextStyles.bodyText2.copyWith( + color: AppColor.neutral80, + fontWeight: FontWeight.w500, + fontFamily: "Poppins", + ), ), // (context.translation.checkIn + diff --git a/lib/new_views/pages/login_page.dart b/lib/new_views/pages/login_page.dart index 06ce38b3..b7d0b6d9 100644 --- a/lib/new_views/pages/login_page.dart +++ b/lib/new_views/pages/login_page.dart @@ -8,10 +8,10 @@ import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; -import 'package:test_sa/new_views/forget_password_module/models/general_response_model.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; -import 'package:test_sa/new_views/pages/land_page/land_page.dart'; import 'package:test_sa/new_views/forget_password_module/forget_passwod_verify_otp.dart'; +import 'package:test_sa/new_views/forget_password_module/models/general_response_model.dart'; +import 'package:test_sa/new_views/pages/land_page/land_page.dart'; import '../../controllers/providers/api/user_provider.dart'; import '../../controllers/providers/settings/setting_provider.dart'; @@ -54,7 +54,7 @@ class _LoginPageState extends State { rememberMe = _settingProvider.rememberMe; if (rememberMe) { _user.userName = _settingProvider.username; - userNameController.text=_user.userName??''; + userNameController.text = _user.userName ?? ''; _user.password = _settingProvider.password; } } @@ -91,9 +91,7 @@ class _LoginPageState extends State { suffixIcon: IconButton( icon: Icon( // Based on passwordVisible state choose the icon - _passwordVisible - ? Icons.visibility - : Icons.visibility_off, + _passwordVisible ? Icons.visibility : Icons.visibility_off, color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, ), onPressed: () { @@ -132,17 +130,22 @@ class _LoginPageState extends State { alignment: AlignmentDirectional.centerEnd, child: InkWell( onTap: () async { - if(userNameController.text.isNotEmpty){ - GeneralResponseModel response = await _userProvider.sendForgetPasswordOtp(context: context, employeeId: userNameController.text); - if(response.isSuccess){ - Navigator.push(context, MaterialPageRoute(builder: (context)=>ForgetPasswordVerifyOtpView(employeeId:userNameController.text,))); - // Navigator.push(context, ForgetPasswordVerifyOtpView.routeName); - }else{ - Fluttertoast.showToast(msg: response?.message ?? context.translation.failedToCompleteRequest); - } - }else{ - Fluttertoast.showToast(msg: context.translation.employeeIdIsRequired); - } + if (userNameController.text.isNotEmpty) { + GeneralResponseModel response = await _userProvider.sendForgetPasswordOtp(context: context, employeeId: userNameController.text); + if (response.isSuccess) { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ForgetPasswordVerifyOtpView( + employeeId: userNameController.text, + ))); + // Navigator.push(context, ForgetPasswordVerifyOtpView.routeName); + } else { + context.showConfirmDialog(response?.message ?? context.translation.failedToCompleteRequest); + } + } else { + Fluttertoast.showToast(msg: context.translation.employeeIdIsRequired); + } }, child: context.translation.forgotPassword.bodyText(context).custom(color: AppColor.primary50, fontWeight: FontWeight.w500), ), diff --git a/lib/new_views/swipe_module/dialoge/confirm_dialog.dart b/lib/new_views/swipe_module/dialoge/confirm_dialog.dart index f586e36c..18bdba4e 100644 --- a/lib/new_views/swipe_module/dialoge/confirm_dialog.dart +++ b/lib/new_views/swipe_module/dialoge/confirm_dialog.dart @@ -16,7 +16,6 @@ class ConfirmDialog extends StatelessWidget { @override Widget build(BuildContext context) { - print('message i got is $message'); return Dialog( backgroundColor: Colors.white, shape: const RoundedRectangleBorder(), diff --git a/lib/new_views/swipe_module/mark_attendance_widget.dart b/lib/new_views/swipe_module/mark_attendance_widget.dart index f4931ee7..7f414a84 100644 --- a/lib/new_views/swipe_module/mark_attendance_widget.dart +++ b/lib/new_views/swipe_module/mark_attendance_widget.dart @@ -1,851 +1,821 @@ -import 'dart:async'; -import 'dart:developer'; -import 'dart:io'; -import 'package:flutter/material.dart'; -import 'package:geolocator/geolocator.dart'; -import 'package:huawei_location/huawei_location.dart'; -import 'package:nfc_manager/nfc_manager.dart'; -import 'package:permission_handler/permission_handler.dart'; -import 'package:provider/provider.dart'; -import 'package:test_sa/controllers/providers/api/user_provider.dart'; -import 'package:test_sa/extensions/int_extensions.dart'; -import 'package:test_sa/extensions/text_extensions.dart'; -import 'package:test_sa/extensions/widget_extensions.dart'; -import 'package:test_sa/new_views/swipe_module/enums/swipe_type.dart'; -import 'package:test_sa/new_views/swipe_module/models/swipe_model.dart'; -import 'package:test_sa/new_views/app_style/app_color.dart'; -import 'package:test_sa/new_views/pages/land_page/nfc/nfc_reader_sheet.dart'; -import 'package:test_sa/new_views/swipe_module/utils/swipe_general_utils.dart'; -import 'package:test_sa/new_views/swipe_module/utils/location_utils.dart'; -import 'package:test_sa/new_views/swipe_module/dialoge/confirm_dialog.dart'; -import 'package:test_sa/new_views/swipe_module/dialoge/success_dialog.dart'; -import 'package:test_sa/new_views/swipe_module/dialoge/qr_scanner_dialog.dart'; -import 'package:wifi_iot/wifi_iot.dart'; - -class MarkAttendanceWidget extends StatefulWidget { - double topPadding; - bool isFromDashboard; - - MarkAttendanceWidget({Key key, this.topPadding = 0, this.isFromDashboard = false}) : super(key: key); - - // todo MarkAttendanceWidget(this.model, {Key? key, this.topPadding = 0, this.isFromDashboard = false}) : super(key: key); - - @override - _MarkAttendanceWidgetState createState() { - return _MarkAttendanceWidgetState(); - } -} - -class _MarkAttendanceWidgetState extends State { - bool isNfcEnabled = false, isQrEnabled = false, isWifiEnabled = false; - UserProvider _userProvider; - - int _locationUpdateCbId = 0; - - @override - void initState() { - super.initState(); - checkAttendanceAvailability(); - } - - void checkAttendanceAvailability() async { - _userProvider = Provider.of(context, listen: false); - bool isAvailable = await NfcManager.instance.isAvailable(); - log('backend enabled values are nfc ${_userProvider.user.enableNFC} qr ${_userProvider.user.enableQR} wifi ${_userProvider.user.enableWifi}'); - setState(() { - if (isAvailable && _userProvider.user.enableNFC) isNfcEnabled = true; - if (_userProvider.user.enableQR) isQrEnabled = true; - if (_userProvider.user.enableWifi) isWifiEnabled = true; - }); - } - - void checkHuaweiLocationPermission(SwipeTypeEnum attendanceType,BuildContext context) async { - // Permission_Handler permissionHandler = PermissionHandler(); - LocationUtilities.isEnabled((bool isEnabled) async { - if (isEnabled) { - LocationUtilities.havePermission((bool permission) async { - if (permission) { - getHuaweiCurrentLocation(attendanceType,context); - } else { - bool has = await requestPermissions(); - if (has) { - getHuaweiCurrentLocation(attendanceType,context); - } else { - showDialog( - context: context, - builder: (BuildContext cxt) => ConfirmDialog( - message: "You need to give location permission to mark attendance", - onTap: () { - Navigator.pop(context); - }, - ), - ); - } - } - }); - } 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(); - }, - ), - ); - } - }); - - // if (await permissionHandler.hasLocationPermission()) { - // getHuaweiCurrentLocation(attendanceType); - // } else { - // bool has = await requestPermissions(); - // if (has) { - // getHuaweiCurrentLocation(attendanceType); - // } else { - // showDialog( - // context: context, - // builder: (BuildContext cxt) => ConfirmDialog( - // message: "You need to give location permission to mark attendance", - // onTap: () { - // Navigator.pop(context); - // }, - // ), - // ); - // } - // } - } - - Future requestPermissions() async { - var result = await [ - Permission.location, - ].request(); - return (result[Permission.location] == PermissionStatus.granted || result[Permission.locationAlways] == PermissionStatus.granted); - } - - @override - void dispose() { - super.dispose(); - // Stop Session - NfcManager.instance.stopSession(); - } - - @override - Widget build(BuildContext context) { - return - Container( - padding: EdgeInsets.only(left: 21, right: 21, bottom: 21, top: widget.topPadding), - decoration: const BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white), - width: double.infinity, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - 20.height, - 'click me '.heading5(context), - // LocaleKeys.markAttendance.tr().toSectionHeading(), - // LocaleKeys.selectMethodOfAttendance.tr().toText11(color: const Color(0xff535353)), - GridView( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: const EdgeInsets.only(bottom: 0, top: 21), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: (MediaQuery.of(context).size.width < 550) ? 3 : 5, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), - children: availableAttendanceMethodList(context: context), - ) - ], - ), - ); - } - - - - - void handleSwipe({ - SwipeTypeEnum swipeType, - @required bool isEnable, - @required BuildContext context, - }) { - // if (AppState().getIsHuawei) { - if (false) { - checkHuaweiLocationPermission(swipeType,context); - } else { - LocationUtilities.isEnabled((bool isEnabled) { - if (isEnabled) { - LocationUtilities.havePermission((bool permission) { - if (permission) { - SwipeGeneralUtils.showLoading(context); - LocationUtilities.getCurrentLocation( - (Position position, bool isMocked) { - if (isMocked) { - SwipeGeneralUtils.hideLoading(context); - SwipeGeneralUtils.markFakeAttendance(swipeType.name, position.latitude.toString() ?? "", position.longitude.toString() ?? "", context); - } else { - SwipeGeneralUtils.hideLoading(context); - //todo performNfcAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? ""); - handleSwipeOperation(swipeType: swipeType, lat: position.latitude, lang: position.longitude); - } - }, - () { - SwipeGeneralUtils.hideLoading(context); - SwipeGeneralUtils.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,BuildContext context}) { - switch (swipeType) { - case SwipeTypeEnum.NFC: - handleNfcAttendance(latitude: lat, longitude: lang,context: context); - return; - case SwipeTypeEnum.QR: - performQrCodeAttendance(latitude: lat, longitude: lang,context:context); - return; - case SwipeTypeEnum.Wifi: - //TODO need to implement. - return; - } - } - - void getHuaweiCurrentLocation(SwipeTypeEnum attendanceType,BuildContext context) async { - try { - SwipeGeneralUtils.showLoading(context); - FusedLocationProviderClient locationService = FusedLocationProviderClient()..initFusedLocationService(); - LocationRequest locationRequest = LocationRequest(); - locationRequest.priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY; - locationRequest.interval = 500; - List locationRequestList = [locationRequest]; - LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList); - - StreamSubscription _streamSubscription; - int requestCode = (await (locationService.requestLocationUpdates(locationRequest))); - - _streamSubscription = locationService.onLocationData.listen( - (Location location) async { - SwipeGeneralUtils.hideLoading(context); - await locationService.removeLocationUpdates(requestCode); - handleSwipeOperation(swipeType: attendanceType); - requestCode = 0; - }, - ); - - // locationService.checkLocationSettings(locationSettingsRequest).then((settings) async { - // await locationService.getLastLocation().then((value) { - // if (value.latitude == null || value.longitude == null) { - // showDialog( - // context: context, - // builder: (BuildContext cxt) => ConfirmDialog( - // message: "Unable to get your location, Please check your location settings & try again.", - // onTap: () { - // Navigator.pop(context); - // }, - // ), - // ); - // } else { - // if (attendanceType == "QR") { - // performQrCodeAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); - // } - // if (attendanceType == "WIFI") { - // performWifiAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); - // } - // if (attendanceType == "NFC") { - // performNfcAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); - // } - // } - // }).catchError((error) { - // log("HUAWEI LOCATION getLastLocation ERROR!!!!!"); - // log(error); - // }); - // }).catchError((error) { - // log("HUAWEI LOCATION checkLocationSettings ERROR!!!!!"); - // log(error); - // if (error.code == "LOCATION_SETTINGS_NOT_AVAILABLE") { - // // Location service not enabled. - // } - // }); - } catch (error) { - log("HUAWEI LOCATION ERROR!!!!!"); - log('$error'); - SwipeGeneralUtils.hideLoading(context); - // SwipeGeneralUtils.handleException(error, context, null); - } - } - - Future handleNfcAttendance({double latitude = 0, double longitude = 0,BuildContext context}) async { - final userProvider = Provider.of(context, listen: false); - - if (Platform.isIOS) { - SwipeGeneralUtils.readNFc(onRead: (String nfcId) async { - await _processNfcAttendance(userProvider, nfcId, latitude, longitude,context); - }); - } else { - showNfcReader(context, onNcfScan: (String nfcId) async { - await _processNfcAttendance(userProvider, nfcId ?? '', latitude, longitude,context); - }); - } - } - - Future _processNfcAttendance( - UserProvider userProvider, - String nfcId, - double latitude, - double longitude, - BuildContext context, - ) async { - SwipeGeneralUtils.showLoading(context); - try { - // final swipeModel = Swipe( - // swipeTypeValue: SwipeTypeEnum.NFC.getIntFromSwipeTypeEnum(), - // value: nfcId, - // latitude: latitude, - // longitude: longitude, - // ); - //Test model... - final swipeModel = Swipe( - swipeTypeValue: SwipeTypeEnum.NFC.getIntFromSwipeTypeEnum(), - value: '123', - latitude: 24.70865415364271, - longitude: 46.66600861881879, - ); - print('swipe model to call api is ${swipeModel.toJson()} '); - final swipeResponse = await userProvider.makeSwipe(model: swipeModel); - log('swipe response i got is ${swipeResponse.toJson()}'); - - if (swipeResponse.isSuccess) { - if (Platform.isIOS) await Future.delayed(const Duration(seconds: 3)); - SwipeGeneralUtils.hideLoading(context); - SwipeGeneralUtils.showSuccessDialog(context: context, fromDashBoard: widget.isFromDashboard); - } else { - SwipeGeneralUtils.hideLoading(context); - SwipeGeneralUtils.showErrorDialog(message: swipeResponse.message ?? "Unexpected error occurred", context: context); - } - } catch (errSwipeGeneralUtilsor) { - SwipeGeneralUtils.hideLoading(context); - // Uncomment below line for error handling if needed - // SwipeGeneralUtils.handleException(error, context, null); - } - } - - Future closeWifiRequest() async { - if (Platform.isAndroid) { - await WiFiForIoTPlugin.forceWifiUsage(false); - } - return await WiFiForIoTPlugin.disconnect(); - } - - Future performQrCodeAttendance({double latitude, double longitude ,BuildContext context}) async { - UserProvider userProvider = Provider.of(context, listen: false); - var qrCodeValue = await Navigator.of(context).push( - MaterialPageRoute( - builder: (BuildContext context) => QrScannerDialog(), - ), - ); - if (qrCodeValue != null) { - SwipeGeneralUtils.showLoading(context); - try { - //test model.. - final swipeModel = Swipe( - swipeTypeValue: SwipeTypeEnum.QR.getIntFromSwipeTypeEnum(), - value: '2323', - latitude: 24.70865415364271, - longitude: 46.66600861881879, - ); - // 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 userProvider.makeSwipe(model: swipeModel); - log('response of swipe is ${swipeResponse.toJson()}'); - - if (swipeResponse.isSuccess) { - SwipeGeneralUtils.hideLoading(context); - SwipeGeneralUtils.showMDialog( - context, - backgroundColor: Colors.transparent, - isDismissable: true, - child: SuccessDialog(widget.isFromDashboard), - ); - } else { - SwipeGeneralUtils.hideLoading(context); - showDialog( - barrierDismissible: true, - context: context, - builder: (cxt) => ConfirmDialog( - message: swipeResponse.message ?? "", - onTap: () { - Navigator.pop(context); - }, - onCloseTap: () {}, - ), - ); - } - } catch (ex) { - log('$ex'); - SwipeGeneralUtils.hideLoading(context); - //this need to confirm where it comes.. - // SwipeGeneralUtils.handleException(ex, context, null); - } - } - } - - List availableAttendanceMethodList({@required BuildContext context}) { - List availableMethods = []; - if (isNfcEnabled) { - availableMethods.add(attendanceMethod(SwipeTypeEnum.NFC.name, 'nfc_icon', isNfcEnabled, () { - handleSwipe(swipeType: SwipeTypeEnum.NFC, isEnable: isNfcEnabled,context: context); - })); - } - if (isQrEnabled) { - availableMethods.add(attendanceMethod(SwipeTypeEnum.QR.name, 'wifi_icon', isQrEnabled, () { - handleSwipe(swipeType: SwipeTypeEnum.QR, isEnable: isQrEnabled,context: context); - })); - } - if (isWifiEnabled) { - availableMethods.add(attendanceMethod(SwipeTypeEnum.Wifi.name, 'wifi_icon', isWifiEnabled, () { - handleSwipe(swipeType: SwipeTypeEnum.Wifi, isEnable: isWifiEnabled,context: context); - })); - } - return availableMethods; - } - - - - - Widget attendanceMethod(String title, String icon, bool isEnabled, VoidCallback onPress) { - return Container( - padding: EdgeInsets.all(12), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(18), - border: Border.all(color: AppColor.white40, width: 2), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - icon.toSvgAsset(), - title.heading5(context).custom(color: AppColor.neutral50), - // Text( - // title, - // style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500), - // ), - ], - ), - ).onPress( - () { - log('isEnabled is ${!isEnabled}'); - if (!isEnabled) return; - onPress(); - }, - ); - // return Container( - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(15), - // color: isEnabled ? null : Colors.grey.withOpacity(.5), - // gradient: isEnabled - // ? const LinearGradient( - // transform: GradientRotation(.64), - // begin: Alignment.topRight, - // end: Alignment.bottomLeft, - // colors: [ - // //ToDo set Colors according to design provided by designer... - // Colors.blue, - // Colors.green, - // // AppColor.gradiantEndColor, - // // MyColors.gradiantStartColor, - // ], - // ) - // : null, - // ), - // clipBehavior: Clip.antiAlias, - // padding: const EdgeInsets.only(left: 10, right: 10, top: 14, bottom: 14), - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // // SvgPicture.asset(image, color: Colors.white, alignment: Alignment.topLeft).expanded, - // Icon(iconData, color: isEnabled ? AppColor.black35 : Colors.grey), - // title.heading6(context), - // // title.toText17(isBold: true, color: Colors.white), - // ], - // ), - // ).onPress( - // () { - // log('isEnabled is ${!isEnabled}'); - // if (!isEnabled) return; - // onPress(); - // }, - // ); - } -} - -// Widget customListItem({required String icon, required String heading, required String subHeading, required VoidCallback onTap}) { -// return GestureDetector( -// onTap: onTap, // Handles the tap -// child: Card( -// shape: RoundedRectangleBorder( -// borderRadius: BorderRadius.circular(14), // Circular border radius -// ), -// color: Colors.white, -// child: Row( -// crossAxisAlignment: CrossAxisAlignment.start, // Align items at the top -// children: [ -// // Icon Section -// icon -// .toSvgAsset( -// width: 32, -// color: AppColor.neutral120, -// height: 29, -// ) -// .paddingOnly(top: 8), -// 14.width, -// Expanded( -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// Text( -// heading, -// style: AppTextStyles.heading6.copyWith(color: AppColor.neutral50), -// ), -// 7.height, -// Text( -// subHeading, -// style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120), -// ), -// ], -// ).paddingOnly(end: 50), -// ), -// ], -// ).paddingAll(12), +// import 'dart:async'; +// import 'dart:developer'; +// import 'dart:io'; +// +// import 'package:flutter/material.dart'; +// import 'package:geolocator/geolocator.dart'; +// import 'package:huawei_location/huawei_location.dart'; +// import 'package:nfc_manager/nfc_manager.dart'; +// import 'package:permission_handler/permission_handler.dart'; +// import 'package:provider/provider.dart'; +// import 'package:test_sa/controllers/providers/api/user_provider.dart'; +// import 'package:test_sa/extensions/int_extensions.dart'; +// import 'package:test_sa/extensions/text_extensions.dart'; +// import 'package:test_sa/extensions/widget_extensions.dart'; +// import 'package:test_sa/new_views/app_style/app_color.dart'; +// import 'package:test_sa/new_views/pages/land_page/nfc/nfc_reader_sheet.dart'; +// import 'package:test_sa/new_views/swipe_module/dialoge/confirm_dialog.dart'; +// import 'package:test_sa/new_views/swipe_module/dialoge/qr_scanner_dialog.dart'; +// import 'package:test_sa/new_views/swipe_module/dialoge/success_dialog.dart'; +// import 'package:test_sa/new_views/swipe_module/enums/swipe_type.dart'; +// import 'package:test_sa/new_views/swipe_module/models/swipe_model.dart'; +// import 'package:test_sa/new_views/swipe_module/swipe_success_view.dart'; +// import 'package:test_sa/new_views/swipe_module/utils/location_utils.dart'; +// import 'package:test_sa/new_views/swipe_module/utils/swipe_general_utils.dart'; +// import 'package:wifi_iot/wifi_iot.dart'; +// todo @sikander delete this file after compelte +// class MarkAttendanceWidget extends StatefulWidget { +// double topPadding; +// bool isFromDashboard; +// +// MarkAttendanceWidget({Key key, this.topPadding = 0, this.isFromDashboard = false}) : super(key: key); +// +// // todo MarkAttendanceWidget(this.model, {Key? key, this.topPadding = 0, this.isFromDashboard = false}) : super(key: key); +// +// @override +// _MarkAttendanceWidgetState createState() { +// return _MarkAttendanceWidgetState(); +// } +// } +// +// class _MarkAttendanceWidgetState extends State { +// bool isNfcEnabled = false, isQrEnabled = false, isWifiEnabled = false; +// UserProvider _userProvider; +// +// int _locationUpdateCbId = 0; +// +// @override +// void initState() { +// super.initState(); +// checkAttendanceAvailability(); +// } +// +// void checkAttendanceAvailability() async { +// _userProvider = Provider.of(context, listen: false); +// bool isAvailable = await NfcManager.instance.isAvailable(); +// log('backend enabled values are nfc ${_userProvider.user.enableNFC} qr ${_userProvider.user.enableQR} wifi ${_userProvider.user.enableWifi}'); +// setState(() { +// if (isAvailable && _userProvider.user.enableNFC) isNfcEnabled = true; +// if (_userProvider.user.enableQR) isQrEnabled = true; +// if (_userProvider.user.enableWifi) isWifiEnabled = true; +// }); +// } +// +// void checkHuaweiLocationPermission(SwipeTypeEnum attendanceType, BuildContext context) async { +// // Permission_Handler permissionHandler = PermissionHandler(); +// LocationUtilities.isEnabled((bool isEnabled) async { +// if (isEnabled) { +// LocationUtilities.havePermission((bool permission) async { +// if (permission) { +// getHuaweiCurrentLocation(attendanceType, context); +// } else { +// bool has = await requestPermissions(); +// if (has) { +// getHuaweiCurrentLocation(attendanceType, context); +// } else { +// showDialog( +// context: context, +// builder: (BuildContext cxt) => ConfirmDialog( +// message: "You need to give location permission to mark attendance", +// onTap: () { +// Navigator.pop(context); +// }, +// ), +// ); +// } +// } +// }); +// } 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(); +// }, +// ), +// ); +// } +// }); +// +// // if (await permissionHandler.hasLocationPermission()) { +// // getHuaweiCurrentLocation(attendanceType); +// // } else { +// // bool has = await requestPermissions(); +// // if (has) { +// // getHuaweiCurrentLocation(attendanceType); +// // } else { +// // showDialog( +// // context: context, +// // builder: (BuildContext cxt) => ConfirmDialog( +// // message: "You need to give location permission to mark attendance", +// // onTap: () { +// // Navigator.pop(context); +// // }, +// // ), +// // ); +// // } +// // } +// } +// +// Future requestPermissions() async { +// var result = await [ +// Permission.location, +// ].request(); +// return (result[Permission.location] == PermissionStatus.granted || result[Permission.locationAlways] == PermissionStatus.granted); +// } +// +// @override +// void dispose() { +// super.dispose(); +// // Stop Session +// NfcManager.instance.stopSession(); +// } +// +// @override +// Widget build(BuildContext context) { +// return Container( +// padding: EdgeInsets.only(left: 21, right: 21, bottom: 21, top: widget.topPadding), +// decoration: const BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white), +// width: double.infinity, +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// mainAxisSize: MainAxisSize.min, +// children: [ +// 20.height, +// 'click me '.heading5(context), +// // LocaleKeys.markAttendance.tr().toSectionHeading(), +// // LocaleKeys.selectMethodOfAttendance.tr().toText11(color: const Color(0xff535353)), +// GridView( +// physics: const NeverScrollableScrollPhysics(), +// shrinkWrap: true, +// padding: const EdgeInsets.only(bottom: 0, top: 21), +// gridDelegate: +// SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: (MediaQuery.of(context).size.width < 550) ? 3 : 5, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), +// children: availableAttendanceMethodList(context: context), +// ) +// ], // ), // ); // } - -//qr older code... - -//nfc older code widget - -// // if (AppState().getIsHuawei) { -// if (false) { -// checkHuaweiLocationPermission(SwipeTypeEnum.NFC); -// } else { -// LocationUtilities.isEnabled((bool isEnabled) { -// if (isEnabled) { -// LocationUtilities.havePermission((bool permission) { -// if (permission) { -// SwipeGeneralUtils.showLoading(context); -// LocationUtilities.getCurrentLocation( -// (Position position, bool isMocked) { -// if (isMocked) { -// SwipeGeneralUtils.hideLoading(context); -// SwipeGeneralUtils.markFakeAttendance("NFC", position.latitude.toString() ?? "", position.longitude.toString() ?? "",context); -// } else { -// SwipeGeneralUtils.hideLoading(context); -// //todo performNfcAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? ""); -// } -// }, -// () { -// SwipeGeneralUtils.hideLoading(context); -// SwipeGeneralUtils.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(); -// }, -// ), -// ); -// } -// }); -// } - -//older code.... -// Future performNfcAttendance({double lat = 0, double lng = 0}) async { -// UserProvider userProvider = Provider.of(context,listen:false); -// if (Platform.isIOS) { -// SwipeGeneralUtils.readNFc(onRead: (String nfcId) async { -// SwipeGeneralUtils.showLoading(context); -// try { -// SwipeModel swipeResponse = await userProvider.makeSwipe(model: Swipe(swipeTypeValue: SwipeTypeEnum.NFC.getIntFromSwipeTypeEnum(), value: '', latitude: lat, longitude: lng)); -// if (swipeResponse.responseCode != 1) { -// SwipeGeneralUtils.hideLoading(context); +// +// void handleSwipe({ +// SwipeTypeEnum swipeType, +// @required bool isEnable, +// @required BuildContext context, +// }) { +// // if (AppState().getIsHuawei) { +// if (false) { +// checkHuaweiLocationPermission(swipeType, context); +// } else { +// LocationUtilities.isEnabled((bool isEnabled) { +// if (isEnabled) { +// LocationUtilities.havePermission((bool permission) { +// if (permission) { +// SwipeGeneralUtils.showLoading(context); +// LocationUtilities.getCurrentLocation( +// (Position position, bool isMocked) { +// if (isMocked) { +// SwipeGeneralUtils.hideLoading(context); +// SwipeGeneralUtils.markFakeAttendance(swipeType.name, position.latitude.toString() ?? "", position.longitude.toString() ?? "", context); +// } else { +// SwipeGeneralUtils.hideLoading(context); +// //todo performNfcAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? ""); +// handleSwipeOperation(swipeType: swipeType, lat: position.latitude, lang: position.longitude); +// } +// }, +// () { +// SwipeGeneralUtils.hideLoading(context); +// SwipeGeneralUtils.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: swipeResponse.message ?? "Unexpected error occurred", -// onTap: () { +// message: "You need to enable location services to mark attendance", +// onTap: () async { // Navigator.pop(context); +// await Geolocator.openLocationSettings(); // }, // ), // ); -// } else { -// bool status = swipeResponse.data; -// if (Platform.isIOS) await Future.delayed(const Duration(seconds: 3)); -// SwipeGeneralUtils.hideLoading(context); -// SwipeGeneralUtils.showMDialog( -// context, -// backgroundColor: Colors.transparent, -// isDismissable: true, -// child: SuccessDialog(widget.isFromDashboard), -// ); // } -// } catch (ex) { +// }); +// } +// } +// +// void handleSwipeOperation({@required SwipeTypeEnum swipeType, double lat, double lang, BuildContext context}) { +// switch (swipeType) { +// case SwipeTypeEnum.NFC: +// handleNfcAttendance(latitude: lat, longitude: lang, context: context); +// return; +// case SwipeTypeEnum.QR: +// performQrCodeAttendance(latitude: lat, longitude: lang, context: context); +// return; +// case SwipeTypeEnum.Wifi: +// //TODO need to implement. +// return; +// } +// } +// +// void getHuaweiCurrentLocation(SwipeTypeEnum attendanceType, BuildContext context) async { +// try { +// SwipeGeneralUtils.showLoading(context); +// FusedLocationProviderClient locationService = FusedLocationProviderClient()..initFusedLocationService(); +// LocationRequest locationRequest = LocationRequest(); +// locationRequest.priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY; +// locationRequest.interval = 500; +// List locationRequestList = [locationRequest]; +// LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList); +// +// StreamSubscription _streamSubscription; +// int requestCode = (await (locationService.requestLocationUpdates(locationRequest))); +// +// _streamSubscription = locationService.onLocationData.listen( +// (Location location) async { +// SwipeGeneralUtils.hideLoading(context); +// await locationService.removeLocationUpdates(requestCode); +// handleSwipeOperation(swipeType: attendanceType); +// requestCode = 0; +// }, +// ); +// +// // locationService.checkLocationSettings(locationSettingsRequest).then((settings) async { +// // await locationService.getLastLocation().then((value) { +// // if (value.latitude == null || value.longitude == null) { +// // showDialog( +// // context: context, +// // builder: (BuildContext cxt) => ConfirmDialog( +// // message: "Unable to get your location, Please check your location settings & try again.", +// // onTap: () { +// // Navigator.pop(context); +// // }, +// // ), +// // ); +// // } else { +// // if (attendanceType == "QR") { +// // performQrCodeAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); +// // } +// // if (attendanceType == "WIFI") { +// // performWifiAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); +// // } +// // if (attendanceType == "NFC") { +// // performNfcAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? ""); +// // } +// // } +// // }).catchError((error) { +// // log("HUAWEI LOCATION getLastLocation ERROR!!!!!"); +// // log(error); +// // }); +// // }).catchError((error) { +// // log("HUAWEI LOCATION checkLocationSettings ERROR!!!!!"); +// // log(error); +// // if (error.code == "LOCATION_SETTINGS_NOT_AVAILABLE") { +// // // Location service not enabled. +// // } +// // }); +// } catch (error) { +// log("HUAWEI LOCATION ERROR!!!!!"); +// log('$error'); +// SwipeGeneralUtils.hideLoading(context); +// // SwipeGeneralUtils.handleException(error, context, null); +// } +// } +// +// Future handleNfcAttendance({double latitude = 0, double longitude = 0, BuildContext context}) async { +// final userProvider = Provider.of(context, listen: false); +// +// if (Platform.isIOS) { +// SwipeGeneralUtils.readNFc(onRead: (String nfcId) async { +// await _processNfcAttendance(userProvider, nfcId, latitude, longitude, context); +// }); +// } else { +// showNfcReader(context, onNcfScan: (String nfcId) async { +// await _processNfcAttendance(userProvider, nfcId ?? '', latitude, longitude, context); +// }); +// } +// } +// +// Future _processNfcAttendance( +// UserProvider userProvider, +// String nfcId, +// double latitude, +// double longitude, +// BuildContext context, +// ) async { +// SwipeGeneralUtils.showLoading(context); +// try { +// // final swipeModel = Swipe( +// // swipeTypeValue: SwipeTypeEnum.NFC.getIntFromSwipeTypeEnum(), +// // value: nfcId, +// // latitude: latitude, +// // longitude: longitude, +// // ); +// //Test model... +// final swipeModel = Swipe(swipeTypeValue: SwipeTypeEnum.NFC.getIntFromSwipeTypeEnum(), value: '123', latitude: 24.70865415364271, longitude: 46.66600861881879); +// final swipeResponse = await userProvider.makeSwipe(model: swipeModel); +// if (swipeResponse.isSuccess) { +// if (Platform.isIOS) await Future.delayed(const Duration(seconds: 3)); +// SwipeGeneralUtils.hideLoading(context); +// Navigator.pushNamed(context, SwipeSuccessView.routeName); +// } else { // SwipeGeneralUtils.hideLoading(context); -// // SwipeGeneralUtils.handleException(ex, context, null); +// SwipeGeneralUtils.showErrorDialog(message: swipeResponse.message ?? "Unexpected error occurred", context: context); // } -// }); -// } else { -// showNfcReader(context, onNcfScan: (String nfcId) async { +// } catch (errSwipeGeneralUtilsor) { +// SwipeGeneralUtils.hideLoading(context); +// // Uncomment below line for error handling if needed +// // SwipeGeneralUtils.handleException(error, context, null); +// } +// } +// +// Future closeWifiRequest() async { +// if (Platform.isAndroid) { +// await WiFiForIoTPlugin.forceWifiUsage(false); +// } +// return await WiFiForIoTPlugin.disconnect(); +// } +// +// Future performQrCodeAttendance({double latitude, double longitude, BuildContext context}) async { +// UserProvider userProvider = Provider.of(context, listen: false); +// var qrCodeValue = await Navigator.of(context).push( +// MaterialPageRoute( +// builder: (BuildContext context) => QrScannerDialog(), +// ), +// ); +// if (qrCodeValue != null) { // SwipeGeneralUtils.showLoading(context); // try { -// SwipeModel swipeResponse = await userProvider.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) { +// //test model.. +// final swipeModel = Swipe( +// swipeTypeValue: SwipeTypeEnum.QR.getIntFromSwipeTypeEnum(), +// value: '2323', +// latitude: 24.70865415364271, +// longitude: 46.66600861881879, +// ); +// final swipeResponse = await userProvider.makeSwipe(model: swipeModel); +// if (swipeResponse.isSuccess) { +// SwipeGeneralUtils.hideLoading(context); +// SwipeGeneralUtils.showMDialog(context, backgroundColor: Colors.transparent, isDismissable: true, child: SuccessDialog(widget.isFromDashboard)); +// } else { // SwipeGeneralUtils.hideLoading(context); // showDialog( +// barrierDismissible: true, // context: context, -// builder: (BuildContext cxt) => ConfirmDialog( -// message: swipeResponse.message ?? "Unexpected error occurred", +// builder: (cxt) => ConfirmDialog( +// message: swipeResponse.message ?? "", // onTap: () { // Navigator.pop(context); // }, +// onCloseTap: () {} // ), // ); -// } else { -// bool status = swipeResponse.data; //use this status to get transactions. -// if (Platform.isIOS) await Future.delayed(const Duration(seconds: 3)); -// SwipeGeneralUtils.hideLoading(context); -// SwipeGeneralUtils.showMDialog( -// context, -// backgroundColor: Colors.transparent, -// isDismissable: true, -// child: SuccessDialog(widget.isFromDashboard), -// ); // } // } catch (ex) { // SwipeGeneralUtils.hideLoading(context); -// // SwipeGeneralUtils.handleException(ex, context, null); // } -// // SwipeGeneralUtils.showLoading(context); -// // try { -// // GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? "", isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng); -// // if (g?.messageStatus != 1) { -// // SwipeGeneralUtils.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); -// // SwipeGeneralUtils.hideLoading(context); -// // showMDialog( -// // context, -// // backgroundColor: Colors.transparent, -// // isDismissable: false, -// // child: SuccessDialog(widget.isFromDashboard), -// // ); -// // } -// // } catch (ex) { -// // log(ex); -// // SwipeGeneralUtils.hideLoading(context); -// // // SwipeGeneralUtils.handleException(ex, context, (String msg) { -// // // SwipeGeneralUtils.confirmDialog(context, msg); -// // // }); -// // } -// }); -// } -// } - -// -// Future checkSession() async { -// try { -// SwipeGeneralUtils.showLoading(context); -// await DashboardApiClient().getOpenMissingSwipes(); -// SwipeGeneralUtils.hideLoading(context); -// return true; -// } catch (ex) { -// SwipeGeneralUtils.hideLoading(context); -// SwipeGeneralUtils.handleException(ex, context, null); -// return false; -// } -// } - -//TODO need to confirm .... -// Future performWifiAttendance({double? latitude, double? lng}) async { -// // if (Platform.isAndroid) { -// // if (!(await checkSession())) { -// // return; -// // } -// // } -// SwipeGeneralUtils.showLoading(context); -// bool isConnected = await WiFiForIoTPlugin.connect(AppState().getMohemmWifiSSID ?? "", -// password: AppState().getMohemmWifiPassword ?? "", joinOnce: Platform.isIOS ? false : true, security: NetworkSecurity.WPA, withInternet: false); -// -// if (Platform.isIOS) { -// if (await WiFiForIoTPlugin.getSSID() == AppState().getMohemmWifiSSID) { -// isConnected = true; -// } else { -// isConnected = false; // } // } // -// if (isConnected && AppState().isAuthenticated) { -// 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); -// SwipeGeneralUtils.hideLoading(context); -// await closeWifiRequest(); -// 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) { -// await closeWifiRequest(); -// SwipeGeneralUtils.hideLoading(context); -// SwipeGeneralUtils.handleException(ex, context, null); +// List availableAttendanceMethodList({@required BuildContext context}) { +// List availableMethods = []; +// if (isNfcEnabled) { +// availableMethods.add(attendanceMethod(SwipeTypeEnum.NFC.name, 'nfc_icon', isNfcEnabled, () { +// handleSwipe(swipeType: SwipeTypeEnum.NFC, isEnable: isNfcEnabled, context: context); +// })); // } -// } else { -// if (AppState().isAuthenticated) { -// SwipeGeneralUtils.hideLoading(context); -// SwipeGeneralUtils.confirmDialog(context, "LocaleKeys.comeNearHMGWifi.tr()"); -// } else { -// await closeWifiRequest(); +// if (isQrEnabled) { +// availableMethods.add(attendanceMethod(SwipeTypeEnum.QR.name, 'wifi_icon', isQrEnabled, () { +// handleSwipe(swipeType: SwipeTypeEnum.QR, isEnable: isQrEnabled, context: context); +// })); // } +// if (isWifiEnabled) { +// availableMethods.add(attendanceMethod(SwipeTypeEnum.Wifi.name, 'wifi_icon', isWifiEnabled, () { +// handleSwipe(swipeType: SwipeTypeEnum.Wifi, isEnable: isWifiEnabled, context: context); +// })); +// } +// return availableMethods; +// } +// +// Widget attendanceMethod(String title, String icon, bool isEnabled, VoidCallback onPress) { +// return Container( +// padding: EdgeInsets.all(12), +// decoration: BoxDecoration( +// color: Colors.white, +// borderRadius: BorderRadius.circular(18), +// border: Border.all(color: AppColor.white40, width: 2), +// ), +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// mainAxisAlignment: MainAxisAlignment.spaceBetween, +// children: [ +// icon.toSvgAsset(), +// title.heading5(context).custom(color: AppColor.neutral50), +// // Text( +// // title, +// // style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500), +// // ), +// ], +// ), +// ).onPress( +// () { +// log('isEnabled is ${!isEnabled}'); +// if (!isEnabled) return; +// onPress(); +// }, +// ); +// // return Container( +// // decoration: BoxDecoration( +// // borderRadius: BorderRadius.circular(15), +// // color: isEnabled ? null : Colors.grey.withOpacity(.5), +// // gradient: isEnabled +// // ? const LinearGradient( +// // transform: GradientRotation(.64), +// // begin: Alignment.topRight, +// // end: Alignment.bottomLeft, +// // colors: [ +// // //ToDo set Colors according to design provided by designer... +// // Colors.blue, +// // Colors.green, +// // // AppColor.gradiantEndColor, +// // // MyColors.gradiantStartColor, +// // ], +// // ) +// // : null, +// // ), +// // clipBehavior: Clip.antiAlias, +// // padding: const EdgeInsets.only(left: 10, right: 10, top: 14, bottom: 14), +// // child: Column( +// // crossAxisAlignment: CrossAxisAlignment.start, +// // children: [ +// // // SvgPicture.asset(image, color: Colors.white, alignment: Alignment.topLeft).expanded, +// // Icon(iconData, color: isEnabled ? AppColor.black35 : Colors.grey), +// // title.heading6(context), +// // // title.toText17(isBold: true, color: Colors.white), +// // ], +// // ), +// // ).onPress( +// // () { +// // log('isEnabled is ${!isEnabled}'); +// // if (!isEnabled) return; +// // onPress(); +// // }, +// // ); // } // } - -// older grid widget.. -// attendanceMethod(SwipeTypeEnum.NFC.name, Icons.nfc, isNfcEnabled, () { -// handleSwipe(swipeType: SwipeTypeEnum.NFC, isEnable: isNfcEnabled); -// }), -// attendanceMethod(SwipeTypeEnum.QR.name, Icons.qr_code_2, isQrEnabled, () async { -// handleSwipe(swipeType: SwipeTypeEnum.QR, isEnable: true); -// }), -// //if (isWifiEnabled) //todo -// attendanceMethod(SwipeTypeEnum.Wifi.name, Icons.wifi, isWifiEnabled, () { -// // if (AppState().getIsHuawei) { -// if (false) { -// checkHuaweiLocationPermission(SwipeTypeEnum.Wifi); -// } else { -// LocationUtilities.isEnabled((bool isEnabled) { -// if (isEnabled) { -// LocationUtilities.havePermission((bool permission) { -// if (permission) { -// SwipeGeneralUtils.showLoading(context); -// LocationUtilities.getCurrentLocation( -// (Position position, bool isMocked) { -// if (isMocked) { -// SwipeGeneralUtils.hideLoading(context); -// SwipeGeneralUtils.markFakeAttendance("WIFI", position.latitude.toString() ?? "", position.longitude.toString() ?? "", context); -// } else { -// SwipeGeneralUtils.hideLoading(context); -// //todo performWifiAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? ""); -// } -// }, -// () { -// SwipeGeneralUtils.hideLoading(context); -// SwipeGeneralUtils.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(); -// }, -// ), -// ); -// } -// }); -// } -// }), +// +// // Widget customListItem({required String icon, required String heading, required String subHeading, required VoidCallback onTap}) { +// // return GestureDetector( +// // onTap: onTap, // Handles the tap +// // child: Card( +// // shape: RoundedRectangleBorder( +// // borderRadius: BorderRadius.circular(14), // Circular border radius +// // ), +// // color: Colors.white, +// // child: Row( +// // crossAxisAlignment: CrossAxisAlignment.start, // Align items at the top +// // children: [ +// // // Icon Section +// // icon +// // .toSvgAsset( +// // width: 32, +// // color: AppColor.neutral120, +// // height: 29, +// // ) +// // .paddingOnly(top: 8), +// // 14.width, +// // Expanded( +// // child: Column( +// // crossAxisAlignment: CrossAxisAlignment.start, +// // children: [ +// // Text( +// // heading, +// // style: AppTextStyles.heading6.copyWith(color: AppColor.neutral50), +// // ), +// // 7.height, +// // Text( +// // subHeading, +// // style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral120), +// // ), +// // ], +// // ).paddingOnly(end: 50), +// // ), +// // ], +// // ).paddingAll(12), +// // ), +// // ); +// // } +// +// //qr older code... +// +// //nfc older code widget +// +// // // if (AppState().getIsHuawei) { +// // if (false) { +// // checkHuaweiLocationPermission(SwipeTypeEnum.NFC); +// // } else { +// // LocationUtilities.isEnabled((bool isEnabled) { +// // if (isEnabled) { +// // LocationUtilities.havePermission((bool permission) { +// // if (permission) { +// // SwipeGeneralUtils.showLoading(context); +// // LocationUtilities.getCurrentLocation( +// // (Position position, bool isMocked) { +// // if (isMocked) { +// // SwipeGeneralUtils.hideLoading(context); +// // SwipeGeneralUtils.markFakeAttendance("NFC", position.latitude.toString() ?? "", position.longitude.toString() ?? "",context); +// // } else { +// // SwipeGeneralUtils.hideLoading(context); +// // //todo performNfcAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? ""); +// // } +// // }, +// // () { +// // SwipeGeneralUtils.hideLoading(context); +// // SwipeGeneralUtils.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(); +// // }, +// // ), +// // ); +// // } +// // }); +// // } +// +// //older code.... +// // Future performNfcAttendance({double lat = 0, double lng = 0}) async { +// // UserProvider userProvider = Provider.of(context,listen:false); +// // if (Platform.isIOS) { +// // SwipeGeneralUtils.readNFc(onRead: (String nfcId) async { +// // SwipeGeneralUtils.showLoading(context); +// // try { +// // SwipeModel swipeResponse = await userProvider.makeSwipe(model: Swipe(swipeTypeValue: SwipeTypeEnum.NFC.getIntFromSwipeTypeEnum(), value: '', latitude: lat, longitude: lng)); +// // if (swipeResponse.responseCode != 1) { +// // SwipeGeneralUtils.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)); +// // SwipeGeneralUtils.hideLoading(context); +// // SwipeGeneralUtils.showMDialog( +// // context, +// // backgroundColor: Colors.transparent, +// // isDismissable: true, +// // child: SuccessDialog(widget.isFromDashboard), +// // ); +// // } +// // } catch (ex) { +// // SwipeGeneralUtils.hideLoading(context); +// // // SwipeGeneralUtils.handleException(ex, context, null); +// // } +// // }); +// // } else { +// // showNfcReader(context, onNcfScan: (String nfcId) async { +// // SwipeGeneralUtils.showLoading(context); +// // try { +// // SwipeModel swipeResponse = await userProvider.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) { +// // SwipeGeneralUtils.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)); +// // SwipeGeneralUtils.hideLoading(context); +// // SwipeGeneralUtils.showMDialog( +// // context, +// // backgroundColor: Colors.transparent, +// // isDismissable: true, +// // child: SuccessDialog(widget.isFromDashboard), +// // ); +// // } +// // } catch (ex) { +// // SwipeGeneralUtils.hideLoading(context); +// // // SwipeGeneralUtils.handleException(ex, context, null); +// // } +// // // SwipeGeneralUtils.showLoading(context); +// // // try { +// // // GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? "", isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng); +// // // if (g?.messageStatus != 1) { +// // // SwipeGeneralUtils.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); +// // // SwipeGeneralUtils.hideLoading(context); +// // // showMDialog( +// // // context, +// // // backgroundColor: Colors.transparent, +// // // isDismissable: false, +// // // child: SuccessDialog(widget.isFromDashboard), +// // // ); +// // // } +// // // } catch (ex) { +// // // log(ex); +// // // SwipeGeneralUtils.hideLoading(context); +// // // // SwipeGeneralUtils.handleException(ex, context, (String msg) { +// // // // SwipeGeneralUtils.confirmDialog(context, msg); +// // // // }); +// // // } +// // }); +// // } +// // } +// +// // +// // Future checkSession() async { +// // try { +// // SwipeGeneralUtils.showLoading(context); +// // await DashboardApiClient().getOpenMissingSwipes(); +// // SwipeGeneralUtils.hideLoading(context); +// // return true; +// // } catch (ex) { +// // SwipeGeneralUtils.hideLoading(context); +// // SwipeGeneralUtils.handleException(ex, context, null); +// // return false; +// // } +// // } +// +// //TODO need to confirm .... +// // Future performWifiAttendance({double? latitude, double? lng}) async { +// // // if (Platform.isAndroid) { +// // // if (!(await checkSession())) { +// // // return; +// // // } +// // // } +// // SwipeGeneralUtils.showLoading(context); +// // bool isConnected = await WiFiForIoTPlugin.connect(AppState().getMohemmWifiSSID ?? "", +// // password: AppState().getMohemmWifiPassword ?? "", joinOnce: Platform.isIOS ? false : true, security: NetworkSecurity.WPA, withInternet: false); +// // +// // if (Platform.isIOS) { +// // if (await WiFiForIoTPlugin.getSSID() == AppState().getMohemmWifiSSID) { +// // isConnected = true; +// // } else { +// // isConnected = false; +// // } +// // } +// // +// // if (isConnected && AppState().isAuthenticated) { +// // 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); +// // SwipeGeneralUtils.hideLoading(context); +// // await closeWifiRequest(); +// // 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) { +// // await closeWifiRequest(); +// // SwipeGeneralUtils.hideLoading(context); +// // SwipeGeneralUtils.handleException(ex, context, null); +// // } +// // } else { +// // if (AppState().isAuthenticated) { +// // SwipeGeneralUtils.hideLoading(context); +// // SwipeGeneralUtils.confirmDialog(context, "LocaleKeys.comeNearHMGWifi.tr()"); +// // } else { +// // await closeWifiRequest(); +// // } +// // } +// // } +// +// // older grid widget.. +// // attendanceMethod(SwipeTypeEnum.NFC.name, Icons.nfc, isNfcEnabled, () { +// // handleSwipe(swipeType: SwipeTypeEnum.NFC, isEnable: isNfcEnabled); +// // }), +// // attendanceMethod(SwipeTypeEnum.QR.name, Icons.qr_code_2, isQrEnabled, () async { +// // handleSwipe(swipeType: SwipeTypeEnum.QR, isEnable: true); +// // }), +// // //if (isWifiEnabled) //todo +// // attendanceMethod(SwipeTypeEnum.Wifi.name, Icons.wifi, isWifiEnabled, () { +// // // if (AppState().getIsHuawei) { +// // if (false) { +// // checkHuaweiLocationPermission(SwipeTypeEnum.Wifi); +// // } else { +// // LocationUtilities.isEnabled((bool isEnabled) { +// // if (isEnabled) { +// // LocationUtilities.havePermission((bool permission) { +// // if (permission) { +// // SwipeGeneralUtils.showLoading(context); +// // LocationUtilities.getCurrentLocation( +// // (Position position, bool isMocked) { +// // if (isMocked) { +// // SwipeGeneralUtils.hideLoading(context); +// // SwipeGeneralUtils.markFakeAttendance("WIFI", position.latitude.toString() ?? "", position.longitude.toString() ?? "", context); +// // } else { +// // SwipeGeneralUtils.hideLoading(context); +// // //todo performWifiAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? ""); +// // } +// // }, +// // () { +// // SwipeGeneralUtils.hideLoading(context); +// // SwipeGeneralUtils.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(); +// // }, +// // ), +// // ); +// // } +// // }); +// // } +// // }), diff --git a/lib/new_views/swipe_module/swipe_success_view.dart b/lib/new_views/swipe_module/swipe_success_view.dart index 8de8d847..717d6684 100644 --- a/lib/new_views/swipe_module/swipe_success_view.dart +++ b/lib/new_views/swipe_module/swipe_success_view.dart @@ -2,47 +2,57 @@ import 'package:flutter/material.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; +import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; +import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; class SwipeSuccessView extends StatelessWidget { static const routeName = '/swipe_success_view'; + const SwipeSuccessView({Key key}) : super(key: key); @override Widget build(BuildContext context) { - return Scaffold( + return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment:CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, children: [ - 'swipe_success'.toSvgAsset(), - 17.height, + 'swipe_success'.toSvgAsset(height: 248, width: 248), + 16.height, context.translation.successful.heading4(context).custom(color: AppColor.neutral80), 8.height, - context.translation.youHaveSuccessfullyMarkedYourAttendance.bodyText2(context).custom(color: AppColor.white20), + context.translation.youHaveSuccessfullyMarkedYourAttendance.bodyText2(context).custom(color: AppColor.white20, align: TextAlign.center), + 24.height, + AppFilledButton( + label: "Go Back", + onPressed: () { + Navigator.pop(context); + Navigator.pop(context); + }, + textColor: Colors.white) + .paddingOnly(start: 24, end: 24), ], - ), + ).paddingAll(16), ), ); } } - class CircularAnimationWithProgressIndicator extends StatefulWidget { Widget child; + CircularAnimationWithProgressIndicator({Key key, this.child}) : super(key: key); + @override - _CircularAnimationWithProgressIndicatorState createState() => - _CircularAnimationWithProgressIndicatorState(); + _CircularAnimationWithProgressIndicatorState createState() => _CircularAnimationWithProgressIndicatorState(); } -class _CircularAnimationWithProgressIndicatorState - extends State - with SingleTickerProviderStateMixin { +class _CircularAnimationWithProgressIndicatorState extends State with SingleTickerProviderStateMixin { AnimationController _controller; - @override void initState() { super.initState(); @@ -88,14 +98,13 @@ class _CircularAnimationWithProgressIndicatorState ), // Static container in the center - widget.child?? const SizedBox(), + widget.child ?? const SizedBox(), ], ), ); } } - // ClipOval( // child: Container( // color: Colors.grey.withOpacity(0.2), diff --git a/lib/new_views/swipe_module/utils/swipe_general_utils.dart b/lib/new_views/swipe_module/utils/swipe_general_utils.dart index 2d85c063..c8f978e4 100644 --- a/lib/new_views/swipe_module/utils/swipe_general_utils.dart +++ b/lib/new_views/swipe_module/utils/swipe_general_utils.dart @@ -170,21 +170,14 @@ class SwipeGeneralUtils { static void confirmDialog(cxt, String message, {VoidCallback onTap}) { showDialog( context: cxt, - builder: (BuildContext cxt) => ConfirmDialog( - message: message, - onTap: onTap, - ), + builder: (BuildContext cxt) => ConfirmDialog(message: message, onTap: onTap), ); } static void showErrorDialog({String message, @required BuildContext context}) { showDialog( context: context, - builder: (context) => ConfirmDialog( - message: message, - title: 'Error', - onTap: () => Navigator.pop(context), - ), + builder: (context) => ConfirmDialog(message: message, title: 'Error', onTap: () => Navigator.pop(context)), ); } @@ -399,8 +392,6 @@ class SwipeGeneralUtils { // } } - // general methods...... - static void handleSwipeOperation({@required SwipeTypeEnum swipeType, double lat, double lang, BuildContext context}) { switch (swipeType) { case SwipeTypeEnum.NFC: @@ -448,7 +439,7 @@ class SwipeGeneralUtils { if (swipeResponse.isSuccess) { hideLoading(context); - showSuccessDialog(context: context); + Navigator.pushNamed(context, SwipeSuccessView.routeName); } else { hideLoading(context); showDialog( @@ -513,7 +504,7 @@ class SwipeGeneralUtils { if (swipeResponse.isSuccess) { hideLoading(context); - showSuccessDialog(context: context, fromDashBoard: true); + Navigator.pushNamed(context, SwipeSuccessView.routeName); } else { hideLoading(context); showErrorDialog(message: swipeResponse.message ?? "Unexpected error occurred", context: context); @@ -525,11 +516,7 @@ class SwipeGeneralUtils { } } - static void handleSwipe({ - SwipeTypeEnum swipeType, - @required bool isEnable, - @required BuildContext context, - }) async { + static void handleSwipe({SwipeTypeEnum swipeType, @required bool isEnable, @required BuildContext context}) async { if (!(await isGoogleServicesAvailable())) { checkHuaweiLocationPermission(attendanceType: swipeType, context: context); } else { @@ -606,10 +593,10 @@ class SwipeGeneralUtils { return availableMethods; } - static Future showSwipeTypeBottomSheetSheet({@required BuildContext context, @required bool isNfcSupported}) { + static void showSwipeTypeBottomSheetSheet({@required BuildContext context, @required bool isNfcSupported}) { UserProvider _userProvider = Provider.of(context, listen: false); - return showModalBottomSheet( + showModalBottomSheet( context: context, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical( @@ -636,16 +623,6 @@ class SwipeGeneralUtils { ); } - static void showSuccessDialog({@required BuildContext context, bool fromDashBoard}) { - Navigator.pushReplacementNamed(context, SwipeSuccessView.routeName); - // showMDialog( - // context, - // backgroundColor: Colors.transparent, - // isDismissable: true, - // child: SuccessDialog(fromDashBoard), - // ); - } - static void readNFc({Function(String) onRead}) { NfcManager.instance.startSession(onDiscovered: (NfcTag tag) async { MifareUltralight f;