From 3b3046804e8123a0e2b49fb246da936c07f432d8 Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Tue, 17 Jun 2025 11:44:02 +0300 Subject: [PATCH] upgraded --- lib/api/chat/chat_api_client.dart | 2 +- lib/classes/consts.dart | 4 ++-- lib/dialogs/otp_dialog.dart | 4 ++-- lib/models/chat/get_user_login_token_model.dart | 8 ++++---- lib/provider/chat_provider_model.dart | 14 ++++++++++---- lib/theme/app_theme.dart | 14 +++++++------- lib/ui/attendance/monthly_attendance_screen.dart | 11 ++++++----- lib/ui/chat/chat_home.dart | 10 ++++++---- lib/ui/landing/dashboard_screen.dart | 3 ++- lib/ui/my_team/view_attendance.dart | 4 ++-- lib/widgets/image_picker.dart | 2 +- pubspec.yaml | 6 +++--- 12 files changed, 46 insertions(+), 36 deletions(-) diff --git a/lib/api/chat/chat_api_client.dart b/lib/api/chat/chat_api_client.dart index 510f6fa..a9667ec 100644 --- a/lib/api/chat/chat_api_client.dart +++ b/lib/api/chat/chat_api_client.dart @@ -28,7 +28,7 @@ class ChatApiClient { factory ChatApiClient() => _instance; Future getUserLoginToken() async { - user.UserAutoLoginModel userLoginResponse = user.UserAutoLoginModel(); + user.UserAutoLoginModel userLoginResponse = user.UserAutoLoginModel(); String? deviceToken = AppState().getIsHuawei ? AppState().getHuaweiPushToken : AppState().getDeviceToken; Response response = await ApiClient().postJsonForResponse( "${ApiConsts.chatLoginTokenUrl}externaluserlogin", diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index bee7a99..5bc445c 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -3,11 +3,11 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart'; class ApiConsts { // static String baseUrl = "http://10.200.204.11"; // Local server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server - static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver + // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver // static String baseUrl = "http://10.20.200.111:1010/"; // static String baseUrl = "https://webservices.hmg.com"; // PreProd - // static String baseUrl = "https://mohemm.hmg.com"; + static String baseUrl = "https://mohemm.hmg.com"; // static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrlServices = baseUrl + "/Services/"; // server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server diff --git a/lib/dialogs/otp_dialog.dart b/lib/dialogs/otp_dialog.dart index 1404131..6c7529a 100644 --- a/lib/dialogs/otp_dialog.dart +++ b/lib/dialogs/otp_dialog.dart @@ -203,11 +203,11 @@ class OtpDialog { ), errorBorder: OutlineInputBorder( borderRadius: const BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).errorColor), + borderSide: BorderSide(color: Colors.red), ), focusedErrorBorder: OutlineInputBorder( borderRadius: const BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).errorColor), + borderSide: BorderSide(color: Colors.red), ), ); } diff --git a/lib/models/chat/get_user_login_token_model.dart b/lib/models/chat/get_user_login_token_model.dart index 8d55461..f0620c3 100644 --- a/lib/models/chat/get_user_login_token_model.dart +++ b/lib/models/chat/get_user_login_token_model.dart @@ -5,21 +5,21 @@ UserAutoLoginModel userAutoLoginModelFromJson(String str) => UserAutoLoginModel. String userAutoLoginModelToJson(UserAutoLoginModel data) => json.encode(data.toJson()); class UserAutoLoginModel { - UserAutoLoginModel({ - this.response, - this.errorResponses, - }); + UserAutoLoginModel({this.response, this.errorResponses, this.StatusCode}); Response? response; List? errorResponses; + int? StatusCode; factory UserAutoLoginModel.fromJson(Map json) => UserAutoLoginModel( response: json["response"] == null ? null : Response.fromJson(json["response"]), + StatusCode: json["StatusCode"], errorResponses: json["errorResponses"] == null ? null : List.from(json["errorResponses"].map((x) => ErrorResponse.fromJson(x))), ); Map toJson() => { "response": response == null ? null : response!.toJson(), + "StatusCode": StatusCode, "errorResponses": errorResponses == null ? null : List.from(errorResponses!.map((x) => x.toJson())), }; } diff --git a/lib/provider/chat_provider_model.dart b/lib/provider/chat_provider_model.dart index 380278d..1ca52af 100644 --- a/lib/provider/chat_provider_model.dart +++ b/lib/provider/chat_provider_model.dart @@ -93,6 +93,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future getUserAutoLoginToken() async { userLoginToken.UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserLoginToken(); + + if (userLoginResponse.StatusCode == 500) { + disbaleChatForThisUser = true; + notifyListeners(); + } + if (userLoginResponse.response != null) { AppState().setchatUserDetails = userLoginResponse; } else { @@ -399,8 +405,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { if (data.first.userChatReplyResponse != null) { if (data.first.fileTypeResponse != null) { if (data.first.userChatReplyResponse!.fileTypeId == 12 || data.first.userChatReplyResponse!.fileTypeId == 4 || data.first.userChatReplyResponse!.fileTypeId == 3) { - data.first.userChatReplyResponse!.image = - await ChatApiClient().downloadURL(fileName: data.first.userChatReplyResponse!.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg", fileSource: 1); + data.first.userChatReplyResponse!.image = await ChatApiClient() + .downloadURL(fileName: data.first.userChatReplyResponse!.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg", fileSource: 1); data.first.userChatReplyResponse!.isImageLoaded = true; } } @@ -476,8 +482,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { if (data.first.groupChatReplyResponse != null) { if (data.first.fileTypeResponse != null) { if (data.first.groupChatReplyResponse!.fileTypeId == 12 || data.first.groupChatReplyResponse!.fileTypeId == 4 || data.first.groupChatReplyResponse!.fileTypeId == 3) { - data.first.groupChatReplyResponse!.image = - await ChatApiClient().downloadURL(fileName: data.first.groupChatReplyResponse!.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg", fileSource: 2); + data.first.groupChatReplyResponse!.image = await ChatApiClient() + .downloadURL(fileName: data.first.groupChatReplyResponse!.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg", fileSource: 2); data.first.groupChatReplyResponse!.isImageLoaded = true; } } diff --git a/lib/theme/app_theme.dart b/lib/theme/app_theme.dart index f3f756f..f228600 100644 --- a/lib/theme/app_theme.dart +++ b/lib/theme/app_theme.dart @@ -18,29 +18,29 @@ class AppTheme { hintColor: Colors.grey[400], colorScheme: ColorScheme.fromSwatch(accentColor: MyColors.backgroundColor).copyWith(surfaceTint : Colors.transparent), disabledColor: Colors.grey[300], - errorColor: const Color.fromRGBO(235, 80, 60, 1.0), + // errorColor: const Color.fromRGBO(235, 80, 60, 1.0), applyElevationOverlayColor: false, scaffoldBackgroundColor: MyColors.backgroundColor, textSelectionTheme: const TextSelectionThemeData(cursorColor: Colors.grey, selectionColor: Color.fromRGBO(80, 100, 253, 0.5), selectionHandleColor: Colors.grey), canvasColor: Colors.white, - backgroundColor: const Color.fromRGBO(255, 255, 255, 1), + // backgroundColor: const Color.fromRGBO(255, 255, 255, 1), highlightColor: Colors.grey[100]!.withOpacity(0.4), splashColor: Colors.transparent, primaryColor: primaryColor, primaryColorDark: primaryColor, - toggleableActiveColor: secondaryColor, + // toggleableActiveColor: secondaryColor, indicatorColor: secondaryColor, bottomSheetTheme: const BottomSheetThemeData( backgroundColor: Color(0xFFE0E0E0), ), primaryTextTheme: const TextTheme( - bodyText2: TextStyle(color: Colors.white), + // bodyText2: TextStyle(color: Colors.white), ), iconTheme: const IconThemeData(color: MyColors.darkIconColor), textTheme: const TextTheme( - bodyText1: TextStyle(color: Colors.black, letterSpacing: 0.6), - headline1: TextStyle(color: Colors.white, letterSpacing: 0.6), - headline2: TextStyle(color: Colors.white, letterSpacing: 0.6), + // bodyText1: TextStyle(color: Colors.black, letterSpacing: 0.6), + // headline1: TextStyle(color: Colors.white, letterSpacing: 0.6), + // headline2: TextStyle(color: Colors.white, letterSpacing: 0.6), ), floatingActionButtonTheme: const FloatingActionButtonThemeData(highlightElevation: 2, disabledElevation: 0, elevation: 2), appBarTheme: AppBarTheme( diff --git a/lib/ui/attendance/monthly_attendance_screen.dart b/lib/ui/attendance/monthly_attendance_screen.dart index 821a4f0..153c999 100644 --- a/lib/ui/attendance/monthly_attendance_screen.dart +++ b/lib/ui/attendance/monthly_attendance_screen.dart @@ -117,8 +117,8 @@ class _MonthlyAttendanceScreenState extends State { initialDate: formattedDate, firstDate: DateTime(searchYear - 2), lastDate: DateTime.now(), - confirmWidget: Text(LocaleKeys.confirm.tr()), - cancelWidget: Text(LocaleKeys.cancel.tr()), + // confirmWidget: Text(LocaleKeys.confirm.tr()), + // cancelWidget: Text(LocaleKeys.cancel.tr()), ).then((selectedDate) { if (selectedDate != null) { searchMonth = getMonth(selectedDate.month); @@ -303,6 +303,7 @@ class _MonthlyAttendanceScreenState extends State { monthCellBuilder: (build, details) { if (details.date.month == formattedDate.month && details.date.year == formattedDate.year) { int val = details.date.day; + int index = val-1; //check day is off // if (getDayHoursTypeDetailsList.isNotEmpty) { // bool isDayIsOff = getDayHoursTypeDetailsList[val - 1].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[val - 1].dAYTYPE == 'OFF'; @@ -312,9 +313,9 @@ class _MonthlyAttendanceScreenState extends State { getDayHoursTypeDetailsList.where((GetDayHoursTypeDetailsList element) => DateFormat("MM/dd/yyyy", "en_US").parse(element.sCHEDULEDATE!).day == details.date.day).toList(); if (getDayHours.isNotEmpty) { - bool isDayIsOff = getDayHoursTypeDetailsList[0].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[0].dAYTYPE == 'OFF'; - bool isDayIsPresent = getDayHoursTypeDetailsList[0].aTTENDEDFLAG == 'Y'; - bool isDayIsAbsent = getDayHoursTypeDetailsList[0].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[0].aBSENTFLAG == 'Y'; + bool isDayIsOff = getDayHoursTypeDetailsList[index].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[index].dAYTYPE == 'OFF'; + bool isDayIsPresent = getDayHoursTypeDetailsList[index].aTTENDEDFLAG == 'Y'; + bool isDayIsAbsent = getDayHoursTypeDetailsList[index].aTTENDEDFLAG == 'N' && getDayHoursTypeDetailsList[index].aBSENTFLAG == 'Y'; if (isDayIsOff) { return Container( diff --git a/lib/ui/chat/chat_home.dart b/lib/ui/chat/chat_home.dart index 426c9a2..c522475 100644 --- a/lib/ui/chat/chat_home.dart +++ b/lib/ui/chat/chat_home.dart @@ -32,8 +32,11 @@ class _ChatHomeState extends State { @override void initState() { super.initState(); - data = Provider.of(context, listen: false); - data.registerEvents(); + + if (chatHubConnection.state == HubConnectionState.Connected) { + data = Provider.of(context, listen: false); + data.registerEvents(); + } } @override @@ -47,7 +50,6 @@ class _ChatHomeState extends State { data.getUserAutoLoginToken().whenComplete(() async { await data.buildHubConnection(); data.getUserRecentChats(); - }); return; } @@ -57,7 +59,7 @@ class _ChatHomeState extends State { // String isAppOpendByChat = await Utils.getStringFromPrefs("isAppOpendByChat"); // String notificationData = await Utils.getStringFromPrefs("notificationData"); // if (isAppOpendByChat != "null" || isAppOpendByChat == "true" && notificationData != "null") { - // data.openChatByNoti(context); + // data.openChatByNoti(context); // } }); } diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 333d271..90e5ef5 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -60,10 +60,10 @@ class _DashboardScreenState extends State with WidgetsBindingOb void initState() { WidgetsBinding.instance.addObserver(this); super.initState(); + cProvider = Provider.of(context, listen: false); scheduleMicrotask(() { data = Provider.of(context, listen: false); marathonProvider = Provider.of(context, listen: false); - cProvider = Provider.of(context, listen: false); if (checkIfPrivilegedForChat()) { _bHubCon(); } @@ -117,6 +117,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb } Future checkHubCon() async { + // chatHubConnection = await context.read().getHubConnection(); if (chatHubConnection.state == HubConnectionState.Connected) { await chatHubConnection.stop(); await chatHubConnection.start(); diff --git a/lib/ui/my_team/view_attendance.dart b/lib/ui/my_team/view_attendance.dart index 15c4325..cadc11d 100644 --- a/lib/ui/my_team/view_attendance.dart +++ b/lib/ui/my_team/view_attendance.dart @@ -169,8 +169,8 @@ class _ViewAttendanceState extends State { initialDate: formattedDate, firstDate: DateTime(searchYear - 2), lastDate: DateTime.now(), - confirmWidget: Text(LocaleKeys.confirm.tr()), - cancelWidget: Text(LocaleKeys.cancel.tr()), + // confirmWidget: Text(LocaleKeys.confirm.tr()), + // cancelWidget: Text(LocaleKeys.cancel.tr()), ).then( (selectedDate) { if (selectedDate != null) { diff --git a/lib/widgets/image_picker.dart b/lib/widgets/image_picker.dart index 943d68e..a5d346f 100644 --- a/lib/widgets/image_picker.dart +++ b/lib/widgets/image_picker.dart @@ -159,7 +159,7 @@ class _BottomSheet extends StatelessWidget { Widget build(BuildContext context) { return Container( padding: const EdgeInsets.symmetric(vertical: 12.0), - decoration: BoxDecoration(color: Theme.of(context).backgroundColor, borderRadius: const BorderRadius.only(topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0))), + decoration: BoxDecoration( borderRadius: const BorderRadius.only(topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0))), child: SafeArea( top: false, child: Column( diff --git a/pubspec.yaml b/pubspec.yaml index 4194812..bf5ea18 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -46,7 +46,7 @@ dependencies: sizer: ^2.0.15 local_auth: ^2.2.0 fluttertoast: ^8.0.8 - syncfusion_flutter_calendar: 21.2.9 + syncfusion_flutter_calendar: ^27.2.5 # flutter_calendar_carousel: ^2.1.0 pie_chart: ^5.1.0 shared_preferences: ^2.0.12 @@ -62,8 +62,8 @@ dependencies: image_picker: ^0.8.5+3 file_picker: 5.2.5 geolocator: ^9.0.2 - month_year_picker: ^0.3.0+1 - month_picker_dialog: ^2.12.0 + month_year_picker: ^0.4.0+1 + month_picker_dialog: ^3.0.0 # open_file: ^3.2.1 open_filex: ^4.4.0 wifi_iot: ^0.3.18