From 6b9cb8aa5f72be3cdc919f0da1a763fd1ce94281 Mon Sep 17 00:00:00 2001 From: FaizHashmiCS22 Date: Tue, 7 Jan 2025 09:19:04 +0300 Subject: [PATCH] Testing --- lib/models/global_config_model.dart | 1 + lib/repositories/screen_details_repo.dart | 2 +- lib/services/text_to_speech_service.dart | 36 ++++---- lib/utilities/extensions.dart | 4 +- lib/view_models/queuing_view_model.dart | 9 +- lib/view_models/screen_config_view_model.dart | 2 +- lib/views/common_widgets/app_footer.dart | 2 +- .../components/priority_tickets_sidelist.dart | 92 +++++++++---------- .../main_queue_screen/main_queue_screen.dart | 23 ++--- 9 files changed, 86 insertions(+), 85 deletions(-) diff --git a/lib/models/global_config_model.dart b/lib/models/global_config_model.dart index 33ab788..d81dba0 100644 --- a/lib/models/global_config_model.dart +++ b/lib/models/global_config_model.dart @@ -1,3 +1,4 @@ +import 'dart:developer'; import 'dart:ui'; import 'package:hmg_qline/utilities/enums.dart'; import 'package:hmg_qline/utilities/extensions.dart'; diff --git a/lib/repositories/screen_details_repo.dart b/lib/repositories/screen_details_repo.dart index 4aa0c16..00d289a 100644 --- a/lib/repositories/screen_details_repo.dart +++ b/lib/repositories/screen_details_repo.dart @@ -24,9 +24,9 @@ abstract class ScreenDetailsRepo { class ScreenDetailsRepoImp implements ScreenDetailsRepo { ApiClient apiClientInstance; - ScreenDetailsRepoImp({required this.apiClientInstance}); + @override Future getGlobalScreenConfigurations({required String ipAddress}) async { try { diff --git a/lib/services/text_to_speech_service.dart b/lib/services/text_to_speech_service.dart index 5fcf3de..917418b 100644 --- a/lib/services/text_to_speech_service.dart +++ b/lib/services/text_to_speech_service.dart @@ -34,9 +34,10 @@ class TextToSpeechServiceImp implements TextToSpeechService { textToSpeechInstance.setSpeechRate(0.45); textToSpeechInstance.setPitch(0.9); + // String postVoice = globalConfigurationsModel.postVoiceText; + String postVoice = ''; LanguageEnum langEnum = globalConfigurationsModel.voiceLanguageEnum; String preVoice = globalConfigurationsModel.ticketNoText; - String postVoice = globalConfigurationsModel.postVoiceText; String ticketNo = ticket.ticketModel!.queueNo!.trim().toString(); bool isClinicNameAdded = false; @@ -75,26 +76,21 @@ class TextToSpeechServiceImp implements TextToSpeechService { log("Speech: $preVoice .. $clinicName .. $patientAlpha .. $patientNumeric .. $postVoice"); // Create Pre Voice Players - if (postVoice.isNotEmpty) { - log('lang $langEnum'); - if (langEnum != LanguageEnum.arabic) { - await textToSpeechInstance.setLanguage(langEnum.enumToString()); - await textToSpeechInstance.speak("$preVoice .. $clinicName .. $patientAlpha .. $patientNumeric .. $postVoice"); - return; - } - + log('lang $langEnum'); + if (langEnum != LanguageEnum.arabic) { await textToSpeechInstance.setLanguage(langEnum.enumToString()); - textToSpeechInstance.setPitch(1.1); - if (isNeedToBreakVoiceForArabic) { - await textToSpeechInstance.speak("$preVoice .. "); - await textToSpeechInstance.setLanguage("en"); - await textToSpeechInstance.speak("$clinicName .. $patientAlpha .. $patientNumeric .. "); - await textToSpeechInstance.setLanguage(langEnum.enumToString()); - await textToSpeechInstance.speak(postVoice); - } else { - log("here"); - await textToSpeechInstance.speak("$preVoice .. .. $clinicName .. $patientAlpha .. .. $patientNumeric .. .. $postVoice"); - } + await textToSpeechInstance.speak("$preVoice .. $clinicName .. $patientAlpha .. $patientNumeric .. $postVoice"); + return; + } + + await textToSpeechInstance.setLanguage(langEnum.enumToString()); + textToSpeechInstance.setPitch(1.3); + if (isNeedToBreakVoiceForArabic) { + await textToSpeechInstance.speak("$preVoice .. "); + await textToSpeechInstance.setLanguage("en"); + await textToSpeechInstance.speak("$clinicName .. $patientAlpha .. $patientNumeric .. "); + } else { + await textToSpeechInstance.speak("$preVoice .. .. $clinicName .. $patientAlpha .. .. $patientNumeric .. .. $postVoice"); } } diff --git a/lib/utilities/extensions.dart b/lib/utilities/extensions.dart index 272e247..9637459 100644 --- a/lib/utilities/extensions.dart +++ b/lib/utilities/extensions.dart @@ -65,7 +65,7 @@ extension QTypeEnumExtension on int { case 4: return QTypeEnum.pharmacy; default: - throw ArgumentError("Invalid QType value: $this"); + return QTypeEnum.lab; } } } @@ -90,7 +90,7 @@ extension ScreenTypeExtension on int { case 4: return ScreenTypeEnum.dashboardScreen; default: - throw ArgumentError("Invalid ScreenType value: $this"); + return ScreenTypeEnum.waitingAreaScreen; } } } diff --git a/lib/view_models/queuing_view_model.dart b/lib/view_models/queuing_view_model.dart index e4fd7d9..951d87a 100644 --- a/lib/view_models/queuing_view_model.dart +++ b/lib/view_models/queuing_view_model.dart @@ -55,9 +55,12 @@ class QueuingViewModel extends ChangeNotifier { Future onHubConfigCall(var response) async { log("onHubConfigCall: $response"); - // TODO: - // ScreenConfigViewModel screenConfigViewModel = getIt.get(); - // screenConfigViewModel.updateGlobalConfigurationsModel(true); + if (response != null && response.isNotEmpty) { + var data = response.first['data']; + GlobalConfigurationsModel globalConfigurationsModel = GlobalConfigurationsModel.fromJson(data as Map); + ScreenConfigViewModel screenConfigViewModel = getIt.get(); + screenConfigViewModel.updateGlobalConfigurationsModel(value: globalConfigurationsModel, needNotify: true); + } } Future onHubReconnected(var response) async { diff --git a/lib/view_models/screen_config_view_model.dart b/lib/view_models/screen_config_view_model.dart index a7e7e1c..9e13631 100644 --- a/lib/view_models/screen_config_view_model.dart +++ b/lib/view_models/screen_config_view_model.dart @@ -276,7 +276,7 @@ class ScreenConfigViewModel extends ChangeNotifier { for (int i = 0; i < numOfTicketsToCreate; i++) { GenericRespModel? response = await screenDetailsRepo.createNextTickets(ticketNumber: startTicket); startTicket = startTicket + 1; - if (response == null) { + if (response == null || response.messageStatus != 1) { log("response null from createNextTickets"); return; } diff --git a/lib/views/common_widgets/app_footer.dart b/lib/views/common_widgets/app_footer.dart index e90a61f..670d932 100644 --- a/lib/views/common_widgets/app_footer.dart +++ b/lib/views/common_widgets/app_footer.dart @@ -83,7 +83,7 @@ class AppFooter extends StatelessWidget { ], ), Expanded( - child: (screenConfigVM.rssFeedModel.rssFeed == null || screenConfigVM.rssFeedModel.rssFeed!.isEmpty) + child: (!screenConfigVM.globalConfigurationsModel.isRssFeedReq || screenConfigVM.rssFeedModel.rssFeed == null || screenConfigVM.rssFeedModel.rssFeed!.isEmpty) ? const SizedBox() : Container( padding: const EdgeInsets.symmetric(horizontal: 10), diff --git a/lib/views/main_queue_screen/components/priority_tickets_sidelist.dart b/lib/views/main_queue_screen/components/priority_tickets_sidelist.dart index 0e2606a..65b79c8 100644 --- a/lib/views/main_queue_screen/components/priority_tickets_sidelist.dart +++ b/lib/views/main_queue_screen/components/priority_tickets_sidelist.dart @@ -61,28 +61,28 @@ class PriorityTicketsSidelist extends StatelessWidget { height: SizeConfig.getHeightMultiplier() * 0.3, margin: const EdgeInsets.symmetric(horizontal: 15), ), - Expanded( - flex: 5, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - globalConfigurationsModel.callForText ?? "", - letterSpacing: -2, - fontHeight: 0.5, - fontWeight: FontWeight.bold, - fontSize: SizeConfig.getWidthMultiplier() * 3.8, - textAlign: TextAlign.center, - ), - ], - ), - ), - Container( - color: Colors.grey.withOpacity(0.5), - width: 5, - height: SizeConfig.getHeightMultiplier() * 0.3, - margin: const EdgeInsets.symmetric(horizontal: 15), - ), + // Expanded( + // flex: 5, + // child: Row( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // AppText( + // globalConfigurationsModel.callForText ?? "", + // letterSpacing: -2, + // fontHeight: 0.5, + // fontWeight: FontWeight.bold, + // fontSize: SizeConfig.getWidthMultiplier() * 3.8, + // textAlign: TextAlign.center, + // ), + // ], + // ), + // ), + // Container( + // color: Colors.grey.withOpacity(0.5), + // width: 5, + // height: SizeConfig.getHeightMultiplier() * 0.3, + // margin: const EdgeInsets.symmetric(horizontal: 15), + // ), Expanded( flex: 3, child: Row( @@ -137,36 +137,36 @@ class PriorityTicketsSidelist extends StatelessWidget { height: SizeConfig.getHeightMultiplier() * 0.3, margin: const EdgeInsets.symmetric(horizontal: 15), ), - Expanded( - flex: 5, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - AppText( - "ZahoorWillAddThis", - color: AppColors.blackColor, - letterSpacing: -1, - fontSize: SizeConfig.getWidthMultiplier() * 3, - fontWeight: FontWeight.w600, - fontHeight: 0.5, - ), - ], - ), - ), - Container( - color: Colors.grey.withOpacity(0.5), - width: 5, - height: SizeConfig.getHeightMultiplier() * 0.3, - margin: const EdgeInsets.symmetric(horizontal: 15), - ), + // Expanded( + // flex: 5, + // child: Row( + // mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // AppText( + // "ZahoorWillAddThis", + // color: AppColors.blackColor, + // letterSpacing: -1, + // fontSize: SizeConfig.getWidthMultiplier() * 3, + // fontWeight: FontWeight.w600, + // fontHeight: 0.5, + // ), + // ], + // ), + // ), + // Container( + // color: Colors.grey.withOpacity(0.5), + // width: 5, + // height: SizeConfig.getHeightMultiplier() * 0.3, + // margin: const EdgeInsets.symmetric(horizontal: 15), + // ), Expanded( flex: 3, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ AppText( - "RoomNo", + ticket.ticketModel!.roomNo ?? "", color: AppColors.blackColor, letterSpacing: -1.5, fontSize: SizeConfig.getWidthMultiplier() * 3.3, diff --git a/lib/views/main_queue_screen/main_queue_screen.dart b/lib/views/main_queue_screen/main_queue_screen.dart index ec809b5..285d3cd 100644 --- a/lib/views/main_queue_screen/main_queue_screen.dart +++ b/lib/views/main_queue_screen/main_queue_screen.dart @@ -132,9 +132,9 @@ class MainQueueScreen extends StatelessWidget { return Consumer2( builder: (BuildContext context, ScreenConfigViewModel screenConfigViewModel, QueuingViewModel queuingViewModel, Widget? child) { Widget widget = const SizedBox(); + // screenConfigViewModel.createAutoTickets(); // queuingViewModel.voiceCallTicket(ticketData: queuingViewModel.currentTickets.first.ticketModel); if (queuingViewModel.currentTickets.isEmpty) { - // screenConfigViewModel.createAutoTickets(); widget = noPatientInQueue(); } else if (screenConfigViewModel.globalConfigurationsModel.screenTypeEnum == ScreenTypeEnum.roomLevelScreen) { widget = PriorityTickets( @@ -180,24 +180,25 @@ class MainQueueScreen extends StatelessWidget { Widget getBody({required BuildContext context}) { return Consumer( - builder: ( - BuildContext context, - ScreenConfigViewModel screenConfigVM, - Widget? child, - ) { + builder: (BuildContext context, ScreenConfigViewModel screenConfigVM, Widget? child) { return Column( children: [ Expanded( flex: getFlexForScreenTypes(screenConfigVM), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), - child: Row( - children: [ + padding: const EdgeInsets.symmetric(horizontal: 20), + child: Row( + children: [ + if (screenConfigVM.globalConfigurationsModel.isWeatherReq) ...[ getWeatherWidget(screenConfigVM), - const SizedBox(width: 20), + ], + const SizedBox(width: 20), + if (screenConfigVM.globalConfigurationsModel.isPrayerTimeReq) ...[ getPrayerWidget(screenConfigVM), ], - )), + ], + ), + ), ), const SizedBox(height: 12), Expanded(flex: 10, child: dataContent(context: context)),