-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathTopBarBackgroundOptions.java
More file actions
44 lines (34 loc) · 1.69 KB
/
TopBarBackgroundOptions.java
File metadata and controls
44 lines (34 loc) · 1.69 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
package com.reactnativenavigation.options;
import android.content.Context;
import com.reactnativenavigation.options.params.Bool;
import com.reactnativenavigation.options.params.NullBool;
import com.reactnativenavigation.options.params.ThemeColour;
import com.reactnativenavigation.options.params.NullThemeColour;
import com.reactnativenavigation.options.parsers.BoolParser;
import org.json.JSONObject;
public class TopBarBackgroundOptions {
public static TopBarBackgroundOptions parse(Context context, JSONObject json) {
TopBarBackgroundOptions options = new TopBarBackgroundOptions();
if (json == null) return options;
options.color = ThemeColour.parse(context, json.optJSONObject("color"));
options.component = ComponentOptions.parse(json.optJSONObject("component"));
options.waitForRender = BoolParser.parse(json, "waitForRender");
if (options.component.hasValue()) {
options.color = ThemeColour.transparent();
}
return options;
}
public ThemeColour color = new NullThemeColour();
public ComponentOptions component = new ComponentOptions();
public Bool waitForRender = new NullBool();
void mergeWith(final TopBarBackgroundOptions other) {
if (other.color.hasValue()) color = other.color;
if (other.waitForRender.hasValue()) waitForRender = other.waitForRender;
component.mergeWith(other.component);
}
void mergeWithDefault(TopBarBackgroundOptions defaultOptions) {
if (!color.hasValue()) color = defaultOptions.color;
if (!waitForRender.hasValue()) waitForRender = defaultOptions.waitForRender;
component.mergeWithDefault(defaultOptions.component);
}
}