@ -10,6 +10,8 @@ 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/extensions/widget_extensions.dart ' ;
import ' package:hmg_patient_app_new/features/medical_file/models/family_file_response_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/generated/locale_keys.g.dart ' ;
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/theme/colors.dart ' ;
import ' package:hmg_patient_app_new/widgets/buttons/custom_button.dart ' ;
import ' package:hmg_patient_app_new/widgets/buttons/custom_button.dart ' ;
import ' package:hmg_patient_app_new/widgets/chip/custom_chip_widget.dart ' ;
import ' package:hmg_patient_app_new/widgets/chip/custom_chip_widget.dart ' ;
@ -42,10 +44,9 @@ class FamilyCards extends StatefulWidget {
class _FamilyCardsState extends State < FamilyCards > {
class _FamilyCardsState extends State < FamilyCards > {
AppState appState = getIt < AppState > ( ) ;
AppState appState = getIt < AppState > ( ) ;
/ / bool isShowActions = true ;
@ override
@ override
Widget build ( BuildContext context ) {
Widget build ( BuildContext context ) {
DialogService dialogService = getIt . get < DialogService > ( ) ;
if ( widget . isRequestDesign ) {
if ( widget . isRequestDesign ) {
return Column (
return Column (
children: [
children: [
@ -53,7 +54,14 @@ class _FamilyCardsState extends State<FamilyCards> {
children: [
children: [
Utils . buildSvgWithAssets ( icon: AppAssets . alertSquare ) ,
Utils . buildSvgWithAssets ( icon: AppAssets . alertSquare ) ,
SizedBox ( width: 8. h ) ,
SizedBox ( width: 8. h ) ,
" Sent Requests " . needTranslation . toText14 ( color: AppColors . textColor , isUnderLine: true , weight: FontWeight . w500 ) ,
" Who can view my medical file ? " . needTranslation . toText14 ( color: AppColors . textColor , isUnderLine: true , weight: FontWeight . w500 ) . onPress ( ( ) {
dialogService . showFamilyBottomSheetWithoutHWithChild (
label: " Manage Family " . needTranslation ,
message: " " ,
child: manageFamily ( ) ,
onOkPressed: ( ) { } ,
) ;
} ) ,
SizedBox ( width: 4. h ) ,
SizedBox ( width: 4. h ) ,
Utils . buildSvgWithAssets ( icon: AppAssets . arrowRight ) ,
Utils . buildSvgWithAssets ( icon: AppAssets . arrowRight ) ,
] ,
] ,
@ -67,15 +75,9 @@ class _FamilyCardsState extends State<FamilyCards> {
itemBuilder: ( context , index ) {
itemBuilder: ( context , index ) {
final mySideProfiles = widget . profiles . where ( ( profile ) = > profile . isRequestFromMySide ? ? false ) . toList ( ) ;
final mySideProfiles = widget . profiles . where ( ( profile ) = > profile . isRequestFromMySide ? ? false ) . toList ( ) ;
FamilyFileResponseModelLists profile = mySideProfiles [ index ] ;
FamilyFileResponseModelLists profile = mySideProfiles [ index ] ;
return Container (
return Container (
margin: EdgeInsets . only (
margin: EdgeInsets . only ( bottom: 12. h ) ,
bottom: 12. h ,
padding: EdgeInsets . symmetric ( vertical: 15. h , horizontal: 15. h ) ,
) ,
padding: EdgeInsets . symmetric (
vertical: 15. h ,
horizontal: 15. h ,
) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration ( color: AppColors . whiteColor , borderRadius: 24 ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration ( color: AppColors . whiteColor , borderRadius: 24 ) ,
child: Opacity (
child: Opacity (
opacity: 1.0 ,
opacity: 1.0 ,
@ -104,27 +106,14 @@ class _FamilyCardsState extends State<FamilyCards> {
? AppColors . primaryRedColor
? AppColors . primaryRedColor
: profile . status = = FamilyFileEnum . active . toInt
: profile . status = = FamilyFileEnum . active . toInt
? AppColors . textGreenColor
? AppColors . textGreenColor
: AppColors . alertColor ,
: AppColors . alertColor ) ,
) ,
SizedBox ( height: 8. h ) ,
Wrap (
Wrap ( alignment: WrapAlignment . start , crossAxisAlignment: WrapCrossAlignment . start , runAlignment: WrapAlignment . start , spacing: 0. h , children: [
alignment: WrapAlignment . start ,
( profile . patientName ? ? " " ) . toText14 ( isBold: false , isCenter: false , maxlines: 1 , weight: FontWeight . w600 ) ,
children: [
( getStatusTextByRequest ( FamilyFileEnum . values . firstWhere ( ( e ) = > e . toInt = = profile . status ) , profile . isRequestFromMySide ? ? false ) )
( profile . patientName ? ? " " ) . toText16 (
. toText14 ( isBold: false , isCenter: false , maxlines: 1 , weight: FontWeight . w500 , color: AppColors . greyTextColor ) ,
isBold: false ,
] ) ,
isCenter: true ,
SizedBox ( height: 8. h ) ,
maxlines: 1 ,
weight: FontWeight . w600 ,
) ,
( " has ${ ( profile . statusDescription ? ? " " ) . toLowerCase ( ) } your family member request " ) . toText14 (
isBold: false ,
isCenter: true ,
maxlines: 1 ,
weight: FontWeight . w500 ,
color: AppColors . greyTextColor ,
) ,
] ,
) ,
SizedBox ( height: 4. h ) ,
CustomChipWidget (
CustomChipWidget (
height: 30. h ,
height: 30. h ,
chipType: ChipTypeEnum . alert ,
chipType: ChipTypeEnum . alert ,
@ -133,8 +122,7 @@ class _FamilyCardsState extends State<FamilyCards> {
iconAsset: null ,
iconAsset: null ,
isShowBorder: false ,
isShowBorder: false ,
borderRadius: 8. h ,
borderRadius: 8. h ,
textColor: AppColors . textColor ,
textColor: AppColors . textColor ) ,
) ,
] ,
] ,
) ,
) ,
) ,
) ,
@ -142,21 +130,111 @@ class _FamilyCardsState extends State<FamilyCards> {
} ,
} ,
) ,
) ,
SizedBox ( height: 20. h ) ,
SizedBox ( height: 20. h ) ,
if ( widget . profiles . where ( ( profile ) = > ! ( profile . isRequestFromMySide ? ? false ) ) . isNotEmpty )
] ,
Row (
) ;
} else {
return GridView . builder (
shrinkWrap: true ,
physics: NeverScrollableScrollPhysics ( ) ,
itemCount: widget . profiles . length ,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount (
crossAxisCount: 2 ,
crossAxisSpacing: 10. h ,
mainAxisSpacing: 10. h ,
childAspectRatio: widget . isShowDetails ? 0.56 . h : 0.65 . h ,
) ,
padding: EdgeInsets . only ( bottom: 20. h ) ,
itemBuilder: ( context , index ) {
final profile = widget . profiles [ index ] ;
final isActive = ( profile . responseId = = appState . getAuthenticatedUser ( ) ? . patientId ) ;
final isParentUser = appState . getAuthenticatedUser ( ) ? . isParentUser ? ? false ;
final canSwitch = isParentUser | | ( ! isParentUser & & profile . responseId = = appState . getSuperUserID ) ;
return Container (
padding: EdgeInsets . symmetric ( vertical: 15. h , horizontal: 15. h ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration ( color: AppColors . whiteColor , borderRadius: 24 ) ,
child: Opacity (
opacity: isActive | | profile . status = = FamilyFileEnum . pending . toInt | | ! canSwitch ? 0.4 : 1.0 , / / Fade all content if active
child: Stack (
children: [
children: [
Utils . buildSvgWithAssets ( icon: AppAssets . alertSquare ) ,
Column (
SizedBox ( width: 8. h ) ,
mainAxisSize: MainAxisSize . min ,
" Users who want to view your profile " . needTranslation . toText14 ( color: AppColors . textColor , isUnderLine: true , weight: FontWeight . w500 ) ,
children: [
SizedBox ( width: 4. h ) ,
Utils . buildImgWithAssets (
Utils . buildSvgWithAssets ( icon: AppAssets . arrowRight ) ,
icon: profile . gender = = null
? AppAssets . dummy_user
: profile . gender = = 1
? ( ( profile . age ? ? 0 ) < 7 ? AppAssets . babyBoyImg : AppAssets . male_img )
: ( profile . age ! < 7 ? AppAssets . babyGirlImg : AppAssets . femaleImg ) ,
width: 80. h ,
height: 78. h ) ,
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 ,
backgroundColor: AppColors . lightGrayBGColor ,
chipText: " Relation: ${ profile . relationship ? ? " N/A " } " ,
iconAsset: AppAssets . heart ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: AppColors . textColor ) ,
widget . isShowDetails ? SizedBox ( height: 4. h ) : SizedBox ( ) ,
widget . isShowDetails
? CustomChipWidget (
chipType: ChipTypeEnum . alert ,
backgroundColor: AppColors . lightGrayBGColor ,
chipText: " Age: ${ profile . age ? ? " N/A " } Years " ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: AppColors . textColor ,
)
: SizedBox ( ) ,
widget . isShowDetails
? SizedBox ( height: 8. h )
: SizedBox (
height: 4. h ,
) ,
Spacer ( ) ,
CustomButton (
height: 40. h ,
onPressed: ( ) {
if ( canSwitch ) widget . onSelect ( profile ) ;
} ,
text: isActive ? " Active " . needTranslation : " Switch " . needTranslation ,
backgroundColor: isActive | | ! canSwitch ? Colors . grey . shade200 : AppColors . secondaryLightRedColor ,
borderColor: isActive | | ! canSwitch ? Colors . grey . shade200 : AppColors . secondaryLightRedColor ,
textColor: isActive | | ! canSwitch ? AppColors . greyTextColor : AppColors . primaryRedColor ,
fontSize: 13. h ,
icon: isActive ? AppAssets . activeCheck : AppAssets . switch_user ,
iconColor: isActive | | ! canSwitch ? ( isActive ? null : AppColors . greyTextColor ) : AppColors . primaryRedColor ,
padding: EdgeInsets . symmetric ( vertical: 0 , horizontal: 0 ) ,
) . paddingOnly ( top: 0 , bottom: 0 ) ,
] ,
) ,
if ( widget . isShowRemoveButton ) . . . [
Positioned (
top: 0 ,
right: 0 ,
child: Utils . buildSvgWithAssets ( icon: AppAssets . deleteIcon ) . onPress ( ( ) {
if ( ! isActive ) widget . onRemove ( profile ) ;
} ) ,
) ,
] ,
] ,
] ,
) ,
) ,
) ,
) ;
} ,
) ;
}
}
/ / Items for second group ( requests from others )
Widget manageFamily ( ) {
ListView . builder (
NavigationService navigationService = getIt < NavigationService > ( ) ;
return ListView . builder (
shrinkWrap: true ,
shrinkWrap: true ,
physics: NeverScrollableScrollPhysics ( ) ,
physics: NeverScrollableScrollPhysics ( ) ,
padding: EdgeInsetsGeometry . zero ,
itemCount: widget . profiles . where ( ( profile ) = > ! ( profile . isRequestFromMySide ? ? false ) ) . length ,
itemCount: widget . profiles . where ( ( profile ) = > ! ( profile . isRequestFromMySide ? ? false ) ) . length ,
itemBuilder: ( context , index ) {
itemBuilder: ( context , index ) {
final otherProfiles = widget . profiles . where ( ( profile ) = > ! ( profile . isRequestFromMySide ? ? false ) ) . toList ( ) ;
final otherProfiles = widget . profiles . where ( ( profile ) = > ! ( profile . isRequestFromMySide ? ? false ) ) . toList ( ) ;
@ -194,11 +272,12 @@ class _FamilyCardsState extends State<FamilyCards> {
? AppColors . textGreenColor
? AppColors . textGreenColor
: AppColors . alertColor ,
: AppColors . alertColor ,
) ,
) ,
SizedBox ( height: 8. h ) ,
Wrap (
Wrap (
alignment: WrapAlignment . start ,
alignment: WrapAlignment . start ,
children: [
children: [
( profile . patientName ? ? " " ) . toText1 6 ( isBold: false , isCenter: true , maxlines: 1 , weight: FontWeight . w600 ) ,
( profile . patientName ? ? " " ) . toText1 4 ( isBold: false , isCenter: true , maxlines: 1 , weight: FontWeight . w600 ) ,
( profile . status = = FamilyFileEnum . active . toInt ? " can view your family " . needTranslation : " wants to add you as their family member " . needTranslation ) . toText14 (
( getStatusTextByRequest ( FamilyFileEnum . values . firstWhere ( ( e ) = > e . toInt = = profile . status ) , profile . isRequestFromMySide ? ? false ) ) . toText14 (
isBold: false ,
isBold: false ,
isCenter: true ,
isCenter: true ,
maxlines: 1 ,
maxlines: 1 ,
@ -207,7 +286,7 @@ class _FamilyCardsState extends State<FamilyCards> {
) ,
) ,
] ,
] ,
) ,
) ,
SizedBox ( height: 4 .h ) ,
SizedBox ( height: 8 .h ) ,
CustomChipWidget (
CustomChipWidget (
height: 30. h ,
height: 30. h ,
chipType: ChipTypeEnum . alert ,
chipType: ChipTypeEnum . alert ,
@ -228,6 +307,7 @@ class _FamilyCardsState extends State<FamilyCards> {
height: 40. h ,
height: 40. h ,
text: LocaleKeys . confirm . tr ( ) ,
text: LocaleKeys . confirm . tr ( ) ,
onPressed: ( ) {
onPressed: ( ) {
navigationService . pop ( ) ;
widget . onSelect ( profile ) ;
widget . onSelect ( profile ) ;
} ,
} ,
backgroundColor: AppColors . lightGreenButtonColor ,
backgroundColor: AppColors . lightGreenButtonColor ,
@ -242,6 +322,7 @@ class _FamilyCardsState extends State<FamilyCards> {
height: 40. h ,
height: 40. h ,
text: profile . status = = FamilyFileEnum . active . toInt ? LocaleKeys . removeMember . tr ( ) : LocaleKeys . cancel . tr ( ) ,
text: profile . status = = FamilyFileEnum . active . toInt ? LocaleKeys . removeMember . tr ( ) : LocaleKeys . cancel . tr ( ) ,
onPressed: ( ) {
onPressed: ( ) {
navigationService . pop ( ) ;
widget . onRemove ( profile ) ;
widget . onRemove ( profile ) ;
} ,
} ,
backgroundColor: AppColors . secondaryLightRedColor ,
backgroundColor: AppColors . secondaryLightRedColor ,
@ -258,99 +339,33 @@ class _FamilyCardsState extends State<FamilyCards> {
) ,
) ,
) ;
) ;
} ,
} ,
) ,
] ,
) ;
) ;
}
String getStatusTextByRequest ( FamilyFileEnum status , bool isRequestFromMySide ) {
switch ( status ) {
case FamilyFileEnum . active:
if ( isRequestFromMySide ) {
return " ${ status . displayName } your request to be your family member " . needTranslation ;
} else {
} else {
return GridView . builder (
return " can view your file " . needTranslation ;
shrinkWrap: true ,
}
physics: NeverScrollableScrollPhysics ( ) ,
case FamilyFileEnum . pending:
itemCount: widget . profiles . length ,
if ( isRequestFromMySide ) {
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount (
return " has a request ${ status . displayName } to be your family member " . needTranslation ;
crossAxisCount: 2 ,
} else {
crossAxisSpacing: 10. h ,
return " wants to add you as their family member " . needTranslation ;
mainAxisSpacing: 10. h ,
}
childAspectRatio: widget . isShowDetails ? 0.56 . h : 0.66 . h ,
case FamilyFileEnum . rejected:
) ,
if ( isRequestFromMySide ) {
padding: EdgeInsets . only ( bottom: 20. h ) ,
return " ${ status . displayName } your request to be your family member " . needTranslation ;
itemBuilder: ( context , index ) {
} else {
final profile = widget . profiles [ index ] ;
return " ${ status . displayName } your family member request " . needTranslation ;
final isActive = ( profile . responseId = = appState . getAuthenticatedUser ( ) ? . patientId ) ;
}
final isParentUser = appState . getAuthenticatedUser ( ) ? . isParentUser ? ? false ;
case FamilyFileEnum . inactive:
final canSwitch = isParentUser | | ( ! isParentUser & & profile . responseId = = appState . getSuperUserID ) ;
return " Inactive " . needTranslation ;
return Container (
default :
padding: EdgeInsets . symmetric ( vertical: 15. h , horizontal: 15. h ) ,
return " N/A " . needTranslation ;
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration ( color: AppColors . whiteColor , borderRadius: 24 ) ,
child: Opacity (
opacity: isActive | | profile . status = = FamilyFileEnum . pending . toInt | | ! canSwitch ? 0.4 : 1.0 , / / Fade all content if active
child: Stack (
children: [
Column (
mainAxisSize: MainAxisSize . min ,
children: [
Utils . buildImgWithAssets (
icon: profile . gender = = null
? AppAssets . dummy_user
: profile . gender = = 1
? ( ( profile . age ? ? 0 ) < 7 ? AppAssets . babyBoyImg : AppAssets . male_img )
: ( profile . age ! < 7 ? AppAssets . babyGirlImg : AppAssets . femaleImg ) ,
width: 80. h ,
height: 78. h ) ,
SizedBox ( height: 8. h ) ,
( profile . patientName ? ? " Unknown " ) . toText16 ( isBold: false , isCenter: true , maxlines: 1 , weight: FontWeight . w600 ) ,
SizedBox ( height: 4. h ) ,
CustomChipWidget (
chipType: ChipTypeEnum . alert ,
backgroundColor: AppColors . lightGrayBGColor ,
chipText: " Relation: ${ profile . relationship ? ? " N/A " } " ,
iconAsset: AppAssets . heart ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: AppColors . textColor ) ,
widget . isShowDetails ? SizedBox ( height: 4. h ) : SizedBox ( ) ,
widget . isShowDetails
? CustomChipWidget (
chipType: ChipTypeEnum . alert ,
backgroundColor: AppColors . lightGrayBGColor ,
chipText: " Age: ${ profile . age ? ? " N/A " } Years " ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: AppColors . textColor ,
)
: SizedBox ( ) ,
widget . isShowDetails ? SizedBox ( height: 8. h ) : SizedBox ( ) ,
Spacer ( ) ,
CustomButton (
height: 40. h ,
onPressed: ( ) {
if ( canSwitch ) widget . onSelect ( profile ) ;
} ,
text: isActive ? " Active " . needTranslation : " Switch " . needTranslation ,
backgroundColor: isActive | | ! canSwitch ? Colors . grey . shade200 : AppColors . secondaryLightRedColor ,
borderColor: isActive | | ! canSwitch ? Colors . grey . shade200 : AppColors . secondaryLightRedColor ,
textColor: isActive | | ! canSwitch ? AppColors . greyTextColor : AppColors . primaryRedColor ,
fontSize: 13. h ,
icon: isActive ? AppAssets . activeCheck : AppAssets . switch_user ,
iconColor: isActive | | ! canSwitch ? ( isActive ? null : AppColors . greyTextColor ) : AppColors . primaryRedColor ,
padding: EdgeInsets . symmetric ( vertical: 0 , horizontal: 0 ) ,
) . paddingOnly ( top: 0 , bottom: 0 ) ,
] ,
) ,
if ( widget . isShowRemoveButton ) . . . [
Positioned (
top: 0 ,
right: 0 ,
child: Utils . buildSvgWithAssets ( icon: AppAssets . deleteIcon ) . onPress ( ( ) {
if ( ! isActive ) widget . onRemove ( profile ) ;
} ) ,
) ,
] ,
] ,
) ,
) ,
) ;
} ,
) ;
}
}
}
}
}
}