diff --git a/lib/presentation/my_family/widget/family_cards.dart b/lib/presentation/my_family/widget/family_cards.dart index 60ec335a..c8553207 100644 --- a/lib/presentation/my_family/widget/family_cards.dart +++ b/lib/presentation/my_family/widget/family_cards.dart @@ -67,6 +67,29 @@ class _FamilyCardsState extends State { super.initState(); } + + double _calculateAspectRatio(BuildContext context) { + final screenWidth = MediaQuery.of(context).size.width; + final itemWidth = (screenWidth - 32.w - 10.w) / 2; + double itemHeight = 0; + itemHeight += 30.h; // 15.h top + 15.h bottom + itemHeight += 70.h; + itemHeight += 8.h; + itemHeight += 20.h; + + if (widget.isShowDetails) { + itemHeight += 4.h; + itemHeight += 30.h; + itemHeight += 8.h; + } else { + itemHeight += 4.h; + } + + itemHeight += 70.h; + final aspectRatio = itemWidth / itemHeight; + return aspectRatio; + } + @override Widget build(BuildContext context) { widget.profileViewList = []; @@ -139,10 +162,8 @@ class _FamilyCardsState extends State { SizedBox(height: 8.h), Wrap(alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.start, runAlignment: WrapAlignment.start, spacing: 0.h, children: [ (profile.patientName ?? "").toText14(isBold: true, isCenter: false, maxlines: 1), - (getStatusTextByRequest( - FamilyFileEnum.values.firstWhere((e) => e.toInt == profile.status), profile.isRequestFromMySide ?? false)) - .toText12( - isCenter: false, maxLine: 1, isBold: true, color: AppColors.greyTextColor), + (getStatusTextByRequest(FamilyFileEnum.values.firstWhere((e) => e.toInt == profile.status), profile.isRequestFromMySide ?? false)) + .toText12(isCenter: false, maxLine: 1, isBold: true, color: AppColors.greyTextColor), ]), SizedBox(height: 8.h), CustomChipWidget( @@ -189,8 +210,8 @@ class _FamilyCardsState extends State { children: [ SizedBox( width: MediaQuery.of(context).size.width * 0.6, - child: "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}" - .toText18(isBold: true, textOverflow: TextOverflow.ellipsis, maxlines: 2), + child: + "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}".toText18(isBold: true, textOverflow: TextOverflow.ellipsis, maxlines: 2), ), SizedBox(height: 4.h), Wrap( @@ -312,8 +333,7 @@ class _FamilyCardsState extends State { crossAxisCount: 2, crossAxisSpacing: 10.w, mainAxisSpacing: 10.h, - childAspectRatio: widget.isShowDetails ? 0.80.h : 0.80.h, - // childAspectRatio: 0.7.h, + childAspectRatio: _calculateAspectRatio(context), ), padding: EdgeInsets.only(bottom: 20.h), itemBuilder: (context, index) {