Merge branch 'refs/heads/ui_ux_rollout_merge' into ui_ux_rollout_merge_notification_settings
# Conflicts: # lib/dashboard_latest/widgets/app_bar_widget.dart # lib/modules/cm_module/cm_detail_page.dartui_ux_rollout_merge_notification_settings
commit
6087f55cc8
@ -0,0 +1,13 @@
|
||||
<svg width="130" height="150" viewBox="0 0 130 150" xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- front face -->
|
||||
<rect x="30" y="46" width="65" height="48" rx="4" fill="none" stroke="#3D3D3A" stroke-width="2"/>
|
||||
<!-- screen indicator -->
|
||||
<rect x="40" y="56" width="26" height="16" rx="2" fill="none" stroke="#3D3D3A" stroke-width="1.2"/>
|
||||
<!-- bottom face (highlighted) -->
|
||||
<polygon points="30,94 50,114 115,114 95,94" fill="#F5C4B3" stroke="#993C1D" stroke-width="2"/>
|
||||
<!-- right side face -->
|
||||
<polygon points="95,46 115,26 115,74 95,94" fill="none" stroke="#3D3D3A" stroke-width="2"/>
|
||||
<!-- arrow pointing up into bottom face -->
|
||||
<line x1="73" y1="142" x2="73" y2="118" stroke="#3D3D3A" stroke-width="3" stroke-linecap="round"/>
|
||||
<polygon points="73,112 66,124 80,124" fill="#3D3D3A"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 808 B |
@ -0,0 +1,13 @@
|
||||
<svg width="150" height="150" viewBox="0 0 150 150" xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- front face (highlighted, left side facing camera) -->
|
||||
<rect x="32" y="52" width="56" height="58" rx="4" fill="#9FE1CB" stroke="#0F6E56" stroke-width="2"/>
|
||||
<!-- screen indicator -->
|
||||
<rect x="42" y="62" width="24" height="15" rx="2" fill="none" stroke="#0F6E56" stroke-width="1.2"/>
|
||||
<!-- top face -->
|
||||
<polygon points="32,52 52,32 118,32 88,52" fill="none" stroke="#3D3D3A" stroke-width="2"/>
|
||||
<!-- right side face -->
|
||||
<polygon points="88,52 118,32 118,90 88,110" fill="none" stroke="#3D3D3A" stroke-width="2"/>
|
||||
<!-- arrow pointing right onto left face -->
|
||||
<line x1="5" y1="81" x2="28" y2="81" stroke="#3D3D3A" stroke-width="3" stroke-linecap="round"/>
|
||||
<polygon points="34,81 22,74 22,88" fill="#3D3D3A"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 824 B |
@ -0,0 +1,13 @@
|
||||
<svg width="150" height="150" viewBox="0 0 150 150" xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- front-left face -->
|
||||
<polygon points="28,52 58,32 58,90 28,110" fill="none" stroke="#3D3D3A" stroke-width="2"/>
|
||||
<!-- top face -->
|
||||
<polygon points="28,52 58,32 95,32 65,52" fill="none" stroke="#3D3D3A" stroke-width="2"/>
|
||||
<!-- right face highlighted, facing camera -->
|
||||
<polygon points="65,52 95,32 95,90 65,110" fill="#FAC775" stroke="#854F0B" stroke-width="2"/>
|
||||
<!-- screen indicator on front-left face for context -->
|
||||
<rect x="34" y="60" width="16" height="14" rx="2" fill="none" stroke="#3D3D3A" stroke-width="1"/>
|
||||
<!-- arrow pointing left onto right face -->
|
||||
<line x1="145" y1="81" x2="122" y2="81" stroke="#3D3D3A" stroke-width="3" stroke-linecap="round"/>
|
||||
<polygon points="116,81 128,74 128,88" fill="#3D3D3A"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 837 B |
@ -0,0 +1,13 @@
|
||||
<svg width="130" height="150" viewBox="0 0 130 150" xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- front face -->
|
||||
<rect x="30" y="68" width="65" height="48" rx="4" fill="none" stroke="#3D3D3A" stroke-width="2"/>
|
||||
<!-- screen indicator -->
|
||||
<rect x="40" y="78" width="26" height="16" rx="2" fill="none" stroke="#3D3D3A" stroke-width="1.2"/>
|
||||
<!-- top face (highlighted) -->
|
||||
<polygon points="30,68 50,48 115,48 95,68" fill="#B5D4F4" stroke="#185FA5" stroke-width="2"/>
|
||||
<!-- right side face -->
|
||||
<polygon points="95,68 115,48 115,96 95,116" fill="none" stroke="#3D3D3A" stroke-width="2"/>
|
||||
<!-- arrow pointing down onto top face -->
|
||||
<line x1="73" y1="8" x2="73" y2="38" stroke="#3D3D3A" stroke-width="3" stroke-linecap="round"/>
|
||||
<polygon points="73,44 66,32 80,32" fill="#3D3D3A"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 797 B |
@ -1,866 +0,0 @@
|
||||
// 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: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: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';
|
||||
// import 'package:test_sa/views/widgets/qr_scanner_dialog.dart';
|
||||
// import 'package:wifi_iot/wifi_iot.dart';
|
||||
//
|
||||
// import '../../app_style/app_color.dart';
|
||||
//
|
||||
// class MarkAttendanceWidget extends StatefulWidget {
|
||||
// // DashboardProviderModel model;
|
||||
// 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<MarkAttendanceWidget> {
|
||||
// bool isNfcEnabled = false, isNfcLocationEnabled = false, isQrEnabled = false, isQrLocationEnabled = false, isWifiEnabled = false, isWifiLocationEnabled = false;
|
||||
//
|
||||
// int _locationUpdateCbId = 0;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// checkAttendanceAvailability();
|
||||
// }
|
||||
//
|
||||
// void checkAttendanceAvailability() async {
|
||||
// bool isAvailable = await NfcManager.instance.isAvailable();
|
||||
// // setState(() {
|
||||
// // AppState().privilegeListModel!.forEach((PrivilegeListModel element) {
|
||||
// // if (element.serviceName == "enableNFC") {
|
||||
// // if (isAvailable) if (element.previlege ?? false) isNfcEnabled = true;
|
||||
// // } else if (element.serviceName == "enableQR") {
|
||||
// // if (element.previlege ?? false) isQrEnabled = true;
|
||||
// // } else if (element.serviceName == "enableWIFI") {
|
||||
// // if (element.previlege ?? false) isWifiEnabled = true;
|
||||
// // } else if (element.serviceName!.trim() == "enableLocationNFC") {
|
||||
// // if (element.previlege ?? false) isNfcLocationEnabled = true;
|
||||
// // } else if (element.serviceName == "enableLocationQR") {
|
||||
// // if (element.previlege ?? false) isQrLocationEnabled = true;
|
||||
// // } else if (element.serviceName == "enableLocationWIFI") {
|
||||
// // if (element.previlege ?? false) isWifiLocationEnabled = true;
|
||||
// // }
|
||||
// // });
|
||||
// // });
|
||||
// }
|
||||
//
|
||||
// void checkHuaweiLocationPermission(String attendanceType) async {
|
||||
// // Permission_Handler permissionHandler = PermissionHandler();
|
||||
// location.Location.isEnabled((bool isEnabled) async {
|
||||
// if (isEnabled) {
|
||||
// location.Location.havePermission((bool permission) async {
|
||||
// if (permission) {
|
||||
// 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);
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// } 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<bool> 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: [
|
||||
// // 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: <Widget>[
|
||||
// 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");
|
||||
// } 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("NFC", position.latitude.toString() ?? "", position.longitude.toString() ?? "");
|
||||
// } else {
|
||||
// Utils.hideLoading(context);
|
||||
// //todo performNfcAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? "");
|
||||
// }
|
||||
// },
|
||||
// () {
|
||||
// Utils.hideLoading(context);
|
||||
// Utils.confirmDialog(context, "Unable to determine your location, Please make sure that your location services are turned on & working.");
|
||||
// },
|
||||
// context,
|
||||
// );
|
||||
// } else {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext cxt) => ConfirmDialog(
|
||||
// message: "You need to give location permission to mark attendance",
|
||||
// onTap: () async {
|
||||
// Navigator.pop(context);
|
||||
// await Geolocator.openAppSettings();
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext cxt) => ConfirmDialog(
|
||||
// message: "You need to enable location services to mark attendance",
|
||||
// onTap: () async {
|
||||
// Navigator.pop(context);
|
||||
// await Geolocator.openLocationSettings();
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }),
|
||||
// //if (isWifiEnabled) //todo
|
||||
// attendanceMethod("Wifi", Icons.wifi, isWifiEnabled, () {
|
||||
// // if (AppState().getIsHuawei) {
|
||||
// if (false) {
|
||||
// checkHuaweiLocationPermission("WIFI");
|
||||
// } 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("WIFI", position.latitude.toString() ?? "", position.longitude.toString() ?? "");
|
||||
// } else {
|
||||
// Utils.hideLoading(context);
|
||||
// //todo performWifiAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? "");
|
||||
// }
|
||||
// },
|
||||
// () {
|
||||
// Utils.hideLoading(context);
|
||||
// Utils.confirmDialog(context, "Unable to determine your location, Please make sure that your location services are turned on & working.");
|
||||
// },
|
||||
// context,
|
||||
// );
|
||||
// } else {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext cxt) => ConfirmDialog(
|
||||
// message: "You need to give location permission to mark attendance",
|
||||
// onTap: () async {
|
||||
// Navigator.pop(context);
|
||||
// await Geolocator.openAppSettings();
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext cxt) => ConfirmDialog(
|
||||
// message: "You need to enable location services to mark attendance",
|
||||
// onTap: () async {
|
||||
// Navigator.pop(context);
|
||||
// await Geolocator.openLocationSettings();
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }),
|
||||
// // if (isQrEnabled) //todo
|
||||
// attendanceMethod(SwipeTypeEnum.QR.name, Icons.qr_code_2, true, () async {
|
||||
// handleSwipe(swipeType: SwipeTypeEnum.QR, isEnable: true);
|
||||
// return;
|
||||
// // if (AppState().getIsHuawei) {
|
||||
// if (false) {
|
||||
// checkHuaweiLocationPermission("QR");
|
||||
// } 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("QR", position.latitude.toString() ?? "", position.longitude.toString() ?? "");
|
||||
// } else {
|
||||
// Utils.hideLoading(context);
|
||||
// //todo performQrCodeAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? "");
|
||||
// }
|
||||
// },
|
||||
// () {
|
||||
// Utils.hideLoading(context);
|
||||
// Utils.confirmDialog(context, "Unable to determine your location, Please make sure that your location services are turned on & working.");
|
||||
// },
|
||||
// context,
|
||||
// );
|
||||
// } else {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext cxt) => ConfirmDialog(
|
||||
// message: "You need to give location permission to mark attendance",
|
||||
// onTap: () async {
|
||||
// Navigator.pop(context);
|
||||
// await Geolocator.openAppSettings();
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext cxt) => ConfirmDialog(
|
||||
// message: "You need to enable location services to mark attendance",
|
||||
// onTap: () async {
|
||||
// Navigator.pop(context);
|
||||
// await Geolocator.openLocationSettings();
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }),
|
||||
// ],
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// FusedLocationProviderClient locationService = FusedLocationProviderClient()..initFusedLocationService();
|
||||
// LocationRequest locationRequest = LocationRequest();
|
||||
// locationRequest.priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
|
||||
// locationRequest.interval = 500;
|
||||
// List<LocationRequest> locationRequestList = <LocationRequest>[locationRequest];
|
||||
// LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList);
|
||||
//
|
||||
// late StreamSubscription<Location> _streamSubscription;
|
||||
// int requestCode = (await (locationService.requestLocationUpdates(locationRequest)))!;
|
||||
//
|
||||
// _streamSubscription = locationService.onLocationData!.listen(
|
||||
// (Location location) async {
|
||||
// Utils.hideLoading(context);
|
||||
// await locationService.removeLocationUpdates(requestCode);
|
||||
// if (attendanceType == "QR") {
|
||||
// // todo performQrCodeAttendance(widget.model, lat: location.latitude.toString() ?? "", lng: location.longitude.toString() ?? "");
|
||||
// }
|
||||
// if (attendanceType == "WIFI") {
|
||||
// // todo performWifiAttendance(widget.model, lat: location.latitude.toString() ?? "", lng: location.longitude.toString() ?? "");
|
||||
// }
|
||||
// if (attendanceType == "NFC") {
|
||||
// //todo performNfcAttendance(widget.model, lat: location.latitude.toString() ?? "", lng: location.longitude.toString() ?? "");
|
||||
// }
|
||||
// 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');
|
||||
// Utils.hideLoading(context);
|
||||
// // Utils.handleException(error, context, null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// 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(
|
||||
// context: context,
|
||||
// barrierDismissible: isDismissable,
|
||||
// builder: (context) {
|
||||
// return Dialog(
|
||||
// shape: isBusniessCard
|
||||
// ? const RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.all(
|
||||
// Radius.circular(15.0),
|
||||
// ),
|
||||
// )
|
||||
// : null,
|
||||
// backgroundColor: backgroundColor,
|
||||
// child: child,
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
// //
|
||||
// // Future<bool> checkSession() async {
|
||||
// // try {
|
||||
// // Utils.showLoading(context);
|
||||
// // await DashboardApiClient().getOpenMissingSwipes();
|
||||
// // Utils.hideLoading(context);
|
||||
// // return true;
|
||||
// // } catch (ex) {
|
||||
// // Utils.hideLoading(context);
|
||||
// // Utils.handleException(ex, context, null);
|
||||
// // return false;
|
||||
// // }
|
||||
// // }
|
||||
//
|
||||
//
|
||||
// //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);
|
||||
// //
|
||||
// // 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);
|
||||
// // Utils.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();
|
||||
// // Utils.hideLoading(context);
|
||||
// // Utils.handleException(ex, context, null);
|
||||
// // }
|
||||
// // } else {
|
||||
// // if (AppState().isAuthenticated) {
|
||||
// // Utils.hideLoading(context);
|
||||
// // Utils.confirmDialog(context, "LocaleKeys.comeNearHMGWifi.tr()");
|
||||
// // } else {
|
||||
// // await closeWifiRequest();
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
//
|
||||
// Future<bool> closeWifiRequest() async {
|
||||
// if (Platform.isAndroid) {
|
||||
// await WiFiForIoTPlugin.forceWifiUsage(false);
|
||||
// }
|
||||
// return await WiFiForIoTPlugin.disconnect();
|
||||
// }
|
||||
//
|
||||
// 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(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) {
|
||||
// log('$ex');
|
||||
// Utils.hideLoading(context);
|
||||
// //Utils.handleException(ex, context, null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Widget attendanceMethod(String title, IconData iconData, bool isEnabled, VoidCallback onPress) => 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();
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
@ -1,61 +1,61 @@
|
||||
import 'package:flutter/material.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 ConfirmDialog extends StatelessWidget {
|
||||
final String? title;
|
||||
final String? message;
|
||||
final String? okTitle;
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onCloseTap;
|
||||
|
||||
const ConfirmDialog({Key? key, this.title, this.message, this.okTitle, this.onTap, this.onCloseTap}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
backgroundColor: AppColor.background(context),
|
||||
shape: const RoundedRectangleBorder(),
|
||||
insetPadding: const EdgeInsets.only(left: 21, right: 21),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
title ?? "Confirm",
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: AppColor.headingTextColor(context), height: 35 / 24, letterSpacing: -0.96),
|
||||
).paddingOnly(top: 16),
|
||||
),
|
||||
IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
icon: const Icon(Icons.close),
|
||||
color: AppColor.iconColor(context),
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () => onCloseTap ?? Navigator.pop(context),
|
||||
// onPressed: () => Navigator.pop(context),
|
||||
)
|
||||
],
|
||||
),
|
||||
message != null ? message!.heading5(context).custom(color: AppColor.textColor(context)) : const SizedBox(),
|
||||
28.height,
|
||||
AppFilledButton(
|
||||
label: okTitle ?? "OK",
|
||||
onPressed: onTap ?? () => Navigator.pop(context),
|
||||
textColor: Colors.white,
|
||||
//color: Ap.green,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
// import 'package:flutter/material.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 ConfirmDialog extends StatelessWidget {
|
||||
// final String? title;
|
||||
// final String? message;
|
||||
// final String? okTitle;
|
||||
// final VoidCallback? onTap;
|
||||
// final VoidCallback? onCloseTap;
|
||||
//
|
||||
// const ConfirmDialog({Key? key, this.title, this.message, this.okTitle, this.onTap, this.onCloseTap}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Dialog(
|
||||
// backgroundColor: AppColor.background(context),
|
||||
// shape: const RoundedRectangleBorder(),
|
||||
// insetPadding: const EdgeInsets.only(left: 21, right: 21),
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28),
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// title ?? "Confirm",
|
||||
// style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: AppColor.headingTextColor(context), height: 35 / 24, letterSpacing: -0.96),
|
||||
// ).paddingOnly(top: 16),
|
||||
// ),
|
||||
// IconButton(
|
||||
// padding: EdgeInsets.zero,
|
||||
// icon: const Icon(Icons.close),
|
||||
// color: AppColor.iconColor(context),
|
||||
// constraints: const BoxConstraints(),
|
||||
// onPressed: () => onCloseTap ?? Navigator.pop(context),
|
||||
// // onPressed: () => Navigator.pop(context),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// message != null ? message!.heading5(context).custom(color: AppColor.textColor(context)) : const SizedBox(),
|
||||
// 28.height,
|
||||
// AppFilledButton(
|
||||
// label: okTitle ?? "OK",
|
||||
// onPressed: onTap ?? () => Navigator.pop(context),
|
||||
// textColor: Colors.white,
|
||||
// //color: Ap.green,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,821 +0,0 @@
|
||||
// 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<MarkAttendanceWidget> {
|
||||
// bool isNfcEnabled = false, isQrEnabled = false, isWifiEnabled = false;
|
||||
// UserProvider _userProvider;
|
||||
//
|
||||
// int _locationUpdateCbId = 0;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// checkAttendanceAvailability();
|
||||
// }
|
||||
//
|
||||
// void checkAttendanceAvailability() async {
|
||||
// _userProvider = Provider.of<UserProvider>(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<bool> 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).custom(color: AppColor.textStyleColor(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<LocationRequest> locationRequestList = <LocationRequest>[locationRequest];
|
||||
// LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList);
|
||||
//
|
||||
// StreamSubscription<Location> _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<void> handleNfcAttendance({double latitude = 0, double longitude = 0, BuildContext context}) async {
|
||||
// final userProvider = Provider.of<UserProvider>(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<void> _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.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<bool> closeWifiRequest() async {
|
||||
// if (Platform.isAndroid) {
|
||||
// await WiFiForIoTPlugin.forceWifiUsage(false);
|
||||
// }
|
||||
// return await WiFiForIoTPlugin.disconnect();
|
||||
// }
|
||||
//
|
||||
// Future<void> performQrCodeAttendance({double latitude, double longitude, BuildContext context}) async {
|
||||
// UserProvider userProvider = Provider.of<UserProvider>(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 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: (cxt) => ConfirmDialog(
|
||||
// message: swipeResponse.message ?? "",
|
||||
// onTap: () {
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// onCloseTap: () {}
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// } catch (ex) {
|
||||
// SwipeGeneralUtils.hideLoading(context);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<Widget> availableAttendanceMethodList({@required BuildContext context}) {
|
||||
// List<Widget> 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),
|
||||
// // ),
|
||||
// // );
|
||||
// // }
|
||||
//
|
||||
// //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<void> performNfcAttendance({double lat = 0, double lng = 0}) async {
|
||||
// // UserProvider userProvider = Provider.of<UserProvider>(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<bool> 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<void> 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();
|
||||
// // },
|
||||
// // ),
|
||||
// // );
|
||||
// // }
|
||||
// // });
|
||||
// // }
|
||||
// // }),
|
||||
@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
|
||||
import '../new_views/app_style/app_color.dart';
|
||||
|
||||
class FullScreenImageViewer extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const FullScreenImageViewer(this.child, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
InteractiveViewer(clipBehavior: Clip.none, panEnabled: true, minScale: 0.5, maxScale: 4.0, child: child).center,
|
||||
SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: FloatingActionButton(
|
||||
heroTag: "full-screen-image-viewer",
|
||||
backgroundColor: AppColor.background(context),
|
||||
onPressed: () => Navigator.maybePop(context),
|
||||
hoverColor: Colors.transparent,
|
||||
splashColor: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(color: AppColor.borderColor(context)),
|
||||
borderRadius: BorderRadius.circular(14.0),
|
||||
),
|
||||
child: Icon(Icons.clear, size: 24, color: AppColor.icon2Color(context)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class LoadingWithTextDialog extends StatelessWidget {
|
||||
final String? message;
|
||||
|
||||
const LoadingWithTextDialog({Key? key, this.message}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
child: Container(
|
||||
height: 150.toScreenWidth,
|
||||
width: 200.toScreenWidth,
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.neutral30,
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
boxShadow: [AppStyle.boxShadow],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const CircularProgressIndicator(strokeWidth: 3),
|
||||
16.height,
|
||||
Text(
|
||||
message ?? "Uploading...",
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: AppColor.textColor(context), height: 35 / 24, letterSpacing: -0.96),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,251 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/devices_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.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/device/asset_by_id_model.dart';
|
||||
import 'package:test_sa/models/generic_attachment_model.dart';
|
||||
import 'package:test_sa/modules/cm_module/cm_request_utils.dart';
|
||||
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.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/common_widgets/default_app_bar.dart';
|
||||
import 'package:test_sa/views/full_screen_image_viewer.dart';
|
||||
import 'package:test_sa/views/widgets/dialogs/dialog.dart';
|
||||
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
|
||||
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
|
||||
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';
|
||||
|
||||
class AssetImageUploadPage extends StatefulWidget {
|
||||
int assetId;
|
||||
TrainingImageData? attachments;
|
||||
|
||||
AssetImageUploadPage({Key? key, required this.assetId, this.attachments}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AssetImageUploadPageState createState() {
|
||||
return _AssetImageUploadPageState();
|
||||
}
|
||||
}
|
||||
|
||||
class _AssetImageUploadPageState extends State<AssetImageUploadPage> {
|
||||
late TrainingImageData trainingImageData;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
trainingImageData = widget.attachments ?? TrainingImageData(additionalImages: []);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const DefaultAppBar(title: "Upload Images"),
|
||||
body: Column(
|
||||
children: [
|
||||
ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
InfoHeader16Widget("Instructions"),
|
||||
InfoTextLabelWidget(
|
||||
label:
|
||||
"* Please upload all images of the sides of the asset as mentioned below.\n* Images should be clear and high quality.\n* Avoid uploading blurry, low-light or low-resolution images."),
|
||||
GridView(
|
||||
padding: const EdgeInsets.only(top: 16, bottom: 16),
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate:
|
||||
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: (MediaQuery.of(context).size.width < 550) ? 4 : 4, childAspectRatio: 1, crossAxisSpacing: 12, mainAxisSpacing: 12),
|
||||
children: <Widget>[
|
||||
gridCard(
|
||||
icon: "asset_image_upload/side_right",
|
||||
title: "Right Side",
|
||||
attachment: trainingImageData.rightImage,
|
||||
onUpdate: (value) {
|
||||
trainingImageData.rightImage = value;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
gridCard(
|
||||
icon: "asset_image_upload/side_left",
|
||||
title: "Left Side",
|
||||
attachment: trainingImageData.leftImage,
|
||||
onUpdate: (value) {
|
||||
trainingImageData.leftImage = value;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
gridCard(
|
||||
icon: "asset_image_upload/side_top",
|
||||
title: "Top Side",
|
||||
attachment: trainingImageData.upImage,
|
||||
onUpdate: (value) {
|
||||
trainingImageData.upImage = value;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
gridCard(
|
||||
icon: "asset_image_upload/side_bottom",
|
||||
title: "Bottom Side",
|
||||
attachment: trainingImageData.downImage,
|
||||
onUpdate: (value) {
|
||||
trainingImageData.downImage = value;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
AttachmentPicker(
|
||||
label: "Additional Images",
|
||||
pickerTitle: "Attach Images",
|
||||
attachment: trainingImageData.additionalImages!,
|
||||
buttonColor: AppColor.black10,
|
||||
onlyImages: true,
|
||||
pickMultiple: true,
|
||||
// showAsGrid: true,
|
||||
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
|
||||
onChange: (_attachments) {
|
||||
trainingImageData.additionalImages = _attachments;
|
||||
setState(() {});
|
||||
},
|
||||
).toShadowContainer(context),
|
||||
],
|
||||
).expanded,
|
||||
FooterActionButton.footerContainer(
|
||||
context: context,
|
||||
child: AppFilledButton(
|
||||
buttonColor: AppColor.primary10,
|
||||
disableButton: trainingImageData.leftImage == null || trainingImageData.rightImage == null || trainingImageData.upImage == null || trainingImageData.downImage == null,
|
||||
label: "Upload",
|
||||
onPressed: () async {
|
||||
bool result = await showDialog(
|
||||
context: context,
|
||||
builder: (_) => AAlertDialog(
|
||||
title: context.translation.confirm,
|
||||
content: "I followed all the instructions and uploading the images in high quality, clear and not blurry.",
|
||||
),
|
||||
);
|
||||
if (result) {
|
||||
Utils.showLoadingWithTextDialog(context);
|
||||
result = await Provider.of<AssetProvider>(context, listen: false).uploadAssetImages(widget.assetId, trainingImageData);
|
||||
Utils.hideLoading(context);
|
||||
if (result) {
|
||||
Navigator.pop(context, result);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
Widget gridCard({
|
||||
required String icon,
|
||||
required String title,
|
||||
required GenericAttachmentModel? attachment,
|
||||
required Function(GenericAttachmentModel?) onUpdate,
|
||||
}) {
|
||||
return Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: AttachmentPicker(
|
||||
label: "",
|
||||
pickerTitle: title,
|
||||
onlyImages: true,
|
||||
checkQuality: true,
|
||||
enabled: attachment == null,
|
||||
attachment: attachment == null ? [] : [attachment],
|
||||
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10),
|
||||
onChange: (_attachments) {
|
||||
if (_attachments.isNotEmpty) {
|
||||
onUpdate(_attachments.first);
|
||||
} else {
|
||||
onUpdate(null);
|
||||
}
|
||||
},
|
||||
child: imageAngleCard(icon, title, attachment),
|
||||
).toShadowContainer(context, padding: 0),
|
||||
),
|
||||
if (attachment != null)
|
||||
Positioned(
|
||||
top: 4,
|
||||
right: 4,
|
||||
child: IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
icon: const Icon(Icons.clear),
|
||||
iconSize: 18,
|
||||
style: IconButton.styleFrom(elevation: 2, tapTargetSize: MaterialTapTargetSize.shrinkWrap, backgroundColor: AppColor.red30, foregroundColor: Colors.white),
|
||||
visualDensity: VisualDensity.compact,
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () {
|
||||
onUpdate(null);
|
||||
},
|
||||
)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget imageAngleCard(String icon, String title, GenericAttachmentModel? attachment) {
|
||||
if (attachment != null) {
|
||||
Widget imageWidget = _getImageWidget(attachment.name!);
|
||||
return ClipRRect(borderRadius: BorderRadius.circular(12), child: imageWidget.onPress(() => context.fullScreenImageViewer(imageWidget)));
|
||||
}
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
icon.toSvgAsset(height: 50, width: 50),
|
||||
Text(
|
||||
title,
|
||||
style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _getImageWidget(String imageUrl) {
|
||||
// Check if it's base64 encoded (contains | separator)
|
||||
if (imageUrl.contains('|')) {
|
||||
try {
|
||||
final base64Data = imageUrl.split('|').last;
|
||||
return Image.memory(
|
||||
base64Decode(base64Data),
|
||||
fit: BoxFit.cover,
|
||||
);
|
||||
} catch (e) {
|
||||
return const Icon(Icons.broken_image, size: 48);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if it's a local file path
|
||||
if (CMRequestUtils.isLocalUrl(imageUrl)) {
|
||||
return Image.file(
|
||||
File(imageUrl),
|
||||
fit: BoxFit.cover,
|
||||
);
|
||||
}
|
||||
|
||||
// Otherwise treat as network URL
|
||||
return Image.network(
|
||||
imageUrl,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return const Icon(Icons.broken_image, size: 48);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue