From 1f983657c0457da09f0980ed21e641a77a25b84b Mon Sep 17 00:00:00 2001
From: langke <lchenfox@foxmail.com>
Date: Mon, 25 May 2020 13:09:51 +0800
Subject: [PATCH] Update: add optional "mask" property to options

---
 index.d.ts            |  3 ++-
 lib/ToastContainer.js | 18 +++++++++++-------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/index.d.ts b/index.d.ts
index 88c2647..fce93b3 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -25,7 +25,8 @@ declare module "react-native-root-toast"{
         onHidden?: Function,
         onShow?: Function,
         onShown?: Function,
-        onPress?: Function
+        onPress?: Function,
+        mask?: boolean,
     }
 
     export interface ToastProps extends ToastOptions,ReactNative.ViewProperties{
diff --git a/lib/ToastContainer.js b/lib/ToastContainer.js
index a645d4d..8a0e613 100644
--- a/lib/ToastContainer.js
+++ b/lib/ToastContainer.js
@@ -81,7 +81,8 @@ class ToastContainer extends Component {
         onHide: PropTypes.func,
         onHidden: PropTypes.func,
         onShow: PropTypes.func,
-        onShown: PropTypes.func
+        onShown: PropTypes.func,
+        mask: PropTypes.bool,
     };
 
     static defaultProps = {
@@ -93,7 +94,8 @@ class ToastContainer extends Component {
         opacity: 0.8,
         delay: 0,
         hideOnPress: true,
-        keyboardAvoiding: true
+        keyboardAvoiding: true,
+        mask: false,
     };
 
     constructor() {
@@ -104,7 +106,8 @@ class ToastContainer extends Component {
             opacity: new Animated.Value(0),
             windowWidth: window.width,
             windowHeight: window.height,
-            keyboardScreenY: window.height
+            keyboardScreenY: window.height,
+            mask: this.props.mask,
         };
     }
 
@@ -194,11 +197,11 @@ class ToastContainer extends Component {
                     pointerEvents: 'none'
                 });
             }
-            
+
             if (this.props.onHide) {
                 this.props.onHide(this.props.siblingManager);
             }
-            
+
             Animated.timing(this.state.opacity, {
                 toValue: 0,
                 duration: this.props.animation ? TOAST_ANIMATION_DURATION : 0,
@@ -207,6 +210,7 @@ class ToastContainer extends Component {
             }).start(({finished}) => {
                 if (finished) {
                     this._animating = false;
+                    this.setState({mask: false});
                     this.props.onHidden && this.props.onHidden(this.props.siblingManager);
                 }
             });
@@ -215,7 +219,7 @@ class ToastContainer extends Component {
 
     render() {
         let {props} =  this;
-        const { windowWidth } = this.state;
+        const { windowWidth, mask } = this.state;
         let offset = props.position;
 
         const { windowHeight, keyboardScreenY } = this.state;
@@ -232,7 +236,7 @@ class ToastContainer extends Component {
                 styles.defaultStyle,
                 position
             ]}
-            pointerEvents="box-none"
+            pointerEvents= {mask ? 'box-only' : 'box-none'}
         >
             <TouchableWithoutFeedback
                 onPress={() => {