Browse Source

add enabled option to SideMenu (#4037)

Rafal Rybarczyk 6 years ago
parent
commit
98f5a005d4

+ 5
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/SideMenuOptions.java View File

@@ -11,6 +11,7 @@ import org.json.JSONObject;
11 11
 
12 12
 public class SideMenuOptions {
13 13
     public Bool visible = new NullBool();
14
+    public Bool enabled = new NullBool();
14 15
     public Number height = new NullNumber();
15 16
     public Number width = new NullNumber();
16 17
 
@@ -19,6 +20,7 @@ public class SideMenuOptions {
19 20
         if (json == null) return options;
20 21
 
21 22
         options.visible = BoolParser.parse(json, "visible");
23
+        options.enabled = BoolParser.parse(json, "enabled");
22 24
         options.height = NumberParser.parse(json, "height");
23 25
         options.width = NumberParser.parse(json, "width");
24 26
 
@@ -29,6 +31,9 @@ public class SideMenuOptions {
29 31
         if (other.visible.hasValue()) {
30 32
             visible = other.visible;
31 33
         }
34
+        if (other.enabled.hasValue()) {
35
+            enabled = other.enabled;
36
+        }
32 37
         if (other.height.hasValue()) {
33 38
             height = other.height;
34 39
         }

+ 14
- 0
lib/android/app/src/main/java/com/reactnativenavigation/presentation/SideMenuOptionsPresenter.java View File

@@ -27,6 +27,20 @@ public class SideMenuOptionsPresenter {
27 27
         } else if (options.right.visible.isFalse() && sideMenu.isDrawerOpen(Gravity.RIGHT)){
28 28
             sideMenu.closeDrawer(Gravity.RIGHT);
29 29
         }
30
+
31
+        if (options.left.enabled.isFalse()) {
32
+            sideMenu.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.LEFT);
33
+        }
34
+        else  if (options.left.enabled.isTrue()) {
35
+            sideMenu.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT);
36
+        }
37
+
38
+        if (options.right.enabled.isFalse()) {
39
+            sideMenu.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
40
+        }
41
+        else  if (options.right.enabled.isTrue()) {
42
+            sideMenu.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
43
+        }
30 44
     }
31 45
 
32 46
     public boolean handleBack() {