File tree Expand file tree Collapse file tree 3 files changed +27
-6
lines changed Expand file tree Collapse file tree 3 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,11 @@ export type Props = React.ComponentProps<typeof Surface> & {
67
67
* Changes Card shadow and background on iOS and Android.
68
68
*/
69
69
elevation ?: 0 | 1 | 2 | 3 | 4 | 5 | Animated . Value ;
70
- style ?: Animated . WithAnimatedValue < StyleProp < ViewStyle > > ;
70
+ /**
71
+ * Style of card's inner content.
72
+ */
73
+ contentStyle ?: StyleProp < ViewStyle > ;
74
+ style ?: StyleProp < ViewStyle > ;
71
75
/**
72
76
* @optional
73
77
*/
@@ -133,6 +137,7 @@ const Card = ({
133
137
mode : cardMode = 'elevated' ,
134
138
children,
135
139
style,
140
+ contentStyle,
136
141
theme : themeOverrides ,
137
142
testID = 'card' ,
138
143
accessible,
@@ -275,7 +280,7 @@ const Card = ({
275
280
testID = { testID }
276
281
accessible = { accessible }
277
282
>
278
- < View style = { styles . innerContainer } >
283
+ < View style = { [ styles . innerContainer , contentStyle ] } >
279
284
{ React . Children . map ( children , ( child , index ) =>
280
285
React . isValidElement ( child )
281
286
? React . cloneElement ( child as React . ReactElement < any > , {
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import { Animated , StyleSheet } from 'react-native' ;
2
+ import { Animated , StyleSheet , Text } from 'react-native' ;
3
3
4
4
import { render } from '@testing-library/react-native' ;
5
5
import color from 'color' ;
@@ -16,6 +16,9 @@ const styles = StyleSheet.create({
16
16
customBorderRadius : {
17
17
borderRadius : 32 ,
18
18
} ,
19
+ contentStyle : {
20
+ flexDirection : 'column-reverse' ,
21
+ } ,
19
22
} ) ;
20
23
21
24
describe ( 'Card' , ( ) => {
@@ -73,6 +76,16 @@ describe('Card', () => {
73
76
backgroundColor : '#0000FF' ,
74
77
} ) ;
75
78
} ) ;
79
+
80
+ it ( 'renders with a content style' , ( ) => {
81
+ const { getByTestId } = render (
82
+ < Card contentStyle = { styles . contentStyle } >
83
+ < Text > Content</ Text >
84
+ </ Card >
85
+ ) ;
86
+
87
+ expect ( getByTestId ( 'card' ) ) . toHaveStyle ( styles . contentStyle ) ;
88
+ } ) ;
76
89
} ) ;
77
90
78
91
describe ( 'CardActions' , ( ) => {
Original file line number Diff line number Diff line change @@ -88,9 +88,12 @@ exports[`Card renders an outlined card 1`] = `
88
88
onResponderTerminationRequest = { [Function ]}
89
89
onStartShouldSetResponder = { [Function ]}
90
90
style = {
91
- Object {
92
- " flexShrink" : 1 ,
93
- }
91
+ Array [
92
+ Object {
93
+ " flexShrink" : 1 ,
94
+ },
95
+ undefined ,
96
+ ]
94
97
}
95
98
testID = " card"
96
99
/>
You can’t perform that action at this time.
0 commit comments