From 0027f88df579c4916c55f884974285e3344b1d34 Mon Sep 17 00:00:00 2001 From: FaizHashmiCS22 Date: Tue, 26 Sep 2023 18:55:20 +0300 Subject: [PATCH] Structure Update --- android/build.gradle | 4 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- lib/core/api.dart | 40 ++- lib/core/response_models/call_config.dart | 112 ------- .../response_models/call_config_model.dart | 155 +++++++++ ...nt_call.dart => patient_ticket_model.dart} | 42 ++- lib/home/app_provider.dart | 178 +++++----- lib/home/home_screen.dart | 5 +- lib/home/priority_calls_components.dart | 303 ++++++++++++------ lib/utils/call_by_voice.dart | 31 +- lib/utils/call_type.dart | 19 +- lib/widget/data_display/app_texts_widget.dart | 116 ++----- 12 files changed, 570 insertions(+), 437 deletions(-) delete mode 100644 lib/core/response_models/call_config.dart create mode 100644 lib/core/response_models/call_config_model.dart rename lib/core/response_models/{patient_call.dart => patient_ticket_model.dart} (83%) diff --git a/android/build.gradle b/android/build.gradle index 9e8dea7..e0d1166 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.6.0' + ext.kotlin_version = '1.9.10' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.android.tools.build:gradle:7.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index bc6a58a..c021028 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip +distributionUrl=https://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/lib/core/api.dart b/lib/core/api.dart index 3f5cd7c..1c1abb5 100644 --- a/lib/core/api.dart +++ b/lib/core/api.dart @@ -3,8 +3,8 @@ import 'dart:io'; import 'package:queuing_system/core/base/base_app_client.dart'; import 'package:queuing_system/core/config/config.dart'; -import 'package:queuing_system/core/response_models/call_config.dart'; -import 'package:queuing_system/core/response_models/patient_call.dart'; +import 'package:queuing_system/core/response_models/call_config_model.dart'; +import 'package:queuing_system/core/response_models/patient_ticket_model.dart'; const _getCallRequestInfoByClinicInfo = "/GetCallRequestInfo_ByIP"; const _callUpdateNotIsQueueRecordByIDAsync = "/CallRequest_QueueUpdate"; @@ -16,16 +16,16 @@ class MyHttpOverrides extends HttpOverrides { } } -bool isDevMode = true; - class API { - static getCallRequestInfoByClinicInfo(String deviceIp, {required Function(List, List, CallConfig callConfig) onSuccess, required Function(dynamic) onFailure}) async { + 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; if (isDevMode) { - var callPatients = Tickets.testCallPatients; - var isQueuePatients = callPatients.where((element) => (element.callType == 1 && element.isQueue == false) || (element.callType == 2 && element.isQueue == false)).toList(); - CallConfig callConfig = CallConfig(); + var callPatients = PatientTicketModel.testCallPatients; + CallConfig callConfig = CallConfig.testCallConfig; + + var isQueuePatients = callPatients.where((element) => (element.isQueue == false)).toList(); onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList(), callConfig); return; } @@ -36,18 +36,14 @@ class API { final response = apiResp["data"]; CallConfig callConfig = CallConfig.fromJson(response["callConfig"]); - var callPatients = (response["callPatients"] as List).map((j) => Tickets.fromJson(j)).toList(); - // final patients = (response["drCallPatients"] as List).map((j) => Tickets.fromJson(j)).toList(); - // callPatients.addAll(patients); - // log("callPatients: ${callPatients.toString()} "); - // log("patients: ${patients.toString()} "); - - var isQueuePatients = callPatients.where((element) => (element.callType == 1 && element.isQueue == false) || (element.callType == 2 && element.isQueue == false)).toList(); - // callPatients.removeWhere((element) => (element.callType == 1 && element.isQueueNurse == false) || (element.callType == 2 && element.isQueueDr == false)); - callPatients.sort((a, b) => a.editedOnTimeStamp!.compareTo(b.editedOnTimeStamp!)); + var callPatients = (response["callPatients"] as List).map((j) => PatientTicketModel.fromJson(j)).toList().where((element) => element.callType != 0).toList(); - // callPatients.addAll(isQueuePatients.toList()); + var isQueuePatients = callPatients.where((element) => (element.isQueue == false && element.callType != 0)).toList(); + 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); } else { onFailure(apiResp); @@ -58,11 +54,11 @@ class API { static callUpdateNotIsQueueRecordByIDAsync( String deviceIp, { - required Tickets ticket, - required Function(List) onSuccess, + required PatientTicketModel ticket, + required Function(List) onSuccess, required Function(dynamic) onFailure, }) async { - List _ticketsUpdated = []; + List _ticketsUpdated = []; // for (var ticket in tickets) { final body = {"id": ticket.id, "apiKey": apiKey, "ipAddress": deviceIp, "callType": ticket.callType}; diff --git a/lib/core/response_models/call_config.dart b/lib/core/response_models/call_config.dart deleted file mode 100644 index 5fdde42..0000000 --- a/lib/core/response_models/call_config.dart +++ /dev/null @@ -1,112 +0,0 @@ -class CallConfig { - late int id; - late bool globalClinicPrefixReq; - late bool clinicPrefixReq; - late int concurrentCallDelaySec; - late int voiceType; - late int screenLanguage; - late int voiceLanguage; - late int screenMaxDisplayPatients; - late int prioritySMS; - late int priorityWhatsApp; - late int priorityEmail; - late String vitalSignText; - late String vitalSignTextN; - late String doctorText; - late String doctorTextN; - late String procedureText; - late String procedureTextN; - late String vaccinationText; - late String vaccinationTextN; - late String nebulizationText; - late String nebulizationTextN; - late int createdBy; - late String createdOn; - late int editedBy; - late String editedOn; - - CallConfig( - {this.id = 0, - this.globalClinicPrefixReq = false, - this.clinicPrefixReq = false, - this.concurrentCallDelaySec = 8, - this.voiceType = 0, - this.screenLanguage = 1, - this.voiceLanguage = 1, - this.screenMaxDisplayPatients = 5, - this.prioritySMS = 1, - this.priorityWhatsApp = 1, - this.priorityEmail = 1, - this.vitalSignText = "", - this.vitalSignTextN = "", - this.doctorText = "", - this.doctorTextN = "", - this.procedureText = "", - this.procedureTextN = "", - this.vaccinationText = "", - this.vaccinationTextN = "", - this.nebulizationText = "", - this.nebulizationTextN = "", - this.createdBy = 0, - this.createdOn = "", - this.editedBy = 0, - this.editedOn = ""}); - - CallConfig.fromJson(Map json) { - id = json['id']; - globalClinicPrefixReq = json['globalClinicPrefixReq']; - clinicPrefixReq = json['clinicPrefixReq']; - concurrentCallDelaySec = json['concurrentCallDelaySec']; - voiceType = json['voiceType']; - screenLanguage = json['screenLanguage'] ?? 1; - voiceLanguage = json['voiceLanguage']; - screenMaxDisplayPatients = json['screenMaxDisplayPatients']; - prioritySMS = json['prioritySMS']; - priorityWhatsApp = json['priorityWhatsApp']; - priorityEmail = json['priorityEmail']; - vitalSignText = json['vitalSignText']; - vitalSignTextN = json['vitalSignTextN']; - doctorText = json['doctorText']; - doctorTextN = json['doctorTextN']; - procedureText = json['procedureText']; - procedureTextN = json['procedureTextN']; - vaccinationText = json['vaccinationText']; - vaccinationTextN = json['vaccinationTextN']; - nebulizationText = json['nebulizationText']; - nebulizationTextN = json['nebulizationTextN']; - createdBy = json['createdBy']; - createdOn = json['createdOn']; - editedBy = json['editedBy']; - editedOn = json['editedOn']; - } - - Map toJson() { - final Map data = {}; - data['id'] = id; - data['globalClinicPrefixReq'] = globalClinicPrefixReq; - data['clinicPrefixReq'] = clinicPrefixReq; - data['concurrentCallDelaySec'] = concurrentCallDelaySec; - data['voiceType'] = voiceType; - data['screenLanguage'] = screenLanguage; - data['voiceLanguage'] = voiceLanguage; - data['screenMaxDisplayPatients'] = screenMaxDisplayPatients; - data['prioritySMS'] = prioritySMS; - data['priorityWhatsApp'] = priorityWhatsApp; - data['priorityEmail'] = priorityEmail; - data['vitalSignText'] = vitalSignText; - data['vitalSignTextN'] = vitalSignTextN; - data['doctorText'] = doctorText; - data['doctorTextN'] = doctorTextN; - data['procedureText'] = procedureText; - data['procedureTextN'] = procedureTextN; - data['vaccinationText'] = vaccinationText; - data['vaccinationTextN'] = vaccinationTextN; - data['nebulizationText'] = nebulizationText; - data['nebulizationTextN'] = nebulizationTextN; - data['createdBy'] = createdBy; - data['createdOn'] = createdOn; - data['editedBy'] = editedBy; - data['editedOn'] = editedOn; - return data; - } -} diff --git a/lib/core/response_models/call_config_model.dart b/lib/core/response_models/call_config_model.dart new file mode 100644 index 0000000..4e24681 --- /dev/null +++ b/lib/core/response_models/call_config_model.dart @@ -0,0 +1,155 @@ +import 'dart:ui'; + +var data = { + "roomText": "غرفة", + "queueNoText": "رقم قائمة الانتظار", + "callForText": "يدعو إلى", + "currentServeText": "العرض الحالي", + "callTypeVitalSignText": "علامة حيوية", + "callTypeDoctorText": "طبيب", + "callTypeProcedureText": "إجراء", + "callTypeVaccinationText": "تلقيح", + "callTypeNebulizationText": "الإرذاذ", +}; + +class CallConfig { + late int id; + late bool globalClinicPrefixReq; + late bool clinicPrefixReq; + late int concurrentCallDelaySec; + late int voiceType; + late int screenLanguage; + late int voiceLanguage; + late int screenMaxDisplayPatients; + late int prioritySMS; + late int priorityWhatsApp; + late int priorityEmail; + late String vitalSignText; + late String doctorText; + late String procedureText; + late String vaccinationText; + late String nebulizationText; + late int createdBy; + late String createdOn; + late int editedBy; + late String editedOn; + late String roomText; + late String queueNoText; + late String callForText; + late String currentServeText; + late String callTypeVitalSignText; + late String callTypeDoctorText; + late String callTypeProcedureText; + late String callTypeVaccinationText; + late String callTypeNebulizationText; + late TextDirection textDirection; + + CallConfig({ + this.id = 0, + this.globalClinicPrefixReq = false, + this.clinicPrefixReq = false, + this.concurrentCallDelaySec = 8, + this.voiceType = 0, + this.screenLanguage = 1, + this.voiceLanguage = 1, + this.screenMaxDisplayPatients = 5, + this.prioritySMS = 1, + this.priorityWhatsApp = 1, + this.priorityEmail = 1, + this.vitalSignText = "", + this.doctorText = "", + this.procedureText = "", + this.vaccinationText = "", + this.nebulizationText = "", + this.createdBy = 0, + this.createdOn = "", + this.editedBy = 0, + this.editedOn = "", + this.roomText = "", + this.queueNoText = "", + this.callForText = "", + this.currentServeText = "", + this.callTypeVitalSignText = "", + this.callTypeDoctorText = "", + this.callTypeProcedureText = "", + this.callTypeVaccinationText = "", + this.callTypeNebulizationText = "", + this.textDirection = TextDirection.ltr, + }); + + CallConfig.fromJson(Map json) { + id = json['id']; + globalClinicPrefixReq = json['globalClinicPrefixReq']; + clinicPrefixReq = json['clinicPrefixReq']; + concurrentCallDelaySec = json['concurrentCallDelaySec']; + voiceType = json['voiceType']; + screenLanguage = json['screenLanguage'] ?? 1; + voiceLanguage = json['voiceLanguage']; + screenMaxDisplayPatients = json['screenMaxDisplayPatients']; + prioritySMS = json['prioritySMS']; + priorityWhatsApp = json['priorityWhatsApp']; + priorityEmail = json['priorityEmail']; + vitalSignText = json['vitalSignText']; + doctorText = json['doctorText']; + procedureText = json['procedureText']; + vaccinationText = json['vaccinationText']; + nebulizationText = json['nebulizationText']; + createdBy = json['createdBy']; + createdOn = json['createdOn']; + editedBy = json['editedBy']; + editedOn = json['editedOn']; + roomText = json['roomText']; + queueNoText = json['queueNoText']; + callForText = json['callForText']; + currentServeText = json['currentServeText']; + callTypeVitalSignText = json['callTypeVitalSignText']; + callTypeVitalSignText = json['callTypeVitalSignText']; + callTypeDoctorText = json['callTypeDoctorText']; + callTypeProcedureText = json['callTypeProcedureText']; + callTypeVaccinationText = json['callTypeVaccinationText']; + callTypeNebulizationText = json['callTypeNebulizationText']; + // textDirection = json['textDirection'] == 2 ? TextDirection.rtl : TextDirection.ltr; + textDirection = TextDirection.ltr; + } + + static var data = { + "id": 1, + "globalClinicPrefixReq": true, + "clinicPrefixReq": true, + "concurrentCallDelaySec": 2, + "voiceType": 2, + "voiceTypeText": "Female", + "screenLanguage": 1, + "screenLanguageText": "English", + "voiceLanguage": 1, + "voiceLanguageText": "English", + "screenMaxDisplayPatients": 3, + "isNotiReq": true, + "prioritySMS": 2, + "priorityWhatsApp": 3, + "priorityEmail": 1, + "textDirection": 2, + "vitalSignText": "Call For VitalSign", + "doctorText": "دعوة للحصول على علامة حيوية", + // "doctorText": "Call For Doctor", + "procedureText": "Call For Procedure", + "vaccinationText": "Call For Vaccination", + "nebulizationText": "Call For Nebulization", + "roomText": "غرفة", + // "roomText": "Room", + "queueNoText": "رقم الانتظار", + "callForText": "يدعو إلى", + "currentServeText": "Current Serving", + "callTypeVitalSignText": "علامة حيوية", + "callTypeDoctorText": "طبيب", + "callTypeProcedureText": "إجراء", + "callTypeVaccinationText": "تلقيح", + "callTypeNebulizationText": "الإرذاذ", + "createdBy": 101, + "createdOn": "2023-08-08T00:00:00", + "editedBy": 101, + "editedOn": "2023-09-26T16:30:41.92" + }; + + static CallConfig testCallConfig = CallConfig.fromJson(data); +} diff --git a/lib/core/response_models/patient_call.dart b/lib/core/response_models/patient_ticket_model.dart similarity index 83% rename from lib/core/response_models/patient_call.dart rename to lib/core/response_models/patient_ticket_model.dart index 74dbbf3..c7676ca 100644 --- a/lib/core/response_models/patient_call.dart +++ b/lib/core/response_models/patient_ticket_model.dart @@ -2,7 +2,7 @@ import 'dart:math'; import 'package:queuing_system/utils/call_type.dart'; -class Tickets { +class PatientTicketModel { late int id; late int patientID; late String mobileNo; @@ -22,7 +22,7 @@ class Tickets { late bool isVoiceReq; late bool callUpdated = false; - Tickets( + PatientTicketModel( {this.id = 0, this.patientID = 0, this.mobileNo = "", @@ -45,13 +45,13 @@ class Tickets { return Random().nextInt(9); } - Tickets.fromJson(Map json) { + PatientTicketModel.fromJson(Map json) { id = json['id']; patientID = json['patientID']; - mobileNo = json['mobileNo']; - doctorName = json['doctorName']; - doctorNameN = json['doctorNameN']; - patientGender = json['patientGender']; + mobileNo = json['mobileNo'] ?? ""; + doctorName = json['doctorName'] ?? ""; + doctorNameN = json['doctorNameN'] ?? ""; + patientGender = json['patientGender'] ?? ""; callType = json['callType']; editedOnTimeStamp = DateTime.parse(json['editedOn']).millisecondsSinceEpoch; roomNo = json['roomNo']; @@ -100,8 +100,8 @@ class Tickets { return CallType.vitalSign; } - static List testCallPatients = [ - Tickets( + static List testCallPatients = [ + PatientTicketModel( id: 1, patientID: 112, mobileNo: "112", @@ -120,7 +120,7 @@ class Tickets { isVoiceReq: true, concurrentCallDelaySec: 8, ), - Tickets( + PatientTicketModel( id: 1, patientID: 112, mobileNo: "112", @@ -138,7 +138,7 @@ class Tickets { isVoiceReq: true, concurrentCallDelaySec: 8, ), - Tickets( + PatientTicketModel( id: 1, patientID: 112, mobileNo: "112", @@ -156,7 +156,25 @@ class Tickets { isVoiceReq: true, concurrentCallDelaySec: 8, ), - Tickets( + 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", diff --git a/lib/home/app_provider.dart b/lib/home/app_provider.dart index 55d1840..1868f48 100644 --- a/lib/home/app_provider.dart +++ b/lib/home/app_provider.dart @@ -4,10 +4,11 @@ import 'dart:io'; import 'package:connectivity/connectivity.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter_tts/flutter_tts.dart'; import 'package:just_audio/just_audio.dart'; import 'package:queuing_system/core/api.dart'; -import 'package:queuing_system/core/response_models/call_config.dart'; -import 'package:queuing_system/core/response_models/patient_call.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/utils/call_by_voice.dart'; import 'package:queuing_system/utils/call_type.dart'; import 'package:queuing_system/utils/signalR_utils.dart'; @@ -16,19 +17,22 @@ class AppProvider extends ChangeNotifier { AppProvider() { startSignalHubConnection(); listenNetworkConnectivity(); + listenAudioPlayerEvents(); } SignalRHelper signalRHelper = SignalRHelper(); final AudioPlayer audioPlayer = AudioPlayer(); + FlutterTts flutterTts = FlutterTts(); CallConfig patientCallConfigurations = CallConfig(); - List patientTickets = []; - List isQueuePatients = []; + List patientTickets = []; + List isQueuePatients = []; String currentDeviceIp = ""; bool isCallingInProgress = false; bool isInternetConnectionAvailable = true; + bool isApiCallNeeded = false; updateInternetConnection(bool value) { isInternetConnectionAvailable = value; @@ -55,13 +59,19 @@ class AppProvider extends ChangeNotifier { Future startSignalHubConnection() async { if (!signalRHelper.getConnectionState()) { - signalRHelper.startSignalRConnection(currentDeviceIp, onUpdateAvailable: onPingReceived, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect); + await getCurrentIP().whenComplete(() => signalRHelper.startSignalRConnection( + currentDeviceIp, + onUpdateAvailable: onPingReceived, + onConnect: onConnect, + onConnecting: onConnecting, + onDisconnect: onDisconnect, + )); } } Future callPatientsAPI() async { patientTickets.clear(); - API.getCallRequestInfoByClinicInfo(currentDeviceIp, onSuccess: (waitingCalls, isQueuePatientsCalls, callConfigs) { + API.getCallRequestInfoByClinicInfo(currentDeviceIp, onSuccess: (waitingCalls, isQueuePatientsCalls, callConfigs) async { patientCallConfigurations = callConfigs; if (waitingCalls.length > patientCallConfigurations.screenMaxDisplayPatients) { patientTickets = waitingCalls.sublist(0, patientCallConfigurations.screenMaxDisplayPatients); @@ -70,17 +80,21 @@ class AppProvider extends ChangeNotifier { } isQueuePatients = isQueuePatientsCalls; notifyListeners(); + if (patientTickets.isNotEmpty) { + voiceCallPatientTicket(patientTickets.first); + updatePatientTicketByIndex(patientTickets.first); + } }, onFailure: (error) { log("Api call failed with this error: ${error.toString()}"); }); } onPingReceived(data) async { + log("isCallingInProgress: $isCallingInProgress"); + log("isApiCallNeeded: $isApiCallNeeded"); if (patientTickets.isNotEmpty) { - if ((patientTickets.first.isToneReq && isCallingInProgress) || (patientTickets.first.isVoiceReq && voiceCaller != null)) { - Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { - await callPatientsAPI(); - }); + if (isCallingInProgress) { + isApiCallNeeded = true; } else { await callPatientsAPI(); } @@ -89,7 +103,7 @@ class AppProvider extends ChangeNotifier { } } - String getCallTypeText(Tickets ticket, CallConfig callConfig) { + String getCallTypeText(PatientTicketModel ticket, CallConfig callConfig) { final callType = ticket.getCallType(); switch (callType) { case CallType.vitalSign: @@ -109,85 +123,99 @@ class AppProvider extends ChangeNotifier { CallByVoice? voiceCaller; - callPatientTicket(AudioPlayer audioPlayer) async { + voiceCallPatientTicket(PatientTicketModel patientTicket) async { isCallingInProgress = true; - if (patientTickets.isNotEmpty) { - if (patientTickets.first.isToneReq && !patientTickets.first.isQueue) { - audioPlayer.setAsset("assets/tones/call_tone.mp3"); - await audioPlayer.play(); - await Future.delayed(const Duration(seconds: 2)); - isCallingInProgress = false; - } - if (patientTickets.first.isVoiceReq && voiceCaller == null && !patientTickets.first.isQueue) { - final postVoice = getCallTypeText(patientTickets.first, patientCallConfigurations); - voiceCaller = CallByVoice(preVoice: "Ticket Number", ticketNo: patientTickets.first.queueNo.trim().toString(), postVoice: postVoice, lang: 'en'); - await voiceCaller!.startCalling(patientTickets.first.queueNo.trim().toString() != patientTickets.first.callNoStr.trim().toString()); - voiceCaller = null; - isCallingInProgress = false; - } + log("Setting isCallingInProgress : $isCallingInProgress"); + + if (patientTicket.isToneReq && !patientTicket.isQueue) { + audioPlayer.setAsset("assets/tones/call_tone.mp3"); + await audioPlayer.play(); + await Future.delayed(const Duration(seconds: 3)); } - if (isQueuePatients.isNotEmpty) { - await Future.delayed(Duration(seconds: isQueuePatients.first.concurrentCallDelaySec)).whenComplete(() async { - if (isQueuePatients.isNotEmpty) { - isQueuePatients.removeAt(0); - } - if (patientTickets.isNotEmpty) { - // Tickets ticket = patientTickets.elementAt(0); - // patientTickets.removeAt(0); - // patientTickets.add(ticket); - } - if (isQueuePatients.isNotEmpty) { - // setState(() {}); - } - }); + if (patientTicket.isVoiceReq && voiceCaller == null && !patientTicket.isQueue) { + final postVoice = getCallTypeText(patientTicket, patientCallConfigurations); + voiceCaller = CallByVoice(preVoice: "Ticket Number", ticketNo: patientTicket.queueNo.trim().toString(), postVoice: postVoice, lang: 'en', flutterTts: flutterTts); + await voiceCaller!.startCalling(patientTicket.queueNo.trim().toString() != patientTicket.callNoStr.trim().toString()); + voiceCaller = null; + if (isQueuePatients.isNotEmpty) { + isQueuePatients.removeAt(0); + } } else { - // if (isQueuePatients.isEmpty && callFlag == 1) { - // callFlag == 0; - // await Future.delayed(const Duration(seconds: 3)); - // patientTickets.clear(); - // API.getCallRequestInfoByClinicInfo(DEVICE_IP, onSuccess: (waitingCalls, isQueuePatientsCalls) { - // setState(() { - // patientTickets = waitingCalls; - // isQueuePatients = isQueuePatientsCalls; - // // currents = currentInClinic; - // }); - // - // log("--------------------"); - // log("waiting: $patientTickets"); - // log("isQueuePatients: $isQueuePatients"); - // log("--------------------"); - // - // updateTickets(); - // }, onFailure: (error) {}); - // } + isCallingInProgress = false; + log("Setting isCallingInProgress : $isCallingInProgress"); + + if (isApiCallNeeded) { + log("I will start waiting!!"); + Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { + await callPatientsAPI(); + log("Called the API after waiting!"); + isApiCallNeeded = false; + }); + } } } Future listenAudioPlayerEvents() async { audioPlayer.playerStateStream.listen((playerState) { if (playerState.processingState == ProcessingState.completed) { - isCallingInProgress = false; + // isCallingInProgress = false; } }); - } - updatePatientTickets() { - if (patientTickets.isNotEmpty) { - List _ticketsToUpdate = patientTickets.where((t) => t.callUpdated == false).toList(); - API.callUpdateNotIsQueueRecordByIDAsync(currentDeviceIp, ticket: _ticketsToUpdate.first, onSuccess: (ticketsUpdated) { - log("[${ticketsUpdated.length}] Tickets Updated: $ticketsUpdated"); - }, onFailure: (e) { - log(" Tickets Update Failed with : ${e.toString()}"); - }); - } + flutterTts.setStartHandler(() { + // isCallingInProgress = true; + }); + + flutterTts.setCompletionHandler(() async { + if (isQueuePatients.isNotEmpty) { + log("isQueuePatients length : ${isQueuePatients.length}"); + 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(); + isQueuePatients.removeAt(0); + patientTickets.add(temp); + notifyListeners(); + await voiceCallPatientTicket(patientTickets.first); + }); + } + } + isCallingInProgress = false; + log("Setting isCallingInProgress : $isCallingInProgress"); + if (isApiCallNeeded) { + log("I will start waiting!!"); + Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { + await callPatientsAPI(); + log("Called the API after waiting!"); + isApiCallNeeded = false; + }); + } + }); } - updatePatientTicketByIndex(int index) { - if (patientTickets.isNotEmpty) { - API.callUpdateNotIsQueueRecordByIDAsync(currentDeviceIp, ticket: patientTickets.elementAt(index), onSuccess: (ticketsUpdated) { - log("[${patientTickets.elementAt(index).callNoStr}] Ticket Updated: $ticketsUpdated"); + // updatePatientTickets() { + // if (patientTickets.isNotEmpty) { + // List _ticketsToUpdate = patientTickets.where((t) => t.callUpdated == false).toList(); + // API.callUpdateNotIsQueueRecordByIDAsync(currentDeviceIp, ticket: _ticketsToUpdate.first, onSuccess: (ticketsUpdated) { + // log("[${ticketsUpdated.length}] Tickets Updated: $ticketsUpdated"); + // }, onFailure: (e) { + // log(" Tickets Update Failed with : ${e.toString()}"); + // }); + // } + // } + + updatePatientTicketByIndex(PatientTicketModel patientTicket) { + return; + if (!patientTicket.isQueue) { + API.callUpdateNotIsQueueRecordByIDAsync(currentDeviceIp, ticket: patientTicket, onSuccess: (ticketsUpdated) { + log("[${patientTicket.callNoStr}] Ticket Updated: $ticketsUpdated"); }, onFailure: (e) { - log(" Tickets Update ${patientTickets.elementAt(index).callNoStr} Failed with Error : ${e.toString()}"); + log(" Tickets Update ${patientTicket.callNoStr} Failed with Error : ${e.toString()}"); }); } } diff --git a/lib/home/home_screen.dart b/lib/home/home_screen.dart index 6fe743a..61bab0f 100644 --- a/lib/home/home_screen.dart +++ b/lib/home/home_screen.dart @@ -33,7 +33,9 @@ class MyHomePage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ InkWell( - onTap: () {}, + onTap: () async { + await context.read().callPatientsAPI(); + }, child: AppText( "Powered By", fontSize: SizeConfig.getWidthMultiplier() * 2.6, @@ -57,6 +59,7 @@ class MyHomePage extends StatelessWidget { } Widget dataContent({required AppProvider appProvider}) { + // appProvider.voiceCallPatientTicket(appProvider.patientTickets.first); if (appProvider.patientTickets.isEmpty) { // No Patient in Queue return noPatientInQueue(); diff --git a/lib/home/priority_calls_components.dart b/lib/home/priority_calls_components.dart index dbb5181..e84244d 100644 --- a/lib/home/priority_calls_components.dart +++ b/lib/home/priority_calls_components.dart @@ -1,13 +1,13 @@ import 'package:blinking_text/blinking_text.dart'; import 'package:flutter/material.dart'; import 'package:queuing_system/core/config/size_config.dart'; -import 'package:queuing_system/core/response_models/call_config.dart'; -import 'package:queuing_system/core/response_models/patient_call.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/utils/call_type.dart'; import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; class PriorityTickets extends StatelessWidget { - final List tickets; + final List tickets; final CallConfig callConfig; const PriorityTickets({required this.tickets, required this.callConfig, Key? key}) : super(key: key); @@ -21,19 +21,19 @@ class PriorityTickets extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - const SizedBox(height: 20), + const SizedBox(height: 50), TicketItem( ticketNo: firstTicket.queueNo ?? '', callType: firstTicket.getCallType(), - scale: 1, + scale: 1.2, blink: true, roomNo: firstTicket.roomNo, isClinicAdded: firstTicket.callNoStr != firstTicket.queueNo, callConfig: callConfig, ), - const SizedBox(height: 40), + const SizedBox(height: 50), if (tickets.length > 1) ...[ - SizedBox(height: SizeConfig.getHeightMultiplier() * 1.5), + SizedBox(height: SizeConfig.getHeightMultiplier() * 1.8), Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: otherTickets @@ -42,7 +42,7 @@ class PriorityTickets extends StatelessWidget { child: TicketItem( ticketNo: ticket.queueNo ?? '', callType: ticket.getCallType(), - scale: 0.7, + scale: 0.8, roomNo: ticket.roomNo, isClinicAdded: ticket.callNoStr != ticket.queueNo, callConfig: callConfig, @@ -86,6 +86,7 @@ class TicketItem extends StatelessWidget { @override Widget build(BuildContext context) { + callConfig.textDirection = TextDirection.rtl; return Transform.scale( scale: scale, child: Column( @@ -104,35 +105,44 @@ class TicketItem extends StatelessWidget { times: 0, duration: const Duration(seconds: 1)), const SizedBox(height: 10), - Row( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - callType.icon(SizeConfig.getHeightMultiplier() * 3), - const SizedBox(width: 10), - AppText( - callType.message(callConfig), - color: callType.color(), - letterSpacing: -1.5, - fontSize: SizeConfig.getWidthMultiplier() * 3.8, - fontWeight: FontWeight.w600, - fontHeight: 0.5, - ), - Container( - color: Colors.grey.withOpacity(0.3), - width: 6, - height: SizeConfig.getHeightMultiplier() * 3, - margin: const EdgeInsets.symmetric(horizontal: 10), - ), - AppText( - "Room: $roomNo", - color: callType.color(), - letterSpacing: -1.5, - fontSize: SizeConfig.getWidthMultiplier() * 3.8, - fontWeight: FontWeight.w600, - fontHeight: 0.5, - ), - ], + Directionality( + textDirection: callConfig.textDirection, + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 8), + child: callType.icon(SizeConfig.getHeightMultiplier() * 3), + ), + const SizedBox(width: 10), + AppText( + callType.message(callConfig), + color: callType.color(), + letterSpacing: -1.5, + fontSize: SizeConfig.getWidthMultiplier() * 3.8, + fontWeight: FontWeight.w600, + fontHeight: 1, + ), + Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Container( + color: Colors.grey.withOpacity(0.5), + width: 5, + height: SizeConfig.getHeightMultiplier() * 2, + margin: const EdgeInsets.symmetric(horizontal: 15), + ), + ), + AppText( + callConfig.textDirection == TextDirection.ltr ? "${callConfig.roomText}: $roomNo" : " $roomNo : ${callConfig.roomText}", + color: callType.color(), + letterSpacing: -1.5, + fontSize: SizeConfig.getWidthMultiplier() * 3.8, + fontWeight: FontWeight.w600, + fontHeight: 1, + ), + ], + ), ), ], ), @@ -151,7 +161,7 @@ Widget noPatientInQueue() { ); } -Widget priorityTicketsWithSideList({required List tickets, required CallConfig callConfig}) { +Widget priorityTicketsWithSideList({required List tickets, required CallConfig callConfig}) { final priorityTickets = tickets.sublist(0, 3); final otherTickets = tickets.sublist(3, tickets.length); return Row( @@ -159,68 +169,169 @@ Widget priorityTicketsWithSideList({required List tickets, required Cal 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: 5, - child: ListView.builder( - padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 50), - itemCount: otherTickets.length, - itemBuilder: (ctx, idx) { - final itm = otherTickets[idx]; - - return Padding( - padding: const EdgeInsets.all(8), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: SizeConfig.getWidthMultiplier() * 19, - child: AppText( - itm.queueNo.toString(), - letterSpacing: -2, - fontWeight: FontWeight.bold, - fontSize: SizeConfig.getWidthMultiplier() * 4, - textAlign: TextAlign.center, - ), - ), - const SizedBox(width: 5), - Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - SizedBox( - width: SizeConfig.getWidthMultiplier() * 3, - child: itm.getCallType().icon(SizeConfig.getHeightMultiplier() * 2.5), + 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, + ), + ], ), - const SizedBox(width: 10), - SizedBox( - width: SizeConfig.getWidthMultiplier() * 28, - child: AppText( - itm.getCallType().message(callConfig), - color: itm.getCallType().color(), - letterSpacing: -1.5, - fontSize: SizeConfig.getWidthMultiplier() * 3, - fontWeight: FontWeight.w600, - fontHeight: 0.5, - ), - ), - Container( - color: Colors.grey.withOpacity(0.3), - width: 6, - height: SizeConfig.getHeightMultiplier() * 3, - margin: const EdgeInsets.symmetric(horizontal: 10), + ), + 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, + ), + ], ), - AppText( - "Room: ${itm.roomNo}", - color: itm.getCallType().color(), - letterSpacing: -1.5, - fontSize: SizeConfig.getWidthMultiplier() * 3.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: 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, + ), + ], ), - ], - ) - ], + ), + ], + ), ), - ); - }, + ), + 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: -2, + fontHeight: 0.5, + fontWeight: FontWeight.bold, + fontSize: SizeConfig.getWidthMultiplier() * 4, + 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, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.only(top: 10), + child: SizedBox( + width: SizeConfig.getWidthMultiplier() * 3, + 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.5, + 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: 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, + ), + ], + ), + ) + ], + ), + ), + ); + }, + ), + ], ), ) ], diff --git a/lib/utils/call_by_voice.dart b/lib/utils/call_by_voice.dart index dade985..f732c61 100644 --- a/lib/utils/call_by_voice.dart +++ b/lib/utils/call_by_voice.dart @@ -1,5 +1,3 @@ -import 'dart:developer'; - import 'package:flutter_tts/flutter_tts.dart'; class CallByVoice { @@ -7,19 +5,21 @@ class CallByVoice { final String preVoice; final String ticketNo; final String postVoice; + final FlutterTts flutterTts; - CallByVoice({this.lang = 'en', required this.ticketNo, required this.preVoice, required this.postVoice}); - - final FlutterTts textToSpeech = FlutterTts(); + CallByVoice({this.lang = 'en', required this.ticketNo, required this.preVoice, required this.postVoice, required this.flutterTts}); double volume = 1.0; double pitch = 0.6; double rate = 0.2; - startCalling(bool isClinicNameAdded) async { - log("langs: ${(await textToSpeech.getVoices).toString()}"); - log("langs: ${(await textToSpeech.getLanguages).toString()}"); - log("langs: ${(await textToSpeech.getEngines).toString()}"); + Future startCalling(bool isClinicNameAdded) async { + // log("langs1: ${(await flutterTts.getVoices).toString()}"); + // log("langs2: ${(await flutterTts.areLanguagesInstalled(["en-AU", "ar-AR"])).toString()}"); + // log("langs3: ${(await flutterTts.getDefaultVoice).toString()}"); + // log("langs3: ${(await flutterTts.getLanguages).toString()}"); + // log("langs4: ${(await flutterTts.setVoice({"name": "kn-in-x-knf-network", "locale": "kn-IN"})).toString()}"); + // log("langs5: ${(await flutterTts.getEngines).toString()}"); String clinicName = ""; String patientAlpha = ""; @@ -34,13 +34,14 @@ class CallByVoice { patientAlpha = ticketNo.split("-")[0]; patientNumeric = ticketNo.split("-")[1]; } - await textToSpeech.setLanguage("en-US"); + // await flutterTts.setLanguage("en-US"); // Create Pre Voice Players - if (preVoice != null && preVoice.isNotEmpty) { - textToSpeech.setSpeechRate(0.4); - textToSpeech.setPitch(0.9); - textToSpeech.setVolume(1.0); - await textToSpeech.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice); + if (postVoice != null && postVoice.isNotEmpty) { + flutterTts.setSpeechRate(0.45); + flutterTts.setPitch(0.9); + flutterTts.setVolume(1.0); + // await flutterTts.speak(clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice); + await flutterTts.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice); } // // Create Ticket Number Voice Players diff --git a/lib/utils/call_type.dart b/lib/utils/call_type.dart index b2c2fc4..d035e40 100644 --- a/lib/utils/call_type.dart +++ b/lib/utils/call_type.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:queuing_system/core/config/config.dart'; -import 'package:queuing_system/core/response_models/call_config.dart'; +import 'package:queuing_system/core/response_models/call_config_model.dart'; enum CallType { vitalSign, doctor, procedure, vaccination, nebulization, none } @@ -22,24 +22,23 @@ extension XCallType on CallType { } } - String message(CallConfig callConfig) { - int language = callConfig.screenLanguage; + String message(CallConfig callConfig, {bool isListView = false}) { switch (this) { case CallType.vitalSign: - return language == 1 ? callConfig.vitalSignText : callConfig.vitalSignTextN; + return isListView ? callConfig.callTypeVitalSignText : callConfig.vitalSignText; case CallType.doctor: - return language == 1 ? callConfig.doctorText : callConfig.doctorTextN; + return isListView ? callConfig.callTypeDoctorText : callConfig.doctorText; case CallType.procedure: - return language == 1 ? callConfig.procedureText : callConfig.procedureTextN; + return isListView ? callConfig.callTypeProcedureText : callConfig.procedureText; case CallType.vaccination: - return language == 1 ? callConfig.vaccinationText : callConfig.vaccinationTextN; + return isListView ? callConfig.callTypeVaccinationText : callConfig.vaccinationText; case CallType.nebulization: - return language == 1 ? callConfig.nebulizationText : callConfig.nebulizationTextN; + return isListView ? callConfig.callTypeNebulizationText : callConfig.nebulizationText; case CallType.none: - return language == 1 ? callConfig.vitalSignText : callConfig.vitalSignTextN; + return isListView ? callConfig.callTypeVitalSignText : callConfig.vitalSignText; default: - return language == 1 ? callConfig.vitalSignText : callConfig.vitalSignTextN; + return callConfig.callTypeVitalSignText; } } diff --git a/lib/widget/data_display/app_texts_widget.dart b/lib/widget/data_display/app_texts_widget.dart index b8f44a5..e4c9767 100644 --- a/lib/widget/data_display/app_texts_widget.dart +++ b/lib/widget/data_display/app_texts_widget.dart @@ -29,6 +29,7 @@ class AppText extends StatefulWidget { final TextOverflow? textOverflow; final TextDecoration? textDecoration; final bool isCopyable; + final TextDirection textDirection; const AppText( this.text, { @@ -59,6 +60,7 @@ class AppText extends StatefulWidget { this.textDecoration, this.letterSpacing, this.isCopyable = false, + this.textDirection = TextDirection.ltr, }) : super(key: key); @override @@ -83,7 +85,6 @@ class _AppTextState extends State { @override void initState() { - hidden = widget.readMore; if (widget.style == "overline") { text = widget.text.toUpperCase(); } else { @@ -101,102 +102,35 @@ class _AppTextState extends State { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Stack( - children: [ - _textWidget(), - if (widget.readMore && text.length > widget.maxLength && hidden) - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Container( - decoration: BoxDecoration( - gradient: LinearGradient(colors: [ - Theme.of(context).colorScheme.background, - Theme.of(context).colorScheme.background.withOpacity(0), - ], begin: Alignment.bottomCenter, end: Alignment.topCenter)), - height: 30, - ), - ) - ], - ), - if (widget.allowExpand && widget.readMore && text.length > widget.maxLength) - Padding( - padding: const EdgeInsets.only(top: 8.0, right: 8.0, bottom: 8.0), - child: InkWell( - onTap: () { - setState(() { - hidden = !hidden; - }); - }, - child: Text(hidden ? "Read More" : "Read less", - style: _getFontStyle()?.copyWith( - color: Colors.white, - fontWeight: FontWeight.w800, - fontFamily: "Poppins", - )), - ), - ), + Text( + text, + textDirection: widget.textDirection, + textAlign: widget.textAlign, + overflow: widget.maxLines != null ? ((widget.maxLines! > 1) ? TextOverflow.fade : TextOverflow.ellipsis) : null, + maxLines: widget.maxLines, + style: widget.style != null + ? _getFontStyle()?.copyWith( + fontStyle: widget.italic ? FontStyle.italic : null, + color: widget.color, + fontWeight: widget.fontWeight ?? _getFontWeight(), + height: widget.fontHeight, + ) + : TextStyle( + fontStyle: widget.italic ? FontStyle.italic : null, + color: widget.color ?? Colors.black, + fontSize: widget.fontSize ?? _getFontSize(), + letterSpacing: widget.letterSpacing ?? (widget.variant == "overline" ? 1.5 : null), + fontWeight: widget.fontWeight ?? _getFontWeight(), + fontFamily: widget.fontFamily ?? 'Poppins', + decoration: widget.textDecoration, + height: widget.fontHeight), + ) ], ), ), ); } - Widget _textWidget() { - if (widget.isCopyable) { - return Theme( - data: ThemeData( - textSelectionTheme: const TextSelectionThemeData(selectionColor: Colors.lightBlueAccent), - ), - child: SelectableText( - !hidden ? text : (text.substring(0, text.length > widget.maxLength ? widget.maxLength : text.length)), - textAlign: widget.textAlign, - // overflow: widget.maxLines != null - // ? ((widget.maxLines > 1) - // ? TextOverflow.fade - // : TextOverflow.ellipsis) - // : null, - maxLines: widget.maxLines, - style: widget.style != null - ? _getFontStyle()?.copyWith(fontStyle: widget.italic ? FontStyle.italic : null, color: widget.color, fontWeight: widget.fontWeight ?? _getFontWeight(), height: widget.fontHeight) - : TextStyle( - fontStyle: widget.italic ? FontStyle.italic : null, - color: widget.color ?? const Color(0xff000000), - fontSize: widget.fontSize ?? _getFontSize(), - letterSpacing: widget.letterSpacing ?? (widget.variant == "overline" ? 1.5 : null), - fontWeight: widget.fontWeight ?? _getFontWeight(), - fontFamily: widget.fontFamily ?? 'Poppins', - decoration: widget.textDecoration, - height: widget.fontHeight), - ), - ); - } else { - return Text( - !hidden ? text : (text.substring(0, text.length > widget.maxLength ? widget.maxLength : text.length)), - textAlign: widget.textAlign, - overflow: widget.maxLines != null ? ((widget.maxLines! > 1) ? TextOverflow.fade : TextOverflow.ellipsis) : null, - maxLines: widget.maxLines, - style: widget.style != null - ? _getFontStyle()?.copyWith( - fontStyle: widget.italic ? FontStyle.italic : null, - color: widget.color, - fontWeight: widget.fontWeight ?? _getFontWeight(), - height: widget.fontHeight, - ) - : TextStyle( - fontStyle: widget.italic ? FontStyle.italic : null, - color: widget.color ?? Colors.black, - fontSize: widget.fontSize ?? _getFontSize(), - letterSpacing: widget.letterSpacing ?? (widget.variant == "overline" ? 1.5 : null), - fontWeight: widget.fontWeight ?? _getFontWeight(), - fontFamily: widget.fontFamily ?? 'Poppins', - decoration: widget.textDecoration, - height: widget.fontHeight), - ); - } - } - TextStyle? _getFontStyle() { switch (widget.style) { case "headline2":