From 0a478e077aec0411bb70ea054acf56930b74142b Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 31 Oct 2023 10:42:07 +0300 Subject: [PATCH] QR Code checkin implemented --- lib/pages/BookAppointment/QRCode.dart | 126 +++++++++++++----- lib/uitl/utils.dart | 23 ++-- .../medical/medical_profile_item.dart | 4 +- 3 files changed, 105 insertions(+), 48 deletions(-) diff --git a/lib/pages/BookAppointment/QRCode.dart b/lib/pages/BookAppointment/QRCode.dart index 5c17950b..ad676eff 100644 --- a/lib/pages/BookAppointment/QRCode.dart +++ b/lib/pages/BookAppointment/QRCode.dart @@ -1,5 +1,6 @@ import 'dart:typed_data'; +import 'package:barcode_scan2/barcode_scan2.dart'; import 'package:diplomaticquarterapp/analytics/google-analytics.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/locator.dart'; @@ -18,6 +19,7 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/custom_text_button.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/new_design/doctor_header.dart'; import 'package:diplomaticquarterapp/widgets/nfc/nfc_reader_sheet.dart'; @@ -56,7 +58,7 @@ class _QRCodeState extends State { }); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { - startNFCScan(); + // startNFCScan(); }); super.initState(); @@ -76,9 +78,18 @@ class _QRCodeState extends State { }); } + startQRCodeScan() async { + String onlineCheckInQRCode = (await BarcodeScanner.scan())?.rawContent; + if (onlineCheckInQRCode != "") { + sendNfcCheckInRequest(onlineCheckInQRCode); + locator().todoList.to_do_list_nfc(widget.appointment); + } else {} + } + @override Widget build(BuildContext context) { _context = context; + List checkInOptionsList = getCheckInOptionsList(context); return AppScaffold( appBarTitle: TranslationBase.of(context).onlineCheckIn, isShowAppBar: true, @@ -123,47 +134,94 @@ class _QRCodeState extends State { )), ), mHeight(21), - Row( - children: [ - - ], - ) - ], - ), - ), - bottomSheet: Container( - color: CustomColors.appBackgroudGreyColor, - padding: EdgeInsets.all(21), - // height: 45.0, - child: Row( - children: [ - Expanded( - flex: 1, - child: ButtonTheme( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10.0), - ), - height: 45.0, - child: CustomTextButton( - backgroundColor: CustomColors.green, - elevation: 0, - onPressed: () { - startNFCScan(); - }, - child: Text(TranslationBase.of(context).scanNFC, - style: TextStyle( - fontSize: 18.0, - color: Colors.white, - )), - ), + Padding( + padding: EdgeInsets.only(left: 21, right: 21), + child: GridView.builder( + shrinkWrap: true, + primary: false, + physics: NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 2 / 2, crossAxisSpacing: 12, mainAxisSpacing: 12), + padding: EdgeInsets.zero, + itemCount: checkInOptionsList.length, + itemBuilder: (BuildContext context, int index) { + return checkInOptionsList[index]; + }, ), ), ], ), ), + // bottomSheet: Container( + // color: CustomColors.appBackgroudGreyColor, + // padding: EdgeInsets.all(21), + // // height: 45.0, + // child: Row( + // children: [ + // Expanded( + // flex: 1, + // child: ButtonTheme( + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(10.0), + // ), + // height: 45.0, + // child: CustomTextButton( + // backgroundColor: CustomColors.green, + // elevation: 0, + // onPressed: () { + // startNFCScan(); + // }, + // child: Text(TranslationBase.of(context).scanNFC, + // style: TextStyle( + // fontSize: 18.0, + // color: Colors.white, + // )), + // ), + // ), + // ), + // ], + // ), + // ), ); } + List getCheckInOptionsList(BuildContext context) { + List optionsList = []; + + optionsList.add( + InkWell( + onTap: () { + startNFCScan(); + }, + child: MedicalProfileItem( + title: TranslationBase.of(context).scanNFC, + imagePath: 'contactless.svg', + subTitle: "", + isEnable: true, + width: 80.0, + height: 80.0, + ), + ), + ); + + optionsList.add( + InkWell( + onTap: () { + startQRCodeScan(); + }, + child: MedicalProfileItem( + title: TranslationBase.of(context).pharmaLiveCareScanQR, + imagePath: 'qr_code.svg', + subTitle: "", + isEnable: true, + width: 80.0, + height: 80.0, + ), + ), + ); + + return optionsList; + } + sendEmail() async { DoctorsListService service = new DoctorsListService(); diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index 75b11879..d41d4f1f 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -294,15 +294,17 @@ class Utils { )); } - medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(7) ? Navigator.push(context, FadePage(page: RadiologyHomePage())) : null, - child: MedicalProfileItem( - title: TranslationBase.of(context).radiology, - imagePath: 'radiology.svg', - subTitle: TranslationBase.of(context).radiologySubtitle, - isEnable: projectViewModel.havePrivilege(7), + medical.add( + InkWell( + onTap: () => projectViewModel.havePrivilege(7) ? Navigator.push(context, FadePage(page: RadiologyHomePage())) : null, + child: MedicalProfileItem( + title: TranslationBase.of(context).radiology, + imagePath: 'radiology.svg', + subTitle: TranslationBase.of(context).radiologySubtitle, + isEnable: projectViewModel.havePrivilege(7), + ), ), - )); + ); medical.add(InkWell( onTap: () => projectViewModel.havePrivilege(12) ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) : null, @@ -820,10 +822,7 @@ class Utils { return isVidaPlus; } - static String generateSignature() { - - } - + static String generateSignature() {} } Widget applyShadow({Color color = Colors.grey, double shadowOpacity = 0.5, double spreadRadius = 2, double blurRadius = 7, Offset offset = const Offset(2, 2), @required Widget child}) { diff --git a/lib/widgets/data_display/medical/medical_profile_item.dart b/lib/widgets/data_display/medical/medical_profile_item.dart index cfe7f59f..0a4a1928 100644 --- a/lib/widgets/data_display/medical/medical_profile_item.dart +++ b/lib/widgets/data_display/medical/medical_profile_item.dart @@ -51,8 +51,8 @@ class MedicalProfileItem extends StatelessWidget { ) : SvgPicture.asset( "assets/images/new/services/$imagePath", - height: SizeConfig.widthMultiplier * 7, - width: SizeConfig.widthMultiplier * 7, + height: height != null ? height : SizeConfig.widthMultiplier * 7, + width: width != null ? width : SizeConfig.widthMultiplier * 7, color: imgColor, ), mFlex(2),