feat: if cardStyle has flexed specified, set the same value on P… (#206)

* feat: if cardStyle has flexed specified, set the same value on PointerEventsView

* Stop producing empty object if no override is needed

* Change produced false to undefined

* Update cardStyle to handle arrays

* Update code to use StyleSheet.flatten

* Use better styling

* Update snapshots
This commit is contained in:
Tomasz Czajęcki
2019-09-10 22:51:58 +02:00
parent 4c012ad1ea
commit f4c8078da8
5 changed files with 69 additions and 0 deletions

View File

@@ -146,6 +146,7 @@ Array [
"flex": 1,
"overflow": "hidden",
},
null,
Object {
"backgroundColor": "#eee",
},
@@ -297,6 +298,7 @@ Array [
"flex": 1,
"overflow": "hidden",
},
null,
Object {
"backgroundColor": "#eee",
},

View File

@@ -146,6 +146,7 @@ Array [
"flex": 1,
"overflow": "hidden",
},
null,
Object {
"backgroundColor": "#eee",
},
@@ -464,6 +465,7 @@ Array [
"flex": 1,
"overflow": "hidden",
},
null,
Object {
"backgroundColor": "#eee",
},

View File

@@ -638,6 +638,14 @@ export default class Card extends React.Component<Props> {
: this.handleGestureEventHorizontal
: undefined;
let overrideFlex = null;
if (cardStyle) {
const style = StyleSheet.flatten(cardStyle) as ViewStyle;
if (style.hasOwnProperty('flex')) {
overrideFlex = { flex: style.flex };
}
}
return (
<StackGestureContext.Provider value={this.gestureRef}>
<View pointerEvents="box-none" {...rest}>
@@ -681,6 +689,7 @@ export default class Card extends React.Component<Props> {
progress={this.props.current}
style={[
styles.content,
overrideFlex,
transparent ? styles.transparent : styles.opaque,
contentStyle,
]}