浏览代码

Consume SideMenu visibility option after applying it

This change ensures that the visibility option is applied only once.
Guy Carmeli 5 年前
父节点
当前提交
c0b9b58aea

+ 12
- 1
lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Param.java 查看文件

4
 
4
 
5
 public abstract class Param<T> {
5
 public abstract class Param<T> {
6
     protected T value;
6
     protected T value;
7
+    private boolean consumed;
7
 
8
 
8
     Param(T value) {
9
     Param(T value) {
9
         this.value = value;
10
         this.value = value;
10
     }
11
     }
11
 
12
 
13
+    public T getAndConsume() {
14
+        T value = get();
15
+        consumed = true;
16
+        return value;
17
+    }
18
+
19
+    public void consume() {
20
+        consumed = true;
21
+    }
22
+
12
     public T get() {
23
     public T get() {
13
         if (hasValue()) {
24
         if (hasValue()) {
14
             return value;
25
             return value;
21
     }
32
     }
22
 
33
 
23
     public boolean hasValue() {
34
     public boolean hasValue() {
24
-        return value != null;
35
+        return value != null && !consumed;
25
     }
36
     }
26
 
37
 
27
     public boolean canApplyValue() {
38
     public boolean canApplyValue() {

+ 3
- 0
lib/android/app/src/main/java/com/reactnativenavigation/presentation/SideMenuPresenter.java 查看文件

68
         } else if (options.right.visible.isFalse()) {
68
         } else if (options.right.visible.isFalse()) {
69
             sideMenu.closeDrawer(Gravity.RIGHT, options.right.animate.get(true));
69
             sideMenu.closeDrawer(Gravity.RIGHT, options.right.animate.get(true));
70
         }
70
         }
71
+
72
+        options.left.visible.consume();
73
+        options.right.visible.consume();
71
     }
74
     }
72
 
75
 
73
     private void mergeLockMode(SideMenuRootOptions options) {
76
     private void mergeLockMode(SideMenuRootOptions options) {