|
|
|
@ -2,9 +2,9 @@ import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:connectivity/connectivity.dart';
|
|
|
|
import 'package:connectivity/connectivity.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.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/base/app_scaffold_widget.dart';
|
|
|
|
import 'package:queuing_system/core/base/app_scaffold_widget.dart';
|
|
|
|
import 'package:queuing_system/core/config/config.dart';
|
|
|
|
|
|
|
|
import 'package:queuing_system/core/config/size_config.dart';
|
|
|
|
import 'package:queuing_system/core/config/size_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';
|
|
|
|
@ -22,7 +22,9 @@ var DEVICE_IP = "10.10.15.11"; // Testing IP
|
|
|
|
// var DEVICE_IP = "10.70.249.21"; // (Make sure by Haroon before use it) Production IP
|
|
|
|
// var DEVICE_IP = "10.70.249.21"; // (Make sure by Haroon before use it) Production IP
|
|
|
|
|
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
String title = "MyHomePage";
|
|
|
|
final String title = "MyHomePage";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const MyHomePage({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
@ -82,30 +84,30 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
// Row(
|
|
|
|
children: [
|
|
|
|
// children: [
|
|
|
|
const SizedBox(width: 60),
|
|
|
|
// const SizedBox(width: 60),
|
|
|
|
SizedBox(
|
|
|
|
// SizedBox(
|
|
|
|
width: 200,
|
|
|
|
// width: 200,
|
|
|
|
child: TextField(
|
|
|
|
// child: TextField(
|
|
|
|
controller: controller,
|
|
|
|
// controller: controller,
|
|
|
|
)),
|
|
|
|
// )),
|
|
|
|
const SizedBox(width: 30),
|
|
|
|
// const SizedBox(width: 30),
|
|
|
|
isLoading
|
|
|
|
// isLoading
|
|
|
|
? const CircularProgressIndicator()
|
|
|
|
// ? const CircularProgressIndicator()
|
|
|
|
: ElevatedButton(
|
|
|
|
// : ElevatedButton(
|
|
|
|
onPressed: onUpdateIPPressed,
|
|
|
|
// onPressed: onUpdateIPPressed,
|
|
|
|
child: const Text(
|
|
|
|
// child: const Text(
|
|
|
|
"Update IP",
|
|
|
|
// "Update IP",
|
|
|
|
style: TextStyle(color: Colors.white),
|
|
|
|
// style: TextStyle(color: Colors.white),
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
style: ElevatedButton.styleFrom(backgroundColor: AppGlobal.appRedColor),
|
|
|
|
// style: ElevatedButton.styleFrom(backgroundColor: AppGlobal.appRedColor),
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
const SizedBox(width: 30),
|
|
|
|
// const SizedBox(width: 30),
|
|
|
|
Text("IP: $DEVICE_IP", style: const TextStyle(fontWeight: FontWeight.w600)),
|
|
|
|
// Text("IP: $DEVICE_IP", style: const TextStyle(fontWeight: FontWeight.w600)),
|
|
|
|
const SizedBox(width: 20),
|
|
|
|
// const SizedBox(width: 20),
|
|
|
|
],
|
|
|
|
// ],
|
|
|
|
),
|
|
|
|
// ),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -168,35 +170,64 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CallByVoice voiceCaller;
|
|
|
|
CallByVoice voiceCaller;
|
|
|
|
|
|
|
|
final AudioPlayer audioPlayer = AudioPlayer();
|
|
|
|
int callFlag = 0;
|
|
|
|
int callFlag = 0;
|
|
|
|
|
|
|
|
|
|
|
|
voiceCall() async {
|
|
|
|
voiceCall() async {
|
|
|
|
//TODO: 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 && voiceCaller == null) {
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
|
|
|
|
if (waitings.first.isToneReq) {
|
|
|
|
|
|
|
|
audioPlayer.setAsset("assets/tones/call_tone.mp3");
|
|
|
|
|
|
|
|
await audioPlayer.play();
|
|
|
|
|
|
|
|
await Future.delayed(const Duration(seconds: 2));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (waitings.first.isVoiceReq && voiceCaller == null) {
|
|
|
|
final postVoice = getCallTypeText(waitings.first);
|
|
|
|
final postVoice = getCallTypeText(waitings.first);
|
|
|
|
voiceCaller = CallByVoice(waitings.first.callNoStr.toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
|
|
|
|
voiceCaller = CallByVoice(waitings.first.queueNo.toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
|
|
|
|
await voiceCaller.startCalling();
|
|
|
|
await voiceCaller.startCalling();
|
|
|
|
voiceCaller = null;
|
|
|
|
voiceCaller = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
await Future.delayed(Duration(milliseconds: int.parse(isQueuePatients.first.queueDuration) * 10)).whenComplete(() async {
|
|
|
|
await Future.delayed(Duration(milliseconds: int.parse(isQueuePatients.first.queueDuration) * 10)).whenComplete(() async {
|
|
|
|
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
isQueuePatients.removeAt(0);
|
|
|
|
isQueuePatients.removeAt(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
Tickets ticket = waitings.elementAt(0);
|
|
|
|
Tickets ticket = waitings.elementAt(0);
|
|
|
|
waitings.removeAt(0);
|
|
|
|
waitings.removeAt(0);
|
|
|
|
waitings.add(ticket);
|
|
|
|
waitings.add(ticket);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isQueuePatients.isEmpty && callFlag == 1) {
|
|
|
|
|
|
|
|
callFlag == 0;
|
|
|
|
|
|
|
|
await Future.delayed(const Duration(seconds: 3));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// if (isQueuePatients.isEmpty && callFlag == 1) {
|
|
|
|
|
|
|
|
// callFlag == 0;
|
|
|
|
|
|
|
|
// await Future.delayed(const Duration(seconds: 3));
|
|
|
|
|
|
|
|
// waitings.clear();
|
|
|
|
|
|
|
|
// API.getCallRequestInfoByClinicInfo(DEVICE_IP, onSuccess: (waitingCalls, isQueuePatientsCalls) {
|
|
|
|
|
|
|
|
// setState(() {
|
|
|
|
|
|
|
|
// waitings = waitingCalls;
|
|
|
|
|
|
|
|
// isQueuePatients = isQueuePatientsCalls;
|
|
|
|
|
|
|
|
// // currents = currentInClinic;
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// log("--------------------");
|
|
|
|
|
|
|
|
// log("waiting: $waitings");
|
|
|
|
|
|
|
|
// log("isQueuePatients: $isQueuePatients");
|
|
|
|
|
|
|
|
// log("--------------------");
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// updateTickets();
|
|
|
|
|
|
|
|
// }, onFailure: (error) {});
|
|
|
|
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onUpdateAvailable(data) async {
|
|
|
|
onUpdateAvailable(data) async {
|
|
|
|
|
|
|
|
print("here is the data: $data");
|
|
|
|
if (isQueuePatients.isNotEmpty && callFlag == 0) {
|
|
|
|
if (isQueuePatients.isNotEmpty && callFlag == 0) {
|
|
|
|
callFlag = 1;
|
|
|
|
callFlag = 1;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|