@lodev09/react-native-true-sheet 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,7 +45,7 @@ def supportsNamespace() {
45
45
 
46
46
  android {
47
47
  if (supportsNamespace()) {
48
- namespace "com.truesheet"
48
+ namespace "com.lodev09.truesheet"
49
49
 
50
50
  sourceSets {
51
51
  main {
@@ -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.
@@ -70,20 +74,20 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
70
74
  var backgroundColor: Int = Color.WHITE
71
75
 
72
76
  // 1st child is the content view
73
- val contentView: ViewGroup
74
- get() = containerView.getChildAt(0) as ViewGroup
77
+ val contentView: ViewGroup?
78
+ get() = containerView?.getChildAt(0) as? ViewGroup
75
79
 
76
80
  // 2nd child is the footer view
77
- val footerView: ViewGroup
78
- get() = containerView.getChildAt(1) as ViewGroup
81
+ val footerView: 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,8 +200,10 @@ 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
 
@@ -178,8 +178,8 @@ class TrueSheetView(context: Context) :
178
178
 
179
179
  // Initialize content
180
180
  UiThreadUtil.runOnUiThread {
181
- setContentHeight(sheetDialog.contentView.height)
182
- setFooterHeight(sheetDialog.footerView.height)
181
+ sheetDialog.contentView?.height?.let { setContentHeight(it) }
182
+ sheetDialog.footerView?.height?.let { setFooterHeight(it) }
183
183
 
184
184
  if (initialIndex >= 0) {
185
185
  currentSizeIndex = initialIndex
@@ -86,7 +86,7 @@ class RootSheetView(private val context: Context?) :
86
86
  }
87
87
 
88
88
  @Deprecated("Deprecated in Java")
89
- override fun onChildStartedNativeGesture(ev: MotionEvent?) {
89
+ override fun onChildStartedNativeGesture(ev: MotionEvent) {
90
90
  eventDispatcher?.let {
91
91
  if (ev != null) {
92
92
  jSTouchDispatcher.onChildStartedNativeGesture(ev, it)
@@ -94,7 +94,7 @@ class RootSheetView(private val context: Context?) :
94
94
  }
95
95
  }
96
96
 
97
- override fun onChildStartedNativeGesture(childView: View, ev: MotionEvent) {
97
+ override fun onChildStartedNativeGesture(childView: View?, ev: MotionEvent) {
98
98
  eventDispatcher?.let { jSTouchDispatcher.onChildStartedNativeGesture(ev, it) }
99
99
  jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher)
100
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodev09/react-native-true-sheet",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "The true native bottom sheet experience for your React Native Apps.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/commonjs/index.js",