diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 12ae1567..7bfb0397 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -2137,4 +2137,7 @@ const Map localizedValues = { "EROnlineCheckInWaitTurnInstruction": {"en": "Please wait in the waiting area until called by the nurse.", "ar": "يرجى الانتظار في منطقة الانتظار حتى يتم استدعاؤك من قبل الممرضة."}, "EROnlineCheckInHoldPhoneInstruction": {"en": "Hold the phone 1 to 2 cm from the NFC sign displayed on the board", "ar": "امسك الهاتف على مسافة 1 إلى 2 سم من علامة NFC المعروضة على اللوحة"}, "EROnlineCheckInTapOnCheckIn": {"en": "Tap on the check-in button within the app", "ar": "اضغط على زر تسجيل الدخول داخل التطبيق"}, + + "download": {"en": "Download", "ar": "تحميل"}, + "share": {"en": "Share", "ar": "يشارك"}, }; diff --git a/lib/pages/medical/reports/report_list_widget.dart b/lib/pages/medical/reports/report_list_widget.dart index 5eee4dfd..1f29c967 100644 --- a/lib/pages/medical/reports/report_list_widget.dart +++ b/lib/pages/medical/reports/report_list_widget.dart @@ -24,6 +24,7 @@ import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:open_filex/open_filex.dart'; import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; +import 'package:share_plus/share_plus.dart'; class ReportListWidget extends StatelessWidget { final List reportList; @@ -131,31 +132,48 @@ class ReportListWidget extends StatelessWidget { if (reportList[index].status == 2) Row( children: [ - // InkWell( - // onTap: () { - // getMedicalReportPDF(report); - // }, - // child: Padding( - // padding: const EdgeInsets.only(right: 11.0, left: 11.0), - // child: Text(TranslationBase.of(context).viewReport, - // style: TextStyle( - // fontSize: 12, - // fontWeight: FontWeight.w600, - // fontStyle: FontStyle.italic, - // color: CustomColors.accentColor, - // letterSpacing: -0.48, - // height: 18 / 12, - // decoration: TextDecoration.underline)), - // ), - // ), - IconButton( - icon: Icon(Icons.email), - color: Color(0xff28323A), - constraints: BoxConstraints(), - padding: EdgeInsets.zero, - onPressed: () { - showConfirmMessage(reportList[index]); - }) + InkWell( + onTap: () { + getMedicalReportPDF(report, false); + }, + child: Padding( + padding: const EdgeInsets.only(right: 11.0, left: 11.0), + child: Text(TranslationBase.of(context).download, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + fontStyle: FontStyle.italic, + color: CustomColors.accentColor, + letterSpacing: -0.48, + height: 18 / 12, + decoration: TextDecoration.underline)), + ), + ), + InkWell( + onTap: () { + getMedicalReportPDF(report, true); + }, + child: Padding( + padding: const EdgeInsets.only(right: 11.0, left: 11.0), + child: Text(TranslationBase.of(context).share, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + fontStyle: FontStyle.italic, + color: CustomColors.accentColor, + letterSpacing: -0.48, + height: 18 / 12, + decoration: TextDecoration.underline)), + ), + ), + // IconButton( + // icon: Icon(Icons.email), + // color: Color(0xff28323A), + // constraints: BoxConstraints(), + // padding: EdgeInsets.zero, + // onPressed: () { + // showConfirmMessage(reportList[index]); + // }) ], ), ], @@ -187,7 +205,7 @@ class ReportListWidget extends StatelessWidget { ); } - void getMedicalReportPDF(Reports report) { + void getMedicalReportPDF(Reports report, bool isShare) { GifLoaderDialogUtils.showMyDialog(AppGlobal.context); ReportsService _reportsService = locator(); _reportsService @@ -195,11 +213,15 @@ class ReportListWidget extends StatelessWidget { DateUtil.convertDateToString(report.requestDate!), report.setupId!) .then((value) async { GifLoaderDialogUtils.hideDialog(AppGlobal.context); - try { - String path = await _createFileFromString(value["MedicalReportBase64"], "pdf"); - OpenFilex.open(path); - } catch (ex) { - AppToast.showErrorToast(message: "Cannot open file."); + String path = await _createFileFromString(value["MedicalReportBase64"], "pdf"); + if (isShare) { + Share.shareXFiles([XFile(path)], text: "Medical Report"); + } else { + try { + OpenFilex.open(path); + } catch (ex) { + AppToast.showErrorToast(message: "Cannot open file."); + } } }).catchError((err) { GifLoaderDialogUtils.hideDialog(AppGlobal.context); diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index af194c7a..3ce068fb 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -3042,6 +3042,9 @@ class TranslationBase { String get EROnlineCheckInWaitTurn => localizedValues["EROnlineCheckInWaitTurn"][locale.languageCode]; String get EROnlineCheckInWaitTurnInstruction => localizedValues["EROnlineCheckInWaitTurnInstruction"][locale.languageCode]; + String get download => localizedValues["download"][locale.languageCode]; + String get share => localizedValues["share"][locale.languageCode]; + } class TranslationBaseDelegate extends LocalizationsDelegate {