11import React from 'react' ;
2+ import type { StyleProp , ViewStyle } from 'react-native' ;
23import { View } from 'react-native' ;
34import { useMemoizedLazyExpensifyIcons } from '@hooks/useLazyAsset' ;
45import useLocalize from '@hooks/useLocalize' ;
@@ -9,16 +10,18 @@ import useThemeStyles from '@hooks/useThemeStyles';
910import DateUtils from '@libs/DateUtils' ;
1011import { getDisplayNameOrDefault } from '@libs/PersonalDetailsUtils' ;
1112import Navigation from '@navigation/Navigation' ;
13+ import variables from '@styles/variables' ;
1214import CONST from '@src/CONST' ;
1315import ONYXKEYS from '@src/ONYXKEYS' ;
1416import ROUTES from '@src/ROUTES' ;
1517import Button from './Button' ;
16- import Icon from './Icon' ;
1718import Text from './Text' ;
1819import TextLink from './TextLink' ;
1920
2021type FrozenCardHeaderProps = {
2122 cardPreview : React . ReactNode ;
23+ children ?: React . ReactNode ;
24+ style ?: StyleProp < ViewStyle > ;
2225 onUnfreezePress : ( ) => void ;
2326 onAskToUnfreezePress : ( ) => void ;
2427 canUnfreezeCard : boolean ;
@@ -27,7 +30,7 @@ type FrozenCardHeaderProps = {
2730 frozenDate ?: string ;
2831} ;
2932
30- function FrozenCardHeader ( { cardPreview, onUnfreezePress, onAskToUnfreezePress, canUnfreezeCard, isWorkspaceAdmin, frozenByAccountID, frozenDate} : FrozenCardHeaderProps ) {
33+ function FrozenCardHeader ( { cardPreview, children , style , onUnfreezePress, onAskToUnfreezePress, canUnfreezeCard, isWorkspaceAdmin, frozenByAccountID, frozenDate} : FrozenCardHeaderProps ) {
3134 const styles = useThemeStyles ( ) ;
3235 const theme = useTheme ( ) ;
3336 const { translate} = useLocalize ( ) ;
@@ -42,6 +45,12 @@ function FrozenCardHeader({cardPreview, onUnfreezePress, onAskToUnfreezePress, c
4245 const adminFrozenTextPrefix = translate ( 'cardPage.frozenByAdminPrefix' , { date : formattedDate } ) ;
4346 const frozenNeedsUnfreezePrefix = translate ( 'cardPage.frozenByAdminNeedsUnfreezePrefix' ) ;
4447 const frozenNeedsUnfreezeSuffix = translate ( 'cardPage.frozenByAdminNeedsUnfreezeSuffix' ) ;
48+ const actionButtons = React . Children . toArray ( children ) ;
49+ const shouldUseEqualButtonWidths = actionButtons . length > 0 ;
50+ const equalButtonWrapperStyles = shouldUseEqualButtonWidths
51+ ? [ styles . flexGrow1 , styles . flexShrink1 , styles . flexBasis0 , { minWidth : variables . cardDetailsActionButtonMinWidth } ]
52+ : undefined ;
53+ const equalButtonInnerStyles = shouldUseEqualButtonWidths ? styles . ph2 : undefined ;
4554
4655 let statusText : React . ReactNode ;
4756
@@ -81,23 +90,36 @@ function FrozenCardHeader({cardPreview, onUnfreezePress, onAskToUnfreezePress, c
8190 }
8291
8392 return (
84- < View style = { [ styles . ph5 , styles . pb5 ] } >
93+ < View style = { [ styles . ph5 , styles . pb5 , style ] } >
8594 { cardPreview }
86- < View style = { [ styles . flexRow , styles . alignItemsCenter , styles . mt9 ] } >
87- < Icon
88- src = { icons . FreezeCard }
89- fill = { theme . icon }
90- small
91- />
92- < Text style = { [ styles . textLabel , styles . colorMuted , styles . ml2 ] } > { statusText } </ Text >
95+ < View style = { [ styles . flexRow , styles . alignItemsCenter , styles . justifyContentCenter , styles . mt2 ] } >
96+ < Text style = { [ styles . textLabel , styles . colorMuted ] } > { statusText } </ Text >
97+ </ View >
98+ < View style = { [ styles . flexRow , styles . flexWrap , styles . alignItemsCenter , styles . justifyContentCenter , styles . gap2 , styles . mt6 , styles . alignSelfStretch ] } >
99+ < View style = { equalButtonWrapperStyles } >
100+ < Button
101+ medium
102+ text = { translate ( canUnfreezeCard ? 'cardPage.unfreezeCard' : 'cardPage.askToUnfreeze' ) }
103+ icon = { icons . FreezeCard }
104+ iconFill = { theme . icon }
105+ onPress = { canUnfreezeCard ? onUnfreezePress : onAskToUnfreezePress }
106+ isDisabled = { canUnfreezeCard && isOffline }
107+ innerStyles = { equalButtonInnerStyles }
108+ style = { shouldUseEqualButtonWidths ? styles . w100 : styles . alignSelfStart }
109+ />
110+ </ View >
111+ { shouldUseEqualButtonWidths
112+ ? actionButtons . map ( ( button , index ) => (
113+ < View
114+ // eslint-disable-next-line react/no-array-index-key
115+ key = { index }
116+ style = { equalButtonWrapperStyles }
117+ >
118+ { button }
119+ </ View >
120+ ) )
121+ : children }
93122 </ View >
94- < Button
95- medium
96- text = { translate ( canUnfreezeCard ? 'cardPage.unfreeze' : 'cardPage.askToUnfreeze' ) }
97- onPress = { canUnfreezeCard ? onUnfreezePress : onAskToUnfreezePress }
98- isDisabled = { canUnfreezeCard && isOffline }
99- style = { [ styles . mt4 ] }
100- />
101123 </ View >
102124 ) ;
103125}
0 commit comments