Преглед на файлове

add enabled option to SideMenu (#4037)

Rafal Rybarczyk преди 6 години
родител
ревизия
98f5a005d4

+ 5
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/SideMenuOptions.java Целия файл

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

+ 14
- 0
lib/android/app/src/main/java/com/reactnativenavigation/presentation/SideMenuOptionsPresenter.java Целия файл

27
         } else if (options.right.visible.isFalse() && sideMenu.isDrawerOpen(Gravity.RIGHT)){
27
         } else if (options.right.visible.isFalse() && sideMenu.isDrawerOpen(Gravity.RIGHT)){
28
             sideMenu.closeDrawer(Gravity.RIGHT);
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
     public boolean handleBack() {
46
     public boolean handleBack() {