diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index f88c890..e8892a8 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -60,11 +60,18 @@ "doNotAddRepeatingLetters": "لا تقم بإضافة أحرف متكررة", "itShouldContainSpecialCharacter": "يجب أن يحتوي على طابع خاص", "confirmPasswordMustMatch": "يجب أن يتطابق تأكيد كلمة المرور", + "sms": "رسالة قصيرة", + "fingerPrint": "بصمة", + "face": "التعرف على الوجه", + "whatsapp": "واتس اب", + "reject": "يرفض", + "approve": "يوافق", "msg": "Hello {} in the {} world ", "msg_named": "{} are written in the {lang} language", "clickMe": "Click me", - "human": "Human", - "resources": "Resources", + "human": "بشري", + "resources": "موارد", + "details": "تفاصيل", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index a669a4f..f5b9b44 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -60,11 +60,18 @@ "doNotAddRepeatingLetters": "Do not add repeating letters", "itShouldContainSpecialCharacter": "It should contain special character", "confirmPasswordMustMatch": "Confirm password must match", + "sms": "SMS", + "fingerPrint": "Fingerprint", + "face": "Face", + "whatsapp": "Whatsapp", + "reject": "Reject", + "approve": "Approve", "msg": "Hello {} in the {} world ", "msg_named": "{} are written in the {lang} language", "clickMe": "Click me", "human": "Human", "resources": "Resources", + "details": "Details", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index 609aca9..17eac0d 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -76,25 +76,25 @@ class ApiClient { print("body:$jsonObject"); } var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes); - try { - if (!kReleaseMode) { - logger.i("res: " + response.body); - } - var jsonData = jsonDecode(response.body); - if (jsonData["ErrorMessage"] == null) { - return factoryConstructor(jsonData); - } else { - APIError? apiError; - apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorMessage']); - throw APIException(APIException.BAD_REQUEST, error: apiError); - } - } catch (ex) { - if (ex is APIException) { - rethrow; - } else { - throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex); - } + // try { + if (!kReleaseMode) { + logger.i("res: " + response.body); } + var jsonData = jsonDecode(response.body); + if (jsonData["ErrorMessage"] == null) { + return factoryConstructor(jsonData); + } else { + APIError? apiError; + apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorMessage']); + throw APIException(APIException.BAD_REQUEST, error: apiError); + } + // } catch (ex) { + // if (ex is APIException) { + // rethrow; + // } else { + // throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex); + // } + // } } Future postJsonForResponse(String url, T jsonObject, {String? token, Map? queryParameters, Map? headers, int retryTimes = 0}) async { @@ -162,6 +162,68 @@ class ApiClient { } } + Future getJsonForResponse(String url, {String? token, Map? queryParameters, Map? headers, int retryTimes = 0}) async { + if (headers == null) { + headers = {'Content-Type': 'application/json'}; + } else { + headers['Content-Type'] = 'application/json'; + } + return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes); + } + + Future _getForResponse(String url, {String? token, Map? queryParameters, Map? headers, int retryTimes = 0}) async { + try { + var _headers = {}; + if (token != null) { + _headers['Authorization'] = 'Bearer $token'; + } + + if (headers != null && headers.isNotEmpty) { + _headers.addAll(headers); + } + + if (queryParameters != null) { + var queryString = new Uri(queryParameters: queryParameters).query; + url = url + '?' + queryString; + } + var response = await _get(Uri.parse(url), headers: _headers).timeout(Duration(seconds: 60)); + + if (response.statusCode >= 200 && response.statusCode < 300) { + return response; + } else { + throw _throwAPIException(response); + } + } on SocketException catch (e) { + if (retryTimes > 0) { + print('will retry after 3 seconds...'); + await Future.delayed(Duration(seconds: 3)); + return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); + } else { + throw APIException(APIException.OTHER, arguments: e); + } + } on HttpException catch (e) { + if (retryTimes > 0) { + print('will retry after 3 seconds...'); + await Future.delayed(Duration(seconds: 3)); + return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); + } else { + throw APIException(APIException.OTHER, arguments: e); + } + } on TimeoutException catch (e) { + throw APIException(APIException.TIMEOUT, arguments: e); + } on ClientException catch (e) { + if (retryTimes > 0) { + print('will retry after 3 seconds...'); + await Future.delayed(Duration(seconds: 3)); + return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); + } else { + throw APIException(APIException.OTHER, arguments: e); + } + } + } + + Future _get(url, {Map? headers}) => _withClient((client) => client.get(url, headers: headers)); + bool _certificateCheck(X509Certificate cert, String host, int port) => true; Future _withClient(Future Function(Client) fn) async { @@ -175,4 +237,4 @@ class ApiClient { } Future _post(url, {Map? headers, body, Encoding? encoding}) => _withClient((client) => client.post(url, headers: headers, body: body, encoding: encoding)); -} + } diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index b98a777..76e2453 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -11,12 +11,12 @@ import 'package:mohem_flutter_app/models/member_login_list_model.dart'; import 'api_client.dart'; -class DashbaordApiClient { - static final DashbaordApiClient _instance = DashbaordApiClient._internal(); +class DashboardApiClient { + static final DashboardApiClient _instance = DashboardApiClient._internal(); - DashbaordApiClient._internal(); + DashboardApiClient._internal(); - factory DashbaordApiClient() => _instance; + factory DashboardApiClient() => _instance; Future getAttendanceTracking() async { String url = "${ApiConsts.erpRest}GET_Attendance_Tracking"; @@ -82,7 +82,7 @@ class DashbaordApiClient { //GET_MENU_ENTRIES Future getGetMenuEntries() async { String url = "${ApiConsts.erpRest}GET_MENU_ENTRIES"; - Map postParams = {"P_SELECTED_RESP_ID": -999,"P_MENU_TYPE":"E"}; + Map postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E"}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); diff --git a/lib/api/login_api_client.dart b/lib/api/login_api_client.dart index f69e317..070fa27 100644 --- a/lib/api/login_api_client.dart +++ b/lib/api/login_api_client.dart @@ -47,6 +47,7 @@ class LoginApiClient { postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + AppState().setLogged = true; return responseData; }, url, postParams); } @@ -82,7 +83,6 @@ class LoginApiClient { postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); - AppState().setLogged = true; AppState().postParamsObject?.setTokenID = responseData.tokenID; AppState().postParamsObject?.mobileNumber = responseData.basicMemberInformation!.pMOBILENUMBER; AppState().postParamsObject?.userName = AppState().getUserName; diff --git a/lib/api/worklist/worklist_api_client.dart b/lib/api/worklist/worklist_api_client.dart new file mode 100644 index 0000000..a473ba7 --- /dev/null +++ b/lib/api/worklist/worklist_api_client.dart @@ -0,0 +1,41 @@ +import 'dart:async'; + +import 'package:mohem_flutter_app/api/api_client.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/consts.dart'; +import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; +import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/worklist_response_model.dart'; + +class WorkListApiClient { + static final WorkListApiClient _instance = WorkListApiClient._internal(); + + WorkListApiClient._internal(); + + factory WorkListApiClient() => _instance; + + Future?> getWorkList(int pPageNum, String pItemType) async { + String url = "${ApiConsts.erpRest}GET_WORKLIST"; + Map postParams = { + "P_NOTIFICATION_TYPE": "1", + "P_PAGE_NUM": pPageNum, + "P_PAGE_LIMIT": 50, + "P_ITEM_TYPE": pItemType, + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return responseData.getWorkList; + }, url, postParams); + } + + Future GetITGTaskCountRequestType() async { + String url = "${ApiConsts.cocRest}ITGGetTaskCountRequestType"; + Map postParams = {}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + ItgFormsModel responseData = ItgFormsModel.fromJson(json); + return responseData; + }, url, postParams); + } +} diff --git a/lib/classes/colors.dart b/lib/classes/colors.dart index 2e5eaef..0d80b05 100644 --- a/lib/classes/colors.dart +++ b/lib/classes/colors.dart @@ -16,6 +16,7 @@ class MyColors { static const Color grey98Color = Color(0xff989898); static const Color lightGreyEFColor = Color(0xffEFEFEF); static const Color lightGreyEDColor = Color(0xffEDEDED); + static const Color lightGreyE6Color = Color(0xffE6E6E6); static const Color lightGreyEAColor = Color(0xffEAEAEA); static const Color darkWhiteColor = Color(0xffE0E0E0); static const Color redColor = Color(0xffD02127); diff --git a/lib/classes/date_uitl.dart b/lib/classes/date_uitl.dart new file mode 100644 index 0000000..d0f4b1f --- /dev/null +++ b/lib/classes/date_uitl.dart @@ -0,0 +1,444 @@ +import 'package:intl/intl.dart'; + +class DateUtil { + /// convert String To Date function + /// [date] String we want to convert + static DateTime convertStringToDate(String date) { + // /Date(1585774800000+0300)/ + if (date != null) { + const start = "/Date("; + const end = "+0300)"; + final startIndex = date.indexOf(start); + final endIndex = date.indexOf(end, startIndex + start.length); + return DateTime.fromMillisecondsSinceEpoch( + int.parse( + date.substring(startIndex + start.length, endIndex), + ), + ); + } else + return DateTime.now(); + } + + static DateTime convertSimpleStringDateToDate(String date) { + return DateFormat("MM/dd/yyyy hh:mm:ss").parse(date); + } + + static DateTime convertStringToDateNoTimeZone(String date) { + // /Date(1585774800000+0300)/ + if (date != null) { + const start = "/Date("; + const end = ")"; + final startIndex = date.indexOf(start); + final endIndex = date.indexOf(end, startIndex + start.length); + return DateTime.fromMillisecondsSinceEpoch( + int.parse( + date.substring(startIndex + start.length, endIndex), + ), + ); + } else + return DateTime.now(); + } + + static DateTime convertStringToDateTime(String date) { + if (date != null) { + try { + var dateT = date.split('/'); + var year = dateT[2].substring(0, 4); + var dateP = DateTime(int.parse(year), int.parse(dateT[1]), int.parse(dateT[0])); + return dateP; + } catch (e) { + print(e); + } + + return DateTime.now(); + } else + return DateTime.now(); + } + + static String convertDateToString(DateTime date) { + const start = "/Date("; + const end = "+0300)"; + int milliseconds = date.millisecondsSinceEpoch; + + return start + "$milliseconds" + end; + } + + static String convertDateToStringLocation(DateTime date) { + const start = "/Date("; + const end = ")/"; + int milliseconds = date.millisecondsSinceEpoch; + + return start + "$milliseconds" + end; + } + + static String formatDateToDate(DateTime date, bool isArabic) { + return DateFormat('dd MMM yyy', isArabic ? "ar_SA" : "en_US").format(date); + } + + static String formatDateToTime(DateTime date) { + return DateFormat('hh:mm a').format(date); + } + + static String yearMonthDay(DateTime dateTime) { + String dateFormat = '${dateTime.year}-${dateTime.month}-${dateTime.day}'; + return dateFormat; + } + + static String time(DateTime dateTime) { + String dateFormat = '${dateTime.hour}:${dateTime.minute}:00'; + return dateFormat; + } + + static String convertDateMSToJsonDate(utc) { + var dt = new DateTime.fromMicrosecondsSinceEpoch(utc); + + return "/Date(" + (dt.millisecondsSinceEpoch * 1000).toString() + '+0300' + ")/"; + } + + /// check Date + /// [dateString] String we want to convert + static String checkDate(DateTime checkedTime) { + DateTime currentTime = DateTime.now(); + if ((currentTime.year == checkedTime.year) && (currentTime.month == checkedTime.month) && (currentTime.day == checkedTime.day)) { + return "Today"; + } else if ((currentTime.year == checkedTime.year) && (currentTime.month == checkedTime.month)) { + if ((currentTime.day - checkedTime.day) == 1) { + return "YESTERDAY"; + } else if ((currentTime.day - checkedTime.day) == -1) { + return "Tomorrow"; + } + + if ((currentTime.day - checkedTime.day) <= -2) { + return "Next Week"; + } else { + return "Old Date"; + } + } + return "Old Date"; + } + + static String getDateFormatted(String date) { + DateTime dateObj = DateUtil.convertStringToDate(date); + return DateUtil.getWeekDay(dateObj.weekday) + ", " + dateObj.day.toString() + " " + DateUtil.getMonth(dateObj.month) + " " + dateObj.year.toString(); + } + + static String getISODateFormat(DateTime dateTime) { + // 2020-04-30T00:00:00.000 + return dateTime.toIso8601String(); + } + + /// get month by + /// [month] convert month number in to month name + static getMonth(int month) { + switch (month) { + case 1: + return "January"; + case 2: + return "February"; + case 3: + return "March"; + case 4: + return "April"; + case 5: + return "May"; + case 6: + return "June"; + case 7: + return "July"; + case 8: + return "August"; + case 9: + return "September"; + case 10: + return "October"; + case 11: + return "November"; + case 12: + return "December"; + } + } + + /// get month by + /// [month] convert month number in to month name in Arabic + static getMonthArabic(int month) { + switch (month) { + case 1: + return "يناير"; + case 2: + return " فبراير"; + case 3: + return "مارس"; + case 4: + return "أبريل"; + case 5: + return "مايو"; + case 6: + return "يونيو"; + case 7: + return "يوليو"; + case 8: + return "أغسطس"; + case 9: + return "سبتمبر"; + case 10: + return " اكتوبر"; + case 11: + return " نوفمبر"; + case 12: + return "ديسمبر"; + } + } + + static getMonthByName(String month) { + switch (month.toLowerCase()) { + case 'january': + return 1; + case 'february': + return 2; + case 'march': + return 3; + case 'april': + return 4; + case 'may': + return 5; + case 'june': + return 6; + case 'july': + return 7; + case 'august': + return 8; + case 'september': + return 9; + case 'october': + return 10; + case 'november': + return 11; + case 'december': + return 12; + } + } + + static DateTime getMonthDateTime(String month, yearName) { + DateTime? date; + try { + date = DateTime(int.parse(yearName), getMonthByName(month)); + } catch (e) { + print(e); + } + return date ?? DateTime.now(); + } + + /// get month by + /// [weekDay] convert week day in int to week day name + static getWeekDay(int weekDay) { + switch (weekDay) { + case 1: + return "Monday"; + case 2: + return "Tuesday"; + case 3: + return "Wednesday"; + case 4: + return "Thursday"; + case 5: + return "Friday"; + case 6: + return "Saturday "; + case 7: + return "Sunday"; + } + } + + /// get month by + /// [weekDay] convert week day in int to week day name arabic + static getWeekDayArabic(int weekDay) { + switch (weekDay) { + case 1: + return "الاثنين"; + case 2: + return "الثلاثاء"; + case 3: + return "الاربعاء"; + case 4: + return "الخميس"; + case 5: + return "الجمعه"; + case 6: + return "السبت "; + case 7: + return "الاحد"; + } + } + + static getWeekDayEnglish(int weekDay) { + switch (weekDay) { + case 1: + return "Monday"; + case 2: + return "Tuesday"; + case 3: + return "Wednesday"; + case 4: + return "Thursday"; + case 5: + return "Friday"; + case 6: + return "Saturday "; + case 7: + return "Sunday"; + } + } + + /// get data formatted like Apr 26,2020 + /// [dateTime] convert DateTime to data formatted + static String getMonthDayYearDateFormatted(DateTime dateTime) { + if (dateTime != null) + return getMonth(dateTime.month) + " " + dateTime.day.toString() + ", " + dateTime.year.toString(); + else + return ""; + } + + /// get data formatted like Apr 26,2020 + /// [dateTime] convert DateTime to data formatted Arabic + static String getMonthDayYearDateFormattedAr(DateTime dateTime) { + if (dateTime != null) + return getMonthArabic(dateTime.month) + " " + dateTime.day.toString() + ", " + dateTime.year.toString(); + else + return ""; + } + + /// get data formatted like Thursday, Apr 26,2020 + /// [dateTime] convert DateTime to date formatted + static String getWeekDayMonthDayYearDateFormatted(DateTime dateTime, String lang) { + // print(dateTime); + // print(dateTime.weekday); + // print(dateTime.weekday.getDayOfWeekEnumValue.value); + if (dateTime != null) + return lang == 'en' + ? getWeekDayEnglish(dateTime.weekday) + ", " + getMonth(dateTime.month) + " " + dateTime.day.toString() + " " + dateTime.year.toString() + : getWeekDayArabic(dateTime.weekday) + ", " + dateTime.day.toString() + " " + getMonthArabic(dateTime.month) + " " + dateTime.year.toString(); + else + return ""; + } + + static String getMonthDayYearLangDateFormatted(DateTime dateTime, String lang) { + if (dateTime != null) + return lang == 'en' + ? getMonth(dateTime.month) + " " + dateTime.day.toString() + " " + dateTime.year.toString() + : dateTime.day.toString() + " " + getMonthArabic(dateTime.month) + " " + dateTime.year.toString(); + else + return ""; + } + + /// get data formatted like 26/4/2020 + static String getDayMonthYearLangDateFormatted(DateTime dateTime, String lang) { + if (dateTime != null) + return lang == 'en' + ? dateTime.day.toString() + " " + getMonth(dateTime.month) + " " + dateTime.year.toString() + : dateTime.day.toString() + " " + getMonthArabic(dateTime.month) + " " + dateTime.year.toString(); + else + return ""; + } + + static String getMonthYearLangDateFormatted(DateTime dateTime, String lang) { + if (dateTime != null) + return lang == 'en' ? getMonth(dateTime.month) + " " + dateTime.year.toString() : getMonthArabic(dateTime.month) + " " + dateTime.year.toString(); + else + return ""; + } + + /// get data formatted like 26/4/2020 + /// [dateTime] convert DateTime to data formatted + static String getDayMonthYearDateFormatted(DateTime dateTime) { + if (dateTime != null) + return dateTime.day.toString() + "/" + dateTime.month.toString() + "/" + dateTime.year.toString(); + else + return ""; + } + + /// get data formatted like 26/4/2020 + /// [dateTime] convert DateTime to data formatted + static String getDayMonthDateFormatted(DateTime dateTime) { + if (dateTime != null) + return DateFormat('dd/MM').format(dateTime); + else + return ""; + } + + /// get data formatted like 26/4/2020 + /// [dateTime] convert DateTime to data formatted according to language + static String getDayMonthYearDateFormattedLang(DateTime dateTime, bool isArabic) { + if (dateTime != null) + return DateFormat('dd/MM/yyyy', isArabic ? "ar_SA" : "en_US").format(dateTime); + else + return ""; + } + + /// get data formatted like 10:30 according to lang + static String formatDateToTimeLang(DateTime date, bool isArabic) { + return DateFormat('HH:mm', isArabic ? "ar_SA" : "en_US").format(date); + } + + /// get data formatted like 26/4/2020 10:30 + /// [dateTime] convert DateTime to data formatted + static String getDayMonthYearHourMinuteDateFormatted(DateTime dateTime) { + if (dateTime != null) + return dateTime.day.toString() + "/" + dateTime.month.toString() + "/" + dateTime.year.toString() + " " + DateFormat('HH:mm').format(dateTime); + else + return ""; + } + + /// get data formatted like 2020-8-13 09:43:00 + /// [dateTime] convert DateTime to data formatted + static String getYearMonthDayHourMinSecDateFormatted(DateTime dateTime) { + if (dateTime != null) + return dateTime.year.toString() + + "-" + + dateTime.month.toString() + + "-" + + dateTime.day.toString() + + " " + + dateTime.hour.toString() + + ":" + + dateTime.minute.toString() + + ":" + + dateTime.second.toString(); + else + return ""; + } + + static String getFormattedDate(DateTime dateTime, String formattedString) { + return DateFormat(formattedString).format(dateTime); + } + + static convertISODateToJsonDate(String isoDate) { + return "/Date(" + DateFormat('mm-dd-yyy').parse(isoDate).millisecondsSinceEpoch.toString() + ")/"; + } + + // static String getDay(DayOfWeek dayOfWeek) { + // switch (dayOfWeek) { + // case DayOfWeek.Monday: + // return "Monday"; + // break; + // case DayOfWeek.Tuesday: + // return "Tuesday"; + // break; + // case DayOfWeek.Wednesday: + // return "Wednesday"; + // break; + // case DayOfWeek.Thursday: + // return "Thursday"; + // break; + // case DayOfWeek.Friday: + // return "Friday"; + // break; + // case DayOfWeek.Saturday: + // return "Saturday"; + // break; + // case DayOfWeek.Sunday: + // return "Sunday"; + // break; + // } + // return ""; + // } +} diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index 5d4f8cd..2db6135 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -1,15 +1,19 @@ +import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/cupertino.dart'; import 'package:intl/intl.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; extension CapExtension on String { String get toCamelCase => "${this[0].toUpperCase()}${this.substring(1)}"; + String get inCaps => '${this[0].toUpperCase()}${this.substring(1)}'; + String get allInCaps => this.toUpperCase(); + String get capitalizeFirstofEach => this.trim().length > 0 ? this.trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") : ""; } - extension EmailValidator on String { Widget get toWidget => Text(this); @@ -65,9 +69,9 @@ extension EmailValidator on String { style: TextStyle(height: 1, color: color ?? MyColors.darkTextColor, fontSize: 22, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), ); - Widget toText24({Color? color, bool isBold = false}) => Text( + Widget toText24({Color? color, bool isBold = false, bool considerHeight = true}) => Text( this, - style: TextStyle(height: 23 / 24, color: color ?? MyColors.darkTextColor, fontSize: 24, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), + style: TextStyle(height: considerHeight ? 23 / 24 : null, color: color ?? MyColors.darkTextColor, fontSize: 24, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), ); Widget toText32({Color? color, bool isBold = false}) => Text( @@ -75,6 +79,38 @@ extension EmailValidator on String { style: TextStyle(height: 32 / 32, color: color ?? MyColors.darkTextColor, fontSize: 32, letterSpacing: -1.92, fontWeight: isBold ? FontWeight.bold : FontWeight.w600), ); + Widget toSectionHeading({String upperHeading = "", String lowerHeading = ""}) { + String upper = ""; + String lower = ""; + String heading = this; + if (heading.isNotEmpty) { + List data = heading.split(" "); + + if (data.length > 1) { + upper = data[0]; + data.removeAt(0); + lower = data.join(" "); + } else { + lower = data[0]; + } + } + if (upperHeading.isNotEmpty) { + upper = upperHeading; + } + if (lowerHeading.isNotEmpty) { + lower = lowerHeading; + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + if (upper.isNotEmpty) upper.toText12(), + lower.toText24(isBold: true), + ], + ); + } + bool isValidEmail() { return RegExp(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$').hasMatch(this); } diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index 130c867..5169f19 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -5,19 +5,27 @@ import 'package:shimmer/shimmer.dart'; extension WidgetExtensions on Widget { Widget onPress(VoidCallback onTap) => InkWell(onTap: onTap, child: this); + Widget get expanded => Expanded(child: this); + + Widget get center => Center(child: this); + Widget paddingAll(double _value) => Padding(padding: EdgeInsets.all(_value), child: this); Widget paddingOnly({double left = 0.0, double right = 0.0, double top = 0.0, double bottom = 0.0}) => Padding(padding: EdgeInsets.only(left: left, right: right, top: top, bottom: bottom), child: this); - Widget toShimmer({bool isShow=true}) =>isShow? Shimmer.fromColors( - baseColor: Color(0xffe8eff0), - highlightColor: Colors.white, - child: Container( + Widget toShimmer({bool isShow = true}) => isShow + ? Shimmer.fromColors( + baseColor: Color(0xffe8eff0), + highlightColor: Colors.white, + child: Container( + child: this, + color: Colors.white, + ), + ) + : Container( child: this, - color: Colors.white, - ), - ):Container(child: this,); + ); Widget animatedSwither() => AnimatedSwitcher( duration: const Duration(milliseconds: 500), diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 3d67def..f4a2a6c 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -6,213 +6,193 @@ import 'dart:ui'; import 'package:easy_localization/easy_localization.dart' show AssetLoader; -class CodegenLoader extends AssetLoader{ +class CodegenLoader extends AssetLoader { const CodegenLoader(); @override - Future> load(String fullPath, Locale locale ) { + Future> load(String fullPath, Locale locale) { return Future.value(mapLocales[locale.toString()]); } - static const Map ar_SA = { - "mohemm": "Mohemm", - "english": "English", - "arabic": "Arabic", - "login": "تسجيل الدخول", - "pleaseEnterLoginDetails": "الرجاء إدخال التفاصيل أدناه لتسجيل الدخول", - "username": "اسم المستخدم", - "password": "كلمة المرور", - "welcomeBack": "مرحبا بعودتك", - "wouldYouLikeToLoginWithCurrentUsername": "هل ترغب في تسجيل الدخول باسم المستخدم الحالي؟", - "lastLoginDetails": "تفاصيل تسجيل الدخول الأخير:", - "verificationType": "نوع التحقق:", - "pleaseVerify": "ارجوك تحقق", - "verifyThroughFace": "تحقق من خلال الوجه", - "verifyThroughFingerprint": "تحقق من خلال بصمة الإصبع", - "verifyThroughSMS": "تحقق من خلال الرسائل القصيرة", - "verifyThroughWhatsapp": "تحقق من خلال Whatsapp", - "useAnotherAccount": "استخدم حسابا آخر", - "pleaseEnterTheVerificationCodeSentTo": "الرجاء إدخال رمز التحقق المرسل إلى ", - "theVerificationCodeWillExpireIn": "ستنتهي صلاحية رمز التحقق في ", - "goodMorning": "صباح الخير", - "markAttendance": "علامة الحضور", - "timeLeftToday": "الوقت المتبقي اليوم", - "checkIn": "تحقق في", - "workList": "قائمة العمل", - "leaveBalance": "رصيد الاجازات", - "missingSwipes": "الضربات الشديدة في عداد المفقودين", - "ticketBalance": "رصيد التذكرة", - "other": "آخر", - "services": "خدمات", - "viewAllServices": "عرض جميع الخدمات", - "monthlyAttendance": "الحضور الشهري", - "workFromHome": "العمل من المنزل", - "ticketRequest": "طلب تذكرة", - "viewAllOffers": "مشاهدة جميع العروض", - "offers": "عروض & ", - "discounts": "الخصومات", - "newString": "جديد", - "setTheNewPassword": "قم بتعيين كلمة المرور الجديدة", - "typeYourNewPasswordBelow": "اكتب كلمة المرور الجديدة أدناه", - "confirmPassword": "تأكيد كلمة المرور", - "update": "تحديث", - "title": "عنوان", - "home": "مسكن", - "mySalary": "راتبي", - "createRequest": "إنشاء طلب", - "forgotPassword": "هل نسيت كلمة السر", - "employeeId": "هوية الموظف", - "loginCodeWillSentToMobileNumber": "الرجاء إدخال معرف الموظف الخاص بك ، وسيتم إرسال رمز تسجيل الدخول إلى رقم هاتفك المحمول", - "changePassword": "تغيير كلمة المرور", - "ok": "موافق", - "confirm": "تؤكد", - "passwordChangedSuccessfully": "تم تغيير الرقم السري بنجاح", - "itemsForSale": "سلع للبيع", - "doNotUseRecentPassword": "لا تستخدم كلمة مرور حديثة", - "atLeastOneLowercase": "حرف صغير واحد على الأقل", - "atLeastOneUppercase": "حرف كبير واحد على الأقل", - "atLeastOneNumeric": "رقم واحد على الأقل", - "minimum8Characters": "8 أحرف على الأقل", - "doNotAddRepeatingLetters": "لا تقم بإضافة أحرف متكررة", - "itShouldContainSpecialCharacter": "يجب أن يحتوي على طابع خاص", - "confirmPasswordMustMatch": "يجب أن يتطابق تأكيد كلمة المرور", - "msg": "Hello {} in the {} world ", - "msg_named": "{} are written in the {lang} language", - "clickMe": "Click me", - "human": "Human", - "resources": "Resources", - "profile": { - "reset_password": { - "label": "Reset Password", - "username": "Username", - "password": "password" - } - }, - "clicked": { - "zero": "You clicked {} times!", - "one": "You clicked {} time!", - "two": "You clicked {} times!", - "few": "You clicked {} times!", - "many": "You clicked {} times!", - "other": "You clicked {} times!" - }, - "amount": { - "zero": "Your amount : {} ", - "one": "Your amount : {} ", - "two": "Your amount : {} ", - "few": "Your amount : {} ", - "many": "Your amount : {} ", - "other": "Your amount : {} " - }, - "gender": { - "male": "Hi man ;) ", - "female": "Hello girl :)", - "with_arg": { - "male": "Hi man ;) {}", - "female": "Hello girl :) {}" - } - }, - "reset_locale": "Reset Language" -}; -static const Map en_US = { - "mohemm": "Mohemm", - "english": "English", - "arabic": "Arabic", - "login": "Login", - "pleaseEnterLoginDetails": "Please enter the detail below to login", - "username": "Username", - "password": "Password", - "welcomeBack": "Welcome back", - "wouldYouLikeToLoginWithCurrentUsername": "Would you like to login with current Username?", - "lastLoginDetails": "Last Login Details:", - "verificationType": "Verification Type:", - "pleaseVerify": "Please Verify", - "verifyThroughFace": "Verify Through Face", - "verifyThroughFingerprint": "Verify Through Fingerprint", - "verifyThroughSMS": "Verify Through SMS", - "verifyThroughWhatsapp": "Verify Through Whatsapp", - "useAnotherAccount": "Use Another Account", - "pleaseEnterTheVerificationCodeSentTo": "Please enter the verification code sent to ", - "theVerificationCodeWillExpireIn": "The verification code will expire in ", - "goodMorning": "Good Morning", - "markAttendance": "Mark Attendance", - "timeLeftToday": "Time Left Today", - "checkIn": "Check In", - "workList": "Work List", - "leaveBalance": "Leave Balance", - "missingSwipes": "Missing Swipes", - "ticketBalance": "Ticket Balance", - "other": "Other", - "services": "Services", - "viewAllServices": "View All Services", - "monthlyAttendance": "Monthly Attendance", - "workFromHome": "Work From Home", - "ticketRequest": "Ticket Request", - "viewAllOffers": "View All Offers", - "offers": "Offers & ", - "discounts": "Discounts", - "newString": "New", - "setTheNewPassword": "Set the new password", - "typeYourNewPasswordBelow": "Type your new password below", - "confirmPassword": "Confirm Password", - "update": "Update", - "title": "Title", - "home": "Home", - "mySalary": "My Salary", - "createRequest": "Create Request", - "forgotPassword": "Forgot Password", - "employeeId": "Employee ID", - "loginCodeWillSentToMobileNumber": "Please Enter your Employee ID, A login code will be sent to your mobile number", - "changePassword": "Change Password", - "ok": "OK", - "confirm": "Confirm", - "passwordChangedSuccessfully": "Password changed successfully", - "itemsForSale": "Items for Sale", - "doNotUseRecentPassword": "Do not use recent password", - "atLeastOneLowercase": "At least one lowercase", - "atLeastOneUppercase": "At least one uppercase", - "atLeastOneNumeric": "At least one numeric", - "minimum8Characters": "Minimum 8 characters", - "doNotAddRepeatingLetters": "Do not add repeating letters", - "itShouldContainSpecialCharacter": "It should contain special character", - "confirmPasswordMustMatch": "Confirm password must match", - "msg": "Hello {} in the {} world ", - "msg_named": "{} are written in the {lang} language", - "clickMe": "Click me", - "human": "Human", - "resources": "Resources", - "profile": { - "reset_password": { - "label": "Reset Password", - "username": "Username", - "password": "password" - } - }, - "clicked": { - "zero": "You clicked {} times!", - "one": "You clicked {} time!", - "two": "You clicked {} times!", - "few": "You clicked {} times!", - "many": "You clicked {} times!", - "other": "You clicked {} times!" - }, - "amount": { - "zero": "Your amount : {} ", - "one": "Your amount : {} ", - "two": "Your amount : {} ", - "few": "Your amount : {} ", - "many": "Your amount : {} ", - "other": "Your amount : {} " - }, - "gender": { - "male": "Hi man ;) ", - "female": "Hello girl :)", - "with_arg": { - "male": "Hi man ;) {}", - "female": "Hello girl :) {}" - } - }, - "reset_locale": "Reset Language" -}; -static const Map> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; + static const Map ar_SA = { + "mohemm": "Mohemm", + "english": "English", + "arabic": "Arabic", + "login": "تسجيل الدخول", + "pleaseEnterLoginDetails": "الرجاء إدخال التفاصيل أدناه لتسجيل الدخول", + "username": "اسم المستخدم", + "password": "كلمة المرور", + "welcomeBack": "مرحبا بعودتك", + "wouldYouLikeToLoginWithCurrentUsername": "هل ترغب في تسجيل الدخول باسم المستخدم الحالي؟", + "lastLoginDetails": "تفاصيل تسجيل الدخول الأخير:", + "verificationType": "نوع التحقق:", + "pleaseVerify": "ارجوك تحقق", + "verifyThroughFace": "تحقق من خلال الوجه", + "verifyThroughFingerprint": "تحقق من خلال بصمة الإصبع", + "verifyThroughSMS": "تحقق من خلال الرسائل القصيرة", + "verifyThroughWhatsapp": "تحقق من خلال Whatsapp", + "useAnotherAccount": "استخدم حسابا آخر", + "pleaseEnterTheVerificationCodeSentTo": "الرجاء إدخال رمز التحقق المرسل إلى ", + "theVerificationCodeWillExpireIn": "ستنتهي صلاحية رمز التحقق في ", + "goodMorning": "صباح الخير", + "markAttendance": "علامة الحضور", + "timeLeftToday": "الوقت المتبقي اليوم", + "checkIn": "تحقق في", + "workList": "قائمة العمل", + "leaveBalance": "رصيد الاجازات", + "missingSwipes": "الضربات الشديدة في عداد المفقودين", + "ticketBalance": "رصيد التذكرة", + "other": "آخر", + "services": "خدمات", + "viewAllServices": "عرض جميع الخدمات", + "monthlyAttendance": "الحضور الشهري", + "workFromHome": "العمل من المنزل", + "ticketRequest": "طلب تذكرة", + "viewAllOffers": "مشاهدة جميع العروض", + "offers": "عروض & ", + "discounts": "الخصومات", + "newString": "جديد", + "setTheNewPassword": "قم بتعيين كلمة المرور الجديدة", + "typeYourNewPasswordBelow": "اكتب كلمة المرور الجديدة أدناه", + "confirmPassword": "تأكيد كلمة المرور", + "update": "تحديث", + "title": "عنوان", + "home": "مسكن", + "mySalary": "راتبي", + "createRequest": "إنشاء طلب", + "forgotPassword": "هل نسيت كلمة السر", + "employeeId": "هوية الموظف", + "loginCodeWillSentToMobileNumber": "الرجاء إدخال معرف الموظف الخاص بك ، وسيتم إرسال رمز تسجيل الدخول إلى رقم هاتفك المحمول", + "changePassword": "تغيير كلمة المرور", + "ok": "موافق", + "confirm": "تؤكد", + "passwordChangedSuccessfully": "تم تغيير الرقم السري بنجاح", + "itemsForSale": "سلع للبيع", + "doNotUseRecentPassword": "لا تستخدم كلمة مرور حديثة", + "atLeastOneLowercase": "حرف صغير واحد على الأقل", + "atLeastOneUppercase": "حرف كبير واحد على الأقل", + "atLeastOneNumeric": "رقم واحد على الأقل", + "minimum8Characters": "8 أحرف على الأقل", + "doNotAddRepeatingLetters": "لا تقم بإضافة أحرف متكررة", + "itShouldContainSpecialCharacter": "يجب أن يحتوي على طابع خاص", + "confirmPasswordMustMatch": "يجب أن يتطابق تأكيد كلمة المرور", + "sms": "رسالة قصيرة", + "fingerPrint": "بصمة", + "face": "التعرف على الوجه", + "whatsapp": "واتس اب", + "msg": "Hello {} in the {} world ", + "msg_named": "{} are written in the {lang} language", + "clickMe": "Click me", + "human": "Human", + "resources": "Resources", + "profile": { + "reset_password": {"label": "Reset Password", "username": "Username", "password": "password"} + }, + "clicked": { + "zero": "You clicked {} times!", + "one": "You clicked {} time!", + "two": "You clicked {} times!", + "few": "You clicked {} times!", + "many": "You clicked {} times!", + "other": "You clicked {} times!" + }, + "amount": {"zero": "Your amount : {} ", "one": "Your amount : {} ", "two": "Your amount : {} ", "few": "Your amount : {} ", "many": "Your amount : {} ", "other": "Your amount : {} "}, + "gender": { + "male": "Hi man ;) ", + "female": "Hello girl :)", + "with_arg": {"male": "Hi man ;) {}", "female": "Hello girl :) {}"} + }, + "reset_locale": "Reset Language" + }; + static const Map en_US = { + "mohemm": "Mohemm", + "english": "English", + "arabic": "Arabic", + "login": "Login", + "pleaseEnterLoginDetails": "Please enter the detail below to login", + "username": "Username", + "password": "Password", + "welcomeBack": "Welcome back", + "wouldYouLikeToLoginWithCurrentUsername": "Would you like to login with current Username?", + "lastLoginDetails": "Last Login Details:", + "verificationType": "Verification Type:", + "pleaseVerify": "Please Verify", + "verifyThroughFace": "Verify Through Face", + "verifyThroughFingerprint": "Verify Through Fingerprint", + "verifyThroughSMS": "Verify Through SMS", + "verifyThroughWhatsapp": "Verify Through Whatsapp", + "useAnotherAccount": "Use Another Account", + "pleaseEnterTheVerificationCodeSentTo": "Please enter the verification code sent to ", + "theVerificationCodeWillExpireIn": "The verification code will expire in ", + "goodMorning": "Good Morning", + "markAttendance": "Mark Attendance", + "timeLeftToday": "Time Left Today", + "checkIn": "Check In", + "workList": "Work List", + "leaveBalance": "Leave Balance", + "missingSwipes": "Missing Swipes", + "ticketBalance": "Ticket Balance", + "other": "Other", + "services": "Services", + "viewAllServices": "View All Services", + "monthlyAttendance": "Monthly Attendance", + "workFromHome": "Work From Home", + "ticketRequest": "Ticket Request", + "viewAllOffers": "View All Offers", + "offers": "Offers & ", + "discounts": "Discounts", + "newString": "New", + "setTheNewPassword": "Set the new password", + "typeYourNewPasswordBelow": "Type your new password below", + "confirmPassword": "Confirm Password", + "update": "Update", + "title": "Title", + "home": "Home", + "mySalary": "My Salary", + "createRequest": "Create Request", + "forgotPassword": "Forgot Password", + "employeeId": "Employee ID", + "loginCodeWillSentToMobileNumber": "Please Enter your Employee ID, A login code will be sent to your mobile number", + "changePassword": "Change Password", + "ok": "OK", + "confirm": "Confirm", + "passwordChangedSuccessfully": "Password changed successfully", + "itemsForSale": "Items for Sale", + "doNotUseRecentPassword": "Do not use recent password", + "atLeastOneLowercase": "At least one lowercase", + "atLeastOneUppercase": "At least one uppercase", + "atLeastOneNumeric": "At least one numeric", + "minimum8Characters": "Minimum 8 characters", + "doNotAddRepeatingLetters": "Do not add repeating letters", + "itShouldContainSpecialCharacter": "It should contain special character", + "confirmPasswordMustMatch": "Confirm password must match", + "sms": "SMS", + "fingerPrint": "Fingerprint", + "face": "Face", + "whatsapp": "Whatsapp", + "msg": "Hello {} in the {} world ", + "msg_named": "{} are written in the {lang} language", + "clickMe": "Click me", + "human": "Human", + "resources": "Resources", + "profile": { + "reset_password": {"label": "Reset Password", "username": "Username", "password": "password"} + }, + "clicked": { + "zero": "You clicked {} times!", + "one": "You clicked {} time!", + "two": "You clicked {} times!", + "few": "You clicked {} times!", + "many": "You clicked {} times!", + "other": "You clicked {} times!" + }, + "amount": {"zero": "Your amount : {} ", "one": "Your amount : {} ", "two": "Your amount : {} ", "few": "Your amount : {} ", "many": "Your amount : {} ", "other": "Your amount : {} "}, + "gender": { + "male": "Hi man ;) ", + "female": "Hello girl :)", + "with_arg": {"male": "Hi man ;) {}", "female": "Hello girl :) {}"} + }, + "reset_locale": "Reset Language" + }; + static const Map> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index b5ecc57..55e543b 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -1,6 +1,6 @@ // DO NOT EDIT. This is code generated via package:easy_localization/generate.dart -abstract class LocaleKeys { +abstract class LocaleKeys { static const mohemm = 'mohemm'; static const english = 'english'; static const arabic = 'arabic'; @@ -61,11 +61,18 @@ abstract class LocaleKeys { static const doNotAddRepeatingLetters = 'doNotAddRepeatingLetters'; static const itShouldContainSpecialCharacter = 'itShouldContainSpecialCharacter'; static const confirmPasswordMustMatch = 'confirmPasswordMustMatch'; + static const sms = 'sms'; + static const fingerPrint = 'fingerPrint'; + static const face = 'face'; + static const whatsapp = 'whatsapp'; static const msg = 'msg'; static const msg_named = 'msg_named'; static const clickMe = 'clickMe'; static const human = 'human'; static const resources = 'resources'; + static const details = 'details'; + static const reject = 'reject'; + static const approve = 'approve'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; @@ -76,5 +83,4 @@ abstract class LocaleKeys { static const gender_with_arg = 'gender.with_arg'; static const gender = 'gender'; static const reset_locale = 'reset_locale'; - } diff --git a/lib/main.dart b/lib/main.dart index 49b0e35..20759d9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,18 +14,19 @@ import 'package:firebase_core/firebase_core.dart'; import 'config/routes.dart'; import 'package:logger/logger.dart'; - var logger = Logger( // filter: null, // Use the default LogFilter (-> only log in debug mode) printer: PrettyPrinter(lineLength: 0), // Use the PrettyPrinter to format and print log // output: null, // U ); - Future main() async { WidgetsFlutterBinding.ensureInitialized(); await EasyLocalization.ensureInitialized(); await Firebase.initializeApp(); + AppState().setPostParamsModel( + PostParamsModel(channel: 31, versionID: 3.2, mobileType: Platform.isAndroid ? "android" : "ios"), + ); runApp( EasyLocalization( supportedLocales: const [ @@ -57,23 +58,22 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return AppProvider( - child: Sizer( - builder: (context, orientation, deviceType) { - AppState().setPostParamsModel( - PostParamsModel(languageID: EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2, channel: 31, versionID: 3.2, mobileType: Platform.isAndroid ? "android" : "ios"), - ); - return MaterialApp( - theme: AppTheme.getTheme(EasyLocalization.of(context)?.locale.languageCode == "ar"), - debugShowCheckedModeBanner: false, - localizationsDelegates: context.localizationDelegates, - supportedLocales: context.supportedLocales, - locale: context.locale, - initialRoute: AppRoutes.initialRoute, - routes: AppRoutes.routes, - ); - }, - ), + return Sizer( + builder: (context, orientation, deviceType) { + print(AppState().postParamsObject?.toJson()); + var obj = AppState().postParamsObject; + obj?.languageID = EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2; + AppState().setPostParamsModel(obj!); + return MaterialApp( + theme: AppTheme.getTheme(EasyLocalization.of(context)?.locale.languageCode == "ar"), + debugShowCheckedModeBanner: false, + localizationsDelegates: context.localizationDelegates, + supportedLocales: context.supportedLocales, + locale: context.locale, + initialRoute: AppRoutes.initialRoute, + routes: AppRoutes.routes, + ); + }, ); } } diff --git a/lib/models/dashboard/itg_forms_model.dart b/lib/models/dashboard/itg_forms_model.dart index c5a0145..5ed719b 100644 --- a/lib/models/dashboard/itg_forms_model.dart +++ b/lib/models/dashboard/itg_forms_model.dart @@ -93,97 +93,163 @@ class ItgFormsModel { dynamic mohemmItgProjectsList; dynamic mohemmItgTicketTypesList; DateTime? referenceNumber; - dynamic requestType; + List? requestType; int? totalCount; int? statuseCode; factory ItgFormsModel.fromJson(Map json) => ItgFormsModel( - date: json["Date"], - languageId: json["LanguageID"] == null ? null : json["LanguageID"], - serviceName: json["ServiceName"] == null ? null : json["ServiceName"], - time: json["Time"], - androidLink: json["AndroidLink"], - authenticationTokenId: json["AuthenticationTokenID"], - data: json["Data"], - dataw: json["Dataw"] == null ? null : json["Dataw"], - dietType: json["DietType"] == null ? null : json["DietType"], - dietTypeId: json["DietTypeID"] == null ? null : json["DietTypeID"], - errorCode: json["ErrorCode"], - errorEndUserMessage: json["ErrorEndUserMessage"], - errorEndUserMessageN: json["ErrorEndUserMessageN"], - errorMessage: json["ErrorMessage"], - errorType: json["ErrorType"] == null ? null : json["ErrorType"], - foodCategory: json["FoodCategory"] == null ? null : json["FoodCategory"], - iosLink: json["IOSLink"], - isAuthenticated: json["IsAuthenticated"] == null ? null : json["IsAuthenticated"], - mealOrderStatus: json["MealOrderStatus"] == null ? null : json["MealOrderStatus"], - mealType: json["MealType"] == null ? null : json["MealType"], - messageStatus: json["MessageStatus"] == null ? null : json["MessageStatus"], - numberOfResultRecords: json["NumberOfResultRecords"] == null ? null : json["NumberOfResultRecords"], - patientBlodType: json["PatientBlodType"], - successMsg: json["SuccessMsg"] == null ? null : json["SuccessMsg"], - successMsgN: json["SuccessMsgN"], - vidaUpdatedResponse: json["VidaUpdatedResponse"], - itgRequest: json["ITGRequest"], - itgFormAttachmentsList: json["Itg_FormAttachmentsList"], - message: json["Message"] == null ? null : json["Message"], - mohemmItgDepartmentSectionsList: json["Mohemm_ITG_DepartmentSectionsList"], - mohemmItgProjectDepartmentsList: json["Mohemm_ITG_ProjectDepartmentsList"], - mohemmItgResponseItem: json["Mohemm_ITG_ResponseItem"], - mohemmItgSectionTopicsList: json["Mohemm_ITG_SectionTopicsList"], - mohemmItgTicketDetailsList: json["Mohemm_ITG_TicketDetailsList"], - mohemmItgTicketTransactionsList: json["Mohemm_ITG_TicketTransactionsList"], - mohemmItgTicketsByEmployeeList: json["Mohemm_ITG_TicketsByEmployeeList"], - mohemmItgProjectsList: json["Mohemm_Itg_ProjectsList"], - mohemmItgTicketTypesList: json["Mohemm_Itg_TicketTypesList"], - referenceNumber: json["ReferenceNumber"] == null ? null : DateTime.parse(json["ReferenceNumber"]), - requestType: json["RequestType"], - totalCount: json["TotalCount"] == null ? null : json["TotalCount"], - statuseCode: json["statuseCode"] == null ? null : json["statuseCode"], - ); + date: json["Date"], + languageId: json["LanguageID"] == null ? null : json["LanguageID"], + serviceName: json["ServiceName"] == null ? null : json["ServiceName"], + time: json["Time"], + androidLink: json["AndroidLink"], + authenticationTokenId: json["AuthenticationTokenID"], + data: json["Data"], + dataw: json["Dataw"] == null ? null : json["Dataw"], + dietType: json["DietType"] == null ? null : json["DietType"], + dietTypeId: json["DietTypeID"] == null ? null : json["DietTypeID"], + errorCode: json["ErrorCode"], + errorEndUserMessage: json["ErrorEndUserMessage"], + errorEndUserMessageN: json["ErrorEndUserMessageN"], + errorMessage: json["ErrorMessage"], + errorType: json["ErrorType"] == null ? null : json["ErrorType"], + foodCategory: json["FoodCategory"] == null ? null : json["FoodCategory"], + iosLink: json["IOSLink"], + isAuthenticated: json["IsAuthenticated"] == null ? null : json["IsAuthenticated"], + mealOrderStatus: json["MealOrderStatus"] == null ? null : json["MealOrderStatus"], + mealType: json["MealType"] == null ? null : json["MealType"], + messageStatus: json["MessageStatus"] == null ? null : json["MessageStatus"], + numberOfResultRecords: json["NumberOfResultRecords"] == null ? null : json["NumberOfResultRecords"], + patientBlodType: json["PatientBlodType"], + successMsg: json["SuccessMsg"] == null ? null : json["SuccessMsg"], + successMsgN: json["SuccessMsgN"], + vidaUpdatedResponse: json["VidaUpdatedResponse"], + itgRequest: json["ITGRequest"], + itgFormAttachmentsList: json["Itg_FormAttachmentsList"], + message: json["Message"] == null ? null : json["Message"], + mohemmItgDepartmentSectionsList: json["Mohemm_ITG_DepartmentSectionsList"], + mohemmItgProjectDepartmentsList: json["Mohemm_ITG_ProjectDepartmentsList"], + mohemmItgResponseItem: json["Mohemm_ITG_ResponseItem"], + mohemmItgSectionTopicsList: json["Mohemm_ITG_SectionTopicsList"], + mohemmItgTicketDetailsList: json["Mohemm_ITG_TicketDetailsList"], + mohemmItgTicketTransactionsList: json["Mohemm_ITG_TicketTransactionsList"], + mohemmItgTicketsByEmployeeList: json["Mohemm_ITG_TicketsByEmployeeList"], + mohemmItgProjectsList: json["Mohemm_Itg_ProjectsList"], + mohemmItgTicketTypesList: json["Mohemm_Itg_TicketTypesList"], + referenceNumber: json["ReferenceNumber"] == null ? null : DateTime.parse(json["ReferenceNumber"]), + requestType: json["RequestType"] == null ? [] : json['RequestType']!.map((v) => RequestType.fromJson(v)).toList(), + totalCount: json["TotalCount"] == null ? null : json["TotalCount"], + statuseCode: json["statuseCode"] == null ? null : json["statuseCode"], + ); Map toMap() => { - "Date": date, - "LanguageID": languageId == null ? null : languageId, - "ServiceName": serviceName == null ? null : serviceName, - "Time": time, - "AndroidLink": androidLink, - "AuthenticationTokenID": authenticationTokenId, - "Data": data, - "Dataw": dataw == null ? null : dataw, - "DietType": dietType == null ? null : dietType, - "DietTypeID": dietTypeId == null ? null : dietTypeId, - "ErrorCode": errorCode, - "ErrorEndUserMessage": errorEndUserMessage, - "ErrorEndUserMessageN": errorEndUserMessageN, - "ErrorMessage": errorMessage, - "ErrorType": errorType == null ? null : errorType, - "FoodCategory": foodCategory == null ? null : foodCategory, - "IOSLink": iosLink, - "IsAuthenticated": isAuthenticated == null ? null : isAuthenticated, - "MealOrderStatus": mealOrderStatus == null ? null : mealOrderStatus, - "MealType": mealType == null ? null : mealType, - "MessageStatus": messageStatus == null ? null : messageStatus, - "NumberOfResultRecords": numberOfResultRecords == null ? null : numberOfResultRecords, - "PatientBlodType": patientBlodType, - "SuccessMsg": successMsg == null ? null : successMsg, - "SuccessMsgN": successMsgN, - "VidaUpdatedResponse": vidaUpdatedResponse, - "ITGRequest": itgRequest, - "Itg_FormAttachmentsList": itgFormAttachmentsList, - "Message": message == null ? null : message, - "Mohemm_ITG_DepartmentSectionsList": mohemmItgDepartmentSectionsList, - "Mohemm_ITG_ProjectDepartmentsList": mohemmItgProjectDepartmentsList, - "Mohemm_ITG_ResponseItem": mohemmItgResponseItem, - "Mohemm_ITG_SectionTopicsList": mohemmItgSectionTopicsList, - "Mohemm_ITG_TicketDetailsList": mohemmItgTicketDetailsList, - "Mohemm_ITG_TicketTransactionsList": mohemmItgTicketTransactionsList, - "Mohemm_ITG_TicketsByEmployeeList": mohemmItgTicketsByEmployeeList, - "Mohemm_Itg_ProjectsList": mohemmItgProjectsList, - "Mohemm_Itg_TicketTypesList": mohemmItgTicketTypesList, - "ReferenceNumber": referenceNumber == null ? null : referenceNumber!.toIso8601String(), - "RequestType": requestType, - "TotalCount": totalCount == null ? null : totalCount, - "statuseCode": statuseCode == null ? null : statuseCode, - }; + "Date": date, + "LanguageID": languageId == null ? null : languageId, + "ServiceName": serviceName == null ? null : serviceName, + "Time": time, + "AndroidLink": androidLink, + "AuthenticationTokenID": authenticationTokenId, + "Data": data, + "Dataw": dataw == null ? null : dataw, + "DietType": dietType == null ? null : dietType, + "DietTypeID": dietTypeId == null ? null : dietTypeId, + "ErrorCode": errorCode, + "ErrorEndUserMessage": errorEndUserMessage, + "ErrorEndUserMessageN": errorEndUserMessageN, + "ErrorMessage": errorMessage, + "ErrorType": errorType == null ? null : errorType, + "FoodCategory": foodCategory == null ? null : foodCategory, + "IOSLink": iosLink, + "IsAuthenticated": isAuthenticated == null ? null : isAuthenticated, + "MealOrderStatus": mealOrderStatus == null ? null : mealOrderStatus, + "MealType": mealType == null ? null : mealType, + "MessageStatus": messageStatus == null ? null : messageStatus, + "NumberOfResultRecords": numberOfResultRecords == null ? null : numberOfResultRecords, + "PatientBlodType": patientBlodType, + "SuccessMsg": successMsg == null ? null : successMsg, + "SuccessMsgN": successMsgN, + "VidaUpdatedResponse": vidaUpdatedResponse, + "ITGRequest": itgRequest, + "Itg_FormAttachmentsList": itgFormAttachmentsList, + "Message": message == null ? null : message, + "Mohemm_ITG_DepartmentSectionsList": mohemmItgDepartmentSectionsList, + "Mohemm_ITG_ProjectDepartmentsList": mohemmItgProjectDepartmentsList, + "Mohemm_ITG_ResponseItem": mohemmItgResponseItem, + "Mohemm_ITG_SectionTopicsList": mohemmItgSectionTopicsList, + "Mohemm_ITG_TicketDetailsList": mohemmItgTicketDetailsList, + "Mohemm_ITG_TicketTransactionsList": mohemmItgTicketTransactionsList, + "Mohemm_ITG_TicketsByEmployeeList": mohemmItgTicketsByEmployeeList, + "Mohemm_Itg_ProjectsList": mohemmItgProjectsList, + "Mohemm_Itg_TicketTypesList": mohemmItgTicketTypesList, + "ReferenceNumber": referenceNumber == null ? null : referenceNumber!.toIso8601String(), + "RequestType": requestType == null ? null : requestType!.map((v) => v.toJson()).toList(), + "TotalCount": totalCount == null ? null : totalCount, + "statuseCode": statuseCode == null ? null : statuseCode, + }; +} + +class RequestType { + int? itemCount; + List? requestDetails; + String? requestTypeCode; + String? requestTypeName; + + RequestType({this.itemCount, this.requestDetails, this.requestTypeCode, this.requestTypeName}); + + RequestType.fromJson(Map json) { + itemCount = json['ItemCount']; + if (json['RequestDetails'] != null) { + requestDetails = []; + json['RequestDetails'].forEach((v) { + requestDetails!.add(new RequestDetails.fromJson(v)); + }); + } + requestTypeCode = json['RequestTypeCode']; + requestTypeName = json['RequestTypeName']; + } + + Map toJson() { + final Map data = new Map(); + data['ItemCount'] = this.itemCount; + if (this.requestDetails != null) { + data['RequestDetails'] = this.requestDetails!.map((v) => v.toJson()).toList(); + } + data['RequestTypeCode'] = this.requestTypeCode; + data['RequestTypeName'] = this.requestTypeName; + return data; + } +} + +class RequestDetails { + int? iD; + int? itemID; + String? listID; + String? listName; + String? modifiedDate; + String? title; + String? uRL; + + RequestDetails({this.iD, this.itemID, this.listID, this.listName, this.modifiedDate, this.title, this.uRL}); + + RequestDetails.fromJson(Map json) { + iD = json['ID']; + itemID = json['ItemID']; + listID = json['ListID']; + listName = json['ListName']; + modifiedDate = json['ModifiedDate']; + title = json['Title']; + uRL = json['URL']; + } + + Map toJson() { + final Map data = new Map(); + data['ID'] = this.iD; + data['ItemID'] = this.itemID; + data['ListID'] = this.listID; + data['ListName'] = this.listName; + data['ModifiedDate'] = this.modifiedDate; + data['Title'] = this.title; + data['URL'] = this.uRL; + return data; + } } diff --git a/lib/models/dashboard/list_menu.dart b/lib/models/dashboard/list_menu.dart index ba327c2..a55cd79 100644 --- a/lib/models/dashboard/list_menu.dart +++ b/lib/models/dashboard/list_menu.dart @@ -18,22 +18,22 @@ class ListMenu { String? subMenuName; factory ListMenu.fromJson(Map json) => ListMenu( - menuId: json["MENU_ID"] == null ? null : json["MENU_ID"], - menuName: json["MENU_NAME"] == null ? null : json["MENU_NAME"], - menuType: json["MENU_TYPE"] == null ? null : json["MENU_TYPE"], - requestGroupId: json["REQUEST_GROUP_ID"] == null ? null : json["REQUEST_GROUP_ID"], - requestGroupName: json["REQUEST_GROUP_NAME"] == null ? null : json["REQUEST_GROUP_NAME"], - respId: json["RESP_ID"], - subMenuName: json["SUB_MENU_NAME"] == null ? null : json["SUB_MENU_NAME"], - ); + menuId: json["MENU_ID"] == null ? null : json["MENU_ID"], + menuName: json["MENU_NAME"] == null ? null : json["MENU_NAME"], + menuType: json["MENU_TYPE"] == null ? null : json["MENU_TYPE"], + requestGroupId: json["REQUEST_GROUP_ID"] == null ? null : json["REQUEST_GROUP_ID"], + requestGroupName: json["REQUEST_GROUP_NAME"] == null ? null : json["REQUEST_GROUP_NAME"], + respId: json["RESP_ID"], + subMenuName: json["SUB_MENU_NAME"] == null ? null : json["SUB_MENU_NAME"], + ); Map toJson() => { - "MENU_ID": menuId == null ? null : menuId, - "MENU_NAME": menuName == null ? null : menuName, - "MENU_TYPE": menuType == null ? null : menuType, - "REQUEST_GROUP_ID": requestGroupId == null ? null : requestGroupId, - "REQUEST_GROUP_NAME": requestGroupName == null ? null : requestGroupName, - "RESP_ID": respId, - "SUB_MENU_NAME": subMenuName == null ? null : subMenuName, - }; + "MENU_ID": menuId == null ? null : menuId, + "MENU_NAME": menuName == null ? null : menuName, + "MENU_TYPE": menuType == null ? null : menuType, + "REQUEST_GROUP_ID": requestGroupId == null ? null : requestGroupId, + "REQUEST_GROUP_NAME": requestGroupName == null ? null : requestGroupName, + "RESP_ID": respId, + "SUB_MENU_NAME": subMenuName == null ? null : subMenuName, + }; } diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index a9781d1..0b5c497 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -1,4 +1,5 @@ import 'package:mohem_flutter_app/models/member_login_list_model.dart'; +import 'package:mohem_flutter_app/models/worklist_response_model.dart'; import 'basic_member_information_model.dart'; import 'get_mobile_login_info_list_model.dart'; @@ -150,7 +151,7 @@ class GenericResponseModel { List? getVaccinationOnHandList; List? getVaccinationsList; List? getValueSetValuesList; - List? getWorkList; + List? getWorkList; String? hRCertificateTemplate; String? imgURLsList; String? insertApInv; @@ -612,7 +613,7 @@ class GenericResponseModel { getItemTypeNotificationsList = json['GetItemTypeNotificationsList']; getItemTypesList = json['GetItemTypesList']; getLookupValuesList = json['GetLookupValuesList']; - getMenuEntriesList= json["GetMenuEntriesList"] == null ? null : List.from(json["GetMenuEntriesList"].map((x) => GetMenuEntriesList.fromJson(x))); + getMenuEntriesList = json["GetMenuEntriesList"] == null ? null : List.from(json["GetMenuEntriesList"].map((x) => GetMenuEntriesList.fromJson(x))); getMoItemHistoryList = json['GetMoItemHistoryList']; getMoNotificationBodyList = json['GetMoNotificationBodyList']; getNotificationButtonsList = json['GetNotificationButtonsList']; @@ -656,7 +657,14 @@ class GenericResponseModel { getVaccinationOnHandList = json['GetVaccinationOnHandList']; getVaccinationsList = json['GetVaccinationsList']; getValueSetValuesList = json['GetValueSetValuesList']; - getWorkList = json['GetWorkList']; + + if (json['GetWorkList'] != null) { + getWorkList = []; + json['GetWorkList'].forEach((v) { + getWorkList!.add(WorkListResponseModel.fromJson(v)); + }); + } + hRCertificateTemplate = json['HRCertificateTemplate']; imgURLsList = json['ImgURLsList']; insertApInv = json['InsertApInv']; @@ -930,7 +938,11 @@ class GenericResponseModel { data['GetVaccinationOnHandList'] = this.getVaccinationOnHandList; data['GetVaccinationsList'] = this.getVaccinationsList; data['GetValueSetValuesList'] = this.getValueSetValuesList; - data['GetWorkList'] = this.getWorkList; + + if (getWorkList != null) { + data['GetWorkList'] = getWorkList!.map((v) => v.toJson()).toList(); + } + data['HRCertificateTemplate'] = this.hRCertificateTemplate; data['ImgURLsList'] = this.imgURLsList; data['InsertApInv'] = this.insertApInv; diff --git a/lib/models/worklist_item_type_model.dart b/lib/models/worklist_item_type_model.dart new file mode 100644 index 0000000..49346c0 --- /dev/null +++ b/lib/models/worklist_item_type_model.dart @@ -0,0 +1,38 @@ +import 'dart:ui'; + +class WorkListItemTypeModelData { + late int value; + late String name; + late String fullName; + late bool active; + late List color; + late String icon; + late String key; + late bool disable; + + WorkListItemTypeModelData({required this.value, required this.name, required this.fullName, required this.active, required this.color, required this.icon, required this.key, required this.disable}); + + WorkListItemTypeModelData.fromJson(Map json) { + value = json['value']; + name = json['name']; + fullName = json['fullName']; + active = json['active']; + color = json['color']; + icon = json['icon']; + key = json['key']; + disable = json['disable']; + } + + Map toJson() { + final Map data = {}; + data['value'] = value; + data['name'] = name; + data['fullName'] = fullName; + data['active'] = active; + data['color'] = color; + data['icon'] = icon; + data['key'] = key; + data['disable'] = disable; + return data; + } +} diff --git a/lib/models/worklist_response_model.dart b/lib/models/worklist_response_model.dart new file mode 100644 index 0000000..4899d5a --- /dev/null +++ b/lib/models/worklist_response_model.dart @@ -0,0 +1,137 @@ + +class WorkListResponseModel { + String? bEGINDATE; + String? dUEDATE; + String? eNDDATE; + String? fROMROLE; + int? fROMROWNUM; + String? fROMUSER; + String? fUNCTIONNAME; + String? iTEMKEY; + String? iTEMTYPE; + String? iTEMTYPEDISPLAYNAME; + String? lANGUAGE; + String? mAILSTATUS; + String? mOREINFOROLE; + int? nOTIFICATIONID; + String? nOTIFICATIONNAME; + int? nOOFROWS; + String? oRIGINALRECIPIENT; + String? pONUMBER; + int? pRIORITY; + String? pRIORITYF; + String? pRNUMBER; + String? rECIPIENTROLE; + String? rEQUESTNUMBER; + String? rEQUESTTYPE; + String? rESPONDER; + int? rOWNUM; + String? sELECTEDEMPLOYEENUMBER; + String? sTATUS; + String? sUBJECT; + int? tOROWNUM; + String? tOUSER; + + WorkListResponseModel( + {this.bEGINDATE, + this.dUEDATE, + this.eNDDATE, + this.fROMROLE, + this.fROMROWNUM, + this.fROMUSER, + this.fUNCTIONNAME, + this.iTEMKEY, + this.iTEMTYPE, + this.iTEMTYPEDISPLAYNAME, + this.lANGUAGE, + this.mAILSTATUS, + this.mOREINFOROLE, + this.nOTIFICATIONID, + this.nOTIFICATIONNAME, + this.nOOFROWS, + this.oRIGINALRECIPIENT, + this.pONUMBER, + this.pRIORITY, + this.pRIORITYF, + this.pRNUMBER, + this.rECIPIENTROLE, + this.rEQUESTNUMBER, + this.rEQUESTTYPE, + this.rESPONDER, + this.rOWNUM, + this.sELECTEDEMPLOYEENUMBER, + this.sTATUS, + this.sUBJECT, + this.tOROWNUM, + this.tOUSER}); + + WorkListResponseModel.fromJson(Map json) { + bEGINDATE = json['BEGIN_DATE']; + dUEDATE = json['DUE_DATE']; + eNDDATE = json['END_DATE']; + fROMROLE = json['FROM_ROLE']; + fROMROWNUM = json['FROM_ROW_NUM']; + fROMUSER = json['FROM_USER']; + fUNCTIONNAME = json['FUNCTION_NAME']; + iTEMKEY = json['ITEM_KEY']; + iTEMTYPE = json['ITEM_TYPE']; + iTEMTYPEDISPLAYNAME = json['ITEM_TYPE_DISPLAY_NAME']; + lANGUAGE = json['LANGUAGE']; + mAILSTATUS = json['MAIL_STATUS']; + mOREINFOROLE = json['MORE_INFO_ROLE']; + nOTIFICATIONID = json['NOTIFICATION_ID']; + nOTIFICATIONNAME = json['NOTIFICATION_NAME']; + nOOFROWS = json['NO_OF_ROWS']; + oRIGINALRECIPIENT = json['ORIGINAL_RECIPIENT']; + pONUMBER = json['PO_NUMBER']; + pRIORITY = json['PRIORITY']; + pRIORITYF = json['PRIORITY_F']; + pRNUMBER = json['PR_NUMBER']; + rECIPIENTROLE = json['RECIPIENT_ROLE']; + rEQUESTNUMBER = json['REQUEST_NUMBER']; + rEQUESTTYPE = json['REQUEST_TYPE']; + rESPONDER = json['RESPONDER']; + rOWNUM = json['ROW_NUM']; + sELECTEDEMPLOYEENUMBER = json['SELECTED_EMPLOYEE_NUMBER']; + sTATUS = json['STATUS']; + sUBJECT = json['SUBJECT']; + tOROWNUM = json['TO_ROW_NUM']; + tOUSER = json['TO_USER']; + } + + Map toJson() { + final Map data = new Map(); + data['BEGIN_DATE'] = this.bEGINDATE; + data['DUE_DATE'] = this.dUEDATE; + data['END_DATE'] = this.eNDDATE; + data['FROM_ROLE'] = this.fROMROLE; + data['FROM_ROW_NUM'] = this.fROMROWNUM; + data['FROM_USER'] = this.fROMUSER; + data['FUNCTION_NAME'] = this.fUNCTIONNAME; + data['ITEM_KEY'] = this.iTEMKEY; + data['ITEM_TYPE'] = this.iTEMTYPE; + data['ITEM_TYPE_DISPLAY_NAME'] = this.iTEMTYPEDISPLAYNAME; + data['LANGUAGE'] = this.lANGUAGE; + data['MAIL_STATUS'] = this.mAILSTATUS; + data['MORE_INFO_ROLE'] = this.mOREINFOROLE; + data['NOTIFICATION_ID'] = this.nOTIFICATIONID; + data['NOTIFICATION_NAME'] = this.nOTIFICATIONNAME; + data['NO_OF_ROWS'] = this.nOOFROWS; + data['ORIGINAL_RECIPIENT'] = this.oRIGINALRECIPIENT; + data['PO_NUMBER'] = this.pONUMBER; + data['PRIORITY'] = this.pRIORITY; + data['PRIORITY_F'] = this.pRIORITYF; + data['PR_NUMBER'] = this.pRNUMBER; + data['RECIPIENT_ROLE'] = this.rECIPIENTROLE; + data['REQUEST_NUMBER'] = this.rEQUESTNUMBER; + data['REQUEST_TYPE'] = this.rEQUESTTYPE; + data['RESPONDER'] = this.rESPONDER; + data['ROW_NUM'] = this.rOWNUM; + data['SELECTED_EMPLOYEE_NUMBER'] = this.sELECTEDEMPLOYEENUMBER; + data['STATUS'] = this.sTATUS; + data['SUBJECT'] = this.sUBJECT; + data['TO_ROW_NUM'] = this.tOROWNUM; + data['TO_USER'] = this.tOUSER; + return data; + } +} \ No newline at end of file diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index 1a83041..f15e244 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -6,6 +6,7 @@ import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/main.dart'; import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; +import 'package:mohem_flutter_app/models/dashboard/get_open_notifications_list.dart'; import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/models/dashboard/menus.dart'; @@ -39,9 +40,9 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { List? getMenuEntriesList; //Attendance Tracking API's & Methods - fetchAttendanceTracking() async { + void fetchAttendanceTracking() async { try { - attendanceTracking = await DashbaordApiClient().getAttendanceTracking(); + attendanceTracking = await DashboardApiClient().getAttendanceTracking(); isAttendanceTrackingLoading = false; isTimeRemainingInSeconds = calculateSeconds("00:00:00"); endTime = DateTime.now().millisecondsSinceEpoch + Duration(seconds: isTimeRemainingInSeconds).inMilliseconds; @@ -67,31 +68,36 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { attendanceTracking?.pSwipeIn = "a"; isTimeRemainingInSeconds = calculateSeconds("00:10:30"); endTime = DateTime.now().millisecondsSinceEpoch + Duration(seconds: isTimeRemainingInSeconds).inMilliseconds; - notifyListeners(); } + ItgFormsModel? itgFormsModel; + List? getOpenNotificationsList; //Work List API's & Methods - fetchWorkListCounter() async { + Future fetchWorkListCounter(context, {bool showLoading = false}) async { try { - GenericResponseModel? genericResponseModel = await DashbaordApiClient().getOpenNotifications(); + if (showLoading) Utils.showLoading(context); + GenericResponseModel? genericResponseModel = await DashboardApiClient().getOpenNotifications(); isWorkListLoading = false; + getOpenNotificationsList = genericResponseModel?.getOpenNotificationsList; workListCounter = genericResponseModel?.pOPENNTFNUMBER ?? 0; - ItgFormsModel? itgFormsModel = await DashbaordApiClient().getItgFormsPendingTask(); + itgFormsModel = await DashboardApiClient().getItgFormsPendingTask(); workListCounter = workListCounter + (itgFormsModel?.totalCount ?? 0); + if (showLoading) Utils.hideLoading(context); notifyListeners(); } catch (ex) { isWorkListLoading = false; logger.wtf(ex); + if (showLoading) Utils.hideLoading(context); notifyListeners(); Utils.handleException(ex, null); } } //Missing Siwpe API's & Methods - fetchMissingSwipe() async { + Future fetchMissingSwipe() async { try { - GenericResponseModel? genericResponseModel = await DashbaordApiClient().getOpenMissingSwipes(); + GenericResponseModel? genericResponseModel = await DashboardApiClient().getOpenMissingSwipes(); isMissingSwipeLoading = false; missingSwipeCounter = genericResponseModel!.getOpenMissingSwipesList!.pOpenMissingSwipes ?? 0; notifyListeners(); @@ -104,9 +110,9 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } //Leave and Ticket Balance API's & Methods - fetchLeaveTicketBalance() async { + Future fetchLeaveTicketBalance() async { try { - GenericResponseModel? genericResponseModel = await DashbaordApiClient().getAccrualBalances(); + GenericResponseModel? genericResponseModel = await DashboardApiClient().getAccrualBalances(); isLeaveTicketBalanceLoading = false; leaveBalance = genericResponseModel?.getAccrualBalancesList![0].accrualNetEntitlement ?? 0.0; ticketBalance = (genericResponseModel?.getAccrualBalancesList![1].accrualNetEntitlement ?? 0.0) + (genericResponseModel?.getAccrualBalancesList![2].accrualNetEntitlement ?? 0.0); @@ -122,7 +128,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { //List Menu API's & Methods fetchListMenu() async { try { - GenericResponseModel? genericResponseModel = await DashbaordApiClient().getListMenu(); + GenericResponseModel? genericResponseModel = await DashboardApiClient().getListMenu(); Map map = {}; print(jsonEncode(genericResponseModel!.listMenu)); for (int i = 0; i < genericResponseModel.listMenu!.length; i++) { @@ -141,7 +147,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { //Menu Entries API's & Methods fetchMenuEntries() async { try { - GenericResponseModel? genericResponseModel = await DashbaordApiClient().getGetMenuEntries(); + GenericResponseModel? genericResponseModel = await DashboardApiClient().getGetMenuEntries(); getMenuEntriesList = genericResponseModel!.getMenuEntriesList; homeMenus = parseMenues(getMenuEntriesList ?? []); isServicesMenusLoading = false; diff --git a/lib/ui/app_bar.dart b/lib/ui/app_bar.dart deleted file mode 100644 index c39e249..0000000 --- a/lib/ui/app_bar.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:easy_localization/src/public_ext.dart'; -import 'package:flutter/material.dart'; -import 'package:mohem_flutter_app/classes/colors.dart'; -import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; -import 'package:mohem_flutter_app/extensions/string_extensions.dart'; - -AppBar appBar(BuildContext context, {required String title}) { - return AppBar( - title: title.toText24(color: MyColors.darkTextColor), - centerTitle: false, - automaticallyImplyLeading: false, - backgroundColor: Colors.white, - - actions: [ - IconButton( - onPressed: () { - Navigator.pop(context); - }, - icon: Icon( - Icons.close, - color: MyColors.darkIconColor, - ), - ), - ], - ); -} diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 747ef1c..3949c8e 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -1,30 +1,20 @@ -import 'dart:convert'; - import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_countdown_timer/flutter_countdown_timer.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/config/routes.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/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; -import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; -import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; -import 'package:mohem_flutter_app/models/dashboard/menus.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; -import 'package:mohem_flutter_app/theme/colors.dart'; import 'package:mohem_flutter_app/ui/landing/widget/menus_widget.dart'; import 'package:mohem_flutter_app/ui/landing/widget/services_widget.dart'; import 'package:mohem_flutter_app/widgets/circular_avatar.dart'; import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; import 'package:provider/provider.dart'; -import 'package:shimmer/shimmer.dart'; - -import '../../main.dart'; class DashboardScreen extends StatefulWidget { DashboardScreen({Key? key}) : super(key: key); @@ -36,14 +26,14 @@ class DashboardScreen extends StatefulWidget { } class _DashboardScreenState extends State { - late var data; + late DashboardProviderModel data; @override void initState() { super.initState(); data = Provider.of(context, listen: false); data.fetchAttendanceTracking(); - data.fetchWorkListCounter(); + data.fetchWorkListCounter(context); data.fetchMissingSwipe(); data.fetchLeaveTicketBalance(); data.fetchMenuEntries(); @@ -129,100 +119,101 @@ class _DashboardScreenState extends State { children: [ Expanded( child: AspectRatio( - aspectRatio: 159 / 159, - child: Consumer( - builder: (context, model, child) { - return (model.isAttendanceTrackingLoading - ? GetAttendanceTrackingShimmer() - : Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - gradient: const LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomRight, colors: [ - MyColors.gradiantEndColor, - MyColors.gradiantStartColor, - ]), - ), - child: Stack( - alignment: Alignment.center, - children: [ - if (model.isTimeRemainingInSeconds == 0) SvgPicture.asset("assets/images/thumb.svg"), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true), - if (model.isTimeRemainingInSeconds == 0) "01-02-2022".toText12(color: Colors.white), - if (model.isTimeRemainingInSeconds != 0) - Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - 9.height, - CountdownTimer( - endTime: model.endTime, - onEnd: null, - endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), - textStyle: TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), - ), - LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), - 9.height, - const ClipRRect( - borderRadius: BorderRadius.all( - Radius.circular(20), - ), - child: LinearProgressIndicator( - value: 0.7, - minHeight: 8, - valueColor: const AlwaysStoppedAnimation(Colors.white), - backgroundColor: const Color(0xff196D73), - ), - ), - ], - ), - ], - ).paddingOnly(top: 12, right: 15, left: 12), - ), - Row( + aspectRatio: 159 / 159, + child: Consumer( + builder: (context, model, child) { + return (model.isAttendanceTrackingLoading + ? GetAttendanceTrackingShimmer() + : Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + gradient: const LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ]), + ), + child: Stack( + alignment: Alignment.center, + children: [ + if (model.isTimeRemainingInSeconds == 0) SvgPicture.asset("assets/images/thumb.svg"), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: Column( + LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true), + if (model.isTimeRemainingInSeconds == 0) "01-02-2022".toText12(color: Colors.white), + if (model.isTimeRemainingInSeconds != 0) + Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - LocaleKeys.checkIn.tr().toText12(color: Colors.white), - (model.isTimeRemainingInSeconds == 0 ? "--:--" : "09:00").toText14(color: Colors.white, isBold: true), - 4.height + 9.height, + CountdownTimer( + endTime: model.endTime, + onEnd: null, + endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), + textStyle: TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + ), + LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), + 9.height, + const ClipRRect( + borderRadius: BorderRadius.all( + Radius.circular(20), + ), + child: LinearProgressIndicator( + value: 0.7, + minHeight: 8, + valueColor: const AlwaysStoppedAnimation(Colors.white), + backgroundColor: const Color(0xff196D73), + ), + ), ], - ).paddingOnly(left: 12), - ), - Container( - width: 45, - height: 45, - padding: const EdgeInsets.only(left: 14, right: 14), - decoration: const BoxDecoration( - color: Color(0xff259EA4), - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(15), - ), ), - child: SvgPicture.asset(model.isTimeRemainingInSeconds == 0 ? "assets/images/play.svg" : "assets/images/stop.svg"), - ), ], - ), - ], - ), - ], - ), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.todayAttendance); - })) - .animatedSwither(); - }, - )), + ).paddingOnly(top: 12, right: 15, left: 12), + ), + Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.checkIn.tr().toText12(color: Colors.white), + (model.isTimeRemainingInSeconds == 0 ? "--:--" : "09:00").toText14(color: Colors.white, isBold: true), + 4.height + ], + ).paddingOnly(left: 12), + ), + Container( + width: 45, + height: 45, + padding: const EdgeInsets.only(left: 14, right: 14), + decoration: const BoxDecoration( + color: Color(0xff259EA4), + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(15), + ), + ), + child: SvgPicture.asset(model.isTimeRemainingInSeconds == 0 ? "assets/images/play.svg" : "assets/images/stop.svg"), + ), + ], + ), + ], + ), + ], + ), + ).onPress(() { + Navigator.pushNamed(context, AppRoutes.todayAttendance); + })) + .animatedSwither(); + }, + ), + ), ), 9.width, Expanded( diff --git a/lib/ui/landing/today_attendance_screen.dart b/lib/ui/landing/today_attendance_screen.dart index ac42dd1..b2ab7aa 100644 --- a/lib/ui/landing/today_attendance_screen.dart +++ b/lib/ui/landing/today_attendance_screen.dart @@ -83,7 +83,7 @@ class _TodayAttendanceScreenState extends State { padding: EdgeInsets.only(left: 31, right: 31, top: 31, bottom: 16), decoration: BoxDecoration( borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), - gradient: const LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomRight, colors: [ + gradient: const LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ MyColors.gradiantEndColor, MyColors.gradiantStartColor, ]), @@ -156,7 +156,7 @@ class _TodayAttendanceScreenState extends State { padding: const EdgeInsets.only(left: 10, right: 10, top: 14, bottom: 14), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - gradient: const LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomRight, colors: [ + gradient: const LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ MyColors.gradiantEndColor, MyColors.gradiantStartColor, ]), diff --git a/lib/ui/landing/widget/menus_widget.dart b/lib/ui/landing/widget/menus_widget.dart index 4d13775..5d73f0a 100644 --- a/lib/ui/landing/widget/menus_widget.dart +++ b/lib/ui/landing/widget/menus_widget.dart @@ -14,7 +14,7 @@ class MenusWidget extends StatelessWidget { Widget build(BuildContext context) { List namesColor = [0xff125765, 0xff239D8F, 0xff2BB8A8, 0xff1D92AA]; - return Consumer(builder: (context, data, child) { + return Consumer(builder: (cxt, data, child) { return GridView( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 2 / 2, crossAxisSpacing: 9, mainAxisSpacing: 9), padding: EdgeInsets.zero, @@ -24,7 +24,7 @@ class MenusWidget extends StatelessWidget { children: [ data.isWorkListLoading ? MenuShimmer().onPress(() { - data.fetchWorkListCounter(); + data.fetchWorkListCounter(context, showLoading: true); }) : Container( decoration: BoxDecoration( @@ -46,13 +46,13 @@ class MenusWidget extends StatelessWidget { ) ], ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), - ).onPress(() { - // Navigator.pushNamed(context, AppRoutes.workList); - data.fetchWorkListCounter(); + ).onPress(() async { + //await data.fetchWorkListCounter(context, showLoading: true); + Navigator.pushNamed(context, AppRoutes.workList); }), data.isMissingSwipeLoading ? MenuShimmer().onPress(() { - data.fetchWorkListCounter(); + data.fetchWorkListCounter(context); }) : Container( decoration: BoxDecoration( @@ -79,7 +79,7 @@ class MenusWidget extends StatelessWidget { }), data.isLeaveTicketBalanceLoading ? MenuShimmer().onPress(() { - data.fetchWorkListCounter(); + data.fetchWorkListCounter(context); }) : Container( decoration: BoxDecoration( @@ -106,7 +106,7 @@ class MenusWidget extends StatelessWidget { }), data.isLeaveTicketBalanceLoading ? MenuShimmer().onPress(() { - data.fetchWorkListCounter(); + data.fetchWorkListCounter(context); }) : Container( decoration: BoxDecoration( diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index 1ad1d62..06ecb22 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -69,12 +69,12 @@ class _LoginScreenState extends State { } String? firebaseToken; - + GetMobileLoginInfoListModel? loginInfo; Future checkFirebaseToken() async { try { Utils.showLoading(context); firebaseToken = await _firebaseMessaging.getToken(); - GetMobileLoginInfoListModel? loginInfo = await LoginApiClient().getMobileLoginInfoNEW(firebaseToken ?? "", Platform.isAndroid ? "android" : "ios"); + loginInfo = await LoginApiClient().getMobileLoginInfoNEW(firebaseToken ?? "", Platform.isAndroid ? "android" : "ios"); if (loginInfo == null) { Utils.hideLoading(context); print("Device token not found"); @@ -112,7 +112,7 @@ class _LoginScreenState extends State { } Utils.hideLoading(context); if (_autoLogin) { - Navigator.pushNamed(context, AppRoutes.verifyLastLogin); + Navigator.pushNamed(context, AppRoutes.verifyLastLogin, arguments: loginInfo); } else { Navigator.pushNamed(context, AppRoutes.verifyLogin, arguments: "$firebaseToken"); } diff --git a/lib/ui/login/verify_last_login_screen.dart b/lib/ui/login/verify_last_login_screen.dart index 282c7a5..52ec751 100644 --- a/lib/ui/login/verify_last_login_screen.dart +++ b/lib/ui/login/verify_last_login_screen.dart @@ -7,6 +7,7 @@ import 'package:local_auth/local_auth.dart'; import 'package:mohem_flutter_app/api/login_api_client.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/date_uitl.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/dialogs/otp_dialog.dart'; @@ -16,6 +17,7 @@ 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/basic_member_information_model.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; +import 'package:mohem_flutter_app/models/get_mobile_login_info_list_model.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; class VerifyLastLoginScreen extends StatefulWidget { @@ -30,6 +32,7 @@ class VerifyLastLoginScreen extends StatefulWidget { class _VerifyLastLoginScreenState extends State { final LocalAuthentication auth = LocalAuthentication(); List _availableBioMetricType = []; + GetMobileLoginInfoListModel? mobileLoginInfoListModel; @override void initState() { @@ -40,6 +43,7 @@ class _VerifyLastLoginScreenState extends State { @override Widget build(BuildContext context) { + mobileLoginInfoListModel ??= ModalRoute.of(context)!.settings.arguments as GetMobileLoginInfoListModel; String empName = AppState().isArabic(context) ? AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEAr! : AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEEn!; return Scaffold( appBar: AppBar( @@ -64,7 +68,7 @@ class _VerifyLastLoginScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ LocaleKeys.welcomeBack.tr().toText12(), - empName.toText24(isBold: true), + mobileLoginInfoListModel!.employeeName!.toText24(isBold: true), 10.height, LocaleKeys.wouldYouLikeToLoginWithCurrentUsername.tr().toText16(), Container( @@ -88,14 +92,7 @@ class _VerifyLastLoginScreenState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ LocaleKeys.lastLoginDetails.tr().toText16(), - // Text( - // user.editedOn != null - // ? DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(user.editedOn)) - // : user.createdOn != null - // ? DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(user.createdOn)) - // : '--', - // style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48), - // ), + DateUtil.formatDateToDate(DateUtil.convertStringToDate(mobileLoginInfoListModel!.editedOn!), false).toText12(), ], ), Row( @@ -103,24 +100,9 @@ class _VerifyLastLoginScreenState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ LocaleKeys.verificationType.tr().toText10(color: MyColors.grey57Color), - Text( - "SMS", - // " " + getType(user.logInType, context), - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - ), - ), + getVerificationType(mobileLoginInfoListModel!.loginType!).toText12(), Expanded(child: SizedBox()), - // Text( - // user.editedOn != null - // ? DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(user.editedOn), false) - // : user.createdOn != null - // ? DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(user.createdOn), false) - // : '--', - // style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.48), - // ), + DateUtil.formatDateToTime(DateUtil.convertStringToDate(mobileLoginInfoListModel!.editedOn!)).toText12(), ], ) ], @@ -201,419 +183,18 @@ class _VerifyLastLoginScreenState extends State { if (mounted) setState(() {}); } - // authenticateUser(int type, {int isActive}) { - // GifLoaderDialogUtils.showMyDialog(context); - // if (type == 2 || type == 3) { - // fingrePrintBefore = type; - // } - // this.selectedOption = fingrePrintBefore != null ? fingrePrintBefore : type; - // - // switch (type) { - // case 1: - // this.loginWithSMS(type); - // break; - // case 2: - // this.loginWithFingurePrintFace(type, isActive); - // break; - // case 3: - // this.loginWithFingurePrintFace(type, isActive); - // break; - // case 4: - // this.loginWithSMS(type); - // break; - // default: - // break; - // } - // sharedPref.setInt(LAST_LOGIN, this.selectedOption); //this.cs.sharedService.setStorage(this.selectedOption, AuthenticationService.LAST_LOGIN); - // } -// -// loginWithSMS(type) { -// //if (!el.disabled) { -// if (this.user != null && this.registerd_data == null) { -// this.checkUserAuthentication(type); -// } else { -// if (this.loginTokenID != null) { -// // Future.delayed(Duration(seconds: 1), () { -// this.sendActivationCode(type); -// // }); -// } else { -// this.checkUserAuthentication(type); -// } -// } -// } -// -// checkUserAuthentication(type) { -// showLoader(true); -// var req = getCommonRequest(type: type); -// req.logInTokenID = ""; -// -// var request = CheckPatientAuthenticationReq.fromJson(req.toJson()); -// -// sharedPref.setObject(REGISTER_DATA_FOR_REGISTER, request); -// authService -// .checkPatientAuthentication(request) -// .then((value) => { -// GifLoaderDialogUtils.hideDialog(context), -// if (value['isSMSSent']) -// { -// sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']), -// this.loginTokenID = value['LogInTokenID'], -// sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request), -// // Future.delayed(Duration(seconds: 1), () { -// this.sendActivationCode(type) -// // }) -// } -// else -// { -// if (value['IsAuthenticated']) {this.checkActivationCode()} -// } -// }) -// .catchError((err) { -// print(err); -// GifLoaderDialogUtils.hideDialog(context); -// }); -// } -// -// sendActivationCode(type) async { -// var request = this.getCommonRequest(type: type); -// request.sMSSignature = await SMSOTP.getSignature(); -// GifLoaderDialogUtils.showMyDialog(context); -// if (healthId != null) { -// // final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); -// // final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); -// request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); -// request.healthId = healthId; -// request.isHijri = isHijri; -// await this.authService.sendActivationCodeRegister(request).then((result) { -// GifLoaderDialogUtils.hideDialog(context); -// if (result != null && result['isSMSSent'] == true) { -// this.startSMSService(type); -// } -// }).catchError((r) { -// GifLoaderDialogUtils.hideDialog(context); -// }); -// } else { -// request.dob = ""; -// request.healthId = ""; -// request.isHijri = 0; -// await this.authService.sendActivationCode(request).then((result) { -// GifLoaderDialogUtils.hideDialog(context); -// if (result != null && result['isSMSSent'] == true) { -// this.startSMSService(type); -// } -// }).catchError((r) { -// GifLoaderDialogUtils.hideDialog(context); -// }); -// } -// } -// -// var tempType; -// -// startSMSService(type) { -// tempType = type; -// new SMSOTP( -// context, -// type, -// this.mobileNumber, -// (value) { -// this.checkActivationCode(value: value); -// }, -// () => { -// Navigator.pop(context), -// }, -// ).displayDialog(context); -// } -// -// loginWithFingurePrintFace(type, int isActive) async { -// if (isActive == 1 || isActive == 0) { -// const iosStrings = -// const IOSAuthMessages(cancelButton: 'cancel', goToSettingsButton: 'settings', goToSettingsDescription: 'Please set up your Touch ID.', lockOut: 'Please reenable your Touch ID'); -// -// try { -// authenticated = await auth.authenticateWithBiometrics(localizedReason: 'Scan your fingerprint to authenticate', useErrorDialogs: true, stickyAuth: true, iOSAuthStrings: iosStrings); -// } on PlatformException catch (e) { -// GifLoaderDialogUtils.hideDialog(context); -// AppToast.showErrorToast(message: 'Please enable your Touch or Face ID'); -// } -// -// if (authenticated == true) { -// // if (user != null && (user.logInType == 2 || user.logInType == 3)) { -// // this.checkActivationCode(); -// // } else { -// -// var request = this.getCommonRequest(type: type); -// this.getMobileInfo(request); -// //} -// } -// } -// } -// -// getMobileInfo(request) { -// // GifLoaderDialogUtils.showMyDialog(context); -// this.authService.getLoginInfo(request).then((result) { -// GifLoaderDialogUtils.hideDialog(context); -// if (result['SMSLoginRequired'] == false) { -// this.loginTokenID = result['LogInTokenID']; -// this.patientOutSA = result['PatientOutSA']; -// // sms for register the biometric -// if (result['isSMSSent']) { -// setState(() { -// isMoreOption = true; -// this.onlySMSBox = true; -// // this.fingrePrintBefore = true; -// }); -// //this.button(); -// } else { -// setDefault(); -// checkActivationCode(); -// } -// } else { -// if (result['IsAuthenticated'] == true) { -// setState(() { -// isMoreOption = true; -// this.onlySMSBox = true; -// // this.fingrePrintBefore = true; -// }); -// } -// } -// }).catchError((err) { -// GifLoaderDialogUtils.hideDialog(context); -// print(err); -// }); -// } -// -// setDefault() async { -// if (await sharedPref.getObject(IMEI_USER_DATA) != null) user = SelectDeviceIMEIRES.fromJson(await sharedPref.getObject(IMEI_USER_DATA)); -// -// if (await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN) != null) { -// isMoreOption = true; -// this.registerd_data = CheckPatientAuthenticationReq.fromJson(await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN)); -// } -// -// this.mobileNumber = this.registerd_data != null ? this.registerd_data.patientMobileNumber : int.parse(this.user.mobile); -// this.zipCode = this.registerd_data != null -// ? this.registerd_data.zipCode -// : this.user.outSA == true -// ? "971" -// : "966"; -// this.patientOutSA = this.registerd_data != null -// ? this.registerd_data.zipCode == "966" -// ? 0 -// : 1 -// : this.user.outSA; -// if (this.registerd_data != null) { -// this.loginTokenID = await sharedPref.getString(LOGIN_TOKEN_ID); -// this.loginType = this.registerd_data.searchType; -// } -// var nhic = await sharedPref.getObject(NHIC_DATA); -// if (nhic != null) { -// final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); -// final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); -// dob = nhic['IsHijri'] ? nhic['DateOfBirth'] : dateFormat2.format(dateFormat.parse(nhic['DateOfBirth'])); -// -// isHijri = nhic['IsHijri'] ? 1 : 0; -// healthId = nhic['HealthId']; -// } -// this.deviceToken = await sharedPref.getString(PUSH_TOKEN); -// this.lastLogin = await sharedPref.getInt(LAST_LOGIN) != null -// ? await sharedPref.getInt(LAST_LOGIN) -// : user != null -// ? user.logInType -// : null; -// -// //this.cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN); -// } -// -// getCommonRequest({type}) { -// var request = SendActivationRequest(); -// request.patientMobileNumber = this.mobileNumber; -// request.mobileNo = '0' + this.mobileNumber.toString(); -// request.deviceToken = this.deviceToken; -// request.projectOutSA = this.patientOutSA == true ? true : false; -// request.loginType = this.selectedOption; -// request.oTPSendType = type == 1 ? type : 2; //this.selectedOption == 1 ? 1 : 2; -// request.zipCode = this.zipCode; -// -// request.logInTokenID = this.loginTokenID ?? ""; -// -// if (this.registerd_data != null) { -// request.searchType = this.registerd_data.searchType != null ? this.registerd_data.searchType : 1; -// request.patientID = this.registerd_data.patientID != null ? this.registerd_data.patientID : 0; -// request.patientIdentificationID = request.nationalID = this.registerd_data.patientIdentificationID != null ? this.registerd_data.patientIdentificationID : '0'; -// -// request.isRegister = this.registerd_data.isRegister; -// } else { -// request.searchType = request.searchType != null ? request.searchType : 2; -// request.patientID = this.user.patientID != null ? this.user.patientID : 0; -// request.nationalID = request.nationalID != null ? request.nationalID : '0'; -// request.patientIdentificationID = request.patientIdentificationID != null ? request.patientIdentificationID : '0'; -// request.isRegister = false; -// } -// request.deviceTypeID = request.searchType; -// return request; -// } -// -// // checkActivationCode({value}) async { -// // // Navigator.pop(context); -// // GifLoaderDialogUtils.showMyDialog(context); -// // var request = this.getCommonRequest().toJson(); -// // dynamic res; -// // if (healthId != null) { -// // request['DOB'] = dob; -// // request['HealthId'] = healthId; -// // request['IsHijri'] = isHijri; -// // -// // authService -// // .checkActivationCodeRegister(request, value) -// // .then((result) => { -// // res = result, -// // if (result is Map) -// // { -// // result = CheckActivationCode.fromJson(result), -// // if (this.registerd_data != null && this.registerd_data.isRegister == true) -// // { -// // widget.changePageViewIndex(1), -// // Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), -// // } -// // } -// // else -// // { -// // // Navigator.of(context).pop(), -// // GifLoaderDialogUtils.hideDialog(context), -// // Future.delayed(Duration(seconds: 1), () { -// // AppToast.showErrorToast(message: result); -// // }), -// // } -// // }) -// // .catchError((err) { -// // print(err); -// // GifLoaderDialogUtils.hideDialog(context); -// // Future.delayed(Duration(seconds: 1), () { -// // AppToast.showErrorToast(message: err); -// // startSMSService(tempType); -// // }); -// // }); -// // } else { -// // authService -// // .checkActivationCode(request, value) -// // .then((result) => { -// // res = result, -// // if (result is Map) -// // { -// // result = CheckActivationCode.fromJson(result), -// // if (this.registerd_data != null && this.registerd_data.isRegister == true) -// // { -// // widget.changePageViewIndex(1), -// // Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), -// // } -// // else -// // { -// // sharedPref.remove(FAMILY_FILE), -// // result.list.isFamily = false, -// // userData = result.list, -// // sharedPref.setString(BLOOD_TYPE, result.patientBloodType), -// // authenticatedUserObject.user = result.list, -// // projectViewModel.setPrivilege(privilegeList: res), -// // sharedPref.setObject(MAIN_USER, result.list), -// // sharedPref.setObject(USER_PROFILE, result.list), -// // loginTokenID = result.logInTokenID, -// // sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), -// // sharedPref.setString(TOKEN, result.authenticationTokenID), -// // checkIfUserAgreedBefore(result), -// // } -// // } -// // else -// // { -// // // // Navigator.of(context).pop(), -// // // GifLoaderDialogUtils.hideDialog(context), -// // // Future.delayed(Duration(seconds: 1), () { -// // // AppToast.showErrorToast(message: result); -// // // startSMSService(tempType); -// // // }), -// // } -// // }) -// // .catchError((err) { -// // // print(err); -// // // GifLoaderDialogUtils.hideDialog(context); -// // // Future.delayed(Duration(seconds: 1), () { -// // // AppToast.showErrorToast(message: err); -// // // startSMSService(tempType); -// // // }); -// // }); -// // } -// // } -// -// // checkIfUserAgreedBefore(CheckActivationCode result) { -// // if (result.isNeedUserAgreement == true) { -// // //move to agreement page. -// // } else { -// // goToHome(); -// // } -// // } -// -// insertIMEI() { -// authService.insertDeviceImei(selectedOption).then((value) => {}).catchError((err) { -// print(err); -// }); -// } -// -// // getToDoCount() { -// // toDoProvider.setState(0, true, "0"); -// // ClinicListService service = new ClinicListService(); -// // service.getActiveAppointmentNo(context).then((res) { -// // if (res['MessageStatus'] == 1) { -// // toDoProvider.setState(res['AppointmentActiveNumber'], true, "0"); -// // } else {} -// // }).catchError((err) { -// // print(err); -// // }); -// // } -// -// // goToHome() async { -// // authenticatedUserObject.isLogin = true; -// // appointmentRateViewModel.isLogin = true; -// // projectViewModel.isLogin = true; -// // projectViewModel.user = authenticatedUserObject.user; -// // await authenticatedUserObject.getUser(getUser: true); -// // -// // // getToDoCount(); -// // -// // appointmentRateViewModel -// // .getIsLastAppointmentRatedList() -// // .then((value) => { -// // getToDoCount(), -// // GifLoaderDialogUtils.hideDialog(AppGlobal.context), -// // if (appointmentRateViewModel.isHaveAppointmentNotRate) -// // { -// // Navigator.pushAndRemoveUntil( -// // context, -// // FadePage( -// // page: RateAppointmentDoctor(), -// // ), -// // (r) => false) -// // } -// // else -// // { -// // Navigator.pushAndRemoveUntil( -// // context, -// // FadePage( -// // page: LandingPage(), -// // ), -// // (r) => false) -// // }, -// // insertIMEI() -// // }) -// // .catchError((err) { -// // print(err); -// // }); -// // } -// -// loading(flag) { -// // setState(() { -// // isLoading = flag; -// // }); -// } -// + String getVerificationType(int type) { + if (type == 1) { + LocaleKeys.sms.tr(); + } else if (type == 2) { + return LocaleKeys.fingerPrint.tr(); + } else if (type == 3) { + return LocaleKeys.face.tr(); + } else if (type == 4) { + return LocaleKeys.whatsapp.tr(); + } + return ""; + } Future loginWithFaceIDAndBiometrics() async { IOSAuthMessages iosStrings = @@ -654,8 +235,8 @@ class _VerifyLastLoginScreenState extends State { } await LoginApiClient().checkMobileAppVersion(); await LoginApiClient().memberLogin(AppState().getUserName!, AppState().password!); - BasicMemberInformationModel? memberInformationModel = await LoginApiClient() - .mohemmSendActivationCodeByOTPNotificationType(checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().getUserName); + BasicMemberInformationModel? memberInformationModel = await LoginApiClient().mohemmSendActivationCodeByOTPNotificationType( + checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().getUserName); Utils.hideLoading(context); OtpDialog( context, diff --git a/lib/ui/work_list/missing_swipe/missing_swipe_screen.dart b/lib/ui/work_list/missing_swipe/missing_swipe_screen.dart index 4af620e..0a27afc 100644 --- a/lib/ui/work_list/missing_swipe/missing_swipe_screen.dart +++ b/lib/ui/work_list/missing_swipe/missing_swipe_screen.dart @@ -1,56 +1,85 @@ +import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; -import 'package:mohem_flutter_app/ui/app_bar.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/widget_extensions.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/ui/work_list/missing_swipe/fragments/actions_fragment.dart'; import 'package:mohem_flutter_app/ui/work_list/missing_swipe/fragments/attachments_fragment.dart'; import 'package:mohem_flutter_app/ui/work_list/missing_swipe/fragments/info_fragments.dart'; import 'package:mohem_flutter_app/ui/work_list/missing_swipe/fragments/request_fragment.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; -import 'package:mohem_flutter_app/extensions/int_extensions.dart'; -class MissingSwipeScreen extends StatelessWidget { +class MissingSwipeScreen extends StatefulWidget { + MissingSwipeScreen({Key? key}) : super(key: key); + + @override + _MissingSwipeScreenState createState() { + return _MissingSwipeScreenState(); + } +} + +class _MissingSwipeScreenState extends State { + int tabIndex = 0; + PageController controller = PageController(); + bool showFabOptions = false; + + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + @override Widget build(BuildContext context) { - return DefaultTabController( - length: 4, - child: Scaffold( - appBar: appBar(context, title: "Missing Swipe Request"), - body: Container( - width: double.infinity, - height: double.infinity, - child: Column( + return Scaffold( + appBar: AppBarWidget(context, title: LocaleKeys.details.tr()), + backgroundColor: Colors.white, + body: Stack( + children: [ + Column( children: [ Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only(bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20)), - gradient: LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomRight, colors: [ - MyColors.gradiantEndColor, - MyColors.gradiantStartColor, - ]), + padding: const EdgeInsets.only(left: 21, right: 21, top: 16, bottom: 16), + decoration: const BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(25), + bottomRight: Radius.circular(25), + ), + gradient: LinearGradient( + transform: GradientRotation(.83), + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ], + ), ), - clipBehavior: Clip.antiAlias, - child: TabBar( - indicatorColor: Colors.white, - labelColor: Colors.white, - tabs: [ - Tab( - text: "Request", - ), - Tab( - text: "Actions", - ), - Tab( - text: "Attachments", - ), - Tab( - text: "Info.", - ), + child: Row( + children: [ + myTab("Request", 0), + myTab("Actions", 1), + myTab("Attachments", 2), + myTab("Info.", 3), ], ), ), Expanded( - child: TabBarView( + child: PageView( + controller: controller, + onPageChanged: (pageIndex) { + setState(() { + tabIndex = pageIndex; + }); + }, children: [ RequestFragment(), ActionsFragment(), @@ -60,39 +89,140 @@ class MissingSwipeScreen extends StatelessWidget { ), ), Container( - width: double.infinity, - height: 60, - padding: EdgeInsets.only(left: 21, right: 21), + padding: const EdgeInsets.only(top: 14, bottom: 14, left: 21, right: 21), + decoration: const BoxDecoration( + color: Colors.white, + border: Border( + top: BorderSide( + color: MyColors.lightGreyEFColor, + width: 1.0, + ), + ), + ), child: Row( children: [ - Expanded( - child: DefaultButton( - "Reject", - () {}, - colors: [ - Color(0xffEB8C90), - Color(0xffDE6C70), - ], - ), - ), - 12.width, - Expanded( - child: DefaultButton( - "Approve", - () {}, - colors: [ - Color(0xff32D892), - Color(0xff1AB170), - ], + DefaultButton( + LocaleKeys.reject.tr(), + () {}, + colors: const [ + Color(0xffEB8C90), + Color(0xffDE6C70), + ], + ).expanded, + 8.width, + DefaultButton( + LocaleKeys.approve.tr(), + () {}, + colors: const [ + Color(0xff32D892), + Color(0xff1AB170), + ], + ).expanded, + 8.width, + Container( + height: 43, + width: 43, + decoration: const BoxDecoration( + shape: BoxShape.circle, + color: MyColors.lightGreyE6Color, ), - ), + child: Icon(showFabOptions ? Icons.more_vert_rounded : Icons.more_horiz_rounded, color: MyColors.darkIconColor), + ).onPress(() { + setState(() { + showFabOptions = true; + }); + }) ], ), ) ], ), - ), + IgnorePointer( + ignoring: !showFabOptions, + child: AnimatedOpacity( + opacity: showFabOptions ? 1 : 0, + duration: const Duration(milliseconds: 250), + child: Container( + padding: const EdgeInsets.only(left: 21, right: 21, bottom: 75), + width: double.infinity, + height: double.infinity, + color: Colors.white.withOpacity(.67), + alignment: Alignment.bottomRight, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + myFab("Skip", "assets/images/skip.svg"), + 12.height, + myFab("Request Info", "assets/images/request_info.svg"), + 12.height, + myFab("Delegate", "assets/images/delegate.svg"), + ], + ), + ), + ).onPress(() { + setState(() { + showFabOptions = false; + }); + }), + ), + ], ), ); } + + Widget myTab(String title, int index) { + bool isSelected = (index == tabIndex); + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + title.toText12(color: isSelected ? Colors.white : Colors.white.withOpacity(.74), isCenter: true), + 4.height, + Container( + height: 8, + width: 8, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: isSelected ? Colors.white : Colors.transparent, + ), + ).onPress(() { + setState(() { + showFabOptions = true; + }); + }) + ], + ).onPress(() { + controller.jumpToPage(index); + }).expanded; + } + + Widget myFab(String title, String icon) { + return Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + title.toText16(), + 14.width, + Container( + height: 43, + width: 43, + padding: const EdgeInsets.all(12), + decoration: const BoxDecoration( + shape: BoxShape.circle, + gradient: LinearGradient( + transform: GradientRotation(.46), + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ], + ), + ), + child: SvgPicture.asset(icon), + ) + ], + ); + } } diff --git a/lib/ui/work_list/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index 06a545c..1e46783 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -1,29 +1,116 @@ import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:mohem_flutter_app/api/worklist/worklist_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/date_uitl.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.dart'; -import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; -import 'package:mohem_flutter_app/ui/app_bar.dart'; -import 'package:mohem_flutter_app/extensions/string_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/widget_extensions.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; +import 'package:mohem_flutter_app/models/worklist_item_type_model.dart'; +import 'package:mohem_flutter_app/models/worklist_response_model.dart'; +import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; +import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; +import 'package:provider/provider.dart'; class WorkListScreen extends StatefulWidget { + WorkListScreen({Key? key}) : super(key: key); + @override - State createState() => _WorkListScreenState(); + _WorkListScreenState createState() { + return _WorkListScreenState(); + } } class _WorkListScreenState extends State { + List workListItemTypes = [ + WorkListItemTypeModelData( + value: 0, name: 'HR', fullName: 'Human Resource', active: false, color: [Color(0xff32D892), Color(0xff1AB170)], icon: "assets/images/miss_swipe.svg", key: 'HRSSA', disable: false), + WorkListItemTypeModelData( + value: 0, name: 'MO', fullName: 'Move Order', active: false, color: [Color(0xff58DCFA), Color(0xff3CB9D5)], icon: "assets/images/miss_swipe.svg", key: 'INVMOA', disable: false), + WorkListItemTypeModelData( + value: 0, name: 'PR', fullName: 'Purchase Requisition', active: false, color: [Color(0xff48EACF), Color(0xff3DCAB3)], icon: "assets/images/miss_swipe.svg", key: 'REQAPPRV', disable: false), + WorkListItemTypeModelData( + value: 0, name: 'PO', fullName: 'Purchase Order', active: false, color: [Color(0xff5099E3), Color(0xff3670AA)], icon: "assets/images/miss_swipe.svg", key: 'POAPPRV', disable: false), + WorkListItemTypeModelData( + value: 0, name: 'ITG', fullName: 'ITG Forms', active: false, color: [Color(0xffEB8C90), Color(0xffDE6C70)], icon: "assets/images/miss_swipe.svg", key: 'ITG', disable: false), + WorkListItemTypeModelData( + value: 0, name: 'IC', fullName: 'Item Creation', active: false, color: [Color(0xff32D892), Color(0xff1AB170)], icon: "assets/images/miss_swipe.svg", key: 'INVITEM', disable: false), + WorkListItemTypeModelData( + value: 0, name: 'STAMP', fullName: 'Stamp', active: false, color: [Color(0xff32D892), Color(0xff1AB170)], icon: "assets/images/miss_swipe.svg", key: 'STAMP', disable: false), + ]; + + int workListItemIndex = 0; + + List? workList; + int pageNumber = 1; + + late DashboardProviderModel providerData; + + @override + void initState() { + super.initState(); + + providerData = Provider.of(context, listen: false); + workListItemTypes.forEach((workListElement) { + if (workListElement.key == "ITG") { + workListElement.value = providerData.itgFormsModel?.totalCount ?? 0; + } else { + var tempList = providerData.getOpenNotificationsList?.where((notificationElement) => notificationElement.itemType == workListElement.key).toList(); + if (tempList!.isNotEmpty) { + workListElement.value = tempList.first.openNtfNumber ?? 0; + } + } + }); + getWorkList(); + } + + ItgFormsModel? itgFormsModel; + int? itgRequestTypeIndex; + + void getWorkList() async { + try { + Utils.showLoading(context); + if (workListItemTypes[workListItemIndex].key == "ITG") { + itgFormsModel = await WorkListApiClient().GetITGTaskCountRequestType(); + List requestAllList = []; + for (int i = 0; i < (itgFormsModel?.requestType!.length ?? 0); i++) { + requestAllList = requestAllList + (itgFormsModel?.requestType![i].requestDetails ?? []); + } + itgFormsModel?.requestType!.insert(0, RequestType(requestDetails: requestAllList, requestTypeCode: "all", requestTypeName: "All")); + if ((itgFormsModel?.requestType?.length ?? 0) > 0) { + itgRequestTypeIndex = 0; + } + } else { + itgRequestTypeIndex = null; + workList = await WorkListApiClient().getWorkList(pageNumber, workListItemTypes[workListItemIndex].key); + } + Utils.hideLoading(context); + setState(() {}); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, null); + } + } + + @override + void dispose() { + super.dispose(); + } + @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, - appBar: appBar( + appBar: AppBarWidget( context, title: LocaleKeys.workList.tr(), ), - body: Container( + body: SizedBox( width: double.infinity, height: double.infinity, child: Column( @@ -31,67 +118,151 @@ class _WorkListScreenState extends State { children: [ Container( width: double.infinity, - height: 2, - color: MyColors.darkWhiteColor, + height: 1, + color: MyColors.lightGreyEFColor, ), - Container( - width: double.infinity, + SizedBox( height: 40, - margin: EdgeInsets.only( - top: 21, - ), child: ListView.separated( itemBuilder: (context, index) { return Container( - padding: EdgeInsets.only( - left: 30, - right: 30, - ), + padding: const EdgeInsets.only(left: 21, right: 21, top: 8, bottom: 8), alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(6), - color: tabList[index].isSelected - ? MyColors.darkIconColor - : MyColors.lightGreyEAColor, - ), - child: tabList[index].title.toText12( - color: tabList[index].isSelected - ? MyColors.white - : MyColors.black, - ), - ); - }, - separatorBuilder: (context, index) { - return 8.width; + decoration: BoxDecoration(borderRadius: BorderRadius.circular(6), color: workListItemIndex == index ? MyColors.darkIconColor : MyColors.lightGreyEAColor), + child: ("${workListItemTypes[index].name} ${workListItemTypes[index].value > 0 ? "(${workListItemTypes[index].value})" : ""}") + .toText12(color: workListItemIndex == index ? MyColors.white : MyColors.black), + ).onPress(() { + if (workListItemIndex != index) { + workListItemIndex = index; + if (workListItemTypes[index].value == 0) { + workList = []; + } else { + workList = null; + } + setState(() {}); + if (workListItemTypes[index].value > 0) { + getWorkList(); + } + } + }); }, + separatorBuilder: (context, index) => 8.width, shrinkWrap: true, - itemCount: tabList.length, + itemCount: workListItemTypes.length, scrollDirection: Axis.horizontal, - padding: const EdgeInsets.only( - left: 21, - right: 21, + padding: const EdgeInsets.only(left: 21, right: 21), + ), + ).paddingOnly(top: 21, bottom: 21), + workListItemTypes[workListItemIndex].fullName.toSectionHeading().paddingOnly(left: 21, right: 21), + if (itgRequestTypeIndex != null) + SizedBox( + height: 40, + child: ListView.separated( + itemBuilder: (context, index) { + RequestType type = itgFormsModel!.requestType![index]; + return Container( + padding: const EdgeInsets.only(left: 21, right: 21, top: 8, bottom: 8), + alignment: Alignment.center, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(30), color: itgRequestTypeIndex == index ? MyColors.darkIconColor : MyColors.lightGreyEAColor), + child: ("${type.requestTypeName}").toText12(color: itgRequestTypeIndex == index ? MyColors.white : MyColors.black), + ).onPress(() { + if (itgRequestTypeIndex != index) { + itgRequestTypeIndex = index; + setState(() {}); + } + }); + }, + separatorBuilder: (context, index) => 8.width, + shrinkWrap: true, + itemCount: itgFormsModel?.requestType?.length ?? 0, + scrollDirection: Axis.horizontal, + padding: const EdgeInsets.only(left: 21, right: 21), ), + ).paddingOnly(top: 16, bottom: 16), + itgRequestTypeIndex != null + ? Expanded( + child: ListView.separated( + physics: BouncingScrollPhysics(), + itemBuilder: (context, index) { + return itgRowItem(workListItemTypes[workListItemIndex], itgFormsModel!.requestType![itgRequestTypeIndex!].requestDetails![index]); + }, + separatorBuilder: (context, index) => 12.height, + itemCount: itgFormsModel!.requestType![itgRequestTypeIndex!].requestDetails?.length ?? 0, + padding: EdgeInsets.only(top: 16, left: 21, right: 21), + ), + ) + : Expanded( + child: workList != null + ? ((workList!).isEmpty + ? "No History Available".toText16().center + : ListView.separated( + physics: BouncingScrollPhysics(), + itemBuilder: (context, index) { + return rowItem(workListItemTypes[workListItemIndex], workList![index]); + }, + separatorBuilder: (context, index) => 12.height, + itemCount: workList?.length ?? 0, + padding: EdgeInsets.only(top: 21, left: 21, right: 21), + )) + : const SizedBox(), + ), + ], + ), + ), + ); + } + + Widget itgRowItem(WorkListItemTypeModelData data, RequestDetails requestDetails) { + return InkWell( + onTap: () { + Navigator.pushNamed(context, AppRoutes.missingSwipe); + }, + child: Container( + width: double.infinity, + padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + gradient: LinearGradient(transform: GradientRotation(.218), begin: Alignment.topRight, end: Alignment.bottomRight, colors: data.color), ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [SvgPicture.asset("assets/images/miss_swipe.svg", width: 20, height: 20, color: Colors.white), 2.height, data.name.toText10(color: Colors.white)], + ).paddingAll(6), ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - LocaleKeys.human.toText12(), - LocaleKeys.resources.tr().toText24(isBold: true), - ], - ).paddingOnly(top: 24, left: 21, right: 21), - 24.height, + 8.width, Expanded( - child: ListView.separated( - itemBuilder: (context, index) { - return rowItem(typesList[index]); - }, - separatorBuilder: (context, index) { - return 12.height; - }, - itemCount: typesList.length, - padding: EdgeInsets.only(left: 21, right: 21), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + requestDetails.title!.toText12(color: MyColors.grey57Color), + 10.height, + Row( + children: [ + DateUtil.formatDateToDate(DateUtil.convertStringToDate(requestDetails.modifiedDate!), false).toText10(color: MyColors.lightTextColor).expanded, + SvgPicture.asset( + "assets/images/arrow_next.svg", + color: MyColors.darkIconColor, + ) + ], + ), + ], ), ), ], @@ -100,14 +271,14 @@ class _WorkListScreenState extends State { ); } - Widget rowItem(Types types) { + Widget rowItem(WorkListItemTypeModelData data, WorkListResponseModel workData) { return InkWell( - onTap: (){ + onTap: () { Navigator.pushNamed(context, AppRoutes.missingSwipe); }, child: Container( width: double.infinity, - padding: EdgeInsets.all(12), + padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10), @@ -126,39 +297,24 @@ class _WorkListScreenState extends State { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), - gradient: LinearGradient( - transform: GradientRotation(.46), - begin: Alignment.topRight, - end: Alignment.bottomRight, - colors: types.colors), + gradient: LinearGradient(transform: GradientRotation(.218), begin: Alignment.topRight, end: Alignment.bottomRight, colors: data.color), ), child: Column( crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SvgPicture.asset( - "assets/images/miss_swipe.svg", - color: Colors.white, - ), - 2.height, - types.title.toText10(color: Colors.white) - ], + children: [SvgPicture.asset("assets/images/miss_swipe.svg", width: 20, height: 20, color: Colors.white), 2.height, data.name.toText10(color: Colors.white)], ).paddingAll(6), ), - 12.width, + 8.width, Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - "Missing Swipe Request".toText16(), - "Missing Swipe Request for Hussain, Mohammad has been approved" - .toText10(), - 12.height, + workData.sUBJECT!.toText12(color: MyColors.grey57Color), + 10.height, Row( children: [ - Expanded( - child: "07 Jan 2021" - .toText10(color: MyColors.lightTextColor)), + DateUtil.formatDateToDate(DateUtil.convertSimpleStringDateToDate(workData.bEGINDATE!), false).toText10(color: MyColors.lightTextColor).expanded, SvgPicture.asset( "assets/images/arrow_next.svg", color: MyColors.darkIconColor, @@ -174,33 +330,3 @@ class _WorkListScreenState extends State { ); } } - -class Tabs { - String title; - bool isSelected; - - Tabs(this.title, this.isSelected); -} - -List tabList = [ - Tabs("All", true), - Tabs("HR", false), - Tabs("MO", false), - Tabs("PR", false), - Tabs("PO", false), -]; - -class Types { - String title; - List colors; - - Types(this.title, this.colors); -} - -List typesList = [ - Types("HR", [Color(0xff32D892), Color(0xff1AB170)]), - Types("ITG", [Color(0xffEB8C90), Color(0xffDE6C70)]), - Types("PO", [Color(0xff5099E3), Color(0xff3670AA)]), - Types("PR", [Color(0xff48EACF), Color(0xff3DCAB3)]), - Types("MO", [Color(0xff58DCFA), Color(0xff3CB9D5)]), -]; diff --git a/lib/widgets/app_bar_widget.dart b/lib/widgets/app_bar_widget.dart new file mode 100644 index 0000000..f079f7f --- /dev/null +++ b/lib/widgets/app_bar_widget.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/classes/colors.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/widget_extensions.dart'; + +AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeButton = false}) { + return AppBar( + leadingWidth: 0, + // leading: GestureDetector( + // behavior: HitTestBehavior.opaque, + // onTap: Feedback.wrapForTap(() => Navigator.maybePop(context), context), + // child: const Icon(Icons.arrow_back_ios, color: MyColors.darkIconColor), + // ), + //titleSpacing: -1.44, + title: Row( + children: [ + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: Feedback.wrapForTap(() => Navigator.maybePop(context), context), + child: const Icon(Icons.arrow_back_ios, color: MyColors.darkIconColor), + ), + 4.width, + title.toText24(color: MyColors.darkTextColor, isBold: true, considerHeight: false).expanded, + ], + ), + centerTitle: false, + elevation: 0, + backgroundColor: Colors.white, + actions: [ + if (showHomeButton) + IconButton( + onPressed: () { + // Navigator.pushAndRemoveUntil( + // context, + // MaterialPageRoute(builder: (context) => LandingPage()), + // (Route route) => false, + // ); + }, + icon: const Icon(Icons.home, color: MyColors.darkIconColor), + ), + ], + ); +}