From 3f7ef48fd5f8bbb20d390757a932b977f4e5da31 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Thu, 9 Jul 2020 16:34:52 +0300 Subject: [PATCH] live care chages --- lib/config/config.dart | 3 + lib/config/localized_values.dart | 4 + lib/models/livecare/end_call_req.dart | 28 ++ lib/models/livecare/start_call_res.dart | 32 ++ lib/models/livecare/transfer_to_admin.dart | 36 ++ lib/providers/livecare_provider.dart | 66 +++- lib/routes.dart | 8 +- lib/screens/live_care/panding_list.dart | 31 +- lib/screens/live_care/video_call.dart | 412 +++++++++++++-------- lib/util/translations_delegate_base.dart | 6 + 10 files changed, 459 insertions(+), 167 deletions(-) create mode 100644 lib/models/livecare/end_call_req.dart create mode 100644 lib/models/livecare/start_call_res.dart create mode 100644 lib/models/livecare/transfer_to_admin.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 1054b1d0..7b75da2a 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -74,6 +74,9 @@ const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = const MEMBER_CHECK_ACTIVATION_CODE_NEW = 'Services/Sentry.svc/REST/MemberCheckActivationCode_New'; const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles'; +const TRANSFERT_TO_ADMIN = 'LiveCareApi/DoctorApp/TransferToAdmin'; +const END_CALL = 'LiveCareApi/DoctorApp/EndCall'; +const END_CALL_WITH_CHARGE = 'LiveCareApi/DoctorApp/CompleteCallWithCharge'; var selectedPatientType = 1; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index c5332425..aa25697e 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -216,4 +216,8 @@ const Map> localizedValues = { 'beingGreat': {'en': 'being great', 'ar': 'رائع'}, 'cancel': {'en': 'CANCEL', 'ar': 'الغاء'}, 'done': {'en': 'DONE', 'ar': 'تأكيد'}, + 'resumecall': {'en': 'Resume call', 'ar': 'استئناف المكالمة'}, + 'endcallwithcharge': {'en': 'End with charge', 'ar': 'ينتهي مع الشحن'}, + 'endcall': {'en': 'End Call', 'ar': 'إنهاء المكالمة'}, + 'transfertoadmin': {'en': 'Transfer to admin', 'ar': 'نقل إلى المسؤول'}, }; diff --git a/lib/models/livecare/end_call_req.dart b/lib/models/livecare/end_call_req.dart new file mode 100644 index 00000000..7a1ae8eb --- /dev/null +++ b/lib/models/livecare/end_call_req.dart @@ -0,0 +1,28 @@ +class EndCallReq { + int vCID; + String tokenID; + String generalid; + int doctorId; + bool isDestroy; + + EndCallReq( + {this.vCID, this.tokenID, this.generalid, this.doctorId, this.isDestroy}); + + EndCallReq.fromJson(Map json) { + vCID = json['VC_ID']; + tokenID = json['TokenID']; + generalid = json['generalid']; + doctorId = json['DoctorId']; + isDestroy = json['IsDestroy']; + } + + Map toJson() { + final Map data = new Map(); + data['VC_ID'] = this.vCID; + data['TokenID'] = this.tokenID; + data['generalid'] = this.generalid; + data['DoctorId'] = this.doctorId; + data['IsDestroy'] = this.isDestroy; + return data; + } +} diff --git a/lib/models/livecare/start_call_res.dart b/lib/models/livecare/start_call_res.dart new file mode 100644 index 00000000..0566d76d --- /dev/null +++ b/lib/models/livecare/start_call_res.dart @@ -0,0 +1,32 @@ +class StartCallRes { + String result; + String openSessionID; + String openTokenID; + bool isAuthenticated; + int messageStatus; + + StartCallRes( + {this.result, + this.openSessionID, + this.openTokenID, + this.isAuthenticated, + this.messageStatus}); + + StartCallRes.fromJson(Map json) { + result = json['Result']; + openSessionID = json['OpenSessionID']; + openTokenID = json['OpenTokenID']; + isAuthenticated = json['IsAuthenticated']; + messageStatus = json['MessageStatus']; + } + + Map toJson() { + final Map data = new Map(); + data['Result'] = this.result; + data['OpenSessionID'] = this.openSessionID; + data['OpenTokenID'] = this.openTokenID; + data['IsAuthenticated'] = this.isAuthenticated; + data['MessageStatus'] = this.messageStatus; + return data; + } +} diff --git a/lib/models/livecare/transfer_to_admin.dart b/lib/models/livecare/transfer_to_admin.dart new file mode 100644 index 00000000..841f5e7d --- /dev/null +++ b/lib/models/livecare/transfer_to_admin.dart @@ -0,0 +1,36 @@ +class TransferToAdminReq { + int vCID; + String tokenID; + String generalid; + int doctorId; + bool isOutKsa; + String notes; + + TransferToAdminReq( + {this.vCID, + this.tokenID, + this.generalid, + this.doctorId, + this.isOutKsa, + this.notes}); + + TransferToAdminReq.fromJson(Map json) { + vCID = json['VC_ID']; + tokenID = json['TokenID']; + generalid = json['generalid']; + doctorId = json['DoctorId']; + isOutKsa = json['IsOutKsa']; + notes = json['Notes']; + } + + Map toJson() { + final Map data = new Map(); + data['VC_ID'] = this.vCID; + data['TokenID'] = this.tokenID; + data['generalid'] = this.generalid; + data['DoctorId'] = this.doctorId; + data['IsOutKsa'] = this.isOutKsa; + data['Notes'] = this.notes; + return data; + } +} diff --git a/lib/providers/livecare_provider.dart b/lib/providers/livecare_provider.dart index 20ee8db0..7afb11af 100644 --- a/lib/providers/livecare_provider.dart +++ b/lib/providers/livecare_provider.dart @@ -2,9 +2,12 @@ import 'dart:convert'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/models/livecare/end_call_req.dart'; import 'package:doctor_app_flutter/models/livecare/get_panding_req_list.dart'; import 'package:doctor_app_flutter/models/livecare/get_pending_res_list.dart'; import 'package:doctor_app_flutter/models/livecare/start_call_req.dart'; +import 'package:doctor_app_flutter/models/livecare/start_call_res.dart'; +import 'package:doctor_app_flutter/models/livecare/transfer_to_admin.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; @@ -14,7 +17,9 @@ class LiveCareProvider with ChangeNotifier { DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); List liveCarePendingList = []; - var inCallResponse = {}; + StartCallRes inCallResponse; + var transferToAdmin = {}; + var endCallResponse = {}; bool isFinished = true; bool hasError = false; String errorMsg = ''; @@ -45,27 +50,76 @@ class LiveCareProvider with ChangeNotifier { return Future.value(liveCarePendingList); } - Future startCall(request, bool isReCall) async { + Future startCall(request, bool isReCall) async { var profile = await sharedPref.getObj(DOCTOR_PROFILE); resetDefaultValues(); /* the request model is not same hence added manually */ var newRequest = new StartCallReq(); newRequest.clinicId = profile["ClinicID"]; - newRequest.vCID = request["VC_ID"]; + newRequest.vCID = request.vCID; //["VC_ID"]; newRequest.isrecall = isReCall; newRequest.doctorId = profile["DoctorID"]; - newRequest.isOutKsa = request["IsOutKSA"]; + newRequest.isOutKsa = request.isOutKSA; //["IsOutKSA"]; newRequest.projectName = profile["ProjectName"]; newRequest.docotrName = profile["DoctorName"]; newRequest.clincName = profile["ClinicDescription"]; - newRequest.clincName = profile["ClinicDescription"]; newRequest.docSpec = profile["DoctorTitleForProfile"]; newRequest.generalid = 'Cs2020@2016\$2958'; isFinished = false; await BaseAppClient.post(START_LIVECARE_CALL, onSuccess: (response, statusCode) async { isFinished = true; - inCallResponse = response; + inCallResponse = StartCallRes.fromJson(response); + }, onFailure: (String error, int statusCode) { + isFinished = true; + throw error; + }, body: newRequest.toJson()); + return Future.value(inCallResponse); + } + + transfterToAdmin(request, notes) async { + var profile = await sharedPref.getObj(DOCTOR_PROFILE); + var newRequest = new TransferToAdminReq(); + newRequest.doctorId = profile["DoctorID"]; + newRequest.isOutKsa = request.isOutKSA; + newRequest.generalid = 'Cs2020@2016\$2958'; + newRequest.vCID = request.vCID; //["VC_ID"]; + newRequest.notes = await BaseAppClient.post(TRANSFERT_TO_ADMIN, + onSuccess: (response, statusCode) async { + isFinished = true; + transferToAdmin = response; + }, onFailure: (String error, int statusCode) { + isFinished = true; + throw error; + }, body: newRequest.toJson()); + return Future.value(inCallResponse); + } + + endCall(request, isPaitent, doctorID) async { + var newRequest = new EndCallReq(); + newRequest.doctorId = doctorID; //profile["DoctorID"]; + newRequest.generalid = 'Cs2020@2016\$2958'; + newRequest.vCID = request.vCID; //["VC_ID"]; + newRequest.isDestroy = isPaitent; + await BaseAppClient.post(END_CALL, onSuccess: (response, statusCode) async { + isFinished = true; + endCallResponse = response; + }, onFailure: (String error, int statusCode) { + isFinished = true; + throw error; + }, body: newRequest.toJson()); + return Future.value(inCallResponse); + } + + endCallWithCharge(vcID, doctorID) async { + var newRequest = new EndCallReq(); + newRequest.vCID = vcID; + newRequest.doctorId = doctorID; + newRequest.generalid = 'Cs2020@2016\$2958'; + await BaseAppClient.post(END_CALL_WITH_CHARGE, + onSuccess: (response, statusCode) async { + isFinished = true; + endCallResponse = response; }, onFailure: (String error, int statusCode) { isFinished = true; throw error; diff --git a/lib/routes.dart b/lib/routes.dart index 9280d95e..d820e83e 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -72,8 +72,9 @@ const String PATIENT_INSURANCE_APPROVALS = const String VITAL_SIGN_DETAILS = 'patients/vital-sign-details'; const String BODY_MEASUREMENTS = 'patients/body-measurements'; const String IN_PATIENT_PRESCRIPTIONS_DETAILS = 'patients/prescription-details'; -const String VIDEO_CALL = 'video-call'; +// const String VIDEO_CALL = 'video-call'; const String LIVECARE_PENDING_LIST = 'livecare-pendinglist'; +// const String LIVECARE_END_DIALOG = 'video-call/EndCallDialogBox'; var routes = { ROOT: (_) => RootPage(), HOME: (_) => LandingPage(), @@ -108,6 +109,7 @@ var routes = { VITAL_SIGN_DETAILS: (_) => VitalSignDetailsScreen(), BODY_MEASUREMENTS: (_) => VitalSignItemDetailsScreen(), IN_PATIENT_PRESCRIPTIONS_DETAILS: (_) => InpatientPrescriptionDetailsScreen(), - VIDEO_CALL: (_) => VideoCallPage(), - LIVECARE_PENDING_LIST: (_) => LiveCarePandingListScreen() + // VIDEO_CALL: (_) => VideoCallPage(patientData: null), + LIVECARE_PENDING_LIST: (_) => LiveCarePandingListScreen(), + // LIVECARE_END_DIALOG: (_) => EndCallDialogBox() }; diff --git a/lib/screens/live_care/panding_list.dart b/lib/screens/live_care/panding_list.dart index 7aea2fcd..ad129d55 100644 --- a/lib/screens/live_care/panding_list.dart +++ b/lib/screens/live_care/panding_list.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/providers/livecare_provider.dart'; +import 'package:doctor_app_flutter/screens/live_care/video_call.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; @@ -204,12 +205,20 @@ class _LiveCarePandingListState extends State { .green, //Colors.black, onPressed: () => { _isInit = true, - sharedPref.setObj( - LIVE_CARE_PATIENT, - item), - Navigator.of(context) - .pushNamed( - VIDEO_CALL) + // sharedPref.setObj( + // LIVE_CARE_PATIENT, + // item), + // Navigator.of(context) + // .pushNamed( + // VIDEO_CALL, + // item) + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + VideoCallPage( + item, + context))) }, ), ) @@ -250,3 +259,13 @@ class _LiveCarePandingListState extends State { ); } } + +MyGlobals myGlobals = new MyGlobals(); + +class MyGlobals { + GlobalKey _scaffoldKey; + MyGlobals() { + _scaffoldKey = GlobalKey(); + } + GlobalKey get scaffoldKey => _scaffoldKey; +} diff --git a/lib/screens/live_care/video_call.dart b/lib/screens/live_care/video_call.dart index 4d7d4170..c4c59af1 100644 --- a/lib/screens/live_care/video_call.dart +++ b/lib/screens/live_care/video_call.dart @@ -1,16 +1,25 @@ import 'dart:async'; +import 'package:doctor_app_flutter/models/livecare/get_pending_res_list.dart'; import 'package:doctor_app_flutter/models/livecare/session_status_model.dart'; +import 'package:doctor_app_flutter/models/livecare/start_call_res.dart'; import 'package:doctor_app_flutter/providers/livecare_provider.dart'; +import 'package:doctor_app_flutter/screens/live_care/panding_list.dart'; import 'package:doctor_app_flutter/util/VideoChannel.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:provider/provider.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; +import '../../routes.dart'; class VideoCallPage extends StatefulWidget { + final LiveCarePendingListResponse patientData; + final listContext; + VideoCallPage(this.patientData, this.listContext); + @override _VideoCallPageState createState() => _VideoCallPageState(); } @@ -24,65 +33,67 @@ class _VideoCallPageState extends State { LiveCareProvider _liveCareProvider; bool _isInit = true; var _tokenData; - var patientData = {}; + bool isTransfer = false; String image_url = 'https://hmgwebservices.com/Images/MobileImages/DUBAI/'; //bool _isOutOfStuck = false; Helpers helpers = new Helpers(); + var doctorprofile = {}; + var notes; @override void didChangeDependencies() { super.didChangeDependencies(); if (_isInit) { _liveCareProvider = Provider.of(context); - startCall(); + startCall(false); } _isInit = false; } - void connectOpenTok(tokenData) async { + void connectOpenTok(StartCallRes tokenData) async { _tokenData = tokenData; + //var profile = await sharedPref.getObj(DOCTOR_PROFILE); + + var token = await sharedPref.getString(TOKEN); + doctorprofile = await sharedPref.getObj(DOCTOR_PROFILE); + /* opentok functionalites need to be written */ await VideoChannel.openVideoCallScreen( - kToken: - 'T1==cGFydG5lcl9pZD00NjgwMzIyNCZzaWc9NWRhNmExMzU4ZDViZGU3OTA5NDY4ODRhNzI4ZGUxZTRmMjZmNzcwMjpzZXNzaW9uX2lkPTFfTVg0ME5qZ3dNekl5Tkg1LU1UVTVNelk0TXpZek9EWXdNMzV1Y0V4V1lWUlZTbTVIY3k5dVdHWm1NMWxPYTNjelpIVi1mZyZjcmVhdGVfdGltZT0xNTkzNjgzNjYyJm5vbmNlPTAuODAxMzMzMzUxMDQwNzE5NSZyb2xlPXB1Ymxpc2hlciZleHBpcmVfdGltZT0xNTk2Mjc1NjYyJmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9', - kSessionId: - '1_MX40NjgwMzIyNH5-MTU5MzY4MzYzODYwM35ucExWYVRVSm5Hcy9uWGZmM1lOa3czZHV-fg', - kApiKey: '46803224', - vcId: 3245, - tokenID: "hfkjshdf347r8743", + kToken: tokenData.openTokenID, + + //'T1==cGFydG5lcl9pZD00NjgwMzIyNCZzaWc9NWRhNmExMzU4ZDViZGU3OTA5NDY4ODRhNzI4ZGUxZTRmMjZmNzcwMjpzZXNzaW9uX2lkPTFfTVg0ME5qZ3dNekl5Tkg1LU1UVTVNelk0TXpZek9EWXdNMzV1Y0V4V1lWUlZTbTVIY3k5dVdHWm1NMWxPYTNjelpIVi1mZyZjcmVhdGVfdGltZT0xNTkzNjgzNjYyJm5vbmNlPTAuODAxMzMzMzUxMDQwNzE5NSZyb2xlPXB1Ymxpc2hlciZleHBpcmVfdGltZT0xNTk2Mjc1NjYyJmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9', + kSessionId: tokenData.openSessionID, + //'1_MX40NjgwMzIyNH5-MTU5MzY4MzYzODYwM35ucExWYVRVSm5Hcy9uWGZmM1lOa3czZHV-fg', + kApiKey: '46209962', + vcId: widget.patientData.vCID, + tokenID: token, //"hfkjshdf347r8743", generalId: "Cs2020@2016\$2958", - doctorId: 1485, + doctorId: doctorprofile['DoctorID'], onFailure: (String error) { //TODO handling Failure + //changeRoute(context); }, onCallEnd: () { //TODO handling onCallEnd + WidgetsBinding.instance.addPostFrameCallback((_) { + changeRoute(context); + }); }, onCallNotRespond: (SessionStatusModel sessionStatusModel) { //TODO handling onCalcallNotRespondlEnd + WidgetsBinding.instance.addPostFrameCallback((_) { + changeRoute(context); + }); }); } - String getTimerTime(int start) { - int minutes = (start ~/ 60); - String sMinute = ''; - if (minutes.toString().length == 1) { - sMinute = '0' + minutes.toString(); - } else - sMinute = minutes.toString(); - - int seconds = (start % 60); - String sSeconds = ''; - if (seconds.toString().length == 1) { - sSeconds = '0' + seconds.toString(); - } else - sSeconds = seconds.toString(); - - return sMinute + ':' + sSeconds; - } + startCall(bool isRecall) async { + //patientData = await sharedPref.getObj(LIVE_CARE_PATIENT); + _liveCareProvider.startCall(widget.patientData, isRecall).then((result) { + // //startTimmer(); + setState(() { + _start = 1; + }); - startCall() async { - patientData = await sharedPref.getObj(LIVE_CARE_PATIENT); - _liveCareProvider.startCall(patientData, false).then((result) { connectOpenTok(result); }).catchError((error) => {helpers.showErrorToast(error), Navigator.of(context).pop()}); @@ -96,134 +107,231 @@ class _VideoCallPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - body: SafeArea( - child: Container( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - decoration: BoxDecoration( - color: Colors.white, + body: Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + decoration: BoxDecoration( + color: Colors.white, + ), + padding: EdgeInsets.all(50.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: 10.0, ), - padding: EdgeInsets.all(50.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 10.0, - ), - Text( - 'Dailing...', - style: TextStyle( - color: Colors.deepPurpleAccent, - fontWeight: FontWeight.w300, - fontSize: 15), - ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.02, - ), - Text( - patientData["PatientName"], - style: TextStyle( - color: Colors.deepPurpleAccent, - fontWeight: FontWeight.w900, - fontSize: 20), - ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.02, - ), - Container( - child: Text( - _timmer == '' ? 'Connecting' : 'Connected', - style: TextStyle( - color: Colors.deepPurpleAccent, - fontWeight: FontWeight.w300, - fontSize: 15), - )), - SizedBox( - height: MediaQuery.of(context).size.height * 0.02, - ), - ClipRRect( - borderRadius: BorderRadius.circular(200.0), - child: Image.network( - patientData["Gender"] == "1" - ? image_url + 'unkown.png' - : image_url + 'unkowwn_female.png', - height: 200.0, - width: 200.0, - ), - ), - SizedBox( - height: MediaQuery.of(context).size.height * .2, - ), - Container( - width: 70.0, - height: 70.0, - child: FloatingActionButton( - onPressed: () { - Navigator.of(context).pop(); - }, - elevation: 30.0, - shape: CircleBorder(side: BorderSide(color: Colors.red)), - mini: false, - child: Icon( - Icons.call_end, - color: Colors.red, - size: 35, - ), - backgroundColor: Colors.red[100], - )) - ], + Text( + _start == 0 ? 'Dailing' : 'Connected', + style: TextStyle( + color: Colors.deepPurpleAccent, + fontWeight: FontWeight.w300, + fontSize: 15), + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.02, + ), + Text( + widget.patientData.patientName, + style: TextStyle( + color: Colors.deepPurpleAccent, + fontWeight: FontWeight.w900, + fontSize: 20), ), - ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.02, + ), + Container( + child: Text( + _start == 0 ? 'Connecting...' : _timmer.toString(), + style: TextStyle( + color: Colors.deepPurpleAccent, + fontWeight: FontWeight.w300, + fontSize: 15), + )), + SizedBox( + height: MediaQuery.of(context).size.height * 0.02, + ), + ClipRRect( + borderRadius: BorderRadius.circular(200.0), + child: Image.network( + image_url + 'unkown.png', + height: 200.0, + width: 200.0, + ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * .2, + ), + Container( + width: 70.0, + height: 70.0, + child: FloatingActionButton( + onPressed: () { + Navigator.of(context).pop(); + }, + elevation: 30.0, + shape: CircleBorder(side: BorderSide(color: Colors.red)), + mini: false, + child: Icon( + Icons.call_end, + color: Colors.red, + size: 35, + ), + backgroundColor: Colors.red[100], + )) + ], ), - ); + )); + } + + changeRoute(con) async { + // await Future.delayed(Duration(seconds: 1), () { + _showAlert(con); + //}); } -} -class FunctionalButton extends StatefulWidget { - final title; - final icon; - final Function() onPressed; + _showAlert(BuildContext context) async { + await showDialog( + context: context, + builder: (dialogContex) => AlertDialog(content: StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return Container( + height: MediaQuery.of(context).size.height * 0.7, + width: MediaQuery.of(context).size.width * .9, + child: Stack( + fit: StackFit.loose, + overflow: Overflow.visible, + children: [ + Positioned( + right: -40.0, + top: -40.0, + child: InkResponse( + onTap: () { + Navigator.of(context, rootNavigator: true) + .pop('dialog'); + Navigator.of(context).pop(); + }, + child: CircleAvatar( + child: Icon(Icons.close), + backgroundColor: Colors.red, + ), + ), + ), + Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: EdgeInsets.all(8.0), + child: RaisedButton( + onPressed: () => {endCall()}, + child: + Text(TranslationBase.of(context).endcall), + color: Colors.red, + textColor: Colors.white, + )), + Padding( + padding: EdgeInsets.all(8.0), + child: RaisedButton( + onPressed: () => {resumeCall()}, + child: + Text(TranslationBase.of(context).resumecall), + color: Colors.green[900], + textColor: Colors.white, + ), + ), + Padding( + padding: EdgeInsets.all(8.0), + child: RaisedButton( + onPressed: () => {endCallWithCharge()}, + child: Text(TranslationBase.of(context) + .endcallwithcharge), + textColor: Colors.white, + ), + ), + Padding( + padding: EdgeInsets.all(8.0), + child: RaisedButton( + onPressed: () => { + setState(() => {isTransfer = true}) + }, + child: Text( + TranslationBase.of(context).transfertoadmin), + color: Colors.yellow[900], + ), + ), + isTransfer == true + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Notes'), + Padding( + padding: EdgeInsets.all(5.0), + child: TextField( + maxLines: 3, + controller: notes, + decoration: InputDecoration.collapsed( + hintText: + "Enter your notes here"), + )), + Center( + child: RaisedButton( + onPressed: () => + {this.transferToAdmin(notes)}, + child: Text('Transfer'), + color: Colors.yellow[900], + )) + ], + ) + : SizedBox() + ], + )) + ], + )); + }))); + Navigator.pop(context); + } - const FunctionalButton({Key key, this.title, this.icon, this.onPressed}) - : super(key: key); + resumeCall() { + closeRoute(); + startCall(true); + } - @override - _FunctionalButtonState createState() => _FunctionalButtonState(); -} + transferToAdmin(notes) { + closeRoute(); + _liveCareProvider + .transfterToAdmin(widget.patientData, notes) + .then((result) { + connectOpenTok(result); + }).catchError((error) => + {helpers.showErrorToast(error), Navigator.of(context).pop()}); + } -class _FunctionalButtonState extends State { - @override - Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - RawMaterialButton( - onPressed: widget.onPressed, - splashColor: Colors.deepPurpleAccent, - fillColor: Colors.white, - elevation: 10.0, - shape: CircleBorder(), - child: Padding( - padding: const EdgeInsets.all(15.0), - child: Icon( - widget.icon, - size: 30.0, - color: Colors.deepPurpleAccent, - ), - ), - ), - Container( - margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 2.0), - child: Text( - widget.title, - style: TextStyle(fontSize: 15.0, color: Colors.deepPurpleAccent), - ), - ) - ], - ); + endCall() { + closeRoute(); + _liveCareProvider + .endCall(widget.patientData, false, doctorprofile['DoctorID']) + .then((result) { + print(result); + }).catchError((error) => + {helpers.showErrorToast(error), Navigator.of(context).pop()}); + } + + endCallWithCharge() { + _liveCareProvider + .endCallWithCharge(widget.patientData.vCID, doctorprofile['DoctorID']) + .then((result) { + closeRoute(); + print('end callwith charge'); + print(result); + }).catchError((error) => + {helpers.showErrorToast(error), Navigator.of(context).pop()}); + } + + closeRoute() { + Navigator.of(context).pop(); } } diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index ad52edd8..a8821dda 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -235,6 +235,12 @@ class TranslationBase { String get beingGreat => localizedValues['beingGreat'][locale.languageCode]; String get cancel => localizedValues['cancel'][locale.languageCode]; String get done => localizedValues['done'][locale.languageCode]; + String get resumecall => localizedValues['resumecall'][locale.languageCode]; + String get endcallwithcharge => + localizedValues['endcallwithcharge'][locale.languageCode]; + String get endcall => localizedValues['endcall'][locale.languageCode]; + String get transfertoadmin => + localizedValues['transfertoadmin'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {