@ -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/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/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/custom_chip_widget.dart ' ;
@ -42,10 +44,9 @@ class FamilyCards extends StatefulWidget {
class _FamilyCardsState extends State < FamilyCards > {
AppState appState = getIt < AppState > ( ) ;
/ / bool isShowActions = true ;
@ override
Widget build ( BuildContext context ) {
DialogService dialogService = getIt . get < DialogService > ( ) ;
if ( widget . isRequestDesign ) {
return Column (
children: [
@ -53,7 +54,14 @@ class _FamilyCardsState extends State<FamilyCards> {
children: [
Utils . buildSvgWithAssets ( icon: AppAssets . alertSquare ) ,
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 ) ,
Utils . buildSvgWithAssets ( icon: AppAssets . arrowRight ) ,
] ,
@ -67,100 +75,6 @@ class _FamilyCardsState extends State<FamilyCards> {
itemBuilder: ( context , index ) {
final mySideProfiles = widget . profiles . where ( ( profile ) = > profile . isRequestFromMySide ? ? false ) . toList ( ) ;
FamilyFileResponseModelLists profile = mySideProfiles [ index ] ;
return Container (
margin: EdgeInsets . only (
bottom: 12. h ,
) ,
padding: EdgeInsets . symmetric (
vertical: 15. h ,
horizontal: 15. h ,
) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration ( color: AppColors . whiteColor , borderRadius: 24 ) ,
child: Opacity (
opacity: 1.0 ,
child: Column (
mainAxisSize: MainAxisSize . min ,
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisAlignment: MainAxisAlignment . start ,
children: [
CustomChipWidget (
height: 30. h ,
chipType: ChipTypeEnum . alert ,
backgroundColor: profile . status = = FamilyFileEnum . pending . toInt
? AppColors . alertLightColor . withValues ( alpha: 0.20 )
: profile . status = = FamilyFileEnum . rejected . toInt
? AppColors . primaryRedColor . withValues ( alpha: 0.20 )
: profile . status = = FamilyFileEnum . active . toInt
? AppColors . lightGreenColor
: AppColors . lightGrayBGColor ,
chipText: profile . statusDescription ? ? " N/A " ,
iconAsset: null ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: profile . status = = FamilyFileEnum . pending . toInt
? AppColors . alertLightColor
: profile . status = = FamilyFileEnum . rejected . toInt
? AppColors . primaryRedColor
: profile . status = = FamilyFileEnum . active . toInt
? AppColors . textGreenColor
: AppColors . alertColor ,
) ,
Wrap (
alignment: WrapAlignment . start ,
children: [
( profile . patientName ? ? " " ) . toText16 (
isBold: false ,
isCenter: true ,
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 (
height: 30. h ,
chipType: ChipTypeEnum . alert ,
backgroundColor: AppColors . lightGrayBGColor ,
chipText: " Medical File: ${ profile . responseId ? ? " N/A " } " ,
iconAsset: null ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: AppColors . textColor ,
) ,
] ,
) ,
) ,
) ;
} ,
) ,
SizedBox ( height: 20. h ) ,
if ( widget . profiles . where ( ( profile ) = > ! ( profile . isRequestFromMySide ? ? false ) ) . isNotEmpty )
Row (
children: [
Utils . buildSvgWithAssets ( icon: AppAssets . alertSquare ) ,
SizedBox ( width: 8. h ) ,
" Users who want to view your profile " . needTranslation . toText14 ( color: AppColors . textColor , isUnderLine: true , weight: FontWeight . w500 ) ,
SizedBox ( width: 4. h ) ,
Utils . buildSvgWithAssets ( icon: AppAssets . arrowRight ) ,
] ,
) ,
/ / Items for second group ( requests from others )
ListView . builder (
shrinkWrap: true ,
physics: NeverScrollableScrollPhysics ( ) ,
itemCount: widget . profiles . where ( ( profile ) = > ! ( profile . isRequestFromMySide ? ? false ) ) . length ,
itemBuilder: ( context , index ) {
final otherProfiles = widget . profiles . where ( ( profile ) = > ! ( profile . isRequestFromMySide ? ? false ) ) . toList ( ) ;
FamilyFileResponseModelLists profile = otherProfiles [ index ] ;
return Container (
margin: EdgeInsets . only ( bottom: 12. h ) ,
padding: EdgeInsets . symmetric ( vertical: 15. h , horizontal: 15. h ) ,
@ -173,92 +87,49 @@ class _FamilyCardsState extends State<FamilyCards> {
mainAxisAlignment: MainAxisAlignment . start ,
children: [
CustomChipWidget (
height: 30. h ,
chipType: ChipTypeEnum . alert ,
backgroundColor: profile . status = = FamilyFileEnum . pending . toInt
? AppColors . alertLightColor . withValues ( alpha: 0.20 )
: profile . status = = FamilyFileEnum . rejected . toInt
? AppColors . primaryRedColor . withValues ( alpha: 0.20 )
: profile . status = = FamilyFileEnum . active . toInt
? AppColors . lightGreenColor
: AppColors . lightGrayBGColor ,
chipText: profile . statusDescription ? ? " N/A " ,
iconAsset: null ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: profile . status = = FamilyFileEnum . pending . toInt
? AppColors . alertLightColor
: profile . status = = FamilyFileEnum . rejected . toInt
? AppColors . primaryRedColor
: profile . status = = FamilyFileEnum . active . toInt
? AppColors . textGreenColor
: AppColors . alertColor ,
) ,
Wrap (
alignment: WrapAlignment . start ,
children: [
( profile . patientName ? ? " " ) . toText16 ( 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 (
isBold: false ,
isCenter: true ,
maxlines: 1 ,
weight: FontWeight . w500 ,
color: AppColors . greyTextColor ,
) ,
] ,
) ,
SizedBox ( height: 4. h ) ,
height: 30. h ,
chipType: ChipTypeEnum . alert ,
backgroundColor: profile . status = = FamilyFileEnum . pending . toInt
? AppColors . alertLightColor . withValues ( alpha: 0.20 )
: profile . status = = FamilyFileEnum . rejected . toInt
? AppColors . primaryRedColor . withValues ( alpha: 0.20 )
: profile . status = = FamilyFileEnum . active . toInt
? AppColors . lightGreenColor
: AppColors . lightGrayBGColor ,
chipText: profile . statusDescription ? ? " N/A " ,
iconAsset: null ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: profile . status = = FamilyFileEnum . pending . toInt
? AppColors . alertLightColor
: profile . status = = FamilyFileEnum . rejected . toInt
? AppColors . primaryRedColor
: profile . status = = FamilyFileEnum . active . toInt
? AppColors . textGreenColor
: AppColors . alertColor ) ,
SizedBox ( height: 8. h ) ,
Wrap ( alignment: WrapAlignment . start , crossAxisAlignment: WrapCrossAlignment . start , runAlignment: WrapAlignment . start , spacing: 0. h , children: [
( profile . patientName ? ? " " ) . toText14 ( isBold: false , isCenter: false , maxlines: 1 , weight: FontWeight . w600 ) ,
( getStatusTextByRequest ( FamilyFileEnum . values . firstWhere ( ( e ) = > e . toInt = = profile . status ) , profile . isRequestFromMySide ? ? false ) )
. toText14 ( isBold: false , isCenter: false , maxlines: 1 , weight: FontWeight . w500 , color: AppColors . greyTextColor ) ,
] ) ,
SizedBox ( height: 8. h ) ,
CustomChipWidget (
height: 30. h ,
chipType: ChipTypeEnum . alert ,
backgroundColor: AppColors . lightGrayBGColor ,
chipText: " Medical File: ${ profile . patientId ? ? " N/A " . needTranslation } " ,
iconAsset: null ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: AppColors . textColor ,
) ,
SizedBox ( height: 16. h ) ,
Row (
children: [
profile . status = = FamilyFileEnum . active . toInt
? SizedBox ( )
: Expanded (
child: CustomButton (
height: 40. h ,
text: LocaleKeys . confirm . tr ( ) ,
onPressed: ( ) {
widget . onSelect ( profile ) ;
} ,
backgroundColor: AppColors . lightGreenButtonColor ,
borderColor: AppColors . lightGreenButtonColor ,
textColor: AppColors . textGreenColor ,
icon: null ,
) ,
) ,
profile . status = = FamilyFileEnum . active . toInt ? SizedBox ( ) : SizedBox ( width: 8. h ) ,
Expanded (
child: CustomButton (
height: 40. h ,
text: profile . status = = FamilyFileEnum . active . toInt ? LocaleKeys . removeMember . tr ( ) : LocaleKeys . cancel . tr ( ) ,
onPressed: ( ) {
widget . onRemove ( profile ) ;
} ,
backgroundColor: AppColors . secondaryLightRedColor ,
borderColor: AppColors . secondaryLightRedColor ,
textColor: AppColors . primaryRedColor ,
icon: null ,
iconColor: AppColors . primaryRedColor ,
) ,
) ,
] ,
) ,
height: 30. h ,
chipType: ChipTypeEnum . alert ,
backgroundColor: AppColors . lightGrayBGColor ,
chipText: " Medical File: ${ profile . responseId ? ? " N/A " } " ,
iconAsset: null ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: AppColors . textColor ) ,
] ,
) ,
) ,
) ;
} ,
) ,
SizedBox ( height: 20. h ) ,
] ,
) ;
} else {
@ -270,7 +141,7 @@ class _FamilyCardsState extends State<FamilyCards> {
crossAxisCount: 2 ,
crossAxisSpacing: 10. h ,
mainAxisSpacing: 10. h ,
childAspectRatio: widget . isShowDetails ? 0.56 . h : 0.6 6 . h ,
childAspectRatio: widget . isShowDetails ? 0.56 . h : 0.6 5 . h ,
) ,
padding: EdgeInsets . only ( bottom: 20. h ) ,
itemBuilder: ( context , index ) {
@ -297,8 +168,8 @@ class _FamilyCardsState extends State<FamilyCards> {
width: 80. h ,
height: 78. h ) ,
SizedBox ( height: 8. h ) ,
( profile . patientName ? ? " Unknown " ) . toText1 6 ( isBold: false , isCenter: true , maxlines: 1 , weight: FontWeight . w600 ) ,
SizedBox ( height: 4 .h ) ,
( profile . patientName ? ? " Unknown " ) . toText1 4 ( isBold: false , isCenter: true , maxlines: 1 , weight: FontWeight . w600 ) ,
SizedBox ( height: 8 .h ) ,
CustomChipWidget (
chipType: ChipTypeEnum . alert ,
backgroundColor: AppColors . lightGrayBGColor ,
@ -318,7 +189,11 @@ class _FamilyCardsState extends State<FamilyCards> {
textColor: AppColors . textColor ,
)
: SizedBox ( ) ,
widget . isShowDetails ? SizedBox ( height: 8. h ) : SizedBox ( ) ,
widget . isShowDetails
? SizedBox ( height: 8. h )
: SizedBox (
height: 4. h ,
) ,
Spacer ( ) ,
CustomButton (
height: 40. h ,
@ -353,4 +228,144 @@ class _FamilyCardsState extends State<FamilyCards> {
) ;
}
}
Widget manageFamily ( ) {
NavigationService navigationService = getIt < NavigationService > ( ) ;
return ListView . builder (
shrinkWrap: true ,
physics: NeverScrollableScrollPhysics ( ) ,
padding: EdgeInsetsGeometry . zero ,
itemCount: widget . profiles . where ( ( profile ) = > ! ( profile . isRequestFromMySide ? ? false ) ) . length ,
itemBuilder: ( context , index ) {
final otherProfiles = widget . profiles . where ( ( profile ) = > ! ( profile . isRequestFromMySide ? ? false ) ) . toList ( ) ;
FamilyFileResponseModelLists profile = otherProfiles [ index ] ;
return Container (
margin: EdgeInsets . only ( bottom: 12. h ) ,
padding: EdgeInsets . symmetric ( vertical: 15. h , horizontal: 15. h ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration ( color: AppColors . whiteColor , borderRadius: 24 ) ,
child: Opacity (
opacity: 1.0 ,
child: Column (
mainAxisSize: MainAxisSize . min ,
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisAlignment: MainAxisAlignment . start ,
children: [
CustomChipWidget (
height: 30. h ,
chipType: ChipTypeEnum . alert ,
backgroundColor: profile . status = = FamilyFileEnum . pending . toInt
? AppColors . alertLightColor . withValues ( alpha: 0.20 )
: profile . status = = FamilyFileEnum . rejected . toInt
? AppColors . primaryRedColor . withValues ( alpha: 0.20 )
: profile . status = = FamilyFileEnum . active . toInt
? AppColors . lightGreenColor
: AppColors . lightGrayBGColor ,
chipText: profile . statusDescription ? ? " N/A " ,
iconAsset: null ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: profile . status = = FamilyFileEnum . pending . toInt
? AppColors . alertLightColor
: profile . status = = FamilyFileEnum . rejected . toInt
? AppColors . primaryRedColor
: profile . status = = FamilyFileEnum . active . toInt
? AppColors . textGreenColor
: AppColors . alertColor ,
) ,
SizedBox ( height: 8. h ) ,
Wrap (
alignment: WrapAlignment . start ,
children: [
( profile . patientName ? ? " " ) . toText14 ( isBold: false , isCenter: true , maxlines: 1 , weight: FontWeight . w600 ) ,
( getStatusTextByRequest ( FamilyFileEnum . values . firstWhere ( ( e ) = > e . toInt = = profile . status ) , profile . isRequestFromMySide ? ? false ) ) . toText14 (
isBold: false ,
isCenter: true ,
maxlines: 1 ,
weight: FontWeight . w500 ,
color: AppColors . greyTextColor ,
) ,
] ,
) ,
SizedBox ( height: 8. h ) ,
CustomChipWidget (
height: 30. h ,
chipType: ChipTypeEnum . alert ,
backgroundColor: AppColors . lightGrayBGColor ,
chipText: " Medical File: ${ profile . patientId ? ? " N/A " . needTranslation } " ,
iconAsset: null ,
isShowBorder: false ,
borderRadius: 8. h ,
textColor: AppColors . textColor ,
) ,
SizedBox ( height: 16. h ) ,
Row (
children: [
profile . status = = FamilyFileEnum . active . toInt
? SizedBox ( )
: Expanded (
child: CustomButton (
height: 40. h ,
text: LocaleKeys . confirm . tr ( ) ,
onPressed: ( ) {
navigationService . pop ( ) ;
widget . onSelect ( profile ) ;
} ,
backgroundColor: AppColors . lightGreenButtonColor ,
borderColor: AppColors . lightGreenButtonColor ,
textColor: AppColors . textGreenColor ,
icon: null ,
) ,
) ,
profile . status = = FamilyFileEnum . active . toInt ? SizedBox ( ) : SizedBox ( width: 8. h ) ,
Expanded (
child: CustomButton (
height: 40. h ,
text: profile . status = = FamilyFileEnum . active . toInt ? LocaleKeys . removeMember . tr ( ) : LocaleKeys . cancel . tr ( ) ,
onPressed: ( ) {
navigationService . pop ( ) ;
widget . onRemove ( profile ) ;
} ,
backgroundColor: AppColors . secondaryLightRedColor ,
borderColor: AppColors . secondaryLightRedColor ,
textColor: AppColors . primaryRedColor ,
icon: null ,
iconColor: AppColors . primaryRedColor ,
) ,
) ,
] ,
) ,
] ,
) ,
) ,
) ;
} ,
) ;
}
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 {
return " can view your file " . needTranslation ;
}
case FamilyFileEnum . pending:
if ( isRequestFromMySide ) {
return " has a request ${ status . displayName } to be your family member " . needTranslation ;
} else {
return " wants to add you as their family member " . needTranslation ;
}
case FamilyFileEnum . rejected:
if ( isRequestFromMySide ) {
return " ${ status . displayName } your request to be your family member " . needTranslation ;
} else {
return " ${ status . displayName } your family member request " . needTranslation ;
}
case FamilyFileEnum . inactive:
return " Inactive " . needTranslation ;
default :
return " N/A " . needTranslation ;
}
}
}