|
|
|
@ -1,23 +1,16 @@
|
|
|
|
import 'package:easy_localization/src/public_ext.dart';
|
|
|
|
import 'package:easy_localization/src/public_ext.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_countdown_timer/flutter_countdown_timer.dart';
|
|
|
|
import 'package:flutter_countdown_timer/flutter_countdown_timer.dart';
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
|
|
|
import 'package:google_maps_flutter/google_maps_flutter.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';
|
|
|
|
import 'package:mohem_flutter_app/classes/date_uitl.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/date_uitl.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
|
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/generic_response_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/widgets/circular_step_progress_bar.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/circular_step_progress_bar.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/location/Location.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/mark_attendance_widget.dart';
|
|
|
|
import 'package:mohem_flutter_app/widgets/nfc/nfc_reader_sheet.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/qr_scanner_dialog.dart';
|
|
|
|
|
|
|
|
import 'package:nfc_manager/nfc_manager.dart';
|
|
|
|
import 'package:nfc_manager/nfc_manager.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:wifi_iot/wifi_iot.dart';
|
|
|
|
import 'package:wifi_iot/wifi_iot.dart';
|
|
|
|
@ -183,62 +176,62 @@ class _TodayAttendanceScreenState extends State<TodayAttendanceScreen> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
), //.expanded,
|
|
|
|
), //.expanded,
|
|
|
|
|
|
|
|
|
|
|
|
// MarkAttendanceWidget(model),
|
|
|
|
MarkAttendanceWidget(model, topPadding: 24),
|
|
|
|
Container(
|
|
|
|
// Container(
|
|
|
|
width: double.infinity,
|
|
|
|
// width: double.infinity,
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white),
|
|
|
|
// decoration: BoxDecoration(borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), color: Colors.white),
|
|
|
|
// margin: EdgeInsets.only(top: 187 - 31),
|
|
|
|
// // margin: EdgeInsets.only(top: 187 - 31),
|
|
|
|
padding: EdgeInsets.only(left: 21, right: 21, top: 24, bottom: 24),
|
|
|
|
// padding: EdgeInsets.only(left: 21, right: 21, top: 24, bottom: 24),
|
|
|
|
child: Column(
|
|
|
|
// child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
// children: [
|
|
|
|
LocaleKeys.markAttendance.tr().toSectionHeading(),
|
|
|
|
// LocaleKeys.markAttendance.tr().toSectionHeading(),
|
|
|
|
LocaleKeys.selectMethodOfAttendance.tr().tr().toText11(color: Color(0xff535353)),
|
|
|
|
// LocaleKeys.selectMethodOfAttendance.tr().tr().toText11(color: Color(0xff535353)),
|
|
|
|
24.height,
|
|
|
|
// 24.height,
|
|
|
|
GridView(
|
|
|
|
// GridView(
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
// physics: const NeverScrollableScrollPhysics(),
|
|
|
|
shrinkWrap: true,
|
|
|
|
// shrinkWrap: true,
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
// padding: EdgeInsets.zero,
|
|
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8),
|
|
|
|
// gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8),
|
|
|
|
children: <Widget>[
|
|
|
|
// children: <Widget>[
|
|
|
|
if (isNfcEnabled)
|
|
|
|
// if (isNfcEnabled)
|
|
|
|
attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () {
|
|
|
|
// attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () {
|
|
|
|
if (isNfcLocationEnabled) {
|
|
|
|
// if (isNfcLocationEnabled) {
|
|
|
|
Location.getCurrentLocation((LatLng? latlng) {
|
|
|
|
// Location.getCurrentLocation((LatLng? latlng) {
|
|
|
|
performNfcAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? "");
|
|
|
|
// performNfcAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? "");
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
performNfcAttendance(model);
|
|
|
|
// performNfcAttendance(model);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}),
|
|
|
|
// }),
|
|
|
|
if (isWifiEnabled)
|
|
|
|
// if (isWifiEnabled)
|
|
|
|
attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () {
|
|
|
|
// attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () {
|
|
|
|
if (isWifiLocationEnabled) {
|
|
|
|
// if (isWifiLocationEnabled) {
|
|
|
|
Location.getCurrentLocation((LatLng? latlng) {
|
|
|
|
// Location.getCurrentLocation((LatLng? latlng) {
|
|
|
|
performWifiAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? "");
|
|
|
|
// performWifiAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? "");
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
performWifiAttendance(model);
|
|
|
|
// performWifiAttendance(model);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
// connectWifi();
|
|
|
|
// // connectWifi();
|
|
|
|
}),
|
|
|
|
// }),
|
|
|
|
if (isQrEnabled)
|
|
|
|
// if (isQrEnabled)
|
|
|
|
attendanceMethod("QR", "assets/images/ic_qr.svg", isQrEnabled, () async {
|
|
|
|
// attendanceMethod("QR", "assets/images/ic_qr.svg", isQrEnabled, () async {
|
|
|
|
if (isQrLocationEnabled) {
|
|
|
|
// if (isQrLocationEnabled) {
|
|
|
|
Location.getCurrentLocation((LatLng? latlng) {
|
|
|
|
// Location.getCurrentLocation((LatLng? latlng) {
|
|
|
|
performQrCodeAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? "");
|
|
|
|
// performQrCodeAttendance(model, lat: latlng?.latitude.toString() ?? "", lng: latlng?.longitude.toString() ?? "");
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
performQrCodeAttendance(model);
|
|
|
|
// performQrCodeAttendance(model);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
// performQrCodeAttendance(model);
|
|
|
|
// // performQrCodeAttendance(model);
|
|
|
|
}),
|
|
|
|
// }),
|
|
|
|
],
|
|
|
|
// ],
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
],
|
|
|
|
// ],
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
// Positioned(
|
|
|
|
// Positioned(
|
|
|
|
// top: 187 - 21,
|
|
|
|
// top: 187 - 21,
|
|
|
|
// child: Container(
|
|
|
|
// child: Container(
|
|
|
|
@ -269,59 +262,59 @@ class _TodayAttendanceScreenState extends State<TodayAttendanceScreen> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
// Future<void> performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
if (isNfcLocationEnabled) {
|
|
|
|
// if (isNfcLocationEnabled) {
|
|
|
|
print("nfc location enabled");
|
|
|
|
// print("nfc location enabled");
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
print("nfc not location enabled");
|
|
|
|
// print("nfc not location enabled");
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
showNfcReader(context, onNcfScan: (String? nfcId) async {
|
|
|
|
// showNfcReader(context, onNcfScan: (String? nfcId) async {
|
|
|
|
print(nfcId);
|
|
|
|
// print(nfcId);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
try {
|
|
|
|
// try {
|
|
|
|
GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? "", isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng);
|
|
|
|
// GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 2, nfcValue: nfcId ?? "", isGpsRequired: isNfcLocationEnabled, lat: lat, long: lng);
|
|
|
|
bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
// bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
} catch (ex) {
|
|
|
|
// } catch (ex) {
|
|
|
|
print(ex);
|
|
|
|
// print(ex);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
Utils.handleException(ex, context, (msg) {
|
|
|
|
// Utils.handleException(ex, context, (msg) {
|
|
|
|
Utils.confirmDialog(context, msg);
|
|
|
|
// Utils.confirmDialog(context, msg);
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
Future<void> performWifiAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
// Future<void> performWifiAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
if (isWifiLocationEnabled) {
|
|
|
|
// if (isWifiLocationEnabled) {
|
|
|
|
print("wifi location enabled");
|
|
|
|
// print("wifi location enabled");
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
print("wifi not location enabled");
|
|
|
|
// print("wifi not location enabled");
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
bool v = await WiFiForIoTPlugin.connect(AppState().mohemmWifiSSID ?? "", password: AppState().mohemmWifiPassword ?? "", joinOnce: true, security: NetworkSecurity.WPA, withInternet: false);
|
|
|
|
// bool v = await WiFiForIoTPlugin.connect(AppState().mohemmWifiSSID ?? "", password: AppState().mohemmWifiPassword ?? "", joinOnce: true, security: NetworkSecurity.WPA, withInternet: false);
|
|
|
|
if (v) {
|
|
|
|
// if (v) {
|
|
|
|
await WiFiForIoTPlugin.forceWifiUsage(true);
|
|
|
|
// await WiFiForIoTPlugin.forceWifiUsage(true);
|
|
|
|
print("connected");
|
|
|
|
// print("connected");
|
|
|
|
Utils.showLoading(context);
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
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();
|
|
|
|
// await closeWifiRequest();
|
|
|
|
} catch (ex) {
|
|
|
|
// } catch (ex) {
|
|
|
|
print(ex);
|
|
|
|
// print(ex);
|
|
|
|
await closeWifiRequest();
|
|
|
|
// await closeWifiRequest();
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
Utils.handleException(ex, context, (msg) {
|
|
|
|
// Utils.handleException(ex, context, (msg) {
|
|
|
|
Utils.confirmDialog(context, msg);
|
|
|
|
// Utils.confirmDialog(context, msg);
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
// } else {
|
|
|
|
Utils.confirmDialog(context, LocaleKeys.comeNearHMGWifi.tr());
|
|
|
|
// Utils.confirmDialog(context, LocaleKeys.comeNearHMGWifi.tr());
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
Future<bool> closeWifiRequest() async {
|
|
|
|
Future<bool> closeWifiRequest() async {
|
|
|
|
await WiFiForIoTPlugin.forceWifiUsage(false);
|
|
|
|
await WiFiForIoTPlugin.forceWifiUsage(false);
|
|
|
|
@ -329,62 +322,62 @@ class _TodayAttendanceScreenState extends State<TodayAttendanceScreen> {
|
|
|
|
return v;
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> performQrCodeAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
// Future<void> performQrCodeAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
var qrCodeValue = await Navigator.of(context).push(
|
|
|
|
// var qrCodeValue = await Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
// MaterialPageRoute(
|
|
|
|
builder: (context) => QrScannerDialog(),
|
|
|
|
// builder: (context) => QrScannerDialog(),
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
);
|
|
|
|
// );
|
|
|
|
if (qrCodeValue != null) {
|
|
|
|
// if (qrCodeValue != null) {
|
|
|
|
print("qrCode: " + qrCodeValue);
|
|
|
|
// print("qrCode: " + qrCodeValue);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
try {
|
|
|
|
// try {
|
|
|
|
GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 1, isGpsRequired: isQrLocationEnabled, lat: lat, long: lng, QRValue: qrCodeValue);
|
|
|
|
// GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 1, isGpsRequired: isQrLocationEnabled, lat: lat, long: lng, QRValue: qrCodeValue);
|
|
|
|
bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
// bool status = await model.fetchAttendanceTracking(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
} catch (ex) {
|
|
|
|
// } catch (ex) {
|
|
|
|
print(ex);
|
|
|
|
// print(ex);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
Utils.handleException(ex, context, (msg) {
|
|
|
|
// Utils.handleException(ex, context, (msg) {
|
|
|
|
Utils.confirmDialog(context, msg);
|
|
|
|
// Utils.confirmDialog(context, msg);
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
Widget attendanceMethod(String title, String image, bool isEnabled, VoidCallback onPress) => Container(
|
|
|
|
// Widget attendanceMethod(String title, String image, bool isEnabled, VoidCallback onPress) => Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
|
// borderRadius: BorderRadius.circular(15),
|
|
|
|
gradient: const LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [
|
|
|
|
// gradient: const LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [
|
|
|
|
MyColors.gradiantEndColor,
|
|
|
|
// MyColors.gradiantEndColor,
|
|
|
|
MyColors.gradiantStartColor,
|
|
|
|
// MyColors.gradiantStartColor,
|
|
|
|
]),
|
|
|
|
// ]),
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
clipBehavior: Clip.antiAlias,
|
|
|
|
// clipBehavior: Clip.antiAlias,
|
|
|
|
child: Stack(
|
|
|
|
// child: Stack(
|
|
|
|
children: [
|
|
|
|
// children: [
|
|
|
|
Container(
|
|
|
|
// Container(
|
|
|
|
padding: const EdgeInsets.only(left: 10, right: 10, top: 14, bottom: 14),
|
|
|
|
// padding: const EdgeInsets.only(left: 10, right: 10, top: 14, bottom: 14),
|
|
|
|
child: Column(
|
|
|
|
// child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
// children: [
|
|
|
|
SvgPicture.asset(
|
|
|
|
// SvgPicture.asset(
|
|
|
|
image,
|
|
|
|
// image,
|
|
|
|
color: Colors.white,
|
|
|
|
// color: Colors.white,
|
|
|
|
).expanded,
|
|
|
|
// ).expanded,
|
|
|
|
title.toText17(isBold: true, color: Colors.white),
|
|
|
|
// title.toText17(isBold: true, color: Colors.white),
|
|
|
|
],
|
|
|
|
// ],
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
if (!isEnabled)
|
|
|
|
// if (!isEnabled)
|
|
|
|
Container(
|
|
|
|
// Container(
|
|
|
|
width: double.infinity,
|
|
|
|
// width: double.infinity,
|
|
|
|
height: double.infinity,
|
|
|
|
// height: double.infinity,
|
|
|
|
color: Colors.grey.withOpacity(0.7),
|
|
|
|
// color: Colors.grey.withOpacity(0.7),
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
],
|
|
|
|
// ],
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
).onPress(onPress);
|
|
|
|
// ).onPress(onPress);
|
|
|
|
|
|
|
|
|
|
|
|
Widget commonStatusView(String title, String time) => Expanded(
|
|
|
|
Widget commonStatusView(String title, String time) => Expanded(
|
|
|
|
child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
|
|
child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
|
|
|