|
|
|
|
@ -60,6 +60,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final AudioPlayer audioPlayer = AudioPlayer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
listenNetworkConnectivity();
|
|
|
|
|
@ -76,7 +79,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final AudioPlayer audioPlayer = AudioPlayer();
|
|
|
|
|
audioPlayer.playerStateStream.listen((playerState) {
|
|
|
|
|
if (playerState.processingState == ProcessingState.completed) {
|
|
|
|
|
isCallingInProgress = false;
|
|
|
|
|
@ -255,14 +257,34 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onUpdateAvailable(data, audioPlayer) async {
|
|
|
|
|
onUpdateAvailable(data) async {
|
|
|
|
|
// if (isQueuePatients.isNotEmpty && callFlag == 0) {
|
|
|
|
|
// callFlag = 1;
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
print("hereValues: ${isCallingInProgress || voiceCaller != null}");
|
|
|
|
|
if ((isCallingInProgress || voiceCaller != null) && waitings.isNotEmpty) {
|
|
|
|
|
Timer(Duration(milliseconds: int.parse(waitings.first.queueDuration)), () {
|
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
|
if ((waitings.first.isToneReq && isCallingInProgress) || (waitings.first.isVoiceReq && voiceCaller != null)) {
|
|
|
|
|
// if (true) {
|
|
|
|
|
print("I will wait with $isCallingInProgress ");
|
|
|
|
|
Timer(Duration(milliseconds: int.parse(waitings.first.queueDuration)), () {
|
|
|
|
|
// Timer(Duration(milliseconds: 0), () {
|
|
|
|
|
waitings.clear();
|
|
|
|
|
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls) {
|
|
|
|
|
setState(() {
|
|
|
|
|
waitings = waitingCalls;
|
|
|
|
|
isQueuePatients = isQueuePatientsCalls;
|
|
|
|
|
// currents = currentInClinic;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
log("--------------------");
|
|
|
|
|
log("waiting: $waitings");
|
|
|
|
|
log("isQueuePatients: $isQueuePatients");
|
|
|
|
|
log("--------------------");
|
|
|
|
|
|
|
|
|
|
updateTickets();
|
|
|
|
|
}, onFailure: (error) {});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
waitings.clear();
|
|
|
|
|
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls) {
|
|
|
|
|
setState(() {
|
|
|
|
|
@ -278,7 +300,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
|
|
|
|
|
updateTickets();
|
|
|
|
|
}, onFailure: (error) {});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
waitings.clear();
|
|
|
|
|
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls) {
|
|
|
|
|
@ -337,3 +359,21 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if (isQueuePatients.length > 1) {
|
|
|
|
|
// Timer(Duration(milliseconds: int.parse(waitings.first.queueDuration)), () {
|
|
|
|
|
// Tickets calledTicket = Tickets();
|
|
|
|
|
// if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
// calledTicket = isQueuePatients.elementAt(0);
|
|
|
|
|
// isQueuePatients.removeAt(0);
|
|
|
|
|
// }
|
|
|
|
|
// if (waitings.isNotEmpty) {
|
|
|
|
|
// // Tickets ticket = waitings.elementAt(0);
|
|
|
|
|
// // waitings.removeAt(0);
|
|
|
|
|
// // waitings.add(ticket);
|
|
|
|
|
// }
|
|
|
|
|
// if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
// // setState(() {});
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|