Made the Strings Dynamic

faiz_dev_new
FaizHashmiCS22 2 years ago
parent 941ca2ff0e
commit 0ac7d68a65

@ -8,6 +8,7 @@ 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/base/app_scaffold_widget.dart'; import 'package:queuing_system/core/base/app_scaffold_widget.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_model/call_config.dart';
import 'package:queuing_system/core/response_model/patient_call.dart'; import 'package:queuing_system/core/response_model/patient_call.dart';
import 'package:queuing_system/header/app_header.dart'; import 'package:queuing_system/header/app_header.dart';
import 'package:queuing_system/home/home_screen_components.dart'; import 'package:queuing_system/home/home_screen_components.dart';
@ -19,7 +20,7 @@ import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
var deviceIPGlobal = "10.10.15.11"; var deviceIPGlobal = "10.10.15.11";
bool isDevMode = true; // Testing IP bool isDevMode = false; // Testing IP
// var DEVICE_IP = "10.10.14.11"; // Testing IP // var DEVICE_IP = "10.10.14.11"; // Testing IP
// var DEVICE_IP = "10.10.15.11"; // var DEVICE_IP = "10.10.15.11";
@ -38,6 +39,7 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> { class _MyHomePageState extends State<MyHomePage> {
SignalRHelper signalRHelper = SignalRHelper(); SignalRHelper signalRHelper = SignalRHelper();
CallConfig callConfigsGlobal = CallConfig();
List<Tickets> waitings = []; List<Tickets> waitings = [];
List<Tickets> isQueuePatients = []; List<Tickets> isQueuePatients = [];
@ -52,8 +54,8 @@ class _MyHomePageState extends State<MyHomePage> {
for (var interface in await NetworkInterface.list(type: InternetAddressType.IPv4)) { for (var interface in await NetworkInterface.list(type: InternetAddressType.IPv4)) {
log("interfaces: ${interface.name}"); log("interfaces: ${interface.name}");
//TODO: WE WILL UPDATE THIS WHEN TESTING ON SCREEN //TODO: WE WILL UPDATE THIS WHEN TESTING ON SCREEN
if (interface.name == "wlan0") { // if (interface.name == "wlan0") {
// if (interface.name == "eth0") { if (interface.name == "eth0") {
for (var address in interface.addresses) { for (var address in interface.addresses) {
deviceIPGlobal = address.address; deviceIPGlobal = address.address;
return deviceIPGlobal; return deviceIPGlobal;
@ -106,7 +108,7 @@ class _MyHomePageState extends State<MyHomePage> {
children: [ children: [
InkWell( InkWell(
onTap: () { onTap: () {
onUpdateAvailable(""); // onUpdateAvailable("");
}, },
child: AppText( child: AppText(
"Powered By", "Powered By",
@ -156,29 +158,30 @@ class _MyHomePageState extends State<MyHomePage> {
return noPatientInQueue(); return noPatientInQueue();
} else if (waitings.length > 3) { } else if (waitings.length > 3) {
// Return Content With Side List // Return Content With Side List
return priorityTicketsWithSideList(waitings); return priorityTicketsWithSideList(waitings, callConfigsGlobal);
} else { } else {
// Return Content In Center Aligned // Return Content In Center Aligned
return priorityTickets(waitings); return priorityTickets(waitings, callConfigsGlobal);
} }
} }
String getCallTypeText(Tickets ticket) { String getCallTypeText(Tickets ticket, CallConfig callConfig) {
final callType = ticket.getCallType(); final callType = ticket.getCallType();
final language = callConfig.screenLanguage;
switch (callType) { switch (callType) {
case CallType.vitalSign: case CallType.vitalSign:
return "Please Visit Nurse"; return callConfig.vitalSignText;
case CallType.doctor: case CallType.doctor:
return "Please Visit Doctor"; return callConfig.doctorText;
case CallType.procedure: case CallType.procedure:
return "Please Visit Procedure"; return callConfig.procedureText;
case CallType.vaccination: case CallType.vaccination:
return "Please Visit Vaccination"; return callConfig.vaccinationText;
case CallType.nebulization: case CallType.nebulization:
return "Please Visit Nebulization"; return callConfig.nebulizationText;
break; break;
default: default:
return ""; return callConfig.vitalSignText;
} }
} }
@ -202,13 +205,13 @@ class _MyHomePageState extends State<MyHomePage> {
isCallingInProgress = true; isCallingInProgress = true;
//DONE: After calling this voice call, we should delay for milliseconds that is given by API. After that we will check if there are more patients in isQueuePatients we will remove the patient from waiting list and then update the state //DONE: After calling this voice call, we should delay for milliseconds that is given by API. After that we will check if there are more patients in isQueuePatients we will remove the patient from waiting list and then update the state
if (waitings.isNotEmpty) { if (waitings.isNotEmpty) {
if (waitings.first.isToneReq && waitings.first.isQueue) { if (waitings.first.isToneReq && !waitings.first.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: 2));
} }
if (waitings.first.isVoiceReq && voiceCaller == null && waitings.first.isQueue) { if (waitings.first.isVoiceReq && voiceCaller == null && !waitings.first.isQueue) {
final postVoice = getCallTypeText(waitings.first); final postVoice = getCallTypeText(waitings.first, callConfigsGlobal);
voiceCaller = CallByVoice(waitings.first.queueNo.trim().toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en'); voiceCaller = CallByVoice(waitings.first.queueNo.trim().toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
await voiceCaller.startCalling(waitings.first.queueNo.trim().toString() != waitings.first.callNoStr.trim().toString()); await voiceCaller.startCalling(waitings.first.queueNo.trim().toString() != waitings.first.callNoStr.trim().toString());
voiceCaller = null; voiceCaller = null;
@ -253,8 +256,9 @@ class _MyHomePageState extends State<MyHomePage> {
Future<void> callPatientsAPI() async { Future<void> callPatientsAPI() async {
waitings.clear(); waitings.clear();
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls) { API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls, callConfigs) {
setState(() { setState(() {
callConfigsGlobal = callConfigs;
waitings = waitingCalls; waitings = waitingCalls;
isQueuePatients = isQueuePatientsCalls; isQueuePatients = isQueuePatientsCalls;
// currents = currentInClinic; // currents = currentInClinic;
@ -277,7 +281,7 @@ class _MyHomePageState extends State<MyHomePage> {
if (waitings.isNotEmpty) { if (waitings.isNotEmpty) {
if ((waitings.first.isToneReq && isCallingInProgress) || (waitings.first.isVoiceReq && voiceCaller != null)) { if ((waitings.first.isToneReq && isCallingInProgress) || (waitings.first.isVoiceReq && voiceCaller != null)) {
// if (true) { // if (true) {
Timer(Duration(seconds: isQueuePatients.first.concurrentCallDelaySec), () async { Timer(Duration(seconds: callConfigsGlobal.concurrentCallDelaySec), () async {
await callPatientsAPI(); await callPatientsAPI();
}); });
} else { } else {

Loading…
Cancel
Save