-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathModalOptions.java
More file actions
40 lines (28 loc) · 1.42 KB
/
ModalOptions.java
File metadata and controls
40 lines (28 loc) · 1.42 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
package com.reactnativenavigation.options;
import androidx.annotation.NonNull;
import com.reactnativenavigation.options.params.Bool;
import com.reactnativenavigation.options.params.NullBool;
import com.reactnativenavigation.options.parsers.BoolParser;
import org.json.JSONObject;
public class ModalOptions {
public static ModalOptions parse(final JSONObject json) {
ModalOptions options = new ModalOptions();
if (json == null) return options;
options.presentationStyle = ModalPresentationStyle.fromString(json.optString("modalPresentationStyle"));
options.blurOnUnmount = BoolParser.parse(json, "blurOnUnmount");
return options;
}
public ModalPresentationStyle presentationStyle = ModalPresentationStyle.Unspecified;
public @NonNull Bool blurOnUnmount = new NullBool();
public void mergeWith(final ModalOptions other) {
if (other.presentationStyleHasValue()) presentationStyle = other.presentationStyle;
if (other.blurOnUnmount.hasValue()) blurOnUnmount = other.blurOnUnmount;
}
private boolean presentationStyleHasValue() {
return presentationStyle != ModalPresentationStyle.Unspecified;
}
public void mergeWithDefault(final ModalOptions defaultOptions) {
if (!presentationStyleHasValue()) presentationStyle = defaultOptions.presentationStyle;
if (!blurOnUnmount.hasValue()) blurOnUnmount = defaultOptions.blurOnUnmount;
}
}