diff --git a/android/app/build.gradle b/android/app/build.gradle index d4f4f6e..cc68d2d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -21,6 +21,7 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } + apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" @@ -44,8 +45,9 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.queuing_system" - minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger() - targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger() + minSdkVersion 24 +// minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger() + targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/android/build.gradle b/android/build.gradle index e0d1166..a1ce039 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/lib/core/api.dart b/lib/core/api.dart index 522ec06..2f7b525 100644 --- a/lib/core/api.dart +++ b/lib/core/api.dart @@ -54,9 +54,9 @@ class API { callPatients.sort((a, b) => a.editedOnTimeStamp.compareTo(b.editedOnTimeStamp)); isQueuePatients.sort((a, b) => a.editedOnTimeStamp.compareTo(b.editedOnTimeStamp)); - log("callPatients: ${callPatients.toString()}"); - log("isQueuePatients: ${isQueuePatients.toString()}"); - onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList(), callConfig); + log("callPatients: ${callPatients.toList().toString()}"); + log("isQueuePatients: ${isQueuePatients.reversed.toList().toString()}"); + onSuccess(callPatients.toList(), isQueuePatients.reversed.toList(), callConfig); } else { onFailure(apiResp); } diff --git a/lib/core/response_models/call_config_model.dart b/lib/core/response_models/call_config_model.dart index ff1e98d..d94dd8c 100644 --- a/lib/core/response_models/call_config_model.dart +++ b/lib/core/response_models/call_config_model.dart @@ -107,6 +107,7 @@ class CallConfig { screenLanguage = json['screenLanguage'] ?? 1; voiceLanguage = screenLanguage; // json['voiceLanguage'] ?? 1; screenMaxDisplayPatients = json['screenMaxDisplayPatients']; + // screenMaxDisplayPatients = 3; prioritySMS = json['prioritySMS']; priorityWhatsApp = json['priorityWhatsApp']; priorityEmail = json['priorityEmail']; diff --git a/lib/footer/app_footer.dart b/lib/footer/app_footer.dart index 16ea52e..298f2f1 100644 --- a/lib/footer/app_footer.dart +++ b/lib/footer/app_footer.dart @@ -15,7 +15,7 @@ class AppFooter extends StatelessWidget { return Consumer(builder: (BuildContext context, AppProvider appProvider, Widget? child) { return Container( color: Colors.grey.withOpacity(0.1), - height: Utils.getHeight() * 0.8, + height: Utils.getHeight() * 0.95, width: double.infinity, child: Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -37,7 +37,8 @@ class AppFooter extends StatelessWidget { fontFamily: 'Poppins-Medium.ttf', ), ), - Text(appProvider.currentDeviceIp, style: TextStyle(fontWeight: FontWeight.w500, fontSize: SizeConfig.getWidthMultiplier() * 2.2)), + Text(appProvider.currentDeviceIp, + style: TextStyle(fontWeight: FontWeight.w500, fontSize: SizeConfig.getWidthMultiplier() * 2.2)), Row( children: [ InkWell( diff --git a/lib/header/app_header.dart b/lib/header/app_header.dart index a543d9b..884aee1 100644 --- a/lib/header/app_header.dart +++ b/lib/header/app_header.dart @@ -6,7 +6,7 @@ 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'; -class AppHeader extends StatelessWidget with PreferredSizeWidget { +class AppHeader extends StatelessWidget implements PreferredSizeWidget { const AppHeader({Key? key}) : super(key: key); // Widget getWeatherWidget() { diff --git a/lib/home/app_provider.dart b/lib/home/app_provider.dart index c07dd0d..efe3a5b 100644 --- a/lib/home/app_provider.dart +++ b/lib/home/app_provider.dart @@ -33,6 +33,7 @@ class AppProvider extends ChangeNotifier { listenNetworkConnectivity(); listenAudioPlayerEvents(); getTheWidgetsConfigurationsEveryMidnight(); + // await callPatientsAPI(); } SignalRHelper signalRHelper = SignalRHelper(); @@ -163,7 +164,8 @@ class AppProvider extends ChangeNotifier { RssFeedModel currentRssFeedModel = RssFeedModel(); Future getRssFeedDetailsFromServer() async { - RssFeedModel? rssFeedModel = await API.getRssFeedDetailsFromServer(languageId: 0, onFailure: (error) => log("Api call failed with this error: ${error.toString()}")); + RssFeedModel? rssFeedModel = + await API.getRssFeedDetailsFromServer(languageId: 0, onFailure: (error) => log("Api call failed with this error: ${error.toString()}")); if (rssFeedModel != null) { currentRssFeedModel = rssFeedModel; @@ -180,7 +182,7 @@ class AppProvider extends ChangeNotifier { await getWeatherDetailsFromServer(); } if (currentWidgetsConfigModel!.isPrayerTimeReq!) { - // await getPrayerDetailsFromServer(); + await getPrayerDetailsFromServer(); } if (currentWidgetsConfigModel!.isRssFeedReq!) { await getRssFeedDetailsFromServer(); @@ -250,6 +252,7 @@ class AppProvider extends ChangeNotifier { } Future callPatientsAPI() async { + log("calling callPatientsAPI"); patientTickets.clear(); API.getCallRequestInfoByClinicInfo(currentDeviceIp, onSuccess: (waitingCalls, isQueuePatientsCalls, callConfigs) async { @@ -259,11 +262,15 @@ class AppProvider extends ChangeNotifier { } else { patientTickets = waitingCalls; } - isQueuePatients = isQueuePatientsCalls; + if (isQueuePatientsCalls.length > patientCallConfigurations.screenMaxDisplayPatients) { + isQueuePatients = isQueuePatientsCalls.sublist(0, patientCallConfigurations.screenMaxDisplayPatients); + } else { + isQueuePatients = isQueuePatientsCalls; + } notifyListeners(); if (patientTickets.isNotEmpty) { updateCurrentScreenRotation(patientTickets.first.screenRotationEnum); - voiceCallPatientTicket(patientTickets.first); + voiceCallPatientTicket(patientTickets.first, "callPatientsAPI"); updatePatientTicket(patientTickets.first); } }, @@ -271,7 +278,8 @@ class AppProvider extends ChangeNotifier { } onPingReceived(data) async { - log("isCallingInProgress: $isCallingInProgress"); + log("A new Ping Received"); + log("isCallingInProgress from onPingReceived: $isCallingInProgress"); log("isApiCallNeeded: $isApiCallNeeded"); if (patientTickets.isNotEmpty) { if (isCallingInProgress) { @@ -316,15 +324,22 @@ class AppProvider extends ChangeNotifier { // await voiceCaller!.startCalling(true); // } - voiceCallPatientTicket(PatientTicketModel patientTicket) async { + voiceCallPatientTicket(PatientTicketModel patientTicket, String calledFrom) async { + log("voiceCallPatientTicket calledFrom : $calledFrom"); + currentPatient = patientTicket; isCallingInProgress = true; log("Setting isCallingInProgress : $isCallingInProgress"); + log("isVoiceReq: ${patientTicket.isVoiceReq}"); + log("voiceCaller: ${voiceCaller == null}"); + log("isQueue: ${patientTicket.isQueue}"); + log("isToneReq: ${patientTicket.isToneReq}"); + if (patientTicket.isToneReq && !patientTicket.isQueue) { audioPlayer.setAsset("assets/tones/call_tone.mp3"); await audioPlayer.play(); - await Future.delayed(const Duration(seconds: 3)); + Future.delayed(const Duration(seconds: 3)); } if (patientTicket.isVoiceReq && voiceCaller == null && !patientTicket.isQueue) { @@ -337,13 +352,16 @@ class AppProvider extends ChangeNotifier { lang: patientTicket.voiceLanguage == 1 ? "en" : "ar", flutterTts: flutterTts, ); - await voiceCaller!.startCalling(patientTicket.queueNo.trim().toString() != patientTicket.callNoStr.trim().toString()); - voiceCaller = null; - if (isQueuePatients.isNotEmpty) { - isQueuePatients.removeAt(0); - } + voiceCaller!.startCalling(patientTicket.queueNo.trim().toString() != patientTicket.callNoStr.trim().toString()).whenComplete(() { + voiceCaller = null; + // if (isQueuePatients.isNotEmpty) { + // isQueuePatients.removeAt(0); + // } + }); } else { isCallingInProgress = false; + log("Setting isCallingInProgress : $isCallingInProgress"); + if (isApiCallNeeded) { Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { await callPatientsAPI(); @@ -362,6 +380,7 @@ class AppProvider extends ChangeNotifier { } if (isQueuePatients.isNotEmpty) { + log("i am here on line 375"); final length = isQueuePatients.length; for (int i = 0; i < length; i++) { await Future.delayed(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec)).whenComplete(() async { @@ -374,12 +393,14 @@ class AppProvider extends ChangeNotifier { isQueuePatients.removeAt(0); patientTickets.add(temp); notifyListeners(); - await voiceCallPatientTicket(patientTickets.first); + await voiceCallPatientTicket(patientTickets.first, "listenAudioPlayerEvents"); updatePatientTicket(patientTickets.first); }); } } isCallingInProgress = false; + log("Setting isCallingInProgress : $isCallingInProgress"); + if (isApiCallNeeded) { Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { await callPatientsAPI(); @@ -391,26 +412,33 @@ class AppProvider extends ChangeNotifier { flutterTts.setCompletionHandler(() async { log("My Value is in setCompletionHandler: $isVoiceActualCompletedGlobally"); - if (!isVoiceActualCompletedGlobally) {} + log("isQueuePatients.length in setCompletionHandler: ${isQueuePatients.length}"); + if (!isVoiceActualCompletedGlobally) { + return; + } if (isQueuePatients.isNotEmpty) { - final length = isQueuePatients.length; - for (int i = 0; i < length; i++) { - await Future.delayed(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec)).whenComplete(() async { - PatientTicketModel temp = PatientTicketModel(); - if (patientTickets.isNotEmpty) { - temp = patientTickets.elementAt(0); - patientTickets.removeAt(0); - } - notifyListeners(); + // final length = isQueuePatients.length; + // for (int i = 0; i < length; i++) { + await Future.delayed(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec)).whenComplete(() async { + PatientTicketModel temp = PatientTicketModel(); + if (patientTickets.isNotEmpty) { + temp = patientTickets.elementAt(0); + patientTickets.removeAt(0); + } + notifyListeners(); + if (isQueuePatients.isNotEmpty) { isQueuePatients.removeAt(0); - patientTickets.add(temp); - notifyListeners(); - await voiceCallPatientTicket(patientTickets.first); - updatePatientTicket(patientTickets.first); - }); - } + } + patientTickets.add(temp); + notifyListeners(); + await voiceCallPatientTicket(patientTickets.first, "setCompletionHandler"); + updatePatientTicket(patientTickets.first); + }); + // } } isCallingInProgress = false; + log("Setting isCallingInProgress : $isCallingInProgress"); + if (isApiCallNeeded) { Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { await callPatientsAPI(); @@ -447,7 +475,8 @@ class AppProvider extends ChangeNotifier { onDisconnect(exception) { log("SignalR: onDisconnect"); - signalRHelper.startSignalRConnection(currentDeviceIp, onUpdateAvailable: onPingReceived, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect); + signalRHelper.startSignalRConnection(currentDeviceIp, + onUpdateAvailable: onPingReceived, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect); } onConnecting() { diff --git a/lib/home/home_screen.dart b/lib/home/home_screen.dart index b45f8cf..a045b01 100644 --- a/lib/home/home_screen.dart +++ b/lib/home/home_screen.dart @@ -18,11 +18,14 @@ class MyHomePage extends StatelessWidget { getWeatherWidget() { return Consumer(builder: (BuildContext context, AppProvider appProvider, Widget? child) { - if (appProvider.currentWeathersWidgetModel.maxTemp == null || appProvider.currentWeathersWidgetModel.minTemp == null || appProvider.currentWeathersWidgetModel.iconPhrase == null) { + if (appProvider.currentWeathersWidgetModel.maxTemp == null || + appProvider.currentWeathersWidgetModel.minTemp == null || + appProvider.currentWeathersWidgetModel.iconPhrase == null) { return const SizedBox.shrink(); } return Container( - height: (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown) + height: (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || + appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown) ? SizeConfig.getHeightMultiplier() * 8 : SizeConfig.getHeightMultiplier() * 5, padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), @@ -66,7 +69,8 @@ class MyHomePage extends StatelessWidget { return const SizedBox.shrink(); } return Container( - height: (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown) + height: (appProvider.currentScreenRotation == ScreenOrientationEnum.portraitUp || + appProvider.currentScreenRotation == ScreenOrientationEnum.portraitDown) ? SizeConfig.getHeightMultiplier() * 8 : SizeConfig.getHeightMultiplier() * 5, padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), @@ -149,8 +153,8 @@ class MyHomePage extends StatelessWidget { log(appProvider.currentScreenRotation.toString()); return RotatedBox( - // quarterTurns: 3, - quarterTurns: getTurnsByOrientation(appProvider.currentScreenRotation), + quarterTurns: 3, + // quarterTurns: getTurnsByOrientation(appProvider.currentScreenRotation), child: AppScaffold( appProvider: appProvider, appBar: const AppHeader(), @@ -161,7 +165,7 @@ class MyHomePage extends StatelessWidget { } Widget dataContent({required AppProvider appProvider, required BuildContext context}) { - log("isCallingInProgress: ${appProvider.isCallingInProgress}"); + log("isCallingInProgress from HomeScreen: ${appProvider.isCallingInProgress}"); // appProvider.voiceCallPatientTicket(appProvider.patientTickets.first); // appProvider.testCalling(); if (appProvider.patientTickets.isEmpty) { diff --git a/pubspec.yaml b/pubspec.yaml index e3636e9..5bb2439 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,7 +35,7 @@ dependencies: provider: ^6.0.1 get_it: ^7.1.3 connectivity: ^3.0.6 - flutter_gifimage: ^1.0.1 +# flutter_gifimage: ^1.0.1 flutter_svg: ^1.0.3 http: ^0.13.0 blinking_text: ^1.0.2