From 5262af379e4b7667255753d0411fd921545e9949 Mon Sep 17 00:00:00 2001 From: FaizHashmiCS22 Date: Wed, 4 Oct 2023 17:43:17 +0300 Subject: [PATCH] Widgets Info Completed --- assets/icons/sunny.svg | 1 + lib/core/config/config.dart | 1 + .../response_models/call_config_model.dart | 45 +++++++++---- .../weathers_widget_model.dart | 48 ++++++++++---- lib/header/app_header.dart | 66 ++++++++++--------- lib/home/app_provider.dart | 10 +-- lib/home/home_screen.dart | 6 +- 7 files changed, 114 insertions(+), 63 deletions(-) create mode 100644 assets/icons/sunny.svg diff --git a/assets/icons/sunny.svg b/assets/icons/sunny.svg new file mode 100644 index 0000000..a84bc71 --- /dev/null +++ b/assets/icons/sunny.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/lib/core/config/config.dart b/lib/core/config/config.dart index 55addbe..9018879 100644 --- a/lib/core/config/config.dart +++ b/lib/core/config/config.dart @@ -44,5 +44,6 @@ class AppGlobal { static String coldIcon = "assets/icons/cold.svg"; static String hotIcon = "assets/icons/hot.svg"; static String rainIcon = "assets/icons/rainy.svg"; + static String sunnyIcon = "assets/icons/sunny.svg"; static String windIcon = "assets/icons/windy.svg"; } diff --git a/lib/core/response_models/call_config_model.dart b/lib/core/response_models/call_config_model.dart index 72023d9..946d55e 100644 --- a/lib/core/response_models/call_config_model.dart +++ b/lib/core/response_models/call_config_model.dart @@ -37,6 +37,14 @@ class CallConfig { late String queueNoText; late String callForText; late String currentServeText; + late String nextPrayerText; + late String minText; + late String maxText; + late String fajrText; + late String dhuhrText; + late String asrText; + late String maghribText; + late String ishaText; late String callTypeVitalSignText; late String callTypeDoctorText; late String callTypeProcedureText; @@ -69,7 +77,14 @@ class CallConfig { this.queueNoText = "", this.callForText = "", this.currentServeText = "Current Serving", - this.callTypeVitalSignText = "", + this.nextPrayerText = "Next Prayer", + this.minText = "Min", + this.maxText = "Max", + this.fajrText = "Fajar", + this.dhuhrText = "Dhuhr", + this.asrText = "Asr", + this.maghribText = "Maghrib", + this.ishaText = "Isha", this.callTypeDoctorText = "", this.callTypeProcedureText = "", this.callTypeVaccinationText = "", @@ -89,11 +104,11 @@ class CallConfig { prioritySMS = json['prioritySMS']; priorityWhatsApp = json['priorityWhatsApp']; priorityEmail = json['priorityEmail']; - vitalSignText = json['vitalSignText']; - doctorText = json['doctorText']; - procedureText = json['procedureText']; - vaccinationText = json['vaccinationText']; - nebulizationText = json['nebulizationText']; + vitalSignText = json['callForVitalSignText']; + doctorText = json['callForDoctorText']; + procedureText = json['callForProcedureText']; + vaccinationText = json['callForVaccinationText']; + nebulizationText = json['callForNebulizationText']; createdBy = json['createdBy']; createdOn = json['createdOn']; editedBy = json['editedBy']; @@ -101,13 +116,19 @@ class CallConfig { roomText = json['roomText']; queueNoText = json['queueNoText']; callForText = json['callForText']; + nextPrayerText = json['nextPrayerText']; + maxText = json['maxText']; + fajrText = json['fajrText']; + dhuhrText = json['dhuhrText']; + asrText = json['asrText']; + maghribText = json['maghribText']; + ishaText = json['ishaText']; currentServeText = json['currentServeText']; - callTypeVitalSignText = json['callTypeVitalSignText']; - callTypeVitalSignText = json['callTypeVitalSignText']; - callTypeDoctorText = json['callTypeDoctorText']; - callTypeProcedureText = json['callTypeProcedureText']; - callTypeVaccinationText = json['callTypeVaccinationText']; - callTypeNebulizationText = json['callTypeNebulizationText']; + callTypeVitalSignText = json['vitalSignText']; + callTypeDoctorText = json['doctorText']; + callTypeProcedureText = json['procedureText']; + callTypeVaccinationText = json['vaccinationText']; + callTypeNebulizationText = json['nebulizationText']; textDirection = json['textDirection'] == 2 ? TextDirection.rtl : TextDirection.ltr; // textDirection = TextDirection.ltr; } diff --git a/lib/core/response_models/weathers_widget_model.dart b/lib/core/response_models/weathers_widget_model.dart index 65732eb..92bf8e7 100644 --- a/lib/core/response_models/weathers_widget_model.dart +++ b/lib/core/response_models/weathers_widget_model.dart @@ -1,3 +1,5 @@ +import 'package:queuing_system/core/config/config.dart'; + class WeathersWidgetModel { int? id; String? headline; @@ -11,20 +13,23 @@ class WeathersWidgetModel { double? windSpeed; String? windDirection; double? windDegrees; + String? weatherIconPath; - WeathersWidgetModel( - {this.id, - this.headline, - this.maxTemp, - this.minTemp, - this.iconPhrase, - this.forecastDate, - this.cityID, - this.forecastDay, - this.createDateTime, - this.windSpeed, - this.windDirection, - this.windDegrees}); + WeathersWidgetModel({ + this.id, + this.headline, + this.maxTemp, + this.minTemp, + this.iconPhrase, + this.forecastDate, + this.cityID, + this.forecastDay, + this.createDateTime, + this.windSpeed, + this.windDirection, + this.windDegrees, + this.weatherIconPath, + }); WeathersWidgetModel.fromJson(Map json) { id = json['id']; @@ -39,6 +44,23 @@ class WeathersWidgetModel { windSpeed = json['windSpeed']; windDirection = json['windDirection']; windDegrees = json['windDegrees']; + weatherIconPath = getWeatherIconPath(json['iconPhrase']); + } + + String getWeatherIconPath(String iconPhrase) { + if (iconPhrase == "Rain" || iconPhrase == "Showers" || iconPhrase == "ThunderStorms") { + return AppGlobal.rainIcon; + } else if (iconPhrase == "Hot") { + return AppGlobal.hotIcon; + } else if (iconPhrase == "Windy") { + return AppGlobal.windIcon; + } else if (iconPhrase == "Cloudy" || iconPhrase == "Mostly cloudy" || iconPhrase == "Intermittent clouds") { + return AppGlobal.cloudIcon; + } else if (iconPhrase == "Sunny" || iconPhrase == "Mostly sunny" || iconPhrase == "Partly sunny" || iconPhrase == "Hazy sunshine") { + return AppGlobal.sunnyIcon; + } else { + return AppGlobal.weatherIcon; + } } Map toJson() { diff --git a/lib/header/app_header.dart b/lib/header/app_header.dart index b2f1518..f204c41 100644 --- a/lib/header/app_header.dart +++ b/lib/header/app_header.dart @@ -17,23 +17,26 @@ class AppHeader extends StatelessWidget with PreferredSizeWidget { if (appProvider.currentWeathersWidgetModel.maxTemp == null || appProvider.currentWeathersWidgetModel.minTemp == null || appProvider.currentWeathersWidgetModel.iconPhrase == null) { return const SizedBox.shrink(); } - return Row( - children: [ - SvgPicture.asset( - AppGlobal.weatherIcon, - height: SizeConfig.getHeightMultiplier() * 2.5, - color: Colors.white, - ), - const SizedBox(width: 10), - Padding( - padding: const EdgeInsets.only(top: 15), - child: AppText( - "Max: ${appProvider.currentWeathersWidgetModel.maxTemp}°C , Min: ${appProvider.currentWeathersWidgetModel.minTemp}°C", + return Directionality( + textDirection: appProvider.patientCallConfigurations.textDirection, + child: Row( + children: [ + SvgPicture.asset( + appProvider.currentWeathersWidgetModel.weatherIconPath ?? AppGlobal.weatherIcon, + height: SizeConfig.getHeightMultiplier() * 2.5, color: Colors.white, - fontSize: SizeConfig.getHeightMultiplier() * 1.3, ), - ), - ], + const SizedBox(width: 10), + Padding( + padding: const EdgeInsets.only(top: 15), + child: AppText( + "${appProvider.patientCallConfigurations.maxText}: ${appProvider.currentWeathersWidgetModel.maxTemp}°C , ${appProvider.patientCallConfigurations.minText}: ${appProvider.currentWeathersWidgetModel.minTemp}°C", + color: Colors.white, + fontSize: SizeConfig.getHeightMultiplier() * 1.3, + ), + ), + ], + ), ); }); } @@ -43,23 +46,26 @@ class AppHeader extends StatelessWidget with PreferredSizeWidget { if (appProvider.nextPrayerToShowWithTime.isEmpty) { return const SizedBox.shrink(); } - return Row( - children: [ - SvgPicture.asset( - AppGlobal.mosqueIcon, - height: SizeConfig.getHeightMultiplier() * 2.5, - color: Colors.white, - ), - const SizedBox(width: 10), - Padding( - padding: const EdgeInsets.only(top: 15), - child: AppText( - "Next Prayer: ${appProvider.nextPrayerToShowWithTime}", + return Directionality( + textDirection: appProvider.patientCallConfigurations.textDirection, + child: Row( + children: [ + SvgPicture.asset( + AppGlobal.mosqueIcon, + height: SizeConfig.getHeightMultiplier() * 2.5, color: Colors.white, - fontSize: SizeConfig.getHeightMultiplier() * 1.3, ), - ), - ], + const SizedBox(width: 10), + Padding( + padding: const EdgeInsets.only(top: 15), + child: AppText( + "Next Prayer: ${appProvider.nextPrayerToShowWithTime}", + color: Colors.white, + fontSize: SizeConfig.getHeightMultiplier() * 1.3, + ), + ), + ], + ), ); }); } diff --git a/lib/home/app_provider.dart b/lib/home/app_provider.dart index ac3a8a4..c52e6ae 100644 --- a/lib/home/app_provider.dart +++ b/lib/home/app_provider.dart @@ -107,31 +107,31 @@ class AppProvider extends ChangeNotifier { final current = DateTime.now(); if (DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.fajr!).isAfter(current)) { final namazTime = DateFormat('hh:mm a').format(DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.fajr!)); - nextPrayerToShowWithTime = "Fajr ($namazTime)"; + nextPrayerToShowWithTime = "${patientCallConfigurations.fajrText} ($namazTime)"; notifyListeners(); return; } if (DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.dhuhr!).isAfter(current)) { final namazTime = DateFormat('hh:mm a').format(DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.dhuhr!)); - nextPrayerToShowWithTime = "Dhuhr ($namazTime)"; + nextPrayerToShowWithTime = "${patientCallConfigurations.dhuhrText} ($namazTime)"; notifyListeners(); return; } if (DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.asr!).isAfter(current)) { final namazTime = DateFormat('hh:mm a').format(DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.asr!)); - nextPrayerToShowWithTime = "Asar ($namazTime)"; + nextPrayerToShowWithTime = "${patientCallConfigurations.asrText} ($namazTime)"; notifyListeners(); return; } if (DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.maghrib!).isAfter(current)) { final namazTime = DateFormat('hh:mm a').format(DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.maghrib!)); - nextPrayerToShowWithTime = "Maghrib ($namazTime)"; + nextPrayerToShowWithTime = "${patientCallConfigurations.maghribText} ($namazTime)"; notifyListeners(); return; } if (DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.isha!).isAfter(current)) { final namazTime = DateFormat('hh:mm a').format(DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.isha!)); - nextPrayerToShowWithTime = "Isha ($namazTime)"; + nextPrayerToShowWithTime = "${patientCallConfigurations.ishaText} ($namazTime)"; notifyListeners(); return; } diff --git a/lib/home/home_screen.dart b/lib/home/home_screen.dart index 6b936d3..4c9c825 100644 --- a/lib/home/home_screen.dart +++ b/lib/home/home_screen.dart @@ -14,10 +14,10 @@ class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { final appProvider = context.watch(); - + return AppScaffold( appProvider: appProvider, - appBar: AppHeader(), + appBar: const AppHeader(), body: dataContent(appProvider: appProvider), bottomNavigationBar: Container( color: Colors.grey.withOpacity(0.1), @@ -35,7 +35,7 @@ class MyHomePage extends StatelessWidget { children: [ InkWell( onTap: () async { - await context.read().callPatientsAPI(); + // await context.read().callPatientsAPI(); }, child: AppText( "Powered By",