-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathSideMenuOptions.java
More file actions
47 lines (39 loc) · 1.89 KB
/
SideMenuOptions.java
File metadata and controls
47 lines (39 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.reactnativenavigation.options;
import com.reactnativenavigation.options.params.Bool;
import com.reactnativenavigation.options.params.NullBool;
import com.reactnativenavigation.options.params.NullNumber;
import com.reactnativenavigation.options.params.Number;
import com.reactnativenavigation.options.parsers.BoolParser;
import com.reactnativenavigation.options.parsers.NumberParser;
import org.json.JSONObject;
public class SideMenuOptions {
public Bool visible = new NullBool();
public Bool animate = new NullBool();
public Bool enabled = new NullBool();
public Number height = new NullNumber();
public Number width = new NullNumber();
public static SideMenuOptions parse(JSONObject json) {
SideMenuOptions options = new SideMenuOptions();
if (json == null) return options;
options.visible = BoolParser.parse(json, "visible");
options.animate = BoolParser.parse(json, "animate");
options.enabled = BoolParser.parse(json, "enabled");
options.height = NumberParser.parse(json, "height");
options.width = NumberParser.parse(json, "width");
return options;
}
public void mergeWith(SideMenuOptions other) {
if (other.visible.hasValue()) visible = other.visible;
if (other.animate.hasValue()) animate = other.animate;
if (other.enabled.hasValue()) enabled = other.enabled;
if (other.height.hasValue()) height = other.height;
if (other.width.hasValue()) width = other.width;
}
public void mergeWithDefault(SideMenuOptions defaultOptions) {
if (!visible.hasValue()) visible = defaultOptions.visible;
if (!animate.hasValue()) animate = defaultOptions.animate;
if (!enabled.hasValue()) enabled = defaultOptions.enabled;
if (!height.hasValue()) height = defaultOptions.height;
if (!width.hasValue()) width = defaultOptions.width;
}
}