ソースを参照

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,11 +4,22 @@ import static com.reactnativenavigation.utils.ObjectUtils.equalsNotNull;
4 4
 
5 5
 public abstract class Param<T> {
6 6
     protected T value;
7
+    private boolean consumed;
7 8
 
8 9
     Param(T value) {
9 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 23
     public T get() {
13 24
         if (hasValue()) {
14 25
             return value;
@@ -21,7 +32,7 @@ public abstract class Param<T> {
21 32
     }
22 33
 
23 34
     public boolean hasValue() {
24
-        return value != null;
35
+        return value != null && !consumed;
25 36
     }
26 37
 
27 38
     public boolean canApplyValue() {

+ 3
- 0
lib/android/app/src/main/java/com/reactnativenavigation/presentation/SideMenuPresenter.java ファイルの表示

@@ -68,6 +68,9 @@ public class SideMenuPresenter {
68 68
         } else if (options.right.visible.isFalse()) {
69 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 76
     private void mergeLockMode(SideMenuRootOptions options) {