You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RSGDoctorApp/lib/screens/live_care/end_call_screen.dart

251 lines
11 KiB
Dart

import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/livecare/session_status_model.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/screens/live_care/live-care_transfer_to_admin.dart';
import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/PatientProfileCardModel.dart';
import 'package:doctor_app_flutter/util/VideoChannel.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/patients/profile/PatientProfileButton.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:hexcolor/hexcolor.dart';
class EndCallScreen extends StatefulWidget {
final PatiantInformtion patient;
const EndCallScreen({Key? key, required this.patient}) : super(key: key);
@override
_EndCallScreenState createState() => _EndCallScreenState();
}
class _EndCallScreenState extends State<EndCallScreen> {
bool isInpatient = false;
bool isDischargedPatient = false;
bool isSearchAndOut = false;
late String patientType;
late String arrivalType;
late String from;
late String to;
late LiveCarePatientViewModel liveCareModel;
@override
Widget build(BuildContext context) {
final List<PatientProfileCardModel> cardsList = [
PatientProfileCardModel(
TranslationBase.of(context).resume!, TranslationBase.of(context).theCall!, '', 'patient/vital_signs.png',
isInPatient: isInpatient, onTap: () async {
GifLoaderDialogUtils.showMyDialog(context);
await liveCareModel.startCall(isReCall: false, vCID: widget.patient.vcId!).then((value) async {
await liveCareModel.getDoctorProfile();
GifLoaderDialogUtils.hideDialog(context);
if (liveCareModel.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(liveCareModel.error);
} else
await VideoChannel.openVideoCallScreen(
kToken: liveCareModel.startCallRes.openTokenID,
kSessionId: liveCareModel.startCallRes.openSessionID,
kApiKey: '46209962',
vcId: widget.patient.vcId,
tokenID: await liveCareModel.getToken(),
generalId: GENERAL_ID,
doctorId: liveCareModel.doctorProfile!.doctorID,
onFailure: (String error) {
DrAppToastMsg.showErrorToast(error);
},
onCallEnd: () async {
GifLoaderDialogUtils.showMyDialog(context);
GifLoaderDialogUtils.showMyDialog(context);
await liveCareModel.endCall(
widget.patient.vcId!,
false,
);
GifLoaderDialogUtils.hideDialog(context);
if (liveCareModel.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(liveCareModel.error);
}
},
onCallNotRespond: (SessionStatusModel sessionStatusModel) async {
GifLoaderDialogUtils.showMyDialog(context);
GifLoaderDialogUtils.showMyDialog(context);
await liveCareModel.endCall(
widget.patient.vcId!,
sessionStatusModel.sessionStatus == 3,
);
GifLoaderDialogUtils.hideDialog(context);
if (liveCareModel.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(liveCareModel.error);
}
});
});
GifLoaderDialogUtils.hideDialog(context);
if (liveCareModel.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(liveCareModel.error);
}
}, isDartIcon: true, dartIcon: DoctorApp.call),
PatientProfileCardModel(
TranslationBase.of(context).endLC!, TranslationBase.of(context).consultation!, '', 'patient/vital_signs.png',
isInPatient: isInpatient, onTap: () {
Helpers.showConfirmationDialog(context,
"${TranslationBase.of(context).areYouSureYouWantTo} ${TranslationBase.of(context).endLC} ${TranslationBase.of(context).consultation} ?",
() async {
Navigator.of(context).pop();
GifLoaderDialogUtils.showMyDialog(context);
await 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),
PatientProfileCardModel(TranslationBase.of(context).sendLC!, TranslationBase.of(context).instruction!, "",
'patient/health_summary.png',
onTap: () {},
isInPatient: isInpatient,
isDartIcon: true,
isDisable: true,
dartIcon: DoctorApp.send_instruction),
PatientProfileCardModel(
TranslationBase.of(context).transferTo!, TranslationBase.of(context).admin!, '', 'patient/health_summary.png',
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (BuildContext context) => LivaCareTransferToAdmin(patient: widget.patient)));
}, isInPatient: isInpatient, isDartIcon: true, dartIcon: DoctorApp.transfer_to_admin),
];
return BaseView<LiveCarePatientViewModel>(
onModelReady: (model) {
liveCareModel = model;
},
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
appBarTitle: TranslationBase.of(context).patientProfile!,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
isShowAppBar: true,
appBar: PatientProfileHeaderNewDesignAppBar(widget.patient, arrivalType ?? '7', '1',
isInpatient: isInpatient,
height: (widget.patient.patientStatusType != null && widget.patient.patientStatusType == 43)
? 210
: isDischargedPatient
? 240
: 0,
isDischargedPatient: isDischargedPatient),
body: Container(
height: !isSearchAndOut
? isDischargedPatient
? MediaQuery.of(context).size.height * 0.64
: MediaQuery.of(context).size.height * 0.65
: MediaQuery.of(context).size.height * 0.69,
child: ListView(
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
TranslationBase.of(context).patient,
fontSize: 14,
fontWeight: FontWeight.w500,
),
AppText(
TranslationBase.of(context).endcall,
fontSize: 26,
fontWeight: FontWeight.bold,
),
SizedBox(
height: 10,
),
StaggeredGridView.countBuilder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
itemCount: cardsList.length,
staggeredTileBuilder: (int index) => StaggeredTile.fit(1),
itemBuilder: (BuildContext context, int index) => PatientProfileButton(
patient: widget.patient,
patientType: patientType,
arrivalType: arrivalType,
from: from,
to: to,
nameLine1: cardsList[index].nameLine1,
nameLine2: cardsList[index].nameLine2,
route: cardsList[index].route,
icon: cardsList[index].icon,
isInPatient: cardsList[index].isInPatient,
isDischargedPatient: cardsList[index].isDischargedPatient,
isDisable: cardsList[index].isDisable,
onTap: cardsList[index].onTap,
isLoading: cardsList[index].isLoading,
isDartIcon: cardsList[index].isDartIcon,
dartIcon: cardsList[index].dartIcon,
),
),
],
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.05,
)
],
),
),
bottomSheet: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(0.0),
),
border: Border.all(color: HexColor('#707070'), width: 0),
),
height: MediaQuery.of(context).size.height * 0.1,
width: double.infinity,
child: Column(
children: [
SizedBox(
height: 10,
),
Container(
child: FractionallySizedBox(
widthFactor: .80,
child: Center(
child: AppButton(
fontWeight: FontWeight.w700,
color: Colors.red[600],
title: "Close", //TranslationBase.of(context).close,
onPressed: () {
Navigator.of(context).pop();
},
),
),
),
),
SizedBox(
height: 5,
),
],
),
),
),
);
}
}