@@ -14,8 +14,8 @@ import CardItem from './CardItem';
14
14
import CardImage from './CardImage' ;
15
15
import Assets from '../../assets' ;
16
16
17
- const DEFAULT_BORDER_RADIUS = BorderRadiuses . br40 ;
18
17
18
+ const DEFAULT_BORDER_RADIUS = BorderRadiuses . br40 ;
19
19
const DEFAULT_SELECTION_PROPS = {
20
20
borderWidth : 2 ,
21
21
color : Colors . blue30 ,
@@ -147,31 +147,39 @@ class Card extends PureBaseComponent {
147
147
148
148
get elevationStyle ( ) {
149
149
const { elevation, enableShadow} = this . getThemeProps ( ) ;
150
+
150
151
if ( enableShadow ) {
151
152
return { elevation : elevation || 2 } ;
152
153
}
153
154
}
154
155
155
156
get shadowStyle ( ) {
156
157
const { enableShadow} = this . getThemeProps ( ) ;
158
+
157
159
if ( enableShadow ) {
158
160
return this . styles . containerShadow ;
159
161
}
160
162
}
161
163
162
164
get blurBgStyle ( ) {
163
165
const { enableBlur} = this . getThemeProps ( ) ;
166
+
164
167
if ( Constants . isIOS && enableBlur ) {
165
168
return { backgroundColor : Colors . rgba ( Colors . white , 0.85 ) } ;
166
169
} else {
167
170
return { backgroundColor : Colors . white } ;
168
171
}
169
172
}
170
173
174
+ get borderRadius ( ) {
175
+ const { borderRadius} = this . getThemeProps ( ) ;
176
+
177
+ return borderRadius === undefined ? DEFAULT_BORDER_RADIUS : borderRadius ;
178
+ }
179
+
171
180
renderSelection ( ) {
172
- const { selectionOptions, borderRadius , selected} = this . getThemeProps ( ) ;
181
+ const { selectionOptions, selected} = this . getThemeProps ( ) ;
173
182
const { animatedSelected} = this . state ;
174
-
175
183
const selectionColor = _ . get ( selectionOptions , 'color' , DEFAULT_SELECTION_PROPS . color ) ;
176
184
177
185
if ( _ . isUndefined ( selected ) ) {
@@ -183,7 +191,7 @@ class Card extends PureBaseComponent {
183
191
style = { [
184
192
this . styles . selectedBorder ,
185
193
{ borderColor : selectionColor } ,
186
- borderRadius && { borderRadius} ,
194
+ { borderRadius : this . borderRadius } ,
187
195
{ opacity : animatedSelected }
188
196
] }
189
197
pointerEvents = "none"
@@ -196,13 +204,12 @@ class Card extends PureBaseComponent {
196
204
}
197
205
198
206
renderChildren ( ) {
199
- const { borderRadius} = this . getThemeProps ( ) ;
200
207
const children = React . Children . map ( this . props . children , ( child , index ) => {
201
208
if ( _ . get ( child , 'type.displayName' ) === CardImage . displayName ) {
202
209
const position = this . calcImagePosition ( index ) ;
203
210
return React . cloneElement ( child , {
204
211
position,
205
- borderRadius : borderRadius || DEFAULT_BORDER_RADIUS
212
+ borderRadius : this . borderRadius
206
213
} ) ;
207
214
}
208
215
return child ;
@@ -211,10 +218,10 @@ class Card extends PureBaseComponent {
211
218
}
212
219
213
220
render ( ) {
214
- const { onPress, style, containerStyle, borderRadius , enableBlur, ...others } = this . getThemeProps ( ) ;
221
+ const { onPress, style, containerStyle, enableBlur, ...others } = this . getThemeProps ( ) ;
215
222
const blurOptions = this . getBlurOptions ( ) ;
216
223
const Container = onPress ? TouchableOpacity : View ;
217
- const brRadius = borderRadius || DEFAULT_BORDER_RADIUS ;
224
+ const brRadius = this . borderRadius ;
218
225
219
226
return (
220
227
< Container
@@ -244,14 +251,16 @@ class Card extends PureBaseComponent {
244
251
}
245
252
}
246
253
247
- function createStyles ( { width, height, borderRadius = DEFAULT_BORDER_RADIUS , selectionOptions} ) {
254
+ function createStyles ( { width, height, borderRadius, selectionOptions} ) {
248
255
const selectionOptionsWithDefaults = _ . merge ( DEFAULT_SELECTION_PROPS , selectionOptions ) ;
256
+ const brRadius = borderRadius === undefined ? DEFAULT_BORDER_RADIUS : borderRadius ;
257
+
249
258
return StyleSheet . create ( {
250
259
container : {
251
260
width,
252
261
height,
253
262
overflow : 'visible' ,
254
- borderRadius
263
+ borderRadius : brRadius
255
264
} ,
256
265
containerShadow : {
257
266
// sh30 bottom
@@ -262,7 +271,7 @@ function createStyles({width, height, borderRadius = DEFAULT_BORDER_RADIUS, sele
262
271
} ,
263
272
blurView : {
264
273
...StyleSheet . absoluteFillObject ,
265
- borderRadius
274
+ borderRadius : brRadius
266
275
} ,
267
276
selectedBorder : {
268
277
...StyleSheet . absoluteFillObject ,
0 commit comments