Merge pull request #28 from janicduplessis/transparent-card

Add transparentCard option to fix cards with a transparent bg when using screens
This commit is contained in:
Brent Vatne
2018-09-24 13:32:16 -07:00
parent 4894bb5042
commit 00b83bb18d
5 changed files with 125 additions and 8 deletions

View File

@@ -29,22 +29,24 @@ class Card extends React.Component {
pointerEvents,
style,
position,
transparent,
scene: { index, isActive },
} = this.props;
const active = isActive
? 1
: position.interpolate({
inputRange: [index, index + 1 - EPS, index + 1],
outputRange: [1, 1, 0],
extrapolate: 'clamp',
});
const active =
transparent || isActive
? 1
: position.interpolate({
inputRange: [index, index + 1 - EPS, index + 1],
outputRange: [1, 1, 0],
extrapolate: 'clamp',
});
return (
<Screen
pointerEvents={pointerEvents}
onComponentRef={this.props.onComponentRef}
style={[styles.main, style]}
style={[transparent ? styles.transparent : styles.main, style]}
active={active}
{...getAccessibilityProps(isActive)}
>
@@ -63,6 +65,10 @@ const styles = StyleSheet.create({
shadowOpacity: 0.2,
shadowRadius: 5,
},
transparent: {
...StyleSheet.absoluteFillObject,
backgroundColor: 'transparent',
},
});
export default createPointerEventsContainer(Card);

View File

@@ -618,6 +618,7 @@ class StackViewLayout extends React.Component {
<Card
{...this.props.transitionProps}
key={`card_${scene.key}`}
transparent={this.props.transparentCard}
style={[style, { paddingTop }, this.props.cardStyle]}
scene={scene}
>