From 0cd7fa0cb2530d811dc1bd7691f99662b17c59ba Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 20 May 2021 17:07:50 +0300 Subject: [PATCH] working on livecare --- .../patient/LiveCarePatientServices.dart | 20 +++++ .../viewModel/LiveCarePatientViewModel.dart | 13 +++ lib/screens/live_care/end_call_screen.dart | 5 +- .../live-care_transfer_to_admin.dart | 86 ++++++++++++++++++- .../shared/buttons/button_bottom_sheet.dart | 38 ++++---- 5 files changed, 142 insertions(+), 20 deletions(-) diff --git a/lib/core/service/patient/LiveCarePatientServices.dart b/lib/core/service/patient/LiveCarePatientServices.dart index 36ca2c7e..0a8c4894 100644 --- a/lib/core/service/patient/LiveCarePatientServices.dart +++ b/lib/core/service/patient/LiveCarePatientServices.dart @@ -12,6 +12,7 @@ class LiveCarePatientServices extends BaseService{ bool get isFinished => _isFinished; var endCallResponse = {}; + var transferToAdminResponse = {}; Future getPendingPatientERForDoctorApp(PendingPatientERForDoctorAppRequestModel pendingPatientERForDoctorAppRequestModel) async{ hasError = false; @@ -58,4 +59,23 @@ class LiveCarePatientServices extends BaseService{ }, ); } + + Future transferToAdmin(int vcID, String notes) async{ + hasError = false; + await baseAppClient.post( + TRANSFERT_TO_ADMIN, + onSuccess: (dynamic response, int statusCode) { + transferToAdminResponse = response; + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: { + "VC_ID": vcID, + "IsOutKsa": false, + "Notes": notes, + }, + ); + } } \ No newline at end of file diff --git a/lib/core/viewModel/LiveCarePatientViewModel.dart b/lib/core/viewModel/LiveCarePatientViewModel.dart index 8c7587a4..e8b07cba 100644 --- a/lib/core/viewModel/LiveCarePatientViewModel.dart +++ b/lib/core/viewModel/LiveCarePatientViewModel.dart @@ -70,6 +70,19 @@ class LiveCarePatientViewModel extends BaseViewModel { } } + Future transferToAdmin(int vcID, String notes) async { + setState(ViewState.BusyLocal); + await _liveCarePatientServices + .transferToAdmin(vcID, notes); + if (_liveCarePatientServices.hasError) { + error = _liveCarePatientServices.error; + setState(ViewState.ErrorLocal); + } else { + await getPendingPatientERForDoctorApp(); + setState(ViewState.Idle); + } + } + searchData(String str) { var strExist= str.length > 0 ? true : false; if (strExist) { diff --git a/lib/screens/live_care/end_call_screen.dart b/lib/screens/live_care/end_call_screen.dart index b7657d31..e33d476c 100644 --- a/lib/screens/live_care/end_call_screen.dart +++ b/lib/screens/live_care/end_call_screen.dart @@ -59,10 +59,13 @@ class _EndCallScreenState extends State { () async { Navigator.of(context).pop(); GifLoaderDialogUtils.showMyDialog(context); - liveCareModel.endCallWithCharge(0); + liveCareModel.endCallWithCharge(widget.patient.vcId); GifLoaderDialogUtils.hideDialog(context); if (liveCareModel.state == ViewState.ErrorLocal) { DrAppToastMsg.showErrorToast(liveCareModel.error); + } else { + Navigator.of(context).pop(); + Navigator.of(context).pop(); } }); }, isDartIcon: true, dartIcon: DoctorApp.end_consultaion), diff --git a/lib/screens/live_care/live-care_transfer_to_admin.dart b/lib/screens/live_care/live-care_transfer_to_admin.dart index 33f55c95..c5bcf304 100644 --- a/lib/screens/live_care/live-care_transfer_to_admin.dart +++ b/lib/screens/live_care/live-care_transfer_to_admin.dart @@ -1,12 +1,19 @@ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/buttons/button_bottom_sheet.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/speech-text-popup.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; @@ -30,6 +37,7 @@ class _LivaCareTransferToAdminState extends State { ProjectViewModel projectViewModel; TextEditingController noteController = TextEditingController(); + String noteError; void initState() { requestPermissions(); @@ -51,10 +59,84 @@ class _LivaCareTransferToAdminState extends State { onModelReady: (model) {}, builder: (_, model, w) => AppScaffold( baseViewModel: model, - appBarTitle: "${TranslationBase.of(context).transferTo}${TranslationBase.of(context).admin}", + appBarTitle: + "${TranslationBase.of(context).transferTo}${TranslationBase.of(context).admin}", backgroundColor: Theme.of(context).scaffoldBackgroundColor, isShowAppBar: true, - body: Container(), + body: Container( + child: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + color: Colors.white, + margin: EdgeInsets.all(16), + child: Stack( + children: [ + AppTextFieldCustom( + hintText: TranslationBase.of(context).notes, + //TranslationBase.of(context).addProgressNote, + controller: noteController, + maxLines: 35, + minLines: 25, + hasBorder: true, + validationError: noteError, + ), + Positioned( + top: -2, //MediaQuery.of(context).size.height * 0, + right: projectViewModel.isArabic + ? MediaQuery.of(context).size.width * 0.75 + : 15, + child: Column( + children: [ + IconButton( + icon: Icon(DoctorApp.speechtotext, + color: Colors.black, size: 35), + onPressed: () { + initSpeechState() + .then((value) => {onVoiceText()}); + }, + ), + ], + )) + ], + ), + ), + ), + ), + ButtonBottomSheet( + title: + "${TranslationBase.of(context).transferTo}${TranslationBase.of(context).admin}", + onPressed: () { + setState(() { + if (noteController.text.isEmpty) { + noteError = TranslationBase.of(context).emptyMessage; + } else { + noteError = null; + } + if (noteController.text.isNotEmpty) { + Helpers.showConfirmationDialog(context, + "${TranslationBase.of(context).areYouSureYouWantTo} ${TranslationBase.of(context).transferTo}${TranslationBase.of(context).admin} ?", + () async { + Navigator.of(context).pop(); + GifLoaderDialogUtils.showMyDialog(context); + model.endCallWithCharge(widget.patient.vcId); + GifLoaderDialogUtils.hideDialog(context); + if (model.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(model.error); + } else { + Navigator.of(context).pop(); + Navigator.of(context).pop(); + Navigator.of(context).pop(); + } + }); + } + }); + }, + ) + ], + ), + ), ), ); } diff --git a/lib/widgets/shared/buttons/button_bottom_sheet.dart b/lib/widgets/shared/buttons/button_bottom_sheet.dart index 9db662d2..3c5cc32d 100644 --- a/lib/widgets/shared/buttons/button_bottom_sheet.dart +++ b/lib/widgets/shared/buttons/button_bottom_sheet.dart @@ -42,23 +42,27 @@ class ButtonBottomSheet extends StatelessWidget { Widget build(BuildContext context) { return Container( margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16), - child: AppButton( - title: title, - onPressed: onPressed, - fontWeight: fontWeight, - color: color, - fontSize: fontSize, - padding: padding, - disabled: disabled, - radius: radius, - hasBorder: hasBorder, - fontColor: fontColor, - icon: icon, - iconData: iconData, - hPadding: hPadding, - vPadding: vPadding, - borderColor: borderColor, - loading: loading, + child: Column( + children: [ + AppButton( + title: title, + onPressed: onPressed, + fontWeight: fontWeight, + color: color, + fontSize: fontSize, + padding: padding, + disabled: disabled, + radius: radius, + hasBorder: hasBorder, + fontColor: fontColor, + icon: icon, + iconData: iconData, + hPadding: hPadding, + vPadding: vPadding, + borderColor: borderColor, + loading: loading, + ), + ], ), ); }