Skip to content

Instantly share code, notes, and snippets.

@fzyzcjy
Created July 29, 2018 07:45
Show Gist options
  • Save fzyzcjy/711abab472af21997157514062d6dc3a to your computer and use it in GitHub Desktop.
Save fzyzcjy/711abab472af21997157514062d6dc3a to your computer and use it in GitHub Desktop.
Modal.js
render() {
if (!this.state.rendered) return null;
const { children, dismissable } = this.props;
return (
<Animated.View
accessibilityViewIsModal
accessibilityLiveRegion="polite"
style={[{ opacity: this.state.opacity }, styles.wrapper]}
>
<View
style={[
StyleSheet.absoluteFill,
{ backgroundColor: "rgba(0, 0, 0, .5)" }
]}
/>
{dismissable && (
<TouchableWithoutFeedback onPress={this._hideModal}>
<View style={StyleSheet.absoluteFill} />
</TouchableWithoutFeedback>
)}
{/* <Animated.View style={[{ opacity: this.state.opacity }]}> */}
<Animated.View style={[{ opacity: this.state.opacity, flex: 1 }]}>
{children}
</Animated.View>
</Animated.View>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment