Pushing till working demo

dev_faiz
Faiz Hashmi 3 years ago
parent c73daeb8e8
commit c9f978f0eb

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:queuing_system/core/base/base_app_client.dart';
import 'package:queuing_system/core/response_model/patient_call.dart';
@ -6,25 +8,22 @@ const _getCallRequestInfoByClinicInfo = "/GetCallRequestInfoByClinincInfo";
const _call_UpdateNotIsQueueRecordByIDAsync = "/Call_UpdateNotIsQueueRecordByID";
class API {
static GetCallRequestInfoByClinincInfo(String deviceIp, {@required Function(List<Tickets>) onSuccess, @required Function(dynamic) onFailure}) async {
static getCallRequestInfoByClinicInfo(String deviceIp, {@required Function(List<Tickets>) onSuccess, @required Function(dynamic) onFailure}) async {
final body = {"IPAdress": deviceIp};
BaseAppClient.post(_getCallRequestInfoByClinicInfo,
body: body,
onSuccess: (response, status) {
if (status == 200) {
var calledByNurse = (response["CalledByNurse"] as List).map((j) => Tickets.fromJson(j)).toList();
print("calledByNurse Length: ${calledByNurse.length}");
log("calledByNurse Length: ${calledByNurse.length}");
final patients = (response["ClinicCurrentPatient"] as List).map((j) => Tickets.fromJson(j)).toList();
print("patients Length: ${patients.length}");
log("patients Length: ${patients.length}");
calledByNurse.addAll(patients);
// calledByNurse.sort((a, b) => a.callNo.compareTo(b.callNo));
// final clinicCurrentPatient = (response["ClinicCurrentPatient"] as List).map((j) => Tickets.fromJson(j)).toList();
onSuccess(calledByNurse.reversed.toList());
} else {
onFailure(response);
@ -33,7 +32,7 @@ class API {
onFailure: (error, status) => onFailure(error));
}
static Call_UpdateNotIsQueueRecordByIDAsync(String deviceIp, {@required Tickets ticket, @required Function(List<Tickets>) onSuccess, @required Function(dynamic) onFailure}) async {
static callUpdateNotIsQueueRecordByIDAsync(String deviceIp, {@required Tickets ticket, @required Function(List<Tickets>) onSuccess, @required Function(dynamic) onFailure}) async {
if (ticket.id == null) {
return;
}
@ -46,7 +45,7 @@ class API {
body: body,
onSuccess: (response, status) {
if (status == 200) {
ticket.call_updated = true;
ticket.callUpdated = true;
_ticketsUpdated.add(ticket);
}
},

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:queuing_system/utils/call_type.dart';
class Tickets {
@ -16,15 +18,11 @@ class Tickets {
this.queueNo,
});
String getParsedDateTime(String date) {
print("gotDate: $date");
DateTime dateTime = DateTime.parse(date);
int getRandomNum() {
return Random().nextInt(1);
}
Tickets.fromJson(dynamic json) {
print("here json: $json");
id = json['ID'];
callNo = json['CallNo'];
roomNo = json['RoomNo'];
@ -38,6 +36,7 @@ class Tickets {
patientID = json['PatientID'];
queueNo = json['QueueNo'];
callNoStr = json['CallNoStr'] ?? json['CallNo'].toString();
isAcknowledged = getRandomNum();
}
int id;
@ -53,7 +52,8 @@ class Tickets {
int patientID;
String queueNo;
String callNoStr;
bool call_updated = false;
bool callUpdated = false;
int isAcknowledged;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
@ -75,7 +75,7 @@ class Tickets {
@override
String toString() {
return (callNo).toString();
return (callNoStr).toString();
}
CallType getCallType() {

@ -14,7 +14,6 @@ import 'package:queuing_system/utils/call_type.dart';
import 'package:queuing_system/utils/signalR_utils.dart';
import 'package:queuing_system/utils/utils.dart';
import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
import 'package:text_to_speech/text_to_speech.dart';
var DEVICE_IP = "10.10.15.11"; // Testing IP
// var DEVICE_IP = "10.10.14.11"; // Testing IP
@ -55,7 +54,6 @@ class _MyHomePageState extends State<MyHomePage> {
TextEditingController controller = TextEditingController();
@override
Widget build(BuildContext context) {
return AppScaffold(
@ -148,26 +146,58 @@ class _MyHomePageState extends State<MyHomePage> {
}
}
String getCallTypeText(Tickets ticket) {
final callType = ticket.getCallType();
switch (callType) {
case CallType.RECEPTION:
return "Please Visit Doctor";
break;
case CallType.NURSE:
return "Please Visit Nurse";
break;
case CallType.DOCTOR:
return "Please Visit Doctor";
break;
case CallType.NONE:
return "";
break;
default:
return "";
}
}
CallByVoice voiceCaller;
voiceCall() async {
var j = {
"ID": 4182,
"PatientID": 123123,
"MobileNo": "05***6794",
"DoctorName": "Shakiera",
"DoctorNameN": "Shakeria",
"PatientGender": 1,
"CallNo": 123,
"callType": 1,
"RoomNo": "10",
"CreatedOn": "/Date(1673771382130+0300)/",
"EditedOn": "/Date(1673771384500+0300)/",
"CallNoStr": "A-5",
"QueueNo": null
};
waitings = [Tickets.fromJson(j)];
if (waitings.isNotEmpty && voiceCaller == null) {
final postVoice = waitings.first.getCallType().audio('en');
voiceCaller = CallByVoice(waitings.first.callNoStr.toString(), preVoice: 'ticket_number.mp3', postVoice: postVoice, lang: 'en');
await voiceCaller.start();
final postVoice = getCallTypeText(waitings.first);
voiceCaller = CallByVoice(waitings.first.callNoStr.toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
await voiceCaller.startCalling();
voiceCaller = null;
}
}
printWaiting() {
for (var value in waitings) {
print("waiting: ${value.callNoStr}");
}
}
onUpdateAvailable(data) async {
waitings.clear();
API.GetCallRequestInfoByClinincInfo(DEVICE_IP, onSuccess: (waitingCalls) {
API.getCallRequestInfoByClinicInfo(DEVICE_IP, onSuccess: (waitingCalls) {
setState(() {
waitings = waitingCalls;
// currents = currentInClinic;
@ -175,9 +205,7 @@ class _MyHomePageState extends State<MyHomePage> {
log("\n\n");
log("--------------------");
// log("Current: $currentInClinic");
// log("Waiting: $waitingCalls");
printWaiting();
log("waiting: $waitings");
log("--------------------");
log("\n\n");
@ -186,12 +214,14 @@ class _MyHomePageState extends State<MyHomePage> {
}
updateTickets() {
// List<Tickets> _ticketsToUpdate = waitings.where((t) => t.call_updated == false).toList();
// API.Call_UpdateNotIsQueueRecordByIDAsync(DEVICE_IP, ticket: _ticketsToUpdate.first, onSuccess: (tickets_updated) {
// print("[${tickets_updated.length}] Tickets Updated: $tickets_updated");
// }, onFailure: (e) {
// print("API UPDate Tickets Failed with : ${e.toString()}");
// });
if (waitings != null && waitings.isNotEmpty) {
List<Tickets> _ticketsToUpdate = waitings.where((t) => t.callUpdated == false).toList();
API.callUpdateNotIsQueueRecordByIDAsync(DEVICE_IP, ticket: _ticketsToUpdate.first, onSuccess: (tickets_updated) {
log("[${tickets_updated.length}] Tickets Updated: $tickets_updated");
}, onFailure: (e) {
log("API UPDate Tickets Failed with : ${e.toString()}");
});
}
}
onConnect() {

@ -1,5 +1,7 @@
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:just_audio/just_audio.dart';
import 'package:flutter_tts/flutter_tts.dart';
class CallByVoice {
final String lang;
@ -9,42 +11,50 @@ class CallByVoice {
CallByVoice(this.ticketNo, {this.lang = 'en', @required this.preVoice, @required this.postVoice});
final _player = AudioPlayer();
final FlutterTts textToSpeech = FlutterTts();
double volume = 1.0;
double pitch = 0.9;
double rate = 0.5;
Future<dynamic> _getLanguages() async => await textToSpeech.getLanguages;
start() async {
startCalling() async {
log("languages: ${await _getLanguages()}");
log("no: $ticketNo");
textToSpeech.setLanguage("en-US");
var splitText = ticketNo.split("-");
// Create Pre Voice Players
if (preVoice != null && preVoice.isNotEmpty) {
await _player.setAsset('assets/voice_$lang/$preVoice');
await _player.play();
textToSpeech.setSpeechRate(rate);
textToSpeech.setPitch(pitch);
textToSpeech.setVolume(volume);
await textToSpeech.speak(preVoice + " .. " + splitText[0] + " .. " + splitText[1] + " .. " + postVoice);
}
// Create Ticket Number Voice Players
final characters = ticketNo.characters.toList();
for (int i = 0; i < characters.length; i++) {
final no = characters[i];
if (no.isNotEmpty && no != "-" && no != "_" && no != " ") {
await Future.delayed(const Duration(milliseconds: 200));
await _player.stop();
await _player.setAsset('assets/voice_$lang/${no.toUpperCase()}.mp3');
await _player.play();
}
}
// // Create Ticket Number Voice Players
// final characters = ticketNo.characters.toList();
// for (int i = 0; i < characters.length; i++) {
// final no = characters[i];
// if (no.isNotEmpty && no != "-" && no != "_" && no != " ") {
//
// await _player.stop();
// await _player.setAsset('assets/voice_$lang/${no.toUpperCase()}.mp3');
// await _player.play();
// }
// }
// Create Post Voice Players
if (postVoice != null && postVoice.isNotEmpty) {
await Future.delayed(const Duration(milliseconds: 1000));
await _player.stop();
await _player.setAsset('assets/voice_$lang/$postVoice');
await _player.play();
}
_player.dispose();
}
stop() async {
await _player.stop();
// if (postVoice != null && postVoice.isNotEmpty) {
// await Future.delayed(const Duration(milliseconds: 1000));
//
// await _player.stop();
// await _player.setAsset('assets/voice_$lang/$postVoice');
// await _player.play();
// }
}
// stop() async {
// await _player.stop();
// }
}

@ -7,14 +7,14 @@ import Foundation
import audio_session
import connectivity_macos
import flutter_tts
import just_audio
import path_provider_macos
import text_to_speech_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
FlutterTtsPlugin.register(with: registry.registrar(forPlugin: "FlutterTtsPlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
TextToSpeechMacOsPlugin.register(with: registry.registrar(forPlugin: "TextToSpeechMacOsPlugin"))
}

@ -151,6 +151,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_tts:
dependency: "direct main"
description:
name: flutter_tts
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.3"
flutter_web_plugins:
dependency: transitive
description: flutter
@ -427,34 +434,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.12"
text_to_speech:
dependency: "direct main"
description:
name: text_to_speech
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.3"
text_to_speech_macos:
dependency: transitive
description:
name: text_to_speech_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1"
text_to_speech_platform_interface:
dependency: transitive
description:
name: text_to_speech_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
text_to_speech_web:
dependency: transitive
description:
name: text_to_speech_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
tuple:
dependency: transitive
description:

@ -40,7 +40,7 @@ dependencies:
http: ^0.13.0
blinking_text: ^1.0.2
just_audio: ^0.9.31
text_to_speech: ^0.2.3
flutter_tts: ^3.6.3
#signalr core
signalr_core: ^1.1.1

@ -6,6 +6,9 @@
#include "generated_plugin_registrant.h"
#include <flutter_tts/flutter_tts_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
FlutterTtsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterTtsPlugin"));
}

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
flutter_tts
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

Loading…
Cancel
Save