|  |  |  | import 'package:easy_localization/easy_localization.dart'; | 
					
						
							|  |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'package:flutter_svg/flutter_svg.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/app_assets.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/app_export.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/dependencies.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/enums.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/utils/utils.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/utils/validation_utils.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/medical_file/medical_file_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/medical_file/models/family_file_response_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/presentation/lab/collapsing_list_view.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/presentation/my_family/widget/family_cards.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/services/dialog_service.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/theme/colors.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/appbar/app_bar_widget.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/custom_tab_bar.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/dropdown/country_dropdown_widget.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/input_widget.dart'; | 
					
						
							|  |  |  | import 'package:provider/provider.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FamilyMedicalScreen extends StatefulWidget { | 
					
						
							|  |  |  |   final List<FamilyFileResponseModelLists> profiles; | 
					
						
							|  |  |  |   final Function(FamilyFileResponseModelLists) onSelect; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const FamilyMedicalScreen({ | 
					
						
							|  |  |  |     super.key, | 
					
						
							|  |  |  |     required this.profiles, | 
					
						
							|  |  |  |     required this.onSelect, | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   State<FamilyMedicalScreen> createState() => _FamilyMedicalScreenState(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> { | 
					
						
							|  |  |  |   List<CustomTabBarModel> tabs = [CustomTabBarModel(null, LocaleKeys.medicalFile.tr()), CustomTabBarModel(null, LocaleKeys.request.tr())]; | 
					
						
							|  |  |  |   MedicalFileViewModel? medicalVM; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   void initState() { | 
					
						
							|  |  |  |     super.initState(); | 
					
						
							|  |  |  |     medicalVM = context.read<MedicalFileViewModel>(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     return Scaffold( | 
					
						
							|  |  |  |       body: CollapsingListView( | 
					
						
							|  |  |  |           title: "My Medical File".needTranslation, | 
					
						
							|  |  |  |           child: Column( | 
					
						
							|  |  |  |             mainAxisSize: MainAxisSize.min, | 
					
						
							|  |  |  |             crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |             children: [ | 
					
						
							|  |  |  |               CustomTabBar( | 
					
						
							|  |  |  |                 tabs: tabs, | 
					
						
							|  |  |  |                 onTabChange: (index) { | 
					
						
							|  |  |  |                   medicalVM!.onFamilyFileTabChange(index); | 
					
						
							|  |  |  |                 }, | 
					
						
							|  |  |  |               ), | 
					
						
							|  |  |  |               SizedBox(height: 25.h), | 
					
						
							|  |  |  |               Consumer<MedicalFileViewModel>(builder: (context, medicalVM, child) => getFamilyTabs(index: medicalVM.getSelectedFamilyFileTabIndex)), | 
					
						
							|  |  |  |               SizedBox(height: 20.h), | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |           ).paddingSymmetrical(20, 0)), | 
					
						
							|  |  |  |       bottomSheet: Container( | 
					
						
							|  |  |  |           decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | 
					
						
							|  |  |  |             color: AppColors.whiteColor, | 
					
						
							|  |  |  |             customBorder: BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24)), | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |           padding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 20.h), | 
					
						
							|  |  |  |           child: CustomButton( | 
					
						
							|  |  |  |               text: "Add a new family member", | 
					
						
							|  |  |  |               onPressed: () { | 
					
						
							|  |  |  |                 showModelSheet(); | 
					
						
							|  |  |  |               }, | 
					
						
							|  |  |  |               icon: AppAssets.add_icon, | 
					
						
							|  |  |  |               height: 56.h, | 
					
						
							|  |  |  |               fontWeight: FontWeight.w600)), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     // return Scaffold(
 | 
					
						
							|  |  |  |     //   backgroundColor: AppColors.scaffoldBgColor,
 | 
					
						
							|  |  |  |     //   appBar: CustomAppBar(
 | 
					
						
							|  |  |  |     //     onBackPressed: () {
 | 
					
						
							|  |  |  |     //       Navigator.of(context).pop();
 | 
					
						
							|  |  |  |     //     },
 | 
					
						
							|  |  |  |     //     onLanguageChanged: (lang) {},
 | 
					
						
							|  |  |  |     //     hideLogoAndLang: true,
 | 
					
						
							|  |  |  |     //   ),
 | 
					
						
							|  |  |  |     //   body: SingleChildScrollView(
 | 
					
						
							|  |  |  |     //     child: Column(
 | 
					
						
							|  |  |  |     //       mainAxisSize: MainAxisSize.min,
 | 
					
						
							|  |  |  |     //       crossAxisAlignment: CrossAxisAlignment.start,
 | 
					
						
							|  |  |  |     //       children: [
 | 
					
						
							|  |  |  |     //         LocaleKeys.myMedicalFile.tr().toText26(color: AppColors.textColor, weight: FontWeight.w600, letterSpacing: -2),
 | 
					
						
							|  |  |  |     //         SizedBox(height: 25.h),
 | 
					
						
							|  |  |  |     //         CustomTabBar(
 | 
					
						
							|  |  |  |     //           tabs: tabs,
 | 
					
						
							|  |  |  |     //           onTabChange: (index) {
 | 
					
						
							|  |  |  |     //             medicalVM!.onFamilyFileTabChange(index);
 | 
					
						
							|  |  |  |     //           },
 | 
					
						
							|  |  |  |     //         ),
 | 
					
						
							|  |  |  |     //         SizedBox(height: 25.h),
 | 
					
						
							|  |  |  |     //         Consumer<MedicalFileViewModel>(builder: (context, medicalVM, child) => getFamilyTabs(index: medicalVM.getSelectedFamilyFileTabIndex)),
 | 
					
						
							|  |  |  |     //         SizedBox(height: 20.h),
 | 
					
						
							|  |  |  |     //       ],
 | 
					
						
							|  |  |  |     //     ).paddingSymmetrical(20, 0),
 | 
					
						
							|  |  |  |     //   ),
 | 
					
						
							|  |  |  |     //   bottomSheet: Container(
 | 
					
						
							|  |  |  |     //       decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
 | 
					
						
							|  |  |  |     //         color: AppColors.whiteColor,
 | 
					
						
							|  |  |  |     //         customBorder: BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24)),
 | 
					
						
							|  |  |  |     //       ),
 | 
					
						
							|  |  |  |     //       padding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 20.h),
 | 
					
						
							|  |  |  |     //       child: CustomButton(
 | 
					
						
							|  |  |  |     //         text: "Add a new family member",
 | 
					
						
							|  |  |  |     //         onPressed: () {
 | 
					
						
							|  |  |  |     //           showModelSheet();
 | 
					
						
							|  |  |  |     //         },
 | 
					
						
							|  |  |  |     //         icon: AppAssets.add_icon,
 | 
					
						
							|  |  |  |     //         height: 56.h,
 | 
					
						
							|  |  |  |     //         fontWeight: FontWeight.w600,
 | 
					
						
							|  |  |  |     //       )),
 | 
					
						
							|  |  |  |     // );
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Widget getFamilyTabs({required int index}) { | 
					
						
							|  |  |  |     switch (index) { | 
					
						
							|  |  |  |       case 0: | 
					
						
							|  |  |  |         return FamilyCards( | 
					
						
							|  |  |  |           profiles: medicalVM!.patientFamilyFiles, | 
					
						
							|  |  |  |           onSelect: (FamilyFileResponseModelLists profile) { | 
					
						
							|  |  |  |             medicalVM!.switchFamilyFiles(responseID: profile.responseId, patientID: profile.patientId, phoneNumber: profile.mobileNumber); | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |           isShowDetails: true, | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       case 1: | 
					
						
							|  |  |  |         return FamilyCards( | 
					
						
							|  |  |  |           profiles: medicalVM!.pendingFamilyFiles, | 
					
						
							|  |  |  |           onSelect: (FamilyFileResponseModelLists profile) { | 
					
						
							|  |  |  |             // medicalVM!.switchFamilyFiles(responseID: profile.responseId, patientID: profile.patientId, phoneNumber: profile.mobileNumber);
 | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |           isShowDetails: true, | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       default: | 
					
						
							|  |  |  |         return SizedBox.shrink(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void showModelSheet() { | 
					
						
							|  |  |  |     AuthenticationViewModel authVm = getIt.get<AuthenticationViewModel>(); | 
					
						
							|  |  |  |     return showCommonBottomSheetWithoutHeight(context, | 
					
						
							|  |  |  |         title: "Add Family Member", | 
					
						
							|  |  |  |         useSafeArea: true, | 
					
						
							|  |  |  |         child: Column( | 
					
						
							|  |  |  |           crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |           mainAxisAlignment: MainAxisAlignment.start, | 
					
						
							|  |  |  |           mainAxisSize: MainAxisSize.min, | 
					
						
							|  |  |  |           children: [ | 
					
						
							|  |  |  |             "Please fill the below field to add a new family member to your profile".toText16(color: AppColors.textColor, weight: FontWeight.w500), | 
					
						
							|  |  |  |             SizedBox(height: 20.h), | 
					
						
							|  |  |  |             Container( | 
					
						
							|  |  |  |               decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(24)), | 
					
						
							|  |  |  |               padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 8.h), | 
					
						
							|  |  |  |               child: Column( | 
					
						
							|  |  |  |                 children: [ | 
					
						
							|  |  |  |                   CustomCountryDropdown( | 
					
						
							|  |  |  |                     countryList: CountryEnum.values, | 
					
						
							|  |  |  |                     onCountryChange: authVm.onCountryChange, | 
					
						
							|  |  |  |                   ).paddingOnly(top: 8.h, bottom: 16.h), | 
					
						
							|  |  |  |                   Divider(height: 1.h, color: AppColors.spacerLineColor), | 
					
						
							|  |  |  |                   TextInputWidget( | 
					
						
							|  |  |  |                     labelText: LocaleKeys.nationalIdNumber.tr(), | 
					
						
							|  |  |  |                     hintText: "xxxxxxxxx", | 
					
						
							|  |  |  |                     controller: authVm.nationalIdController, | 
					
						
							|  |  |  |                     // focusNode: _nationalIdFocusNode,
 | 
					
						
							|  |  |  |                     isEnable: true, | 
					
						
							|  |  |  |                     prefix: null, | 
					
						
							|  |  |  |                     isAllowRadius: true, | 
					
						
							|  |  |  |                     isBorderAllowed: false, | 
					
						
							|  |  |  |                     isAllowLeadingIcon: true, | 
					
						
							|  |  |  |                     autoFocus: true, | 
					
						
							|  |  |  |                     keyboardType: TextInputType.number, | 
					
						
							|  |  |  |                     padding: EdgeInsets.symmetric(vertical: 8.h), | 
					
						
							|  |  |  |                     leadingIcon: AppAssets.student_card, | 
					
						
							|  |  |  |                   ).paddingOnly(top: 8.h, bottom: 8.h), | 
					
						
							|  |  |  |                   Divider(height: 1.h, color: AppColors.spacerLineColor), | 
					
						
							|  |  |  |                   TextInputWidget( | 
					
						
							|  |  |  |                     labelText: LocaleKeys.phoneNumber.tr(), | 
					
						
							|  |  |  |                     hintText: "", | 
					
						
							|  |  |  |                     controller: authVm.phoneNumberController, | 
					
						
							|  |  |  |                     isEnable: true, | 
					
						
							|  |  |  |                     prefix: authVm.selectedCountrySignup.countryCode, | 
					
						
							|  |  |  |                     isAllowRadius: true, | 
					
						
							|  |  |  |                     isBorderAllowed: false, | 
					
						
							|  |  |  |                     isAllowLeadingIcon: true, | 
					
						
							|  |  |  |                     autoFocus: true, | 
					
						
							|  |  |  |                     keyboardType: TextInputType.number, | 
					
						
							|  |  |  |                     padding: EdgeInsets.symmetric(vertical: 8.h), | 
					
						
							|  |  |  |                     leadingIcon: AppAssets.smart_phone, | 
					
						
							|  |  |  |                   ).paddingOnly(top: 8.h, bottom: 4.h), | 
					
						
							|  |  |  |                 ], | 
					
						
							|  |  |  |               ), | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |             SizedBox(height: 20.h), | 
					
						
							|  |  |  |             CustomButton( | 
					
						
							|  |  |  |                 text: "Verify the member", | 
					
						
							|  |  |  |                 onPressed: () { | 
					
						
							|  |  |  |                   FocusScope.of(context).unfocus(); | 
					
						
							|  |  |  |                   if (ValidationUtils.isValidatedIdAndPhoneWithCountryValidation( | 
					
						
							|  |  |  |                     nationalId: authVm.nationalIdController.text, | 
					
						
							|  |  |  |                     selectedCountry: authVm.selectedCountrySignup, | 
					
						
							|  |  |  |                     phoneNumber: authVm.phoneNumberController.text, | 
					
						
							|  |  |  |                     onOkPress: () { | 
					
						
							|  |  |  |                       Navigator.of(context).pop(); | 
					
						
							|  |  |  |                     }, | 
					
						
							|  |  |  |                   )) { | 
					
						
							|  |  |  |                     // authVm.addFamilyMember(otpTypeEnum: OTPTypeEnum.sms, isExcludedUser: true);
 | 
					
						
							|  |  |  |                     medicalVM?.addFamilyFile(otpTypeEnum: OTPTypeEnum.sms, isExcludedUser: true); | 
					
						
							|  |  |  |                   } | 
					
						
							|  |  |  |                 }, | 
					
						
							|  |  |  |                 icon: AppAssets.add_icon, | 
					
						
							|  |  |  |                 height: 56.h, | 
					
						
							|  |  |  |                 fontWeight: FontWeight.w600), | 
					
						
							|  |  |  |             SizedBox(height: 20.h), | 
					
						
							|  |  |  |           ], | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         callBackFunc: () {}); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |