@@ -24,11 +24,15 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
24
24
private var windowAnimation: Int = 0
25
25
26
26
// First child of the rootSheetView
27
- private val containerView: ViewGroup
28
- get() = rootSheetView.getChildAt(0 ) as ViewGroup
27
+ private val containerView: ViewGroup ?
28
+ get() = if (rootSheetView.childCount > 0 ) {
29
+ rootSheetView.getChildAt(0 ) as ? ViewGroup
30
+ } else {
31
+ null
32
+ }
29
33
30
- private val sheetContainerView: ViewGroup
31
- get() = rootSheetView.parent as ViewGroup
34
+ private val sheetContainerView: ViewGroup ?
35
+ get() = rootSheetView.parent?. let { it as ? ViewGroup }
32
36
33
37
/* *
34
38
* Specify whether the sheet background is dimmed.
@@ -71,19 +75,19 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
71
75
72
76
// 1st child is the content view
73
77
val contentView: ViewGroup ?
74
- get() = containerView.getChildAt(0 ) as ? ViewGroup
78
+ get() = containerView? .getChildAt(0 ) as ? ViewGroup
75
79
76
80
// 2nd child is the footer view
77
81
val footerView: ViewGroup ?
78
- get() = containerView.getChildAt(1 ) as ? ViewGroup
82
+ get() = containerView? .getChildAt(1 ) as ? ViewGroup
79
83
80
84
var sizes: Array <Any > = arrayOf(" medium" , " large" )
81
85
82
86
init {
83
87
setContentView(rootSheetView)
84
88
85
- sheetContainerView.setBackgroundColor(backgroundColor)
86
- sheetContainerView.clipToOutline = true
89
+ sheetContainerView? .setBackgroundColor(backgroundColor)
90
+ sheetContainerView? .clipToOutline = true
87
91
88
92
// Setup window params to adjust layout based on Keyboard state
89
93
window?.apply {
@@ -131,7 +135,7 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
131
135
132
136
// Use current background color
133
137
background.paint.color = backgroundColor
134
- sheetContainerView.background = background
138
+ sheetContainerView? .background = background
135
139
}
136
140
137
141
/* *
@@ -196,11 +200,14 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
196
200
}
197
201
198
202
fun positionFooter () {
199
- footerView?.apply {
200
- y = (maxScreenHeight - sheetContainerView.top - footerHeight).toFloat()
203
+ footerView?.let { footer ->
204
+ sheetContainerView?.let { container ->
205
+ footer.y = (maxScreenHeight - container.top - footerHeight).toFloat()
206
+ }
201
207
}
202
208
}
203
209
210
+
204
211
/* *
205
212
* Set the state based for the given size index.
206
213
*/
0 commit comments