-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathElementTransitions.kt
More file actions
29 lines (23 loc) · 978 Bytes
/
ElementTransitions.kt
File metadata and controls
29 lines (23 loc) · 978 Bytes
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
package com.reactnativenavigation.options
import org.json.JSONObject
class ElementTransitions {
var transitions = arrayListOf<ElementTransitionOptions>()
companion object {
fun parse(json: JSONObject): ElementTransitions {
val result = ElementTransitions()
val elementTransitions = json.optJSONArray("elementTransitions")
if (elementTransitions == null || elementTransitions.length() == 0) return result
for (i in 0 until elementTransitions.length()) {
result.transitions.add(ElementTransitionOptions(elementTransitions.getJSONObject(i)))
}
return result
}
}
fun mergeWith(other: ElementTransitions) {
if (other.hasValue()) transitions = other.transitions
}
fun mergeWithDefault(defaultOptions: ElementTransitions) {
if (!hasValue()) transitions = defaultOptions.transitions
}
fun hasValue() = transitions.isNotEmpty()
}