|
|
|
|
@ -78,7 +78,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return AppScaffold(
|
|
|
|
|
appBar: AppHeader(),
|
|
|
|
|
body: content(),
|
|
|
|
|
body: dataContent(),
|
|
|
|
|
bottomNavigationBar: Container(
|
|
|
|
|
color: Colors.grey.withOpacity(0.1),
|
|
|
|
|
height: Utils.getHeight(),
|
|
|
|
|
@ -132,7 +132,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget content() {
|
|
|
|
|
Widget dataContent() {
|
|
|
|
|
// waitings.removeAt(0);
|
|
|
|
|
// waitings = waitings.sublist(0,3);
|
|
|
|
|
voiceCall();
|
|
|
|
|
@ -173,16 +173,37 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
final AudioPlayer audioPlayer = AudioPlayer();
|
|
|
|
|
int callFlag = 0;
|
|
|
|
|
|
|
|
|
|
bool isRequiredVoice({CallType callType, bool isQueueNurse, bool isQueueDr}) {
|
|
|
|
|
if (callType == CallType.DOCTOR && !isQueueDr) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (callType == CallType.NURSE && !isQueueNurse) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
voiceCall() async {
|
|
|
|
|
//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
|
|
|
|
|
|
|
|
|
|
print("I am here");
|
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
|
if (waitings.first.isToneReq) {
|
|
|
|
|
if (waitings.first.isToneReq &&
|
|
|
|
|
isRequiredVoice(
|
|
|
|
|
callType: waitings.first.getCallType(),
|
|
|
|
|
isQueueDr: waitings.first.isQueueDr,
|
|
|
|
|
isQueueNurse: waitings.first.isQueueNurse,
|
|
|
|
|
)) {
|
|
|
|
|
audioPlayer.setAsset("assets/tones/call_tone.mp3");
|
|
|
|
|
await audioPlayer.play();
|
|
|
|
|
await Future.delayed(const Duration(seconds: 2));
|
|
|
|
|
// await Future.delayed(const Duration(seconds: 2));
|
|
|
|
|
}
|
|
|
|
|
if (waitings.first.isVoiceReq && voiceCaller == null) {
|
|
|
|
|
if (waitings.first.isVoiceReq &&
|
|
|
|
|
voiceCaller == null &&
|
|
|
|
|
isRequiredVoice(
|
|
|
|
|
callType: waitings.first.getCallType(),
|
|
|
|
|
isQueueDr: waitings.first.isQueueDr,
|
|
|
|
|
isQueueNurse: waitings.first.isQueueNurse,
|
|
|
|
|
)) {
|
|
|
|
|
final postVoice = getCallTypeText(waitings.first);
|
|
|
|
|
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());
|
|
|
|
|
@ -195,12 +216,12 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
isQueuePatients.removeAt(0);
|
|
|
|
|
}
|
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
|
Tickets ticket = waitings.elementAt(0);
|
|
|
|
|
waitings.removeAt(0);
|
|
|
|
|
waitings.add(ticket);
|
|
|
|
|
// Tickets ticket = waitings.elementAt(0);
|
|
|
|
|
// waitings.removeAt(0);
|
|
|
|
|
// waitings.add(ticket);
|
|
|
|
|
}
|
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
setState(() {});
|
|
|
|
|
// setState(() {});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
|