Structure Update

faiz_dev_structure_update
FaizHashmiCS22 3 years ago
parent f524cee132
commit 0027f88df5

@ -1,12 +1,12 @@
buildscript { buildscript {
ext.kotlin_version = '1.6.0' ext.kotlin_version = '1.9.10'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
} }
dependencies { 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" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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

@ -3,8 +3,8 @@ import 'dart:io';
import 'package:queuing_system/core/base/base_app_client.dart'; import 'package:queuing_system/core/base/base_app_client.dart';
import 'package:queuing_system/core/config/config.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';
import 'package:queuing_system/core/response_models/patient_call.dart'; import 'package:queuing_system/core/response_models/patient_ticket_model.dart';
const _getCallRequestInfoByClinicInfo = "/GetCallRequestInfo_ByIP"; const _getCallRequestInfoByClinicInfo = "/GetCallRequestInfo_ByIP";
const _callUpdateNotIsQueueRecordByIDAsync = "/CallRequest_QueueUpdate"; const _callUpdateNotIsQueueRecordByIDAsync = "/CallRequest_QueueUpdate";
@ -16,16 +16,16 @@ class MyHttpOverrides extends HttpOverrides {
} }
} }
bool isDevMode = true;
class API { class API {
static getCallRequestInfoByClinicInfo(String deviceIp, {required Function(List<Tickets>, List<Tickets>, CallConfig callConfig) onSuccess, required Function(dynamic) onFailure}) async { static getCallRequestInfoByClinicInfo(String deviceIp,
{required Function(List<PatientTicketModel>, List<PatientTicketModel>, CallConfig callConfig) onSuccess, required Function(dynamic) onFailure}) async {
final body = {"ipAdress": deviceIp, "apiKey": apiKey}; final body = {"ipAdress": deviceIp, "apiKey": apiKey};
bool isDevMode = false;
if (isDevMode) { if (isDevMode) {
var callPatients = Tickets.testCallPatients; var callPatients = PatientTicketModel.testCallPatients;
var isQueuePatients = callPatients.where((element) => (element.callType == 1 && element.isQueue == false) || (element.callType == 2 && element.isQueue == false)).toList(); CallConfig callConfig = CallConfig.testCallConfig;
CallConfig callConfig = CallConfig();
var isQueuePatients = callPatients.where((element) => (element.isQueue == false)).toList();
onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList(), callConfig); onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList(), callConfig);
return; return;
} }
@ -36,18 +36,14 @@ class API {
final response = apiResp["data"]; final response = apiResp["data"];
CallConfig callConfig = CallConfig.fromJson(response["callConfig"]); CallConfig callConfig = CallConfig.fromJson(response["callConfig"]);
var callPatients = (response["callPatients"] as List).map((j) => Tickets.fromJson(j)).toList(); var callPatients = (response["callPatients"] as List).map((j) => PatientTicketModel.fromJson(j)).toList().where((element) => element.callType != 0).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!));
// 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); onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList(), callConfig);
} else { } else {
onFailure(apiResp); onFailure(apiResp);
@ -58,11 +54,11 @@ class API {
static callUpdateNotIsQueueRecordByIDAsync( static callUpdateNotIsQueueRecordByIDAsync(
String deviceIp, { String deviceIp, {
required Tickets ticket, required PatientTicketModel ticket,
required Function(List<Tickets>) onSuccess, required Function(List<PatientTicketModel>) onSuccess,
required Function(dynamic) onFailure, required Function(dynamic) onFailure,
}) async { }) async {
List<Tickets> _ticketsUpdated = []; List<PatientTicketModel> _ticketsUpdated = [];
// for (var ticket in tickets) { // for (var ticket in tickets) {
final body = {"id": ticket.id, "apiKey": apiKey, "ipAddress": deviceIp, "callType": ticket.callType}; final body = {"id": ticket.id, "apiKey": apiKey, "ipAddress": deviceIp, "callType": ticket.callType};

@ -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<String, dynamic> 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<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
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;
}
}

@ -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<String, dynamic> 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);
}

@ -2,7 +2,7 @@ import 'dart:math';
import 'package:queuing_system/utils/call_type.dart'; import 'package:queuing_system/utils/call_type.dart';
class Tickets { class PatientTicketModel {
late int id; late int id;
late int patientID; late int patientID;
late String mobileNo; late String mobileNo;
@ -22,7 +22,7 @@ class Tickets {
late bool isVoiceReq; late bool isVoiceReq;
late bool callUpdated = false; late bool callUpdated = false;
Tickets( PatientTicketModel(
{this.id = 0, {this.id = 0,
this.patientID = 0, this.patientID = 0,
this.mobileNo = "", this.mobileNo = "",
@ -45,13 +45,13 @@ class Tickets {
return Random().nextInt(9); return Random().nextInt(9);
} }
Tickets.fromJson(Map<String, dynamic> json) { PatientTicketModel.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
patientID = json['patientID']; patientID = json['patientID'];
mobileNo = json['mobileNo']; mobileNo = json['mobileNo'] ?? "";
doctorName = json['doctorName']; doctorName = json['doctorName'] ?? "";
doctorNameN = json['doctorNameN']; doctorNameN = json['doctorNameN'] ?? "";
patientGender = json['patientGender']; patientGender = json['patientGender'] ?? "";
callType = json['callType']; callType = json['callType'];
editedOnTimeStamp = DateTime.parse(json['editedOn']).millisecondsSinceEpoch; editedOnTimeStamp = DateTime.parse(json['editedOn']).millisecondsSinceEpoch;
roomNo = json['roomNo']; roomNo = json['roomNo'];
@ -100,8 +100,8 @@ class Tickets {
return CallType.vitalSign; return CallType.vitalSign;
} }
static List<Tickets> testCallPatients = [ static List<PatientTicketModel> testCallPatients = [
Tickets( PatientTicketModel(
id: 1, id: 1,
patientID: 112, patientID: 112,
mobileNo: "112", mobileNo: "112",
@ -120,7 +120,7 @@ class Tickets {
isVoiceReq: true, isVoiceReq: true,
concurrentCallDelaySec: 8, concurrentCallDelaySec: 8,
), ),
Tickets( PatientTicketModel(
id: 1, id: 1,
patientID: 112, patientID: 112,
mobileNo: "112", mobileNo: "112",
@ -138,7 +138,7 @@ class Tickets {
isVoiceReq: true, isVoiceReq: true,
concurrentCallDelaySec: 8, concurrentCallDelaySec: 8,
), ),
Tickets( PatientTicketModel(
id: 1, id: 1,
patientID: 112, patientID: 112,
mobileNo: "112", mobileNo: "112",
@ -156,7 +156,25 @@ class Tickets {
isVoiceReq: true, isVoiceReq: true,
concurrentCallDelaySec: 8, 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, id: 1,
patientID: 112, patientID: 112,
mobileNo: "112", mobileNo: "112",

@ -4,10 +4,11 @@ import 'dart:io';
import 'package:connectivity/connectivity.dart'; import 'package:connectivity/connectivity.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_tts/flutter_tts.dart';
import 'package:just_audio/just_audio.dart'; import 'package:just_audio/just_audio.dart';
import 'package:queuing_system/core/api.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/call_config_model.dart';
import 'package:queuing_system/core/response_models/patient_call.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_by_voice.dart';
import 'package:queuing_system/utils/call_type.dart'; import 'package:queuing_system/utils/call_type.dart';
import 'package:queuing_system/utils/signalR_utils.dart'; import 'package:queuing_system/utils/signalR_utils.dart';
@ -16,19 +17,22 @@ class AppProvider extends ChangeNotifier {
AppProvider() { AppProvider() {
startSignalHubConnection(); startSignalHubConnection();
listenNetworkConnectivity(); listenNetworkConnectivity();
listenAudioPlayerEvents();
} }
SignalRHelper signalRHelper = SignalRHelper(); SignalRHelper signalRHelper = SignalRHelper();
final AudioPlayer audioPlayer = AudioPlayer(); final AudioPlayer audioPlayer = AudioPlayer();
FlutterTts flutterTts = FlutterTts();
CallConfig patientCallConfigurations = CallConfig(); CallConfig patientCallConfigurations = CallConfig();
List<Tickets> patientTickets = []; List<PatientTicketModel> patientTickets = [];
List<Tickets> isQueuePatients = []; List<PatientTicketModel> isQueuePatients = [];
String currentDeviceIp = ""; String currentDeviceIp = "";
bool isCallingInProgress = false; bool isCallingInProgress = false;
bool isInternetConnectionAvailable = true; bool isInternetConnectionAvailable = true;
bool isApiCallNeeded = false;
updateInternetConnection(bool value) { updateInternetConnection(bool value) {
isInternetConnectionAvailable = value; isInternetConnectionAvailable = value;
@ -55,13 +59,19 @@ class AppProvider extends ChangeNotifier {
Future<void> startSignalHubConnection() async { Future<void> startSignalHubConnection() async {
if (!signalRHelper.getConnectionState()) { 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<void> callPatientsAPI() async { Future<void> callPatientsAPI() async {
patientTickets.clear(); patientTickets.clear();
API.getCallRequestInfoByClinicInfo(currentDeviceIp, onSuccess: (waitingCalls, isQueuePatientsCalls, callConfigs) { API.getCallRequestInfoByClinicInfo(currentDeviceIp, onSuccess: (waitingCalls, isQueuePatientsCalls, callConfigs) async {
patientCallConfigurations = callConfigs; patientCallConfigurations = callConfigs;
if (waitingCalls.length > patientCallConfigurations.screenMaxDisplayPatients) { if (waitingCalls.length > patientCallConfigurations.screenMaxDisplayPatients) {
patientTickets = waitingCalls.sublist(0, patientCallConfigurations.screenMaxDisplayPatients); patientTickets = waitingCalls.sublist(0, patientCallConfigurations.screenMaxDisplayPatients);
@ -70,17 +80,21 @@ class AppProvider extends ChangeNotifier {
} }
isQueuePatients = isQueuePatientsCalls; isQueuePatients = isQueuePatientsCalls;
notifyListeners(); notifyListeners();
if (patientTickets.isNotEmpty) {
voiceCallPatientTicket(patientTickets.first);
updatePatientTicketByIndex(patientTickets.first);
}
}, onFailure: (error) { }, onFailure: (error) {
log("Api call failed with this error: ${error.toString()}"); log("Api call failed with this error: ${error.toString()}");
}); });
} }
onPingReceived(data) async { onPingReceived(data) async {
log("isCallingInProgress: $isCallingInProgress");
log("isApiCallNeeded: $isApiCallNeeded");
if (patientTickets.isNotEmpty) { if (patientTickets.isNotEmpty) {
if ((patientTickets.first.isToneReq && isCallingInProgress) || (patientTickets.first.isVoiceReq && voiceCaller != null)) { if (isCallingInProgress) {
Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async { isApiCallNeeded = true;
await callPatientsAPI();
});
} else { } else {
await callPatientsAPI(); 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(); final callType = ticket.getCallType();
switch (callType) { switch (callType) {
case CallType.vitalSign: case CallType.vitalSign:
@ -109,85 +123,99 @@ class AppProvider extends ChangeNotifier {
CallByVoice? voiceCaller; CallByVoice? voiceCaller;
callPatientTicket(AudioPlayer audioPlayer) async { voiceCallPatientTicket(PatientTicketModel patientTicket) async {
isCallingInProgress = true; isCallingInProgress = true;
if (patientTickets.isNotEmpty) { log("Setting isCallingInProgress : $isCallingInProgress");
if (patientTickets.first.isToneReq && !patientTickets.first.isQueue) {
if (patientTicket.isToneReq && !patientTicket.isQueue) {
audioPlayer.setAsset("assets/tones/call_tone.mp3"); audioPlayer.setAsset("assets/tones/call_tone.mp3");
await audioPlayer.play(); await audioPlayer.play();
await Future.delayed(const Duration(seconds: 2)); await Future.delayed(const Duration(seconds: 3));
isCallingInProgress = false;
} }
if (patientTickets.first.isVoiceReq && voiceCaller == null && !patientTickets.first.isQueue) { if (patientTicket.isVoiceReq && voiceCaller == null && !patientTicket.isQueue) {
final postVoice = getCallTypeText(patientTickets.first, patientCallConfigurations); final postVoice = getCallTypeText(patientTicket, patientCallConfigurations);
voiceCaller = CallByVoice(preVoice: "Ticket Number", ticketNo: patientTickets.first.queueNo.trim().toString(), postVoice: postVoice, lang: 'en'); voiceCaller = CallByVoice(preVoice: "Ticket Number", ticketNo: patientTicket.queueNo.trim().toString(), postVoice: postVoice, lang: 'en', flutterTts: flutterTts);
await voiceCaller!.startCalling(patientTickets.first.queueNo.trim().toString() != patientTickets.first.callNoStr.trim().toString()); await voiceCaller!.startCalling(patientTicket.queueNo.trim().toString() != patientTicket.callNoStr.trim().toString());
voiceCaller = null; voiceCaller = null;
isCallingInProgress = false;
}
}
if (isQueuePatients.isNotEmpty) {
await Future.delayed(Duration(seconds: isQueuePatients.first.concurrentCallDelaySec)).whenComplete(() async {
if (isQueuePatients.isNotEmpty) { if (isQueuePatients.isNotEmpty) {
isQueuePatients.removeAt(0); isQueuePatients.removeAt(0);
} }
if (patientTickets.isNotEmpty) {
// Tickets ticket = patientTickets.elementAt(0);
// patientTickets.removeAt(0);
// patientTickets.add(ticket);
}
if (isQueuePatients.isNotEmpty) {
// setState(() {});
}
});
} else { } else {
// if (isQueuePatients.isEmpty && callFlag == 1) { isCallingInProgress = false;
// callFlag == 0; log("Setting isCallingInProgress : $isCallingInProgress");
// await Future.delayed(const Duration(seconds: 3));
// patientTickets.clear(); if (isApiCallNeeded) {
// API.getCallRequestInfoByClinicInfo(DEVICE_IP, onSuccess: (waitingCalls, isQueuePatientsCalls) { log("I will start waiting!!");
// setState(() { Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async {
// patientTickets = waitingCalls; await callPatientsAPI();
// isQueuePatients = isQueuePatientsCalls; log("Called the API after waiting!");
// // currents = currentInClinic; isApiCallNeeded = false;
// }); });
// }
// log("--------------------");
// log("waiting: $patientTickets");
// log("isQueuePatients: $isQueuePatients");
// log("--------------------");
//
// updateTickets();
// }, onFailure: (error) {});
// }
} }
} }
Future<void> listenAudioPlayerEvents() async { Future<void> listenAudioPlayerEvents() async {
audioPlayer.playerStateStream.listen((playerState) { audioPlayer.playerStateStream.listen((playerState) {
if (playerState.processingState == ProcessingState.completed) { if (playerState.processingState == ProcessingState.completed) {
isCallingInProgress = false; // isCallingInProgress = false;
} }
}); });
}
updatePatientTickets() { 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) { if (patientTickets.isNotEmpty) {
List<Tickets> _ticketsToUpdate = patientTickets.where((t) => t.callUpdated == false).toList(); temp = patientTickets.elementAt(0);
API.callUpdateNotIsQueueRecordByIDAsync(currentDeviceIp, ticket: _ticketsToUpdate.first, onSuccess: (ticketsUpdated) { patientTickets.removeAt(0);
log("[${ticketsUpdated.length}] Tickets Updated: $ticketsUpdated"); }
}, onFailure: (e) { notifyListeners();
log(" Tickets Update Failed with : ${e.toString()}"); 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) { // updatePatientTickets() {
if (patientTickets.isNotEmpty) { // if (patientTickets.isNotEmpty) {
API.callUpdateNotIsQueueRecordByIDAsync(currentDeviceIp, ticket: patientTickets.elementAt(index), onSuccess: (ticketsUpdated) { // List<Tickets> _ticketsToUpdate = patientTickets.where((t) => t.callUpdated == false).toList();
log("[${patientTickets.elementAt(index).callNoStr}] Ticket Updated: $ticketsUpdated"); // 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) { }, onFailure: (e) {
log(" Tickets Update ${patientTickets.elementAt(index).callNoStr} Failed with Error : ${e.toString()}"); log(" Tickets Update ${patientTicket.callNoStr} Failed with Error : ${e.toString()}");
}); });
} }
} }

@ -33,7 +33,9 @@ class MyHomePage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
InkWell( InkWell(
onTap: () {}, onTap: () async {
await context.read<AppProvider>().callPatientsAPI();
},
child: AppText( child: AppText(
"Powered By", "Powered By",
fontSize: SizeConfig.getWidthMultiplier() * 2.6, fontSize: SizeConfig.getWidthMultiplier() * 2.6,
@ -57,6 +59,7 @@ class MyHomePage extends StatelessWidget {
} }
Widget dataContent({required AppProvider appProvider}) { Widget dataContent({required AppProvider appProvider}) {
// appProvider.voiceCallPatientTicket(appProvider.patientTickets.first);
if (appProvider.patientTickets.isEmpty) { if (appProvider.patientTickets.isEmpty) {
// No Patient in Queue // No Patient in Queue
return noPatientInQueue(); return noPatientInQueue();

@ -1,13 +1,13 @@
import 'package:blinking_text/blinking_text.dart'; import 'package:blinking_text/blinking_text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:queuing_system/core/config/size_config.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/call_config_model.dart';
import 'package:queuing_system/core/response_models/patient_call.dart'; import 'package:queuing_system/core/response_models/patient_ticket_model.dart';
import 'package:queuing_system/utils/call_type.dart'; import 'package:queuing_system/utils/call_type.dart';
import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
class PriorityTickets extends StatelessWidget { class PriorityTickets extends StatelessWidget {
final List<Tickets> tickets; final List<PatientTicketModel> tickets;
final CallConfig callConfig; final CallConfig callConfig;
const PriorityTickets({required this.tickets, required this.callConfig, Key? key}) : super(key: key); const PriorityTickets({required this.tickets, required this.callConfig, Key? key}) : super(key: key);
@ -21,19 +21,19 @@ class PriorityTickets extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
const SizedBox(height: 20), const SizedBox(height: 50),
TicketItem( TicketItem(
ticketNo: firstTicket.queueNo ?? '', ticketNo: firstTicket.queueNo ?? '',
callType: firstTicket.getCallType(), callType: firstTicket.getCallType(),
scale: 1, scale: 1.2,
blink: true, blink: true,
roomNo: firstTicket.roomNo, roomNo: firstTicket.roomNo,
isClinicAdded: firstTicket.callNoStr != firstTicket.queueNo, isClinicAdded: firstTicket.callNoStr != firstTicket.queueNo,
callConfig: callConfig, callConfig: callConfig,
), ),
const SizedBox(height: 40), const SizedBox(height: 50),
if (tickets.length > 1) ...[ if (tickets.length > 1) ...[
SizedBox(height: SizeConfig.getHeightMultiplier() * 1.5), SizedBox(height: SizeConfig.getHeightMultiplier() * 1.8),
Column( Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: otherTickets children: otherTickets
@ -42,7 +42,7 @@ class PriorityTickets extends StatelessWidget {
child: TicketItem( child: TicketItem(
ticketNo: ticket.queueNo ?? '', ticketNo: ticket.queueNo ?? '',
callType: ticket.getCallType(), callType: ticket.getCallType(),
scale: 0.7, scale: 0.8,
roomNo: ticket.roomNo, roomNo: ticket.roomNo,
isClinicAdded: ticket.callNoStr != ticket.queueNo, isClinicAdded: ticket.callNoStr != ticket.queueNo,
callConfig: callConfig, callConfig: callConfig,
@ -86,6 +86,7 @@ class TicketItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
callConfig.textDirection = TextDirection.rtl;
return Transform.scale( return Transform.scale(
scale: scale, scale: scale,
child: Column( child: Column(
@ -104,11 +105,16 @@ class TicketItem extends StatelessWidget {
times: 0, times: 0,
duration: const Duration(seconds: 1)), duration: const Duration(seconds: 1)),
const SizedBox(height: 10), const SizedBox(height: 10),
Row( Directionality(
textDirection: callConfig.textDirection,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
callType.icon(SizeConfig.getHeightMultiplier() * 3), Padding(
padding: const EdgeInsets.only(bottom: 8),
child: callType.icon(SizeConfig.getHeightMultiplier() * 3),
),
const SizedBox(width: 10), const SizedBox(width: 10),
AppText( AppText(
callType.message(callConfig), callType.message(callConfig),
@ -116,24 +122,28 @@ class TicketItem extends StatelessWidget {
letterSpacing: -1.5, letterSpacing: -1.5,
fontSize: SizeConfig.getWidthMultiplier() * 3.8, fontSize: SizeConfig.getWidthMultiplier() * 3.8,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontHeight: 0.5, 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),
), ),
Container(
color: Colors.grey.withOpacity(0.3),
width: 6,
height: SizeConfig.getHeightMultiplier() * 3,
margin: const EdgeInsets.symmetric(horizontal: 10),
), ),
AppText( AppText(
"Room: $roomNo", callConfig.textDirection == TextDirection.ltr ? "${callConfig.roomText}: $roomNo" : " $roomNo : ${callConfig.roomText}",
color: callType.color(), color: callType.color(),
letterSpacing: -1.5, letterSpacing: -1.5,
fontSize: SizeConfig.getWidthMultiplier() * 3.8, fontSize: SizeConfig.getWidthMultiplier() * 3.8,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontHeight: 0.5, fontHeight: 1,
), ),
], ],
), ),
),
], ],
), ),
); );
@ -151,64 +161,161 @@ Widget noPatientInQueue() {
); );
} }
Widget priorityTicketsWithSideList({required List<Tickets> tickets, required CallConfig callConfig}) { Widget priorityTicketsWithSideList({required List<PatientTicketModel> tickets, required CallConfig callConfig}) {
final priorityTickets = tickets.sublist(0, 3); final priorityTickets = tickets.sublist(0, 3);
final otherTickets = tickets.sublist(3, tickets.length); final otherTickets = tickets.sublist(3, tickets.length);
return Row( return Row(
children: [ children: [
Expanded(flex: 7, child: PriorityTickets(callConfig: callConfig, tickets: priorityTickets)), 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)), 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( Expanded(
flex: 5, flex: 5,
child: ListView.builder( child: Row(
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 50), 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),
),
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, itemCount: otherTickets.length,
itemBuilder: (ctx, idx) { itemBuilder: (ctx, idx) {
final itm = otherTickets[idx]; final itm = otherTickets[idx];
return Padding( return Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Directionality(
textDirection: callConfig.textDirection,
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
SizedBox( Expanded(
width: SizeConfig.getWidthMultiplier() * 19, flex: 3,
child: AppText( child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppText(
itm.queueNo.toString(), itm.queueNo.toString(),
letterSpacing: -2, letterSpacing: -2,
fontHeight: 0.5,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: SizeConfig.getWidthMultiplier() * 4, fontSize: SizeConfig.getWidthMultiplier() * 4,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
],
),
), ),
const SizedBox(width: 5), Container(
Row( 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, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
SizedBox( Padding(
padding: const EdgeInsets.only(top: 10),
child: SizedBox(
width: SizeConfig.getWidthMultiplier() * 3, width: SizeConfig.getWidthMultiplier() * 3,
child: itm.getCallType().icon(SizeConfig.getHeightMultiplier() * 2.5), child: itm.getCallType().icon(SizeConfig.getHeightMultiplier() * 2.5),
), ),
const SizedBox(width: 10), ),
SizedBox( const SizedBox(width: 15),
width: SizeConfig.getWidthMultiplier() * 28, AppText(
child: AppText( itm.getCallType().message(callConfig, isListView: true),
itm.getCallType().message(callConfig),
color: itm.getCallType().color(), color: itm.getCallType().color(),
letterSpacing: -1.5, letterSpacing: -1.5,
fontSize: SizeConfig.getWidthMultiplier() * 3, fontSize: SizeConfig.getWidthMultiplier() * 3,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontHeight: 0.5, fontHeight: 0.5,
), ),
],
),
), ),
Container( Container(
color: Colors.grey.withOpacity(0.3), color: Colors.grey.withOpacity(0.5),
width: 6, width: 5,
height: SizeConfig.getHeightMultiplier() * 3, height: SizeConfig.getHeightMultiplier() * 2,
margin: const EdgeInsets.symmetric(horizontal: 10), margin: const EdgeInsets.symmetric(horizontal: 15),
), ),
Expanded(
flex: 3,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppText( AppText(
"Room: ${itm.roomNo}", itm.roomNo, // callConfig.textDirection == TextDirection.ltr ? "${callConfig.roomText}: ${itm.roomNo}" : " ${itm.roomNo} ${callConfig.roomText}: ",
color: itm.getCallType().color(), color: itm.getCallType().color(),
letterSpacing: -1.5, letterSpacing: -1.5,
fontSize: SizeConfig.getWidthMultiplier() * 3.3, fontSize: SizeConfig.getWidthMultiplier() * 3.3,
@ -216,12 +323,16 @@ Widget priorityTicketsWithSideList({required List<Tickets> tickets, required Cal
fontHeight: 0.5, fontHeight: 0.5,
), ),
], ],
),
) )
], ],
), ),
),
); );
}, },
), ),
],
),
) )
], ],
); );

@ -1,5 +1,3 @@
import 'dart:developer';
import 'package:flutter_tts/flutter_tts.dart'; import 'package:flutter_tts/flutter_tts.dart';
class CallByVoice { class CallByVoice {
@ -7,19 +5,21 @@ class CallByVoice {
final String preVoice; final String preVoice;
final String ticketNo; final String ticketNo;
final String postVoice; final String postVoice;
final FlutterTts flutterTts;
CallByVoice({this.lang = 'en', required this.ticketNo, required this.preVoice, required this.postVoice}); CallByVoice({this.lang = 'en', required this.ticketNo, required this.preVoice, required this.postVoice, required this.flutterTts});
final FlutterTts textToSpeech = FlutterTts();
double volume = 1.0; double volume = 1.0;
double pitch = 0.6; double pitch = 0.6;
double rate = 0.2; double rate = 0.2;
startCalling(bool isClinicNameAdded) async { Future<void> startCalling(bool isClinicNameAdded) async {
log("langs: ${(await textToSpeech.getVoices).toString()}"); // log("langs1: ${(await flutterTts.getVoices).toString()}");
log("langs: ${(await textToSpeech.getLanguages).toString()}"); // log("langs2: ${(await flutterTts.areLanguagesInstalled(["en-AU", "ar-AR"])).toString()}");
log("langs: ${(await textToSpeech.getEngines).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 clinicName = "";
String patientAlpha = ""; String patientAlpha = "";
@ -34,13 +34,14 @@ class CallByVoice {
patientAlpha = ticketNo.split("-")[0]; patientAlpha = ticketNo.split("-")[0];
patientNumeric = ticketNo.split("-")[1]; patientNumeric = ticketNo.split("-")[1];
} }
await textToSpeech.setLanguage("en-US"); // await flutterTts.setLanguage("en-US");
// Create Pre Voice Players // Create Pre Voice Players
if (preVoice != null && preVoice.isNotEmpty) { if (postVoice != null && postVoice.isNotEmpty) {
textToSpeech.setSpeechRate(0.4); flutterTts.setSpeechRate(0.45);
textToSpeech.setPitch(0.9); flutterTts.setPitch(0.9);
textToSpeech.setVolume(1.0); flutterTts.setVolume(1.0);
await textToSpeech.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice); // await flutterTts.speak(clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice);
await flutterTts.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice);
} }
// // Create Ticket Number Voice Players // // Create Ticket Number Voice Players

@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:queuing_system/core/config/config.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 } enum CallType { vitalSign, doctor, procedure, vaccination, nebulization, none }
@ -22,24 +22,23 @@ extension XCallType on CallType {
} }
} }
String message(CallConfig callConfig) { String message(CallConfig callConfig, {bool isListView = false}) {
int language = callConfig.screenLanguage;
switch (this) { switch (this) {
case CallType.vitalSign: case CallType.vitalSign:
return language == 1 ? callConfig.vitalSignText : callConfig.vitalSignTextN; return isListView ? callConfig.callTypeVitalSignText : callConfig.vitalSignText;
case CallType.doctor: case CallType.doctor:
return language == 1 ? callConfig.doctorText : callConfig.doctorTextN; return isListView ? callConfig.callTypeDoctorText : callConfig.doctorText;
case CallType.procedure: case CallType.procedure:
return language == 1 ? callConfig.procedureText : callConfig.procedureTextN; return isListView ? callConfig.callTypeProcedureText : callConfig.procedureText;
case CallType.vaccination: case CallType.vaccination:
return language == 1 ? callConfig.vaccinationText : callConfig.vaccinationTextN; return isListView ? callConfig.callTypeVaccinationText : callConfig.vaccinationText;
case CallType.nebulization: case CallType.nebulization:
return language == 1 ? callConfig.nebulizationText : callConfig.nebulizationTextN; return isListView ? callConfig.callTypeNebulizationText : callConfig.nebulizationText;
case CallType.none: case CallType.none:
return language == 1 ? callConfig.vitalSignText : callConfig.vitalSignTextN; return isListView ? callConfig.callTypeVitalSignText : callConfig.vitalSignText;
default: default:
return language == 1 ? callConfig.vitalSignText : callConfig.vitalSignTextN; return callConfig.callTypeVitalSignText;
} }
} }

@ -29,6 +29,7 @@ class AppText extends StatefulWidget {
final TextOverflow? textOverflow; final TextOverflow? textOverflow;
final TextDecoration? textDecoration; final TextDecoration? textDecoration;
final bool isCopyable; final bool isCopyable;
final TextDirection textDirection;
const AppText( const AppText(
this.text, { this.text, {
@ -59,6 +60,7 @@ class AppText extends StatefulWidget {
this.textDecoration, this.textDecoration,
this.letterSpacing, this.letterSpacing,
this.isCopyable = false, this.isCopyable = false,
this.textDirection = TextDirection.ltr,
}) : super(key: key); }) : super(key: key);
@override @override
@ -83,7 +85,6 @@ class _AppTextState extends State<AppText> {
@override @override
void initState() { void initState() {
hidden = widget.readMore;
if (widget.style == "overline") { if (widget.style == "overline") {
text = widget.text.toUpperCase(); text = widget.text.toUpperCase();
} else { } else {
@ -101,79 +102,9 @@ class _AppTextState extends State<AppText> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Stack( Text(
children: [ text,
_textWidget(), textDirection: widget.textDirection,
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",
)),
),
),
],
),
),
);
}
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, textAlign: widget.textAlign,
overflow: widget.maxLines != null ? ((widget.maxLines! > 1) ? TextOverflow.fade : TextOverflow.ellipsis) : null, overflow: widget.maxLines != null ? ((widget.maxLines! > 1) ? TextOverflow.fade : TextOverflow.ellipsis) : null,
maxLines: widget.maxLines, maxLines: widget.maxLines,
@ -193,9 +124,12 @@ class _AppTextState extends State<AppText> {
fontFamily: widget.fontFamily ?? 'Poppins', fontFamily: widget.fontFamily ?? 'Poppins',
decoration: widget.textDecoration, decoration: widget.textDecoration,
height: widget.fontHeight), height: widget.fontHeight),
)
],
),
),
); );
} }
}
TextStyle? _getFontStyle() { TextStyle? _getFontStyle() {
switch (widget.style) { switch (widget.style) {

Loading…
Cancel
Save