|
|
|
@ -4,10 +4,8 @@ import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
import 'package:geolocator/geolocator.dart';
|
|
|
|
import 'package:geolocator/geolocator.dart';
|
|
|
|
import 'package:huawei_location/location/fused_location_provider_client.dart';
|
|
|
|
|
|
|
|
import 'package:huawei_location/location/location_request.dart';
|
|
|
|
// import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
import 'package:huawei_location/location/location_settings_request.dart';
|
|
|
|
|
|
|
|
import 'package:huawei_location/permission/permission_handler.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/api/dashboard_api_client.dart';
|
|
|
|
import 'package:mohem_flutter_app/api/dashboard_api_client.dart';
|
|
|
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
|
|
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
@ -18,6 +16,7 @@ import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/generic_response_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/generic_response_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/privilege_list_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/privilege_list_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/provider/hmg_connection_provider.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/dialogs/success_dialog.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/dialogs/success_dialog.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart';
|
|
|
|
@ -25,8 +24,7 @@ import 'package:mohem_flutter_app/widgets/location/Location.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/nfc/nfc_reader_sheet.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/nfc/nfc_reader_sheet.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/qr_scanner_dialog.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/qr_scanner_dialog.dart';
|
|
|
|
import 'package:nfc_manager/nfc_manager.dart';
|
|
|
|
import 'package:nfc_manager/nfc_manager.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:platform_device_id/platform_device_id.dart';
|
|
|
|
|
|
|
|
import 'package:wifi_iot/wifi_iot.dart';
|
|
|
|
import 'package:wifi_iot/wifi_iot.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class MarkAttendanceWidget extends StatefulWidget {
|
|
|
|
class MarkAttendanceWidget extends StatefulWidget {
|
|
|
|
@ -45,8 +43,6 @@ class MarkAttendanceWidget extends StatefulWidget {
|
|
|
|
class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
bool isNfcEnabled = false, isNfcLocationEnabled = false, isQrEnabled = false, isQrLocationEnabled = false, isWifiEnabled = false, isWifiLocationEnabled = false;
|
|
|
|
bool isNfcEnabled = false, isNfcLocationEnabled = false, isQrEnabled = false, isQrLocationEnabled = false, isWifiEnabled = false, isWifiLocationEnabled = false;
|
|
|
|
|
|
|
|
|
|
|
|
int _locationUpdateCbId = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
@ -54,8 +50,6 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void checkAttendanceAvailability() async {
|
|
|
|
void checkAttendanceAvailability() async {
|
|
|
|
String? deviceID = await PlatformDeviceId.getDeviceId;
|
|
|
|
|
|
|
|
print("Platform Device ID: $deviceID");
|
|
|
|
|
|
|
|
bool isAvailable = await NfcManager.instance.isAvailable();
|
|
|
|
bool isAvailable = await NfcManager.instance.isAvailable();
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
AppState().privilegeListModel!.forEach((PrivilegeListModel element) {
|
|
|
|
AppState().privilegeListModel!.forEach((PrivilegeListModel element) {
|
|
|
|
@ -76,36 +70,6 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void checkHuaweiLocationPermission(String attendanceType) async {
|
|
|
|
|
|
|
|
PermissionHandler permissionHandler = PermissionHandler();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
super.dispose();
|
|
|
|
@ -115,135 +79,103 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
return Consumer<HmgConnectionProvider>(builder: (_, HmgConnectionProvider provider, __) {
|
|
|
|
padding: EdgeInsets.only(left: 21, right: 21, bottom: 21, top: widget.topPadding),
|
|
|
|
return Container(
|
|
|
|
decoration: const BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
width: double.infinity,
|
|
|
|
borderRadius: const BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)),
|
|
|
|
child: Column(
|
|
|
|
color: provider.isConnectedToHMG ? MyColors.greenColor : MyColors.pinkDarkColor,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
),
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
width: double.infinity,
|
|
|
|
children: [
|
|
|
|
child: Column(
|
|
|
|
LocaleKeys.markAttendance.tr().toSectionHeading(),
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
LocaleKeys.selectMethodOfAttendance.tr().tr().toText11(color: const Color(0xff535353)),
|
|
|
|
children: [
|
|
|
|
GridView(
|
|
|
|
Padding(
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
padding: const EdgeInsets.only(left: 25, right: 25, top: 10, bottom: 10),
|
|
|
|
shrinkWrap: true,
|
|
|
|
// child: (provider.isConnectedToHMG ? LocaleKeys.connectedWithHmg.tr() : LocaleKeys.networkMustHMG.tr()).toText12(color: Colors.white),
|
|
|
|
padding: const EdgeInsets.only(bottom: 0, top: 21),
|
|
|
|
child: (provider.isConnectedToHMG ? "Connected With HMG" : "Network Must be HMG").toText12(color: Colors.white),
|
|
|
|
gridDelegate:
|
|
|
|
),
|
|
|
|
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: (MediaQuery.of(context).size.width < 550) ? 3 : 5, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8),
|
|
|
|
Container(
|
|
|
|
children: <Widget>[
|
|
|
|
padding: EdgeInsets.only(left: 21, right: 21, bottom: 21, top: widget.topPadding),
|
|
|
|
// if (isNfcEnabled)
|
|
|
|
decoration: const BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white),
|
|
|
|
attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () {
|
|
|
|
width: double.infinity,
|
|
|
|
// if (isNfcLocationEnabled) {
|
|
|
|
child: Column(
|
|
|
|
if (AppState().getIsHuawei) {
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
checkHuaweiLocationPermission("NFC");
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
} else {
|
|
|
|
children: [
|
|
|
|
Location.getCurrentLocation((Position position, bool isMocked) {
|
|
|
|
LocaleKeys.markAttendance.tr().toSectionHeading(),
|
|
|
|
if (isMocked) {
|
|
|
|
LocaleKeys.selectMethodOfAttendance.tr().tr().toText11(color: const Color(0xff535353)),
|
|
|
|
markFakeAttendance("NFC", position.latitude.toString() ?? "", position.longitude.toString() ?? "");
|
|
|
|
GridView(
|
|
|
|
} else {
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
performNfcAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? "");
|
|
|
|
shrinkWrap: true,
|
|
|
|
}
|
|
|
|
padding: const EdgeInsets.only(bottom: 0, top: 21),
|
|
|
|
}, context);
|
|
|
|
gridDelegate:
|
|
|
|
}
|
|
|
|
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: (MediaQuery.of(context).size.width < 550) ? 3 : 5, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8),
|
|
|
|
// } else {
|
|
|
|
children: <Widget>[
|
|
|
|
// performNfcAttendance(widget.model);
|
|
|
|
// if (isNfcEnabled)
|
|
|
|
// }
|
|
|
|
attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, provider.isConnectedToHMG, () async {
|
|
|
|
}),
|
|
|
|
if (await provider.checkHmgNetworkConnectivity()) {
|
|
|
|
if (isWifiEnabled)
|
|
|
|
if (isNfcLocationEnabled) {
|
|
|
|
attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () {
|
|
|
|
Location.getCurrentLocation((Position? latlng, bool isMocked) {
|
|
|
|
// if (isWifiLocationEnabled) {
|
|
|
|
if (isMocked) {
|
|
|
|
if (AppState().getIsHuawei) {
|
|
|
|
markFakeAttendance("NFC", latlng?.latitude.toString() ?? "", latlng?.longitude.toString() ?? "", provider: provider);
|
|
|
|
checkHuaweiLocationPermission("WIFI");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
performNfcAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? "", provider: provider);
|
|
|
|
Location.getCurrentLocation((Position position, bool isMocked) {
|
|
|
|
}
|
|
|
|
if (isMocked) {
|
|
|
|
}, context);
|
|
|
|
markFakeAttendance("WIFI", position.latitude.toString() ?? "", position.longitude.toString() ?? "");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
performNfcAttendance(widget.model, provider: provider);
|
|
|
|
performWifiAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}, context);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// performWifiAttendance(widget.model);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
if (isQrEnabled)
|
|
|
|
|
|
|
|
attendanceMethod("QR", "assets/images/ic_qr.svg", isQrEnabled, () async {
|
|
|
|
|
|
|
|
// if (isQrLocationEnabled) {
|
|
|
|
|
|
|
|
if (AppState().getIsHuawei) {
|
|
|
|
|
|
|
|
checkHuaweiLocationPermission("QR");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Location.getCurrentLocation((Position position, bool isMocked) {
|
|
|
|
|
|
|
|
if (isMocked) {
|
|
|
|
|
|
|
|
markFakeAttendance("QR", position.latitude.toString() ?? "", position.longitude.toString() ?? "");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
performQrCodeAttendance(widget.model, lat: position.latitude.toString() ?? "", lng: position.longitude.toString() ?? "");
|
|
|
|
Utils.showToast("Please connect with the HMG internet to mark attendance");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, context);
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
if (isWifiEnabled)
|
|
|
|
// } else {
|
|
|
|
attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, provider.isConnectedToHMG, () async {
|
|
|
|
// performQrCodeAttendance(widget.model);
|
|
|
|
if (await provider.checkHmgNetworkConnectivity()) {
|
|
|
|
// }
|
|
|
|
if (isWifiLocationEnabled) {
|
|
|
|
// performQrCodeAttendance(model);
|
|
|
|
Location.getCurrentLocation((Position? latlng, bool isMocked) {
|
|
|
|
}),
|
|
|
|
if (isMocked) {
|
|
|
|
],
|
|
|
|
markFakeAttendance("WIFI", latlng?.latitude.toString() ?? "", latlng?.longitude.toString() ?? "", provider: provider);
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
],
|
|
|
|
performWifiAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? "", provider: provider);
|
|
|
|
),
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}, context);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
performWifiAttendance(widget.model, provider: provider);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Utils.showToast("Please connect with the HMG internet to mark attendance");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void getHuaweiCurrentLocation(String attendanceType) {
|
|
|
|
// connectWifi();
|
|
|
|
try {
|
|
|
|
}),
|
|
|
|
FusedLocationProviderClient locationService = FusedLocationProviderClient();
|
|
|
|
if (isQrEnabled)
|
|
|
|
LocationRequest locationRequest = LocationRequest();
|
|
|
|
attendanceMethod("QR", "assets/images/ic_qr.svg", isQrEnabled, provider.isConnectedToHMG, () async {
|
|
|
|
locationRequest.priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
|
|
|
|
// if (isQrLocationEnabled) {
|
|
|
|
locationRequest.interval = 1000;
|
|
|
|
// Location.getCurrentLocation((Position? latlng, bool isMocked) {
|
|
|
|
List<LocationRequest> locationRequestList = <LocationRequest>[locationRequest];
|
|
|
|
// if (isMocked) {
|
|
|
|
LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList);
|
|
|
|
// markFakeAttendance("QR", latlng?.latitude.toString() ?? "", latlng?.longitude.toString() ?? "", provider: provider);
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
locationService.checkLocationSettings(locationSettingsRequest).then((settings) async {
|
|
|
|
// performQrCodeAttendance(widget.model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? "");
|
|
|
|
await locationService.getLastLocation().then((value) {
|
|
|
|
// }
|
|
|
|
if (value.latitude == null || value.longitude == null) {
|
|
|
|
// }, context);
|
|
|
|
showDialog(
|
|
|
|
// } else {
|
|
|
|
context: context,
|
|
|
|
// performQrCodeAttendance(widget.model);
|
|
|
|
builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
// }
|
|
|
|
message: "Unable to get your location, Please check your location settings & try again.",
|
|
|
|
performQrCodeAttendance(widget.model);
|
|
|
|
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) {
|
|
|
|
|
|
|
|
print("HUAWEI LOCATION getLastLocation ERROR!!!!!");
|
|
|
|
|
|
|
|
print(error);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}).catchError((error) {
|
|
|
|
|
|
|
|
print("HUAWEI LOCATION checkLocationSettings ERROR!!!!!");
|
|
|
|
|
|
|
|
print(error);
|
|
|
|
|
|
|
|
if (error.code == "LOCATION_SETTINGS_NOT_AVAILABLE") {
|
|
|
|
|
|
|
|
// Location service not enabled.
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
print("HUAWEI LOCATION ERROR!!!!!");
|
|
|
|
|
|
|
|
print(error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
Future<void> performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0", required HmgConnectionProvider provider}) async {
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
Utils.readNFc(onRead: (String nfcId) async {
|
|
|
|
Utils.readNFc(onRead: (String nfcId) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
@ -270,6 +202,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
isDismissable: true,
|
|
|
|
isDismissable: true,
|
|
|
|
child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
provider.closeWifiRequest();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (ex) {
|
|
|
|
} catch (ex) {
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
@ -301,6 +234,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
isDismissable: false,
|
|
|
|
isDismissable: false,
|
|
|
|
child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
provider.closeWifiRequest();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (ex) {
|
|
|
|
} catch (ex) {
|
|
|
|
print(ex);
|
|
|
|
print(ex);
|
|
|
|
@ -326,54 +260,28 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> performWifiAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
Future<void> performWifiAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0", required HmgConnectionProvider provider}) async {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
if (!(await checkSession())) {
|
|
|
|
if (!(await checkSession())) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
bool isConnected = await WiFiForIoTPlugin.connect(AppState().getMohemmWifiSSID ?? "",
|
|
|
|
if (AppState().isAuthenticated) {
|
|
|
|
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));
|
|
|
|
await Future.delayed(const Duration(seconds: 6));
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng);
|
|
|
|
GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng);
|
|
|
|
bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
await closeWifiRequest();
|
|
|
|
|
|
|
|
if (g?.messageStatus == 2) {
|
|
|
|
showMDialog(
|
|
|
|
showDialog(
|
|
|
|
context,
|
|
|
|
barrierDismissible: true,
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
context: context,
|
|
|
|
isDismissable: false,
|
|
|
|
builder: (cxt) => ConfirmDialog(
|
|
|
|
child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
message: g?.errorEndUserMessage ?? "",
|
|
|
|
);
|
|
|
|
onTap: () {
|
|
|
|
provider.closeWifiRequest();
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onCloseTap: () {},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
showMDialog(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
|
|
|
isDismissable: false,
|
|
|
|
|
|
|
|
child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (ex) {
|
|
|
|
} catch (ex) {
|
|
|
|
await closeWifiRequest();
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -382,7 +290,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.confirmDialog(context, LocaleKeys.comeNearHMGWifi.tr());
|
|
|
|
Utils.confirmDialog(context, LocaleKeys.comeNearHMGWifi.tr());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
await closeWifiRequest();
|
|
|
|
// await closeWifiRequest();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -401,40 +309,43 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
if (qrCodeValue != null) {
|
|
|
|
if (qrCodeValue != null) {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
print("-----------f---");
|
|
|
|
try {
|
|
|
|
print(qrCodeValue);
|
|
|
|
GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 1, isGpsRequired: isQrLocationEnabled, lat: lat, long: lng, QRValue: qrCodeValue);
|
|
|
|
Utils.showToast(qrCodeValue);
|
|
|
|
bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
checkLocalIP(qrCodeValue);
|
|
|
|
if (g?.messageStatus == 2) {
|
|
|
|
// try {
|
|
|
|
showDialog(
|
|
|
|
// GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 1, isGpsRequired: isQrLocationEnabled, lat: lat, long: lng, QRValue: qrCodeValue);
|
|
|
|
barrierDismissible: true,
|
|
|
|
// bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
context: context,
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
builder: (cxt) => ConfirmDialog(
|
|
|
|
// showMDialog(
|
|
|
|
message: g?.errorEndUserMessage ?? "",
|
|
|
|
// context,
|
|
|
|
onTap: () {
|
|
|
|
// backgroundColor: Colors.transparent,
|
|
|
|
Navigator.pop(context);
|
|
|
|
// isDismissable: true,
|
|
|
|
},
|
|
|
|
// child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
onCloseTap: () {},
|
|
|
|
// );
|
|
|
|
),
|
|
|
|
// } catch (ex) {
|
|
|
|
);
|
|
|
|
// print(ex);
|
|
|
|
} else {
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
showMDialog(
|
|
|
|
// Utils.handleException(ex, context, null);
|
|
|
|
context,
|
|
|
|
// }
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
}
|
|
|
|
isDismissable: true,
|
|
|
|
}
|
|
|
|
child: SuccessDialog(widget.isFromDashboard),
|
|
|
|
|
|
|
|
);
|
|
|
|
void checkLocalIP(String qrValue) async {
|
|
|
|
}
|
|
|
|
Utils.showLoading(context);
|
|
|
|
} catch (ex) {
|
|
|
|
try {
|
|
|
|
print(ex);
|
|
|
|
await DashboardApiClient().checkLocelIP(qrValue);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
Utils.confirmDialog(context, "Local Ip called");
|
|
|
|
}
|
|
|
|
} catch (ex) {
|
|
|
|
|
|
|
|
print(ex);
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void markFakeAttendance(String sourceName, String lat, String long) async {
|
|
|
|
void markFakeAttendance(String sourceName, String lat, String long, {required HmgConnectionProvider provider}) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await DashboardApiClient().markFakeLocation(sourceName: sourceName, lat: lat, long: long);
|
|
|
|
await DashboardApiClient().markFakeLocation(sourceName: sourceName, lat: lat, long: long);
|
|
|
|
@ -447,11 +358,11 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget attendanceMethod(String title, String image, bool isEnabled, VoidCallback onPress) => Container(
|
|
|
|
Widget attendanceMethod(String title, String image, bool isEnabled, bool isHmgNetworkAvailable, VoidCallback onPress) => Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
|
color: isEnabled ? null : Colors.grey.withOpacity(.5),
|
|
|
|
color: isHmgNetworkAvailable && isEnabled ? null : Colors.grey.withOpacity(.5),
|
|
|
|
gradient: isEnabled
|
|
|
|
gradient: isHmgNetworkAvailable && isEnabled
|
|
|
|
? const LinearGradient(
|
|
|
|
? const LinearGradient(
|
|
|
|
transform: GradientRotation(.64),
|
|
|
|
transform: GradientRotation(.64),
|
|
|
|
begin: Alignment.topRight,
|
|
|
|
begin: Alignment.topRight,
|
|
|
|
|