diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 070597d..f187ebd 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -10,9 +10,9 @@
toJson() => {'errorCode': errorCode, 'errorMessage': errorMessage, 'errorType': errorType,};
+ Map toJson() => {
+ 'errorCode': errorCode,
+ 'errorMessage': errorMessage,
+ 'errorType': errorType,
+ };
@override
String toString() {
@@ -79,28 +83,30 @@ class ApiClient {
print("body:$bodyJson");
}
var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes, isFormData: isFormData);
- // try {
- if (!kReleaseMode) {
- logger.i("res: " + response.body);
- }
- var jsonData = jsonDecode(response.body);
- if (jsonData["IsAuthenticated"] != null) {
- AppState().setIsAuthenticated = jsonData["IsAuthenticated"];
- }
- if (jsonData["ErrorMessage"] == null) {
- return factoryConstructor(jsonData);
- } else {
- APIError? apiError;
- apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorEndUserMessage'], jsonData['ErrorType']);
- throw APIException(APIException.BAD_REQUEST, error: apiError);
+ try {
+ if (!kReleaseMode) {
+ logger.i("res: " + response.body);
+ }
+ var jsonData = jsonDecode(response.body);
+ if (jsonData["MessageStatus"] == 2) {
+ AppState().setIsAuthenticated = false;
+ }
+
+
+ if (jsonData["ErrorMessage"] == null && jsonData["MessageStatus"] == 1) {
+ return factoryConstructor(jsonData);
+ } else {
+ APIError? apiError;
+ apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorEndUserMessage'], jsonData['ErrorType'] ?? 0);
+ throw APIException(APIException.BAD_REQUEST, error: apiError);
+ }
+ } catch (ex) {
+ if (ex is APIException) {
+ rethrow;
+ } else {
+ throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex);
+ }
}
- // } catch (ex) {
- // if (ex is APIException) {
- // rethrow;
- // } else {
- // throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex);
- // }
- // }
}
Future postJsonForResponse(String url, T jsonObject,
diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart
index 56b0008..96fd4b0 100644
--- a/lib/classes/consts.dart
+++ b/lib/classes/consts.dart
@@ -4,7 +4,7 @@ class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local server
// static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server
// static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server
- static String baseUrl = "https://hmgwebservices.com"; // Live server
+ static String baseUrl = "https://hmgwebservices.com"; // Live server
static String baseUrlServices = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/";
@@ -44,7 +44,6 @@ class ApiConsts {
static int tabletMinLength = 500;
}
-
class SharedPrefsConsts {
static String isRememberMe = "remember_me";
static String username = "username";
diff --git a/lib/ui/landing/today_attendance_screen2.dart b/lib/ui/landing/today_attendance_screen2.dart
index f0228eb..a72df34 100644
--- a/lib/ui/landing/today_attendance_screen2.dart
+++ b/lib/ui/landing/today_attendance_screen2.dart
@@ -50,23 +50,23 @@ class _TodayAttendanceScreenState extends State {
icon: const Icon(Icons.arrow_back_ios, color: Colors.white),
onPressed: () => Navigator.pop(context),
),
- actions: [
- IconButton(
- onPressed: () {
- data.fetchAttendanceTracking(context);
- },
- icon: const Icon(
- Icons.ac_unit,
- color: Colors.white,
- ),
- )
- ],
+ // actions: [
+ // IconButton(
+ // onPressed: () {
+ // data.fetchAttendanceTracking(context);
+ // },
+ // icon: const Icon(
+ // Icons.ac_unit,
+ // color: Colors.white,
+ // ),
+ // )
+ // ],
),
backgroundColor: MyColors.backgroundBlackColor,
body: Consumer(
builder: (context, model, child) {
return (model.isAttendanceTrackingLoading
- ? Center(child: CircularProgressIndicator())
+ ? const Center(child: CircularProgressIndicator())
: Column(
children: [
Container(
diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart
index 1c10bb6..2dfd63a 100644
--- a/lib/ui/login/login_screen.dart
+++ b/lib/ui/login/login_screen.dart
@@ -30,6 +30,7 @@ import 'package:mohem_flutter_app/widgets/button/default_button.dart';
import 'package:mohem_flutter_app/widgets/input_widget.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:safe_device/safe_device.dart';
+import 'package:wifi_iot/wifi_iot.dart';
class LoginScreen extends StatefulWidget {
LoginScreen({Key? key}) : super(key: key);
@@ -166,8 +167,8 @@ class _LoginScreenState extends State {
isAppOpenBySystem = (ModalRoute.of(context)!.settings.arguments ?? true) as bool;
if (!kReleaseMode) {
// username.text = "15444"; // Maha User
- // username.text = "15153"; // Tamer User
- // password.text = "Abcd@1234";
+ username.text = "15153"; // Tamer User
+ password.text = "Abcd@12345";
// username.text = "206535"; // Hashim User
// password.text = "Namira786";
@@ -230,6 +231,14 @@ class _LoginScreenState extends State {
Navigator.pushNamed(context, AppRoutes.forgotPassword);
}),
),
+ 20.height,
+ // DefaultButton(
+ // "Connect HMG Network",
+ // () async {
+ // SystemChannels.textInput.invokeMethod('TextInput.hide');
+ // connectWithHmgNetwork();
+ // },
+ // ),
],
),
)
@@ -245,4 +254,30 @@ class _LoginScreenState extends State {
),
);
}
+
+ void connectWithHmgNetwork() async {
+ try {
+ bool isConnected = await WiFiForIoTPlugin.connect("MOHEMM-CONNECT", password: "0987654321", joinOnce: Platform.isIOS ? false : true, security: NetworkSecurity.WPA, withInternet: false);
+
+ if (isConnected) {
+ await WiFiForIoTPlugin.forceWifiUsage(true);
+ // if (Platform.isIOS) {
+ // await closeWifiRequest();
+ // await Future.delayed(Duration(seconds: 6));
+ // } else {
+ // await WiFiForIoTPlugin.forceWifiUsage(true);
+ // }
+ }
+ } catch (e) {
+ print("----------------o----");
+ print(e);
+ }
+ }
+
+ Future closeWifiRequest() async {
+ if (Platform.isAndroid) {
+ await WiFiForIoTPlugin.forceWifiUsage(false);
+ }
+ return await WiFiForIoTPlugin.disconnect();
+ }
}
diff --git a/lib/widgets/mark_attendance_widget.dart b/lib/widgets/mark_attendance_widget.dart
index 6b89c42..03d4847 100644
--- a/lib/widgets/mark_attendance_widget.dart
+++ b/lib/widgets/mark_attendance_widget.dart
@@ -12,6 +12,7 @@ import 'package:mohem_flutter_app/extensions/string_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/models/generic_response_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/ui/dialogs/success_dialog.dart';
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
@@ -47,7 +48,7 @@ class _MarkAttendanceWidgetState extends State {
void checkAttendanceAvailability() async {
bool isAvailable = await NfcManager.instance.isAvailable();
setState(() {
- AppState().privilegeListModel!.forEach((element) {
+ AppState().privilegeListModel!.forEach((PrivilegeListModel element) {
if (element.serviceName == "enableNFC") {
if (isAvailable) if (element.previlege ?? false) isNfcEnabled = true;
} else if (element.serviceName == "enableQR") {
@@ -144,6 +145,7 @@ class _MarkAttendanceWidgetState extends State {
Future performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
if (Platform.isIOS) {
+
Utils.readNFc(onRead: (String nfcId) async {
Utils.showLoading(context);
try {
@@ -152,7 +154,7 @@ class _MarkAttendanceWidgetState extends State {
Utils.hideLoading(context);
showDialog(
context: context,
- builder: (cxt) => ConfirmDialog(
+ builder: (BuildContext cxt) => ConfirmDialog(
message: g?.errorEndUserMessage ?? "Unexpected error occurred",
onTap: () {
Navigator.pop(context);
@@ -172,9 +174,7 @@ class _MarkAttendanceWidgetState extends State {
}
} catch (ex) {
Utils.hideLoading(context);
- Utils.handleException(ex, context, (msg) {
- Utils.confirmDialog(context, msg);
- });
+ Utils.handleException(ex, context, null);
}
});
} else {
@@ -186,7 +186,7 @@ class _MarkAttendanceWidgetState extends State {
Utils.hideLoading(context);
showDialog(
context: context,
- builder: (cxt) => ConfirmDialog(
+ builder: (BuildContext cxt) => ConfirmDialog(
message: g?.errorEndUserMessage ?? "Unexpected error occurred",
onTap: () {
Navigator.pop(context);
@@ -206,7 +206,7 @@ class _MarkAttendanceWidgetState extends State {
} catch (ex) {
print(ex);
Utils.hideLoading(context);
- Utils.handleException(ex, context, (msg) {
+ Utils.handleException(ex, context, (String msg) {
Utils.confirmDialog(context, msg);
});
}
@@ -228,19 +228,23 @@ class _MarkAttendanceWidgetState extends State {
}
if (isConnected) {
- if (Platform.isIOS) {
- await closeWifiRequest();
- await Future.delayed(Duration(seconds: 6));
- } else {
- await WiFiForIoTPlugin.forceWifiUsage(true);
- }
+ // if (Platform.isIOS) {
+ // await closeWifiRequest();
+ // await Future.delayed(Duration(seconds: 6));
+ // } else {
+ // await WiFiForIoTPlugin.forceWifiUsage(true);
+ // }
+ 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);
- if (Platform.isAndroid) {
- await closeWifiRequest();
- }
+ // if (Platform.isAndroid) {
+ // await closeWifiRequest();
+ // }
+
+ await closeWifiRequest();
showMDialog(
context,
backgroundColor: Colors.transparent,
@@ -250,9 +254,7 @@ class _MarkAttendanceWidgetState extends State {
} catch (ex) {
await closeWifiRequest();
Utils.hideLoading(context);
- Utils.handleException(ex, context, (msg) {
- Utils.confirmDialog(context, msg);
- });
+ Utils.handleException(ex, context, null);
}
} else {
Utils.hideLoading(context);
@@ -270,7 +272,7 @@ class _MarkAttendanceWidgetState extends State {
Future performQrCodeAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
var qrCodeValue = await Navigator.of(context).push(
MaterialPageRoute(
- builder: (context) => QrScannerDialog(),
+ builder: (BuildContext context) => QrScannerDialog(),
),
);
if (qrCodeValue != null) {
@@ -288,9 +290,7 @@ class _MarkAttendanceWidgetState extends State {
} catch (ex) {
print(ex);
Utils.hideLoading(context);
- Utils.handleException(ex, context, (msg) {
- Utils.confirmDialog(context, msg);
- });
+ Utils.handleException(ex, context, null);
}
}
}
@@ -304,9 +304,7 @@ class _MarkAttendanceWidgetState extends State {
} catch (ex) {
print(ex);
Utils.hideLoading(context);
- Utils.handleException(ex, context, (msg) {
- Utils.confirmDialog(context, msg);
- });
+ Utils.handleException(ex, context, null);
}
}
diff --git a/pubspec.yaml b/pubspec.yaml
index f8748e6..e78da23 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -67,7 +67,7 @@ dependencies:
month_year_picker: ^0.2.0+1
month_picker_dialog_2: 0.5.5
open_file: ^3.2.1
- wifi_iot: ^0.3.16
+ wifi_iot: ^0.3.18
flutter_html: ^3.0.0-alpha.6
# flutter_barcode_scanner: ^2.0.0
qr_code_scanner: ^1.0.0