|  |  |  | import 'dart:convert'; | 
					
						
							|  |  |  | import 'dart:developer'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import 'package:easy_localization/easy_localization.dart'; | 
					
						
							|  |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'package:flutter_swiper_view/flutter_swiper_view.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/app_state.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/utils/date_util.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/core/app_state.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/extensions/int_extensions.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/habib_wallet/habib_wallet_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/insurance/insurance_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/features/profile_settings/profile_settings_view_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/presentation/habib_wallet/habib_wallet_page.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/presentation/habib_wallet/recharge_wallet_page.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/services/dialog_service.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/theme/colors.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/app_language_change.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart'; | 
					
						
							|  |  |  | import 'package:provider/provider.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import '../../core/dependencies.dart' show getIt; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ProfileSettings extends StatefulWidget { | 
					
						
							|  |  |  |   ProfileSettings({Key? key}) : super(key: key); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   _ProfileSettingsState createState() { | 
					
						
							|  |  |  |     return _ProfileSettingsState(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class _ProfileSettingsState extends State<ProfileSettings> { | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   void initState() { | 
					
						
							|  |  |  |     super.initState(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   void dispose() { | 
					
						
							|  |  |  |     super.dispose(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   int length = 3; | 
					
						
							|  |  |  |   final SwiperController _controller = SwiperController(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     return CollapsingListView( | 
					
						
							|  |  |  |       title: "Profile & Settings".needTranslation, | 
					
						
							|  |  |  |       logout: () {}, | 
					
						
							|  |  |  |       isClose: true, | 
					
						
							|  |  |  |       child: SingleChildScrollView( | 
					
						
							|  |  |  |         padding: EdgeInsets.only(top: 24, bottom: 24), | 
					
						
							|  |  |  |         physics: NeverScrollableScrollPhysics(), | 
					
						
							|  |  |  |         child: Consumer2<ProfileSettingsViewModel, MedicalFileViewModel>( | 
					
						
							|  |  |  |           builder: (context, profileVm, medicalVm, child) { | 
					
						
							|  |  |  |             return Column( | 
					
						
							|  |  |  |               crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |               children: [ | 
					
						
							|  |  |  |                 Swiper( | 
					
						
							|  |  |  |                   itemCount: medicalVm.patientFamilyFiles.length, | 
					
						
							|  |  |  |                   layout: SwiperLayout.STACK, | 
					
						
							|  |  |  |                   loop: true, | 
					
						
							|  |  |  |                   itemWidth: MediaQuery.of(context).size.width - 42, | 
					
						
							|  |  |  |                   indicatorLayout: PageIndicatorLayout.COLOR, | 
					
						
							|  |  |  |                   axisDirection: AxisDirection.right, | 
					
						
							|  |  |  |                   controller: _controller, | 
					
						
							|  |  |  |                   itemHeight: 200.h, | 
					
						
							|  |  |  |                   pagination: const SwiperPagination( | 
					
						
							|  |  |  |                     alignment: Alignment.bottomCenter, | 
					
						
							|  |  |  |                     margin: EdgeInsets.only(top: 210 + 8 + 24), | 
					
						
							|  |  |  |                     builder: DotSwiperPaginationBuilder(color: Color(0xffD9D9D9), activeColor: AppColors.blackBgColor), | 
					
						
							|  |  |  |                   ), | 
					
						
							|  |  |  |                   itemBuilder: (BuildContext context, int index) { | 
					
						
							|  |  |  |                     return FamilyCardWidget( | 
					
						
							|  |  |  |                       profile: medicalVm.patientFamilyFiles[index], | 
					
						
							|  |  |  |                       onAddFamilyMemberPress: () { | 
					
						
							|  |  |  |                         DialogService dialogService = getIt.get<DialogService>(); | 
					
						
							|  |  |  |                         dialogService.showAddFamilyFileSheet( | 
					
						
							|  |  |  |                             label: "Add Family Member".needTranslation, | 
					
						
							|  |  |  |                             message: "Please fill the below field to add a new family member to your profile".needTranslation, | 
					
						
							|  |  |  |                             onVerificationPress: () { | 
					
						
							|  |  |  |                               medicalVm.addFamilyFile(otpTypeEnum: OTPTypeEnum.sms); | 
					
						
							|  |  |  |                             }); | 
					
						
							|  |  |  |                       }, | 
					
						
							|  |  |  |                       onFamilySwitchPress: (FamilyFileResponseModelLists profile) { | 
					
						
							|  |  |  |                         medicalVm.switchFamilyFiles(responseID: profile.responseId, patientID: profile.patientId, phoneNumber: profile.mobileNumber); | 
					
						
							|  |  |  |                       }, | 
					
						
							|  |  |  |                     ).paddingOnly(right: 16); | 
					
						
							|  |  |  |                   }, | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |                 GridView( | 
					
						
							|  |  |  |                   gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 9, mainAxisSpacing: 9), | 
					
						
							|  |  |  |                   physics: const NeverScrollableScrollPhysics(), | 
					
						
							|  |  |  |                   padding: const EdgeInsets.all(24), | 
					
						
							|  |  |  |                   shrinkWrap: true, | 
					
						
							|  |  |  |                   children: [ | 
					
						
							|  |  |  |                     Container( | 
					
						
							|  |  |  |                       padding: EdgeInsets.all(16), | 
					
						
							|  |  |  |                       decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | 
					
						
							|  |  |  |                         color: AppColors.whiteColor, | 
					
						
							|  |  |  |                         borderRadius: 20.h, | 
					
						
							|  |  |  |                         hasShadow: true, | 
					
						
							|  |  |  |                       ), | 
					
						
							|  |  |  |                       child: Column( | 
					
						
							|  |  |  |                         crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |                         spacing: 4.h, | 
					
						
							|  |  |  |                         children: [ | 
					
						
							|  |  |  |                           Row( | 
					
						
							|  |  |  |                             spacing: 8.h, | 
					
						
							|  |  |  |                             crossAxisAlignment: CrossAxisAlignment.center, | 
					
						
							|  |  |  |                             children: [ | 
					
						
							|  |  |  |                               Utils.buildSvgWithAssets(icon: AppAssets.wallet, width: 40.h, height: 40.h), | 
					
						
							|  |  |  |                               "Habib Wallet".needTranslation.toText14(weight: FontWeight.w600, maxlines: 2).expanded, | 
					
						
							|  |  |  |                               Utils.buildSvgWithAssets(icon: AppAssets.arrow_forward), | 
					
						
							|  |  |  |                             ], | 
					
						
							|  |  |  |                           ), | 
					
						
							|  |  |  |                           Spacer(), | 
					
						
							|  |  |  |                           Consumer<HabibWalletViewModel>(builder: (context, habibWalletVM, child) { | 
					
						
							|  |  |  |                             return Utils.getPaymentAmountWithSymbol2(habibWalletVM.habibWalletAmount, isExpanded: false) | 
					
						
							|  |  |  |                                 .toShimmer2(isShow: habibWalletVM.isWalletAmountLoading, radius: 12.h, width: 80.h, height: 24.h); | 
					
						
							|  |  |  |                           }), | 
					
						
							|  |  |  |                           CustomButton( | 
					
						
							|  |  |  |                             height: 40.h, | 
					
						
							|  |  |  |                             icon: AppAssets.recharge_icon, | 
					
						
							|  |  |  |                             iconSize: 24.h, | 
					
						
							|  |  |  |                             iconColor: AppColors.infoColor, | 
					
						
							|  |  |  |                             textColor: AppColors.infoColor, | 
					
						
							|  |  |  |                             text: "Recharge".needTranslation, | 
					
						
							|  |  |  |                             borderWidth: 0.h, | 
					
						
							|  |  |  |                             fontWeight: FontWeight.w500, | 
					
						
							|  |  |  |                             borderColor: Colors.transparent, | 
					
						
							|  |  |  |                             backgroundColor: Color(0xff45A2F8).withValues(alpha: 0.08), | 
					
						
							|  |  |  |                             padding: EdgeInsets.all(8.h), | 
					
						
							|  |  |  |                             fontSize: 14, | 
					
						
							|  |  |  |                             onPressed: () { | 
					
						
							|  |  |  |                               Navigator.of(context).push(CustomPageRoute(page: RechargeWalletPage())); | 
					
						
							|  |  |  |                             }, | 
					
						
							|  |  |  |                           ), | 
					
						
							|  |  |  |                         ], | 
					
						
							|  |  |  |                       ).onPress(() { | 
					
						
							|  |  |  |                         Navigator.of(context).push(CustomPageRoute(page: HabibWalletPage())); | 
					
						
							|  |  |  |                       }), | 
					
						
							|  |  |  |                     ) | 
					
						
							|  |  |  |                   ], | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |                 "Quick Actions".needTranslation.toText18(weight: FontWeight.w600, textOverflow: TextOverflow.ellipsis, maxlines: 1).paddingOnly(left: 24, right: 24), | 
					
						
							|  |  |  |                 Container( | 
					
						
							|  |  |  |                   margin: EdgeInsets.only(left: 24, right: 24, top: 16, bottom: 24), | 
					
						
							|  |  |  |                   padding: EdgeInsets.only(top: 4, bottom: 4), | 
					
						
							|  |  |  |                   decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.h, hasShadow: true), | 
					
						
							|  |  |  |                   child: Column( | 
					
						
							|  |  |  |                     children: [ | 
					
						
							|  |  |  |                       actionItem(AppAssets.language_change, "Language".needTranslation, () { | 
					
						
							|  |  |  |                         showCommonBottomSheetWithoutHeight(context, title: "Application Language".needTranslation, child: AppLanguageChange(), callBackFunc: () {}, isFullScreen: false); | 
					
						
							|  |  |  |                       }, trailingLabel: Utils.appState.isArabic() ? "العربية".needTranslation : "English".needTranslation), | 
					
						
							|  |  |  |                       1.divider, | 
					
						
							|  |  |  |                       actionItem(AppAssets.accessibility, "Accessibility".needTranslation, () {}), | 
					
						
							|  |  |  |                       1.divider, | 
					
						
							|  |  |  |                       actionItem(AppAssets.bell, "Notifications Settings".needTranslation, () {}), | 
					
						
							|  |  |  |                       1.divider, | 
					
						
							|  |  |  |                       actionItem(AppAssets.touch_face_id, "Touch ID / Face ID Services".needTranslation, () {}, switchValue: true), | 
					
						
							|  |  |  |                     ], | 
					
						
							|  |  |  |                   ), | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |                 "Personal Information".needTranslation.toText18(weight: FontWeight.w600, textOverflow: TextOverflow.ellipsis, maxlines: 1).paddingOnly(left: 24, right: 24), | 
					
						
							|  |  |  |                 Container( | 
					
						
							|  |  |  |                   margin: EdgeInsets.only(left: 24, right: 24, top: 16, bottom: 24), | 
					
						
							|  |  |  |                   padding: EdgeInsets.only(top: 4, bottom: 4), | 
					
						
							|  |  |  |                   decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.h, hasShadow: true), | 
					
						
							|  |  |  |                   child: Column( | 
					
						
							|  |  |  |                     children: [ | 
					
						
							|  |  |  |                       actionItem(AppAssets.email_transparent, "Update Email Address".needTranslation, () {}), | 
					
						
							|  |  |  |                       1.divider, | 
					
						
							|  |  |  |                       actionItem(AppAssets.smart_phone_fill, "Phone Number".needTranslation, () {}), | 
					
						
							|  |  |  |                       1.divider, | 
					
						
							|  |  |  |                       actionItem(AppAssets.my_address, "My Addresses".needTranslation, () {}), | 
					
						
							|  |  |  |                       1.divider, | 
					
						
							|  |  |  |                       actionItem(AppAssets.emergency, "Emergency Contact".needTranslation, () {}), | 
					
						
							|  |  |  |                     ], | 
					
						
							|  |  |  |                   ), | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |                 "Help & Support".needTranslation.toText18(weight: FontWeight.w600, textOverflow: TextOverflow.ellipsis, maxlines: 1).paddingOnly(left: 24, right: 24), | 
					
						
							|  |  |  |                 Container( | 
					
						
							|  |  |  |                   margin: EdgeInsets.only(left: 24, right: 24, top: 16), | 
					
						
							|  |  |  |                   padding: EdgeInsets.only(top: 4, bottom: 4), | 
					
						
							|  |  |  |                   decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.h, hasShadow: true), | 
					
						
							|  |  |  |                   child: Column( | 
					
						
							|  |  |  |                     children: [ | 
					
						
							|  |  |  |                       actionItem(AppAssets.call_fill, "Contact Us".needTranslation, () {}, trailingLabel: "9200666666"), | 
					
						
							|  |  |  |                       1.divider, | 
					
						
							|  |  |  |                       actionItem(AppAssets.permission, "Permissions".needTranslation, () {}, trailingLabel: "Location, Camera"), | 
					
						
							|  |  |  |                       1.divider, | 
					
						
							|  |  |  |                       actionItem(AppAssets.rate, "Rate Our App".needTranslation, () {}, isExternalLink: true), | 
					
						
							|  |  |  |                       1.divider, | 
					
						
							|  |  |  |                       actionItem(AppAssets.privacy_terms, "Privacy Policy".needTranslation, () {}, isExternalLink: true), | 
					
						
							|  |  |  |                       1.divider, | 
					
						
							|  |  |  |                       actionItem(AppAssets.privacy_terms, "Terms & Conditions".needTranslation, () {}, isExternalLink: true), | 
					
						
							|  |  |  |                     ], | 
					
						
							|  |  |  |                   ), | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |                 CustomButton(icon: AppAssets.minus, text: "Deactivate account".needTranslation, onPressed: () {}).paddingAll(24), | 
					
						
							|  |  |  |               ], | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Widget actionItem(String icon, String label, VoidCallback onPress, {String trailingLabel = "", bool? switchValue, bool isExternalLink = false}) { | 
					
						
							|  |  |  |     return SizedBox( | 
					
						
							|  |  |  |       height: 56, | 
					
						
							|  |  |  |       child: Row( | 
					
						
							|  |  |  |         spacing: 8.h, | 
					
						
							|  |  |  |         children: [ | 
					
						
							|  |  |  |           Utils.buildSvgWithAssets(icon: icon, iconColor: AppColors.greyTextColor), | 
					
						
							|  |  |  |           label.toText14(weight: FontWeight.w500, textOverflow: TextOverflow.ellipsis, maxlines: 1).expanded, | 
					
						
							|  |  |  |           if (trailingLabel.isNotEmpty) trailingLabel.toText14(color: AppColors.greyTextColor, weight: FontWeight.w500, textOverflow: TextOverflow.ellipsis, maxlines: 1), | 
					
						
							|  |  |  |           switchValue != null | 
					
						
							|  |  |  |               ? Switch( | 
					
						
							|  |  |  |                   value: switchValue, | 
					
						
							|  |  |  |                   onChanged: (value) {}, | 
					
						
							|  |  |  |                   activeColor: AppColors.successColor, | 
					
						
							|  |  |  |                   activeTrackColor: AppColors.successColor.withValues(alpha: .15), | 
					
						
							|  |  |  |                 ) | 
					
						
							|  |  |  |               : Transform.scale( | 
					
						
							|  |  |  |                   scaleX: Utils.appState.isArabic() ? -1 : 1, | 
					
						
							|  |  |  |                   child: Utils.buildSvgWithAssets(icon: isExternalLink ? AppAssets.externalLink : AppAssets.arrow_forward), | 
					
						
							|  |  |  |                 ) | 
					
						
							|  |  |  |         ], | 
					
						
							|  |  |  |       ).paddingOnly(left: 16, right: 16).onPress(onPress), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FamilyCardWidget extends StatelessWidget { | 
					
						
							|  |  |  |   late AppState appState; | 
					
						
							|  |  |  |   final Function() onAddFamilyMemberPress; | 
					
						
							|  |  |  |   final Function(FamilyFileResponseModelLists member) onFamilySwitchPress; | 
					
						
							|  |  |  |   final FamilyFileResponseModelLists profile; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   FamilyCardWidget({super.key, required this.onAddFamilyMemberPress, required this.profile, required this.onFamilySwitchPress(FamilyFileResponseModelLists member)}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     AppState appState = getIt.get<AppState>(); | 
					
						
							|  |  |  |     final isActive = (profile.responseId == appState.getAuthenticatedUser()?.patientId); | 
					
						
							|  |  |  |     final isParentUser = appState.getAuthenticatedUser()?.isParentUser ?? false; | 
					
						
							|  |  |  |     final canSwitch = isParentUser || (!isParentUser && profile.responseId == appState.getSuperUserID); | 
					
						
							|  |  |  |     return Container( | 
					
						
							|  |  |  |       decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 20.h, hasShadow: true), | 
					
						
							|  |  |  |       child: Column( | 
					
						
							|  |  |  |         children: [ | 
					
						
							|  |  |  |           Column( | 
					
						
							|  |  |  |             crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |             spacing: 8.h, | 
					
						
							|  |  |  |             children: [ | 
					
						
							|  |  |  |               Row( | 
					
						
							|  |  |  |                 crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |                 spacing: 8.h, | 
					
						
							|  |  |  |                 children: [ | 
					
						
							|  |  |  |                   Image.asset(profile.gender == 1 ? AppAssets.male_img : AppAssets.femaleImg, width: 56.h, height: 56.h), | 
					
						
							|  |  |  |                   Column( | 
					
						
							|  |  |  |                     crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |                     spacing: 0.h, | 
					
						
							|  |  |  |                     mainAxisSize: MainAxisSize.min, | 
					
						
							|  |  |  |                     children: [ | 
					
						
							|  |  |  |                       "${profile.patientName}".toText18(isBold: true, weight: FontWeight.w600, textOverflow: TextOverflow.ellipsis, maxlines: 1), | 
					
						
							|  |  |  |                       AppCustomChipWidget( | 
					
						
							|  |  |  |                         icon: AppAssets.file_icon, | 
					
						
							|  |  |  |                         labelText: "${LocaleKeys.fileNo.tr(context: context)}: ${profile.responseId}", | 
					
						
							|  |  |  |                         iconSize: 12, | 
					
						
							|  |  |  |                       ), | 
					
						
							|  |  |  |                     ], | 
					
						
							|  |  |  |                   ).expanded, | 
					
						
							|  |  |  |                   Icon(Icons.qr_code, size: 56) | 
					
						
							|  |  |  |                 ], | 
					
						
							|  |  |  |               ), | 
					
						
							|  |  |  |               SizedBox(height: 4.h), | 
					
						
							|  |  |  |               SizedBox( | 
					
						
							|  |  |  |                 child: Wrap( | 
					
						
							|  |  |  |                   alignment: WrapAlignment.start, | 
					
						
							|  |  |  |                   spacing: 4.h, | 
					
						
							|  |  |  |                   runSpacing: 4.h, | 
					
						
							|  |  |  |                   children: [ | 
					
						
							|  |  |  |                     AppCustomChipWidget(labelText: "${profile.age} Years Old".needTranslation), | 
					
						
							|  |  |  |                     isActive && appState.getAuthenticatedUser()!.bloodGroup != null | 
					
						
							|  |  |  |                         ? AppCustomChipWidget( | 
					
						
							|  |  |  |                             icon: AppAssets.blood_icon, | 
					
						
							|  |  |  |                             labelPadding: EdgeInsetsDirectional.only(start: -6.h, end: 8.h), | 
					
						
							|  |  |  |                             labelText: "Blood: ${appState.getAuthenticatedUser()!.bloodGroup ?? ""}", | 
					
						
							|  |  |  |                             iconColor: AppColors.primaryRedColor) | 
					
						
							|  |  |  |                         : SizedBox(), | 
					
						
							|  |  |  |                     Selector<InsuranceViewModel, ({bool isEmpty, int? patientID, bool isLoading, String? cardValidTo})>( | 
					
						
							|  |  |  |                       selector: (context, insuranceVM) => ( | 
					
						
							|  |  |  |                         isEmpty: insuranceVM.patientInsuranceList.isEmpty, | 
					
						
							|  |  |  |                         patientID: insuranceVM.patientInsuranceList.isNotEmpty ? insuranceVM.patientInsuranceList.first.patientID : null, | 
					
						
							|  |  |  |                         isLoading: insuranceVM.isInsuranceLoading, | 
					
						
							|  |  |  |                         cardValidTo: insuranceVM.patientInsuranceList.isNotEmpty ? insuranceVM.patientInsuranceList.first.cardValidTo : null | 
					
						
							|  |  |  |                       ), | 
					
						
							|  |  |  |                       builder: (context, data, child) { | 
					
						
							|  |  |  |                         if (data.isEmpty) { | 
					
						
							|  |  |  |                           return const SizedBox(); | 
					
						
							|  |  |  |                         } else if (profile.responseId != data.patientID) { | 
					
						
							|  |  |  |                           return SizedBox(); | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         final isLoading = data.isLoading; | 
					
						
							|  |  |  |                         final isExpired = !isLoading && DateTime.now().isAfter(DateUtil.convertStringToDate(data.cardValidTo)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         final String icon; | 
					
						
							|  |  |  |                         final String labelText; | 
					
						
							|  |  |  |                         final Color iconColor; | 
					
						
							|  |  |  |                         final Color backgroundColor; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         if (isLoading) { | 
					
						
							|  |  |  |                           icon = AppAssets.cancel_circle_icon; | 
					
						
							|  |  |  |                           labelText = "Insurance".needTranslation; | 
					
						
							|  |  |  |                           iconColor = AppColors.primaryRedColor; | 
					
						
							|  |  |  |                           backgroundColor = AppColors.primaryRedColor; | 
					
						
							|  |  |  |                         } else if (isExpired) { | 
					
						
							|  |  |  |                           icon = AppAssets.cancel_circle_icon; | 
					
						
							|  |  |  |                           labelText = "Insurance Expired".needTranslation; | 
					
						
							|  |  |  |                           iconColor = AppColors.primaryRedColor; | 
					
						
							|  |  |  |                           backgroundColor = AppColors.primaryRedColor.withValues(alpha: 0.15); | 
					
						
							|  |  |  |                         } else { | 
					
						
							|  |  |  |                           icon = AppAssets.insurance_active_icon; | 
					
						
							|  |  |  |                           labelText = "Insurance Active".needTranslation; | 
					
						
							|  |  |  |                           iconColor = AppColors.successColor; | 
					
						
							|  |  |  |                           backgroundColor = AppColors.successColor.withValues(alpha: 0.15); | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         return AppCustomChipWidget( | 
					
						
							|  |  |  |                           icon: icon, | 
					
						
							|  |  |  |                           labelText: labelText, | 
					
						
							|  |  |  |                           iconColor: iconColor, | 
					
						
							|  |  |  |                           iconSize: 12, | 
					
						
							|  |  |  |                           backgroundColor: backgroundColor, | 
					
						
							|  |  |  |                           labelPadding: EdgeInsetsDirectional.only(start: -6.h, end: 8.h), | 
					
						
							|  |  |  |                           // padding: EdgeInsets.zero,
 | 
					
						
							|  |  |  |                         ).toShimmer2(isShow: isLoading); | 
					
						
							|  |  |  |                       }, | 
					
						
							|  |  |  |                     ) | 
					
						
							|  |  |  |                   ], | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |               ), | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |           ).paddingOnly(top: 16.h, right: 16.h, left: 16.h, bottom: 12.h).expanded, | 
					
						
							|  |  |  |           1.divider, | 
					
						
							|  |  |  |           _buildActionButton(appState), | 
					
						
							|  |  |  |         ], | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Widget _buildActionButton(AppState appState) { | 
					
						
							|  |  |  |     final isParentUser = appState.getAuthenticatedUser()?.isParentUser ?? false; | 
					
						
							|  |  |  |     final int? currentUserId = appState.getAuthenticatedUser()?.patientId; | 
					
						
							|  |  |  |     final int? superUserId = appState.getSuperUserID; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (isParentUser) { | 
					
						
							|  |  |  |       return _buildParentUserButton(currentUserId); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       return _buildNonParentUserButton(superUserId); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Widget _buildParentUserButton(int? currentUserId) { | 
					
						
							|  |  |  |     final canSwitch = profile.responseId != currentUserId; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return CustomButton( | 
					
						
							|  |  |  |       icon: canSwitch ? AppAssets.switch_user : AppAssets.add_family, | 
					
						
							|  |  |  |       text: canSwitch ? "Switch Family File".needTranslation : "Add a new family member".needTranslation, | 
					
						
							|  |  |  |       onPressed: canSwitch ? () => onFamilySwitchPress(profile) : onAddFamilyMemberPress, | 
					
						
							|  |  |  |       backgroundColor: canSwitch ? AppColors.secondaryLightRedColor : AppColors.primaryRedColor, | 
					
						
							|  |  |  |       borderColor: canSwitch ? AppColors.secondaryLightRedColor : AppColors.primaryRedColor, | 
					
						
							|  |  |  |       textColor: canSwitch ? AppColors.primaryRedColor : AppColors.whiteColor, | 
					
						
							|  |  |  |       iconColor: canSwitch ? AppColors.primaryRedColor : AppColors.whiteColor, | 
					
						
							|  |  |  |       height: 40.h, | 
					
						
							|  |  |  |       fontSize: 14, | 
					
						
							|  |  |  |     ).paddingOnly(top: 12, right: 16, left: 16, bottom: 16); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Widget _buildNonParentUserButton(int? superUserId) { | 
					
						
							|  |  |  |     final canSwitchBack = superUserId != null && superUserId == profile.responseId; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return CustomButton( | 
					
						
							|  |  |  |       icon: AppAssets.switch_user, | 
					
						
							|  |  |  |       text: canSwitchBack ? "Switch Back To Family File".needTranslation : "Switch".needTranslation, | 
					
						
							|  |  |  |       backgroundColor: canSwitchBack ? AppColors.primaryRedColor : Colors.grey.shade200, | 
					
						
							|  |  |  |       borderColor: canSwitchBack ? AppColors.primaryRedColor : Colors.grey.shade200, | 
					
						
							|  |  |  |       textColor: canSwitchBack ? AppColors.whiteColor : AppColors.greyTextColor, | 
					
						
							|  |  |  |       iconColor: canSwitchBack ? AppColors.whiteColor : AppColors.greyTextColor, | 
					
						
							|  |  |  |       onPressed: canSwitchBack ? () => onFamilySwitchPress(profile) : () {}, | 
					
						
							|  |  |  |       height: 40.h, | 
					
						
							|  |  |  |       fontSize: 14, | 
					
						
							|  |  |  |     ).paddingOnly(top: 12, right: 16, left: 16, bottom: 16); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //    //TODO: Add family file switch logic here
 | 
					
						
							|  |  |  | //           isRootUser
 | 
					
						
							|  |  |  | //               ? CustomButton(icon: AppAssets.add_family, text: "Add a new family member".needTranslation, height: 40.h, fontSize: 14, onPressed: () {})
 | 
					
						
							|  |  |  | //                   .paddingOnly(top: 12, right: 16, left: 16, bottom: 16)
 | 
					
						
							|  |  |  | //               : CustomButton(
 | 
					
						
							|  |  |  | //                       icon: AppAssets.add_family,
 | 
					
						
							|  |  |  | //                       backgroundColor: AppColors.secondaryLightRedColor,
 | 
					
						
							|  |  |  | //                       borderColor: AppColors.secondaryLightRedColor,
 | 
					
						
							|  |  |  | //                       textColor: AppColors.primaryRedColor,
 | 
					
						
							|  |  |  | //                       iconColor: AppColors.primaryRedColor,
 | 
					
						
							|  |  |  | //                       text: "Switch to this medical file".needTranslation,
 | 
					
						
							|  |  |  | //                       height: 40.h,
 | 
					
						
							|  |  |  | //                       fontSize: 14,
 | 
					
						
							|  |  |  | //                       onPressed: () {})
 | 
					
						
							|  |  |  | //                   .paddingOnly(top: 12, right: 16, left: 16, bottom: 16),
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | } |