diff --git a/lib/screens/patients/profile/lab_result/special_result/all_lab_special_result_page.dart b/lib/screens/patients/profile/lab_result/special_result/all_lab_special_result_page.dart index 2dfa1391..e37d3fc7 100644 --- a/lib/screens/patients/profile/lab_result/special_result/all_lab_special_result_page.dart +++ b/lib/screens/patients/profile/lab_result/special_result/all_lab_special_result_page.dart @@ -153,6 +153,8 @@ class _AllLabSpecialResultState extends State { resultData: model.allSpecialLabList[index] .resultDataHTML!, patient: patient!, + labResult: model.allSpecialLabList[index], + model: model ), ), ), diff --git a/lib/screens/patients/profile/lab_result/special_result/special_lab_result_details_page.dart b/lib/screens/patients/profile/lab_result/special_result/special_lab_result_details_page.dart index c3c47010..bc121c13 100644 --- a/lib/screens/patients/profile/lab_result/special_result/special_lab_result_details_page.dart +++ b/lib/screens/patients/profile/lab_result/special_result/special_lab_result_details_page.dart @@ -1,24 +1,32 @@ +import 'package:doctor_app_flutter/core/model/labs/all_special_lab_result_model.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientMedicalReportViewModel.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/labs_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; +import '../../../../../config/size_config.dart'; +import '../../../../../core/model/labs/lab_result.dart'; +import '../../../../../widgets/shared/app_texts_widget.dart'; + class SpecialLabResultDetailsPage extends StatelessWidget { final String resultData; final PatiantInformtion patient; - const SpecialLabResultDetailsPage({Key? key, required this.resultData, required this.patient}) - : super(key: key); + final AllSpecialLabResultModel labResult; + + const SpecialLabResultDetailsPage({Key? key, required this.resultData, required this.patient, required this.labResult}) : super(key: key); @override Widget build(BuildContext context) { - return BaseView( + return BaseView( builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, @@ -26,47 +34,214 @@ class SpecialLabResultDetailsPage extends StatelessWidget { appBar: PatientProfileAppBar( patient, ), - body: Container( - child: SingleChildScrollView( + body: NetworkBaseView( + baseViewModel: model, + child: Container( + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ServiceTitle( + title: TranslationBase.of(context).special + " " + TranslationBase.of(context).lab, + subTitle: TranslationBase.of(context).result, + ), + Row( + children: [ + Expanded( + child: Column( + children: [ + (resultData != null && resultData.isNotEmpty) + ? Container( + width: double.infinity, + margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16), + padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), + decoration: BoxDecoration( + color: Colors.white, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all(Radius.circular(8)), + border: Border.fromBorderSide( + BorderSide( + color: Colors.white, + width: 1.0, + ), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Html(data: resultData ?? ""), + Visibility( + visible: labResult.IsLabTestAttachment ?? false, + child: InkWell( + onTap: () async { + var labAccessNumber = labResult.LabAccessionNo; + // if (patientLabResultList[index].FileNameWithExtensionList?.isNotEmpty == true || patientLabResultList[index].FileNameWithExtensionList?.length == 1) { + // await model.getLabAttachments(patient, labAccessNumber: labAccessNumber, FileName: patientLabResultList[index].FileNameWithExtensionList?.first); + // model.openPDF(); + // return; + // } + // + // if (patientLabResultList[index].UploadedDocuments?.isNotEmpty == true || patientLabResultList[index].UploadedDocuments?.length == 1) { + // await model.getLabAttachments(patient, labAccessNumber: labAccessNumber, uploadedDocument: patientLabResultList[index].UploadedDocuments?.first); + // model.openPDF(); + // return; + // } + + showUploadedDocumentsBottomSheet(context, + documents: labResult.UploadedDocuments, + fileName: labResult.FileNameWithExtensionList, + labAccessNumber: labAccessNumber, + projectID: int.parse(labResult.projectID!), + // projectID: 160, + setupID: labResult.setupID, + model: model); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AppText( + TranslationBase + .of(context) + .showAttachment, + textDecoration: TextDecoration.underline, + color: Colors.red.shade700, + fontSize: SizeConfig.textMultiplier! * 1.2, + fontWeight: FontWeight.w700, + ), + ], + ), + ), + ), + ], + ), + ) + : Container( + child: ErrorMessage( + error: TranslationBase + .of(context) + .noItem, + ), + ), + ], + ), + ), + ], + ), + ], + ), + ), + ), + ), + ), + ); + } + void showUploadedDocumentsBottomSheet( + BuildContext context, { + List? documents, + List? fileName, + String? labAccessNumber, + int? projectID, + String? setupID, + required LabsViewModel model, + }) { + const double kItemHeight = 66.0; // ListTile with contentPadding: 10 + final double screenHeight = MediaQuery.of(context).size.height; + final double maxSheetHeight = screenHeight * 0.5; + final double minSheetHeight = (kItemHeight + 100).clamp(0, maxSheetHeight); + + showModalBottomSheet( + context: context, + isScrollControlled: true, // lets the sheet respect custom height constraints + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(16)), + ), + builder: (BuildContext context) { + return ConstrainedBox( + constraints: BoxConstraints( + minHeight: minSheetHeight, + maxHeight: maxSheetHeight, + ), + child: SafeArea( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, children: [ - ServiceTitle( - title: TranslationBase.of(context).special + - " " + - TranslationBase.of(context).lab, - subTitle: TranslationBase.of(context).result, + // Drag handle + Container( + margin: const EdgeInsets.symmetric(vertical: 8), + width: 40, + height: 4, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(2), + ), ), - resultData != null - ? Container( - width: double.infinity, - margin: - EdgeInsets.symmetric(horizontal: 16, vertical: 16), - padding: - EdgeInsets.symmetric(horizontal: 16, vertical: 16), - decoration: BoxDecoration( - color: Colors.white, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.all(Radius.circular(8)), - border: Border.fromBorderSide( - BorderSide( - color: Colors.white, - width: 1.0, - ), - ), - ), - child: Html(data: resultData ?? ""), - ) - : Container( - child: ErrorMessage( - error: TranslationBase.of(context).noItem, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: Align( + alignment: AlignmentDirectional.centerStart, + child: Text( + TranslationBase.of(context).selectAnAttachment, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + Flexible( + child: Padding( + padding: const EdgeInsets.all(16), + child: Material( + color: const Color(0X55F2F2F2), + child: ListView.separated( + shrinkWrap: true, + padding: EdgeInsets.zero, + itemCount: documents?.length ?? fileName?.length ?? 0, + separatorBuilder: (context, index) => Padding( + padding: const EdgeInsets.all(8.0), + child: const Divider(height: 1, color: Colors.grey), ), + itemBuilder: (context, index) { + final docName = documents?[index]?.fileName ?? fileName?[index]; + + return ListTile( + contentPadding: const EdgeInsets.all(10), + title: Text( + docName ?? "Unnamed Document", + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w500, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + trailing: const Icon( + Icons.chevron_right, + color: Colors.grey, + ), + onTap: () async { + Navigator.pop(context); + if (documents?.isNotEmpty == true) { + await model.getLabAttachments(patient, uploadedDocument: documents![index], projectID: projectID, setupID: setupID); + model.openPDF(); + } + if (fileName?.isNotEmpty == true) { + await model.getLabAttachments(patient, labAccessNumber: labAccessNumber, FileName: fileName![index], projectID: projectID, setupID: setupID); + model.openPDF(); + } + }, + ); + }, ), + ), + ), + ), + const SizedBox(height: 8), ], ), ), - ), - ), + ); + }, ); } }