From cd81372fc6dad55572e226ec924e8e3906c8247b Mon Sep 17 00:00:00 2001 From: aamir-csol Date: Thu, 9 Oct 2025 11:21:07 +0300 Subject: [PATCH] family screen add fixes & remove & switch & widgets --- .../medical_file/medical_file_view_model.dart | 7 +-- .../medical_file/medical_file_page.dart | 4 +- lib/presentation/my_family/my_family.dart | 24 ++++++--- .../my_family/widget/family_cards.dart | 53 ++++++++++--------- lib/services/dialog_service.dart | 22 +++++--- 5 files changed, 63 insertions(+), 47 deletions(-) diff --git a/lib/features/medical_file/medical_file_view_model.dart b/lib/features/medical_file/medical_file_view_model.dart index db2d7fe..e4dc854 100644 --- a/lib/features/medical_file/medical_file_view_model.dart +++ b/lib/features/medical_file/medical_file_view_model.dart @@ -59,6 +59,7 @@ class MedicalFileViewModel extends ChangeNotifier { _selectedFamilyFileTabIndex = value; notifyListeners(); } + } static final DialogService _dialogService = getIt.get(); @@ -89,7 +90,6 @@ class MedicalFileViewModel extends ChangeNotifier { void onFamilyFileTabChange(int index) { setSelectedFamilyFileTabIndex = index; - notifyListeners(); } setIsPatientVaccineListLoading(bool isLoading) { @@ -439,9 +439,6 @@ class MedicalFileViewModel extends ChangeNotifier { ); } - - - Future addFamilyFile({required OTPTypeEnum otpTypeEnum}) async { LoaderBottomSheet.showLoader(); AuthenticationViewModel authVM = getIt.get(); @@ -597,7 +594,7 @@ class MedicalFileViewModel extends ChangeNotifier { getFamilyFiles(status: 0); getAllPendingRecordsByResponseId(); LoaderBottomSheet.hideLoader(); - onFamilyFileTabChange(0); + // onFamilyFileTabChange(0); } }, ); diff --git a/lib/presentation/medical_file/medical_file_page.dart b/lib/presentation/medical_file/medical_file_page.dart index 1eff927..19d4335 100644 --- a/lib/presentation/medical_file/medical_file_page.dart +++ b/lib/presentation/medical_file/medical_file_page.dart @@ -114,8 +114,8 @@ class _MedicalFilePageState extends State { ).onPress(() { DialogService dialogService = getIt.get(); dialogService.showFamilyBottomSheetWithoutH( - label: "Who do you want to book for?".needTranslation, - message: "This clinic or doctor is only available for the below eligible profiles.".needTranslation, + label: "Family Members".needTranslation, + message: "Choose a profile to swithc family file.".needTranslation, onSwitchPress: (FamilyFileResponseModelLists profile) { medicalFileViewModel.switchFamilyFiles(responseID: profile.responseId, patientID: profile.patientId, phoneNumber: profile.mobileNumber); }, diff --git a/lib/presentation/my_family/my_family.dart b/lib/presentation/my_family/my_family.dart index f9c4799..9b8014a 100644 --- a/lib/presentation/my_family/my_family.dart +++ b/lib/presentation/my_family/my_family.dart @@ -46,7 +46,11 @@ class _FamilyMedicalScreenState extends State { void initState() { super.initState(); medicalVM = context.read(); + WidgetsBinding.instance.addPostFrameCallback((_) { + medicalVM?.onFamilyFileTabChange(0); + }); } + @override Widget build(BuildContext context) { @@ -84,13 +88,17 @@ class _FamilyMedicalScreenState extends State { children: [ appState.isChildLoggedIn ? SizedBox() - : CustomTabBar( - activeBackgroundColor: AppColors.secondaryLightRedColor, - activeTextColor: AppColors.primaryRedColor, - tabs: [CustomTabBarModel(null, LocaleKeys.family.tr()), CustomTabBarModel(null, LocaleKeys.request.tr())], - onTabChange: (index) { - medicalVM!.onFamilyFileTabChange(index); - }, + : Selector( + selector: (_, model) => model.getSelectedFamilyFileTabIndex, + builder: (context, selectedIndex, child) => CustomTabBar( + activeBackgroundColor: AppColors.secondaryLightRedColor, + activeTextColor: AppColors.primaryRedColor, + // selectedIndex: selectedIndex, + tabs: [CustomTabBarModel(null, LocaleKeys.family.tr()), CustomTabBarModel(null, LocaleKeys.request.tr())], + onTabChange: (index) { + medicalVM!.onFamilyFileTabChange(index); + }, + ), ), appState.isChildLoggedIn ? SizedBox() : SizedBox(height: 25.h), Selector(selector: (_, model) => model.getSelectedFamilyFileTabIndex, builder: (context, selectedIndex, child) => getFamilyTabs(index: selectedIndex)), @@ -118,7 +126,7 @@ class _FamilyMedicalScreenState extends State { case 1: return FamilyCards( profiles: medicalVM!.pendingFamilyFiles, - isRequestDesign: true, + isRequestDesign: medicalVM!.getSelectedFamilyFileTabIndex == 1, onSelect: (FamilyFileResponseModelLists profile) { medicalVM!.acceptRejectFileFromFamilyMembers(id: profile.id, status: 3); }, diff --git a/lib/presentation/my_family/widget/family_cards.dart b/lib/presentation/my_family/widget/family_cards.dart index 9b1fb4b..50aec1c 100644 --- a/lib/presentation/my_family/widget/family_cards.dart +++ b/lib/presentation/my_family/widget/family_cards.dart @@ -14,6 +14,7 @@ import 'package:hmg_patient_app_new/services/dialog_service.dart'; import 'package:hmg_patient_app_new/services/navigation_service.dart'; import 'package:hmg_patient_app_new/theme/colors.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/chip/custom_chip_widget.dart'; class FamilyCards extends StatefulWidget { @@ -88,9 +89,9 @@ class _FamilyCardsState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - CustomChipWidget( - height: 30.h, - chipType: ChipTypeEnum.alert, + AppCustomChipWidget( + // height: 30.h, + // chipType: ChipTypeEnum.alert, backgroundColor: profile.status == FamilyFileEnum.pending.toInt ? AppColors.alertLightColor.withValues(alpha: 0.20) : profile.status == FamilyFileEnum.rejected.toInt @@ -98,10 +99,10 @@ class _FamilyCardsState extends State { : profile.status == FamilyFileEnum.active.toInt ? AppColors.lightGreenColor : AppColors.lightGrayBGColor, - chipText: profile.statusDescription ?? "N/A", - iconAsset: null, - isShowBorder: false, - borderRadius: 8.h, + labelText: profile.statusDescription ?? "N/A", + // iconAsset: null, + // isShowBorder: false, + // borderRadius: 8.h, textColor: profile.status == FamilyFileEnum.pending.toInt ? AppColors.alertLightColor : profile.status == FamilyFileEnum.rejected.toInt @@ -116,14 +117,14 @@ class _FamilyCardsState extends State { .toText12(isBold: false, isCenter: false, maxLine: 1, fontWeight: FontWeight.w500, color: AppColors.greyTextColor), ]), SizedBox(height: 8.h), - CustomChipWidget( - height: 30.h, - chipType: ChipTypeEnum.alert, + AppCustomChipWidget( + // height: 30.h, + // chipType: ChipTypeEnum.alert, backgroundColor: AppColors.lightGrayBGColor, - chipText: "Medical File: ${profile.responseId ?? "N/A"}", - iconAsset: null, - isShowBorder: false, - borderRadius: 8.h, + labelText: "Medical File: ${profile.responseId ?? "N/A"}", + // iconAsset: null, + // isShowBorder: false, + // borderRadius: 8.h, textColor: AppColors.textColor), ], ), @@ -172,22 +173,22 @@ class _FamilyCardsState extends State { SizedBox(height: 8.h), (profile.patientName ?? "Unknown").toText14(isBold: false, isCenter: true, maxlines: 1, weight: FontWeight.w600), SizedBox(height: 8.h), - CustomChipWidget( - chipType: ChipTypeEnum.alert, + AppCustomChipWidget( + // chipType: ChipTypeEnum.alert, backgroundColor: AppColors.lightGrayBGColor, - chipText: "Relation:${profile.relationship ?? "N/A"}", - iconAsset: AppAssets.heart, - isShowBorder: false, - borderRadius: 8.h, + labelText: "Relation:${profile.relationship ?? "N/A"}", + icon: AppAssets.heart, + // isShowBorder: false, + // borderRadius: 8.h, textColor: AppColors.textColor), widget.isShowDetails ? SizedBox(height: 4.h) : SizedBox(), widget.isShowDetails - ? CustomChipWidget( - chipType: ChipTypeEnum.alert, + ? AppCustomChipWidget( + // chipType: ChipTypeEnum.alert, backgroundColor: AppColors.lightGrayBGColor, - chipText: "Age:${profile.age ?? "N/A"} Years", - isShowBorder: false, - borderRadius: 8.h, + labelText: "Age:${profile.age ?? "N/A"} Years", + // isShowBorder: false, + // borderRadius: 8.h, textColor: AppColors.textColor, ) : SizedBox(), @@ -208,6 +209,7 @@ class _FamilyCardsState extends State { textColor: isActive || !canSwitch ? AppColors.greyTextColor : AppColors.primaryRedColor, fontSize: 13.h, icon: isActive ? AppAssets.activeCheck : AppAssets.switch_user, + iconSize: 18.h, iconColor: isActive || !canSwitch ? (isActive ? null : AppColors.greyTextColor) : AppColors.primaryRedColor, padding: EdgeInsets.symmetric(vertical: 0, horizontal: 0), ).paddingOnly(top: 0, bottom: 0), @@ -318,6 +320,7 @@ class _FamilyCardsState extends State { backgroundColor: AppColors.lightGreenButtonColor, borderColor: AppColors.lightGreenButtonColor, textColor: AppColors.textGreenColor, + borderWidth: 0, icon: null, ), ), diff --git a/lib/services/dialog_service.dart b/lib/services/dialog_service.dart index 915f795..6c232f5 100644 --- a/lib/services/dialog_service.dart +++ b/lib/services/dialog_service.dart @@ -112,13 +112,21 @@ class DialogServiceImp implements DialogService { if (context == null) return; showCommonBottomSheetWithoutHeight(context, title: label ?? "", - child: FamilyCards( - profiles: profiles, - onSelect: (FamilyFileResponseModelLists profile) { - onSwitchPress(profile); - }, - onRemove: (FamilyFileResponseModelLists profile) {}, - isShowDetails: false, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + (message).toText16(isBold: false, color: AppColors.textColor), + SizedBox(height: 24.h), + FamilyCards( + profiles: profiles, + onSelect: (FamilyFileResponseModelLists profile) { + onSwitchPress(profile); + }, + onRemove: (FamilyFileResponseModelLists profile) {}, + isShowDetails: false, + ), + ], ), callBackFunc: () {}); }