-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathTopTabsOptions.java
More file actions
60 lines (49 loc) · 2.45 KB
/
TopTabsOptions.java
File metadata and controls
60 lines (49 loc) · 2.45 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
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.reactnativenavigation.options;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
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.params.ThemeColour;
import com.reactnativenavigation.options.params.NullThemeColour;
import com.reactnativenavigation.options.parsers.BoolParser;
import com.reactnativenavigation.options.parsers.NumberParser;
import org.json.JSONObject;
public class TopTabsOptions {
@NonNull
public ThemeColour selectedTabColor = new NullThemeColour();
@NonNull
public ThemeColour unselectedTabColor = new NullThemeColour();
@NonNull
public Number fontSize = new NullNumber();
@NonNull
public Bool visible = new NullBool();
@NonNull
public Number height = new NullNumber();
public static TopTabsOptions parse(Context context, @Nullable JSONObject json) {
TopTabsOptions result = new TopTabsOptions();
if (json == null) return result;
result.selectedTabColor = ThemeColour.parse(context, json.optJSONObject("selectedTabColor"));
result.unselectedTabColor = ThemeColour.parse(context, json.optJSONObject("unselectedTabColor"));
result.fontSize = NumberParser.parse(json, "fontSize");
result.visible = BoolParser.parse(json, "visible");
result.height = NumberParser.parse(json, "height");
return result;
}
void mergeWith(TopTabsOptions other) {
if (other.selectedTabColor.hasValue()) selectedTabColor = other.selectedTabColor;
if (other.unselectedTabColor.hasValue()) unselectedTabColor = other.unselectedTabColor;
if (other.fontSize.hasValue()) fontSize = other.fontSize;
if (other.visible.hasValue()) visible = other.visible;
if (other.height.hasValue()) height = other.height;
}
void mergeWithDefault(TopTabsOptions defaultOptions) {
if (!selectedTabColor.hasValue()) selectedTabColor = defaultOptions.selectedTabColor;
if (!unselectedTabColor.hasValue()) unselectedTabColor = defaultOptions.unselectedTabColor;
if (!fontSize.hasValue()) fontSize = defaultOptions.fontSize;
if (!visible.hasValue()) visible = defaultOptions.visible;
if (!height.hasValue()) height = defaultOptions.height;
}
}