diff --git a/lib/core/api.dart b/lib/core/api.dart index 3af2d12..f72e367 100644 --- a/lib/core/api.dart +++ b/lib/core/api.dart @@ -9,6 +9,7 @@ import 'package:queuing_system/core/response_models/prayers_widget_model.dart'; import 'package:queuing_system/core/response_models/rss_feed_model.dart'; import 'package:queuing_system/core/response_models/weathers_widget_model.dart'; import 'package:queuing_system/core/response_models/widgets_config_model.dart'; +import 'package:queuing_system/core/response_models/test_patients.dart'; const _getCallRequestInfoByClinicInfo = "/GetCallRequestInfo_ByIP"; const _callUpdateNotIsQueueRecordByIDAsync = "/CallRequest_QueueUpdate"; @@ -28,12 +29,15 @@ class API { static getCallRequestInfoByClinicInfo(String deviceIp, {required Function(List, List, CallConfig callConfig) onSuccess, required Function(dynamic) onFailure}) async { final body = {"ipAdress": deviceIp, "apiKey": apiKey}; - bool isDevMode = false; + bool isDevMode = true; if (isDevMode) { - var callPatients = PatientTicketModel.testCallPatients; - CallConfig callConfig = CallConfig.testCallConfig; + final Map response = testPatientsData["data"] as Map; - var isQueuePatients = callPatients.where((element) => (element.isQueue == false)).toList(); + CallConfig callConfig = CallConfig.fromJson(response["callConfig"]); + var callPatients = (response["callPatients"] as List).map((j) => PatientTicketModel.fromJson(j)).toList().where((element) => element.callType != 0).toList(); + var isQueuePatients = callPatients.where((element) => (element.isQueue == false && element.callType != 0)).toList(); + log("callPatients: ${callPatients.toString()}"); + log("isQueuePatients: ${isQueuePatients.toString()}"); onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList(), callConfig); return; } diff --git a/lib/core/response_models/call_config_model.dart b/lib/core/response_models/call_config_model.dart index b3715bf..449797b 100644 --- a/lib/core/response_models/call_config_model.dart +++ b/lib/core/response_models/call_config_model.dart @@ -53,6 +53,7 @@ class CallConfig { late String callTypeVaccinationText; late String callTypeNebulizationText; late TextDirection textDirection; + late ScreenOrientationEnum screenRotationEnum; CallConfig({ this.id = 0, @@ -94,6 +95,7 @@ class CallConfig { this.callTypeVaccinationText = "", this.callTypeNebulizationText = "", this.textDirection = TextDirection.ltr, + this.screenRotationEnum = ScreenOrientationEnum.portraitUp, }); CallConfig.fromJson(Map json) { @@ -137,7 +139,8 @@ class CallConfig { callTypeVaccinationText = json['vaccinationText']; callTypeNebulizationText = json['nebulizationText']; textDirection = json['textDirection'] == 2 ? TextDirection.rtl : TextDirection.ltr; - // textDirection = TextDirection.ltr; + screenRotationEnum = (json['orientationType'] as int).toScreenOrientationEnum(); + // screenRotationEnum = (json['screenRotationId'] as int).toScreenOrientationEnum(); } static var data = { @@ -187,3 +190,26 @@ class CallConfig { static CallConfig testCallConfig = CallConfig.fromJson(data); } + +enum ScreenOrientationEnum { + landscapeRight, + landscapeLeft, + portraitUp, + portraitDown, +} + +extension ScreenOrientationEnumExt on int { + ScreenOrientationEnum toScreenOrientationEnum() { + if (this == 1) { + return ScreenOrientationEnum.portraitUp; + } else if (this == 2) { + return ScreenOrientationEnum.portraitDown; + } else if (this == 3) { + return ScreenOrientationEnum.landscapeRight; + } else if (this == 4) { + return ScreenOrientationEnum.landscapeLeft; + } else { + return ScreenOrientationEnum.portraitUp; + } + } +} diff --git a/lib/core/response_models/patient_ticket_model.dart b/lib/core/response_models/patient_ticket_model.dart index 003de2c..b23e0c7 100644 --- a/lib/core/response_models/patient_ticket_model.dart +++ b/lib/core/response_models/patient_ticket_model.dart @@ -1,5 +1,6 @@ import 'dart:math'; +import 'package:queuing_system/core/response_models/call_config_model.dart'; import 'package:queuing_system/utils/call_type.dart'; class PatientTicketModel { @@ -36,6 +37,9 @@ class PatientTicketModel { late String roomText; late String queueNoText; late String callForText; + late int orientationType; + late ScreenOrientationEnum screenRotationEnum; + late bool callUpdated = false; PatientTicketModel({ @@ -72,6 +76,8 @@ class PatientTicketModel { this.roomText = "Room", this.queueNoText = "Queue No", this.callForText = "Call For", + this.orientationType = 1, + this.screenRotationEnum = ScreenOrientationEnum.portraitUp, }); int getRandomNum() { @@ -111,6 +117,8 @@ class PatientTicketModel { roomText = json['roomText']; queueNoText = json['queueNoText']; callForText = json['callForText']; + orientationType = json['orientationType']; + screenRotationEnum = (json['orientationType'] as int).toScreenOrientationEnum(); } // "voiceLanguage": 1, @@ -130,27 +138,6 @@ class PatientTicketModel { // "queueNoText": "Queue No", // "callForText": "Call For" - Map toJson() { - final Map data = {}; - data['id'] = id; - data['patientID'] = patientID; - data['mobileNo'] = mobileNo; - data['doctorName'] = doctorName; - data['doctorNameN'] = doctorNameN; - data['patientGender'] = patientGender; - data['callType'] = callType; - data['roomNo'] = roomNo; - data['createdOn'] = createdOn; - data['editedOn'] = editedOn; - data['queueNo'] = queueNo; - data['callNoStr'] = callNoStr; - data['isQueue'] = isQueue; - data['isToneReq'] = isToneReq; - data['isVoiceReq'] = isVoiceReq; - data['concurrentCallDelaySec'] = concurrentCallDelaySec; - return data; - } - @override String toString() { return (queueNo).toString(); @@ -164,98 +151,98 @@ class PatientTicketModel { if (callType == 5) return CallType.nebulization; return CallType.vitalSign; } - - static List testCallPatients = [ - PatientTicketModel( - id: 1, - patientID: 112, - mobileNo: "112", - doctorName: "name", - doctorNameN: "nameN", - patientGender: 1, - callType: 1, - roomNo: "617", - createdOn: DateTime.now().millisecondsSinceEpoch.toString(), - editedOn: DateTime.now().millisecondsSinceEpoch.toString(), - editedOnTimeStamp: DateTime.now().millisecondsSinceEpoch, - queueNo: "B-89", - callNoStr: "B-89", - isQueue: true, - isToneReq: true, - isVoiceReq: true, - concurrentCallDelaySec: 8, - ), - PatientTicketModel( - id: 1, - patientID: 112, - mobileNo: "112", - doctorName: "name", - doctorNameN: "nameN", - patientGender: 1, - callType: 1, - roomNo: "617", - createdOn: DateTime.now().millisecondsSinceEpoch.toString(), - editedOn: DateTime.now().millisecondsSinceEpoch.toString(), - queueNo: "B-89", - callNoStr: "B-89", - isQueue: true, - isToneReq: true, - isVoiceReq: true, - concurrentCallDelaySec: 8, - ), - PatientTicketModel( - id: 1, - patientID: 112, - mobileNo: "112", - doctorName: "name", - doctorNameN: "nameN", - patientGender: 1, - callType: 1, - roomNo: "617", - createdOn: DateTime.now().millisecondsSinceEpoch.toString(), - editedOn: DateTime.now().millisecondsSinceEpoch.toString(), - queueNo: "B-89", - callNoStr: "B-89", - isQueue: true, - isToneReq: true, - isVoiceReq: true, - concurrentCallDelaySec: 8, - ), - PatientTicketModel( - id: 1, - patientID: 112, - mobileNo: "112", - doctorName: "name", - doctorNameN: "nameN", - patientGender: 1, - callType: 1, - roomNo: "617", - createdOn: DateTime.now().millisecondsSinceEpoch.toString(), - editedOn: DateTime.now().millisecondsSinceEpoch.toString(), - queueNo: "B-89", - callNoStr: "B-89", - isQueue: true, - isToneReq: true, - isVoiceReq: true, - concurrentCallDelaySec: 8, - ), - PatientTicketModel( - id: 1, - patientID: 112, - mobileNo: "112", - doctorName: "name", - doctorNameN: "nameN", - patientGender: 1, - callType: 1, - roomNo: "617", - createdOn: DateTime.now().millisecondsSinceEpoch.toString(), - editedOn: DateTime.now().millisecondsSinceEpoch.toString(), - queueNo: "B-89", - callNoStr: "B-89", - isQueue: true, - isToneReq: true, - isVoiceReq: true, - concurrentCallDelaySec: 8, - ), - ]; + // + // static List testCallPatients = [ + // PatientTicketModel( + // id: 1, + // patientID: 112, + // mobileNo: "112", + // doctorName: "name", + // doctorNameN: "nameN", + // patientGender: 1, + // callType: 1, + // roomNo: "617", + // createdOn: DateTime.now().millisecondsSinceEpoch.toString(), + // editedOn: DateTime.now().millisecondsSinceEpoch.toString(), + // editedOnTimeStamp: DateTime.now().millisecondsSinceEpoch, + // queueNo: "B-89", + // callNoStr: "B-89", + // isQueue: true, + // isToneReq: true, + // isVoiceReq: true, + // concurrentCallDelaySec: 8, + // ), + // PatientTicketModel( + // id: 1, + // patientID: 112, + // mobileNo: "112", + // doctorName: "name", + // doctorNameN: "nameN", + // patientGender: 1, + // callType: 1, + // roomNo: "617", + // createdOn: DateTime.now().millisecondsSinceEpoch.toString(), + // editedOn: DateTime.now().millisecondsSinceEpoch.toString(), + // queueNo: "B-89", + // callNoStr: "B-89", + // isQueue: true, + // isToneReq: true, + // isVoiceReq: true, + // concurrentCallDelaySec: 8, + // ), + // PatientTicketModel( + // id: 1, + // patientID: 112, + // mobileNo: "112", + // doctorName: "name", + // doctorNameN: "nameN", + // patientGender: 1, + // callType: 1, + // roomNo: "617", + // createdOn: DateTime.now().millisecondsSinceEpoch.toString(), + // editedOn: DateTime.now().millisecondsSinceEpoch.toString(), + // queueNo: "B-89", + // callNoStr: "B-89", + // isQueue: true, + // isToneReq: true, + // isVoiceReq: true, + // concurrentCallDelaySec: 8, + // ), + // PatientTicketModel( + // id: 1, + // patientID: 112, + // mobileNo: "112", + // doctorName: "name", + // doctorNameN: "nameN", + // patientGender: 1, + // callType: 1, + // roomNo: "617", + // createdOn: DateTime.now().millisecondsSinceEpoch.toString(), + // editedOn: DateTime.now().millisecondsSinceEpoch.toString(), + // queueNo: "B-89", + // callNoStr: "B-89", + // isQueue: true, + // isToneReq: true, + // isVoiceReq: true, + // concurrentCallDelaySec: 8, + // ), + // PatientTicketModel( + // id: 1, + // patientID: 112, + // mobileNo: "112", + // doctorName: "name", + // doctorNameN: "nameN", + // patientGender: 1, + // callType: 1, + // roomNo: "617", + // createdOn: DateTime.now().millisecondsSinceEpoch.toString(), + // editedOn: DateTime.now().millisecondsSinceEpoch.toString(), + // queueNo: "B-89", + // callNoStr: "B-89", + // isQueue: true, + // isToneReq: true, + // isVoiceReq: true, + // concurrentCallDelaySec: 8, + // ), + // ]; } diff --git a/lib/footer/app_footer.dart b/lib/footer/app_footer.dart index efa1a02..16ea52e 100644 --- a/lib/footer/app_footer.dart +++ b/lib/footer/app_footer.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:marquee/marquee.dart'; import 'package:provider/provider.dart'; import 'package:queuing_system/core/config/size_config.dart'; +import 'package:queuing_system/core/response_models/call_config_model.dart'; import 'package:queuing_system/home/app_provider.dart'; import 'package:queuing_system/utils/Utils.dart'; import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; @@ -28,7 +29,7 @@ class AppFooter extends StatelessWidget { children: [ InkWell( onTap: () async { - await context.read().callPatientsAPI(); + // await context.read().callPatientsAPI(); }, child: AppText( "Powered By", @@ -37,6 +38,34 @@ class AppFooter extends StatelessWidget { ), ), Text(appProvider.currentDeviceIp, style: TextStyle(fontWeight: FontWeight.w500, fontSize: SizeConfig.getWidthMultiplier() * 2.2)), + Row( + children: [ + InkWell( + onTap: () { + appProvider.updateCurrentScreenRotation(ScreenOrientationEnum.portraitUp); + }, + child: const Icon(Icons.arrow_upward), + ), + InkWell( + onTap: () { + appProvider.updateCurrentScreenRotation(ScreenOrientationEnum.landscapeRight); + }, + child: const Icon(Icons.arrow_forward), + ), + InkWell( + onTap: () { + appProvider.updateCurrentScreenRotation(ScreenOrientationEnum.portraitDown); + }, + child: const Icon(Icons.arrow_downward), + ), + InkWell( + onTap: () { + appProvider.updateCurrentScreenRotation(ScreenOrientationEnum.landscapeLeft); + }, + child: const Icon(Icons.arrow_back), + ), + ], + ), ], ), const SizedBox(width: 10), diff --git a/lib/header/app_header.dart b/lib/header/app_header.dart index cff0392..183a754 100644 --- a/lib/header/app_header.dart +++ b/lib/header/app_header.dart @@ -1,9 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:marquee/marquee.dart'; import 'package:provider/provider.dart'; import 'package:queuing_system/core/config/config.dart'; -import 'package:queuing_system/core/config/size_config.dart'; import 'package:queuing_system/home/app_provider.dart'; import 'package:queuing_system/utils/utils.dart'; import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; @@ -11,7 +9,6 @@ import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; class AppHeader extends StatelessWidget with PreferredSizeWidget { const AppHeader({Key? key}) : super(key: key); - // // Widget getWeatherWidget() { // return Consumer(builder: (BuildContext context, AppProvider appProvider, Widget? child) { // if (appProvider.currentWeathersWidgetModel.maxTemp == null || appProvider.currentWeathersWidgetModel.minTemp == null || appProvider.currentWeathersWidgetModel.iconPhrase == null) { @@ -71,37 +68,41 @@ class AppHeader extends StatelessWidget with PreferredSizeWidget { // }); // } - @override Widget build(BuildContext context) { - AppProvider appProvider = context.read(); // return SizedBox(); - return Container( - height: 100, - padding: const EdgeInsets.only(left: 20, right: 20), - decoration: BoxDecoration(color: AppGlobal.vitalSignColor), - child: Directionality( - textDirection: appProvider.patientCallConfigurations.textDirection, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - InkWell( - onTap: () {}, - child: AppText( - appProvider.patientCallConfigurations.currentServeText, - color: Colors.white, - ), - ), - // getPrayerWidget(), - // getWeatherWidget(), - SvgPicture.asset( - "assets/images/hmglogo.svg", - height: Utils.getHeight() * 0.5, + return Consumer( + builder: (BuildContext context, AppProvider appProvider, Widget? child) { + return Container( + height: 100, + padding: const EdgeInsets.only(left: 20, right: 20), + decoration: BoxDecoration(color: AppGlobal.vitalSignColor), + child: Directionality( + textDirection: appProvider.patientCallConfigurations.textDirection, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + InkWell( + onTap: () async { + await appProvider.callPatientsAPI(); + }, + child: AppText( + appProvider.patientCallConfigurations.currentServeText, + color: Colors.white, + ), + ), + // getPrayerWidget(), + // getWeatherWidget(), + SvgPicture.asset( + "assets/images/hmglogo.svg", + height: Utils.getHeight() * 0.5, + ), + ], ), - ], - ), - ), + ), + ); + }, ); } diff --git a/lib/home/app_provider.dart b/lib/home/app_provider.dart index 03c3a90..b12e247 100644 --- a/lib/home/app_provider.dart +++ b/lib/home/app_provider.dart @@ -19,6 +19,8 @@ import 'package:queuing_system/utils/call_type.dart'; import 'package:queuing_system/utils/signalR_utils.dart'; import 'package:shared_preferences/shared_preferences.dart'; +bool isVoiceActualCompletedGlobally = false; + class AppProvider extends ChangeNotifier { AppProvider() { callInitializations(); @@ -52,6 +54,13 @@ class AppProvider extends ChangeNotifier { notifyListeners(); } + ScreenOrientationEnum currentScreenRotation = ScreenOrientationEnum.portraitUp; + + updateCurrentScreenRotation(ScreenOrientationEnum value) { + currentScreenRotation = value; + notifyListeners(); + } + Future getCurrentIP() async { final ips = await NetworkInterface.list(type: InternetAddressType.IPv4); for (var interface in ips) { @@ -100,8 +109,9 @@ class AppProvider extends ChangeNotifier { String nextPrayerToShowWithTime = ''; void getNextPrayerToShow() { - log("Checking Namaz time Locally!"); final current = DateTime.now(); + log("Checking Namaz time Locally at ${current.toString()} and ${current.timeZoneName} "); + if (DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.fajr!).isAfter(current)) { final namazTime = DateFormat('hh:mm a').format(DateTime.fromMillisecondsSinceEpoch(currentPrayersWidgetModel.fajr!)); nextPrayerToShowWithTime = "${patientCallConfigurations.fajrText} at $namazTime"; @@ -252,6 +262,7 @@ class AppProvider extends ChangeNotifier { isQueuePatients = isQueuePatientsCalls; notifyListeners(); if (patientTickets.isNotEmpty) { + updateCurrentScreenRotation(patientTickets.first.screenRotationEnum); voiceCallPatientTicket(patientTickets.first); updatePatientTicket(patientTickets.first); } @@ -317,6 +328,7 @@ class AppProvider extends ChangeNotifier { } if (patientTicket.isVoiceReq && voiceCaller == null && !patientTicket.isQueue) { + log("patientTicket.voiceLanguage: ${patientTicket.voiceLanguage}"); final postVoice = getCallTypeText(patientTicket); voiceCaller = CallByVoice( preVoice: patientTicket.ticketNoText, @@ -332,7 +344,6 @@ class AppProvider extends ChangeNotifier { } } else { isCallingInProgress = false; - if (isApiCallNeeded) { Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { await callPatientsAPI(); @@ -345,9 +356,10 @@ class AppProvider extends ChangeNotifier { Future listenAudioPlayerEvents() async { audioPlayer.playerStateStream.listen((playerState) async { if (playerState.processingState == ProcessingState.completed) { - // isCallingInProgress = false; - - if (currentPatient.isVoiceReq) return; + if (currentPatient.isVoiceReq) { + isCallingInProgress = true; + return; + } if (isQueuePatients.isNotEmpty) { final length = isQueuePatients.length; @@ -377,11 +389,10 @@ class AppProvider extends ChangeNotifier { } }); - flutterTts.setStartHandler(() { - // isCallingInProgress = true; - }); - flutterTts.setCompletionHandler(() async { + log("My Value is in setCompletionHandler: $isVoiceActualCompletedGlobally"); + if (!isVoiceActualCompletedGlobally) {} + ; if (isQueuePatients.isNotEmpty) { final length = isQueuePatients.length; for (int i = 0; i < length; i++) { @@ -401,7 +412,6 @@ class AppProvider extends ChangeNotifier { } } isCallingInProgress = false; - print("I am gere with: $isCallingInProgress"); if (isApiCallNeeded) { Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { await callPatientsAPI(); diff --git a/lib/home/home_screen.dart b/lib/home/home_screen.dart index 1cf5741..a84d5a0 100644 --- a/lib/home/home_screen.dart +++ b/lib/home/home_screen.dart @@ -1,9 +1,12 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; import 'package:queuing_system/core/base/app_scaffold_widget.dart'; import 'package:queuing_system/core/config/config.dart'; import 'package:queuing_system/core/config/size_config.dart'; +import 'package:queuing_system/core/response_models/call_config_model.dart'; import 'package:queuing_system/footer/app_footer.dart'; import 'package:queuing_system/header/app_header.dart'; import 'package:queuing_system/home/app_provider.dart'; @@ -19,10 +22,9 @@ class MyHomePage extends StatelessWidget { return const SizedBox.shrink(); } return Container( - constraints: BoxConstraints( - minWidth: SizeConfig.getWidthMultiplier() * 30, - minHeight: SizeConfig.getHeightMultiplier() * 5.5, - ), + height: (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown) + ? SizeConfig.getHeightMultiplier() * 8 + : SizeConfig.getHeightMultiplier() * 5, padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), decoration: AppGlobal.configWidgetDecoration, child: Directionality( @@ -64,10 +66,9 @@ class MyHomePage extends StatelessWidget { return const SizedBox.shrink(); } return Container( - constraints: BoxConstraints( - minWidth: SizeConfig.getWidthMultiplier() * 25, - minHeight: SizeConfig.getHeightMultiplier() * 5, - ), + height: (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown) + ? SizeConfig.getHeightMultiplier() * 8 + : SizeConfig.getHeightMultiplier() * 5, padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), decoration: AppGlobal.configWidgetDecoration, child: Directionality( @@ -102,7 +103,7 @@ class MyHomePage extends StatelessWidget { }); } - getBody(AppProvider appProvider) { + getBody(AppProvider appProvider, context) { return Column( children: [ const SizedBox(height: 12), @@ -121,32 +122,52 @@ class MyHomePage extends StatelessWidget { const SizedBox(height: 20), Expanded( flex: 9, - child: dataContent(appProvider: appProvider), + child: dataContent(appProvider: appProvider, context: context), ), ], ); } + int getTurnsByOrientation(ScreenOrientationEnum screenOrientationEnum) { + switch (screenOrientationEnum) { + case ScreenOrientationEnum.portraitUp: + return 0; + case ScreenOrientationEnum.portraitDown: + return 2; + case ScreenOrientationEnum.landscapeRight: + return 1; + case ScreenOrientationEnum.landscapeLeft: + return 3; + default: + return 0; + } + } + @override Widget build(BuildContext context) { final appProvider = context.watch(); - return AppScaffold( - appProvider: appProvider, - appBar: const AppHeader(), - body: getBody(appProvider), - bottomNavigationBar: const AppFooter(), + log(appProvider.currentScreenRotation.toString()); + + return RotatedBox( + // quarterTurns: 3, + quarterTurns: getTurnsByOrientation(appProvider.currentScreenRotation), + child: AppScaffold( + appProvider: appProvider, + appBar: const AppHeader(), + body: getBody(appProvider, context), + bottomNavigationBar: const AppFooter(), + ), ); } - Widget dataContent({required AppProvider appProvider}) { + Widget dataContent({required AppProvider appProvider, required BuildContext context}) { // appProvider.testCalling(); - if (appProvider.patientTickets.isEmpty) { // No Patient in Queue - return noPatientInQueue(); + return noPatientInQueue(screenOrientationEnum: appProvider.currentScreenRotation); } else if (appProvider.patientTickets.length > 3) { // Return Content With Side List - return priorityTicketsWithSideList(tickets: appProvider.patientTickets, callConfig: appProvider.patientCallConfigurations); + return priorityTicketsWithSideList(tickets: appProvider.patientTickets, callConfig: appProvider.patientCallConfigurations, context: context); } else { // Return Content In Center Aligned return PriorityTickets(tickets: appProvider.patientTickets, callConfig: appProvider.patientCallConfigurations); diff --git a/lib/home/priority_calls_components.dart b/lib/home/priority_calls_components.dart index 296d6ec..fc177e1 100644 --- a/lib/home/priority_calls_components.dart +++ b/lib/home/priority_calls_components.dart @@ -1,8 +1,12 @@ +import 'dart:developer'; + import 'package:blinking_text/blinking_text.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:queuing_system/core/config/size_config.dart'; import 'package:queuing_system/core/response_models/call_config_model.dart'; import 'package:queuing_system/core/response_models/patient_ticket_model.dart'; +import 'package:queuing_system/home/app_provider.dart'; import 'package:queuing_system/utils/call_type.dart'; import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; @@ -148,12 +152,18 @@ class TicketItem extends StatelessWidget { } } -Widget noPatientInQueue() { +Widget noPatientInQueue({required ScreenOrientationEnum screenOrientationEnum}) { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Center( - child: AppText("Awaiting Patients Arrival", fontFamily: 'Poppins-SemiBold.ttf', fontSize: SizeConfig.getWidthMultiplier() * 9), + child: AppText( + "Awaiting Patients Arrival", + fontFamily: 'Poppins-SemiBold.ttf', + fontSize: (screenOrientationEnum == ScreenOrientationEnum.portraitDown || screenOrientationEnum == ScreenOrientationEnum.portraitUp) + ? SizeConfig.getWidthMultiplier() * 9 + : SizeConfig.getWidthMultiplier() * 7, + ), ), ], ); @@ -171,179 +181,183 @@ Widget qamarsBirthdayWidget() { ); } -Widget priorityTicketsWithSideList({required List tickets, required CallConfig callConfig}) { +Widget priorityTicketsWithSideList({required List tickets, required CallConfig callConfig, required BuildContext context}) { final priorityTickets = tickets.sublist(0, 3); final otherTickets = tickets.sublist(3, tickets.length); - return Row( - children: [ - Expanded(flex: 7, child: PriorityTickets(callConfig: callConfig, tickets: priorityTickets)), - Container(color: Colors.grey.withOpacity(0.1), width: 10, margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 50)), - Expanded( - flex: 6, - child: ListView( - children: [ - Padding( - padding: EdgeInsets.fromLTRB(10, SizeConfig.getHeightMultiplier() * 3.3, 10, 10), - child: Directionality( - textDirection: callConfig.textDirection, - child: Row( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Expanded( - flex: 3, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - callConfig.queueNoText, - 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() * 2, - margin: const EdgeInsets.symmetric(horizontal: 15), - ), - Expanded( - flex: 5, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - callConfig.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() * 2, - margin: const EdgeInsets.symmetric(horizontal: 15), + final AppProvider appProvider = context.watch(); + log("appProvider.currentScreenRotation: ${appProvider.currentScreenRotation}"); + + final List children = [ + Expanded(flex: 7, child: PriorityTickets(callConfig: callConfig, tickets: priorityTickets)), + Container(color: Colors.grey.withOpacity(0.1), width: 10, margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 50)), + Expanded( + flex: 6, + child: ListView( + children: [ + Padding( + padding: EdgeInsets.fromLTRB(10, SizeConfig.getHeightMultiplier() * 3.3, 10, 10), + child: Directionality( + textDirection: callConfig.textDirection, + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Expanded( + flex: 3, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AppText( + callConfig.queueNoText, + letterSpacing: -2, + fontHeight: 0.5, + fontWeight: FontWeight.bold, + fontSize: SizeConfig.getWidthMultiplier() * 3.8, + textAlign: TextAlign.center, + ), + ], ), - Expanded( - flex: 3, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - callConfig.roomText, - 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() * 2, + margin: const EdgeInsets.symmetric(horizontal: 15), + ), + Expanded( + flex: 5, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AppText( + callConfig.callForText, + letterSpacing: -2, + fontHeight: 0.5, + fontWeight: FontWeight.bold, + fontSize: SizeConfig.getWidthMultiplier() * 3.8, + textAlign: TextAlign.center, + ), + ], ), - ], - ), - ), - ), - ListView.builder( - shrinkWrap: true, - itemCount: otherTickets.length, - itemBuilder: (ctx, idx) { - final itm = otherTickets[idx]; - return Padding( - padding: const EdgeInsets.all(8), - child: Directionality( - textDirection: callConfig.textDirection, + ), + Container( + color: Colors.grey.withOpacity(0.5), + width: 5, + height: SizeConfig.getHeightMultiplier() * 2, + margin: const EdgeInsets.symmetric(horizontal: 15), + ), + Expanded( + flex: 3, child: Row( - crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.center, children: [ - Expanded( - flex: 3, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - itm.queueNo.toString(), - letterSpacing: -1, - fontHeight: 0.5, - fontWeight: FontWeight.bold, - fontSize: SizeConfig.getWidthMultiplier() * 4, - textAlign: TextAlign.center, - ), - ], - ), + AppText( + callConfig.roomText, + 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() * 2, - margin: const EdgeInsets.symmetric(horizontal: 15), + ], + ), + ), + ], + ), + ), + ), + ListView.builder( + shrinkWrap: true, + itemCount: otherTickets.length, + itemBuilder: (ctx, idx) { + final itm = otherTickets[idx]; + return Padding( + padding: const EdgeInsets.all(8), + child: Directionality( + textDirection: callConfig.textDirection, + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + flex: 3, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AppText( + itm.queueNo.toString(), + letterSpacing: -1, + fontHeight: 0.5, + fontWeight: FontWeight.bold, + fontSize: SizeConfig.getWidthMultiplier() * 4, + textAlign: TextAlign.center, + ), + ], ), - Expanded( - flex: 5, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(bottom: 10), - child: SizedBox( - width: SizeConfig.getWidthMultiplier() * 3.5, - child: itm.getCallType().icon(SizeConfig.getHeightMultiplier() * 2.5), - ), - ), - const SizedBox(width: 15), - AppText( - itm.getCallType().message(callConfig, isListView: true), - color: itm.getCallType().color(), - letterSpacing: -1, - fontSize: SizeConfig.getWidthMultiplier() * 3, - fontWeight: FontWeight.w600, - fontHeight: 0.5, + ), + Container( + color: Colors.grey.withOpacity(0.5), + width: 5, + height: SizeConfig.getHeightMultiplier() * 2, + margin: const EdgeInsets.symmetric(horizontal: 15), + ), + Expanded( + flex: 5, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 10), + child: SizedBox( + width: SizeConfig.getWidthMultiplier() * 3.5, + child: itm.getCallType().icon(SizeConfig.getHeightMultiplier() * 2.5), ), - ], - ), + ), + const SizedBox(width: 15), + AppText( + itm.getCallType().message(callConfig, isListView: true), + color: itm.getCallType().color(), + letterSpacing: -1, + fontSize: SizeConfig.getWidthMultiplier() * 3, + fontWeight: FontWeight.w600, + fontHeight: 0.5, + ), + ], ), - Container( - color: Colors.grey.withOpacity(0.5), - width: 5, - height: SizeConfig.getHeightMultiplier() * 2, - margin: const EdgeInsets.symmetric(horizontal: 15), + ), + Container( + color: Colors.grey.withOpacity(0.5), + width: 5, + height: SizeConfig.getHeightMultiplier() * 2, + margin: const EdgeInsets.symmetric(horizontal: 15), + ), + Expanded( + flex: 3, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AppText( + itm.roomNo, // callConfig.textDirection == TextDirection.ltr ? "${callConfig.roomText}: ${itm.roomNo}" : " ${itm.roomNo} ${callConfig.roomText}: ", + color: itm.getCallType().color(), + letterSpacing: -1.5, + fontSize: SizeConfig.getWidthMultiplier() * 3.3, + fontWeight: FontWeight.w600, + fontHeight: 0.5, + ), + ], ), - Expanded( - flex: 3, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - itm.roomNo, // callConfig.textDirection == TextDirection.ltr ? "${callConfig.roomText}: ${itm.roomNo}" : " ${itm.roomNo} ${callConfig.roomText}: ", - color: itm.getCallType().color(), - letterSpacing: -1.5, - fontSize: SizeConfig.getWidthMultiplier() * 3.3, - fontWeight: FontWeight.w600, - fontHeight: 0.5, - ), - ], - ), - ) - ], - ), + ) + ], ), - ); - }, - ), - ], - ), - ) - ], - ); + ), + ); + }, + ), + ], + ), + ) + ]; + return (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown) + ? Row(children: children) + : Column(children: children); } diff --git a/lib/main.dart b/lib/main.dart index eaea716..9b3b1c6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,8 @@ +import 'dart:developer'; import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:queuing_system/core/api.dart'; import 'package:queuing_system/home/app_provider.dart'; @@ -32,6 +34,13 @@ class MyApp extends StatelessWidget { builder: (context, constraints) { return OrientationBuilder(builder: (context, orientation) { SizeConfig().init(constraints, orientation); + SystemChrome.setPreferredOrientations([ + DeviceOrientation.portraitUp, + // DeviceOrientation.portraitDown, + // DeviceOrientation.landscapeLeft, + // DeviceOrientation.landscapeRight, + ]); + return MultiProvider( providers: [ ChangeNotifierProvider(create: (context) => AppProvider()), diff --git a/lib/utils/call_by_voice.dart b/lib/utils/call_by_voice.dart index 3d38af5..6448c29 100644 --- a/lib/utils/call_by_voice.dart +++ b/lib/utils/call_by_voice.dart @@ -1,4 +1,5 @@ import 'package:flutter_tts/flutter_tts.dart'; +import 'package:queuing_system/home/app_provider.dart'; class CallByVoice { final String lang; @@ -42,20 +43,27 @@ class CallByVoice { // Create Pre Voice Players if (postVoice != null && postVoice.isNotEmpty) { flutterTts.setSpeechRate(0.45); - if (lang == "ar") { - flutterTts.setPitch(1.1); - } else { + if (lang != "ar") { + await flutterTts.setLanguage(lang); flutterTts.setPitch(0.9); + flutterTts.setVolume(1.0); + isVoiceActualCompletedGlobally = true; + await flutterTts.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice); + return; } + + flutterTts.setPitch(1.1); flutterTts.setVolume(1.0); await flutterTts.setLanguage(lang); - await flutterTts.awaitSpeakCompletion(true); + isVoiceActualCompletedGlobally = false; + await flutterTts.awaitSpeakCompletion(true); // TODO : BUG HERE // await flutterTts.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice); await flutterTts.speak(preVoice + " .. "); await flutterTts.setLanguage("en"); await flutterTts.speak(clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. "); await flutterTts.setLanguage(lang); + isVoiceActualCompletedGlobally = true; await flutterTts.speak(postVoice); } diff --git a/pubspec.lock b/pubspec.lock index 17d4c9f..8ecea70 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -296,6 +296,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.0" + native_device_orientation: + dependency: "direct main" + description: + name: native_device_orientation + sha256: "744a03030fad5a332a54833cd34f1e2ee51ae9acf477b4ef85bacc8823af9937" + url: "https://pub.dev" + source: hosted + version: "1.2.1" nested: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index e3636e9..95e1a27 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,6 +47,7 @@ dependencies: signalr_core: ^1.1.1 intl: ^0.18.1 marquee: ^2.2.3 + native_device_orientation: ^1.2.1