Skip to content

Commit 8ac8d37

Browse files
committed
fix(android): corner radius & auto size bug
1 parent 744905a commit 8ac8d37

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

android/src/main/java/com/lodev09/truesheet/TrueSheetDialog.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
103103
* Setup background color and corner radius.
104104
*/
105105
fun setupBackground() {
106-
val outerRadii = FloatArray(8) { cornerRadius }
106+
val outerRadii = floatArrayOf(
107+
cornerRadius, cornerRadius,
108+
cornerRadius, cornerRadius,
109+
0f, 0f,
110+
0f, 0f
111+
)
112+
107113
val background = ShapeDrawable(RoundRectShape(outerRadii, null, null))
108114

109115
// Use current background color

android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt

+4-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.lodev09.truesheet.core
22

33
import android.annotation.SuppressLint
44
import android.content.Context
5+
import android.util.Log
56
import android.view.MotionEvent
67
import android.view.View
78
import com.facebook.react.config.ReactFeatureFlags
@@ -30,6 +31,8 @@ class RootSheetView(private val context: Context?) :
3031
private var viewWidth = 0
3132
private var viewHeight = 0
3233

34+
private var hasUpdatedSize = false
35+
3336
private val jSTouchDispatcher = JSTouchDispatcher(this)
3437
private var jSPointerDispatcher: JSPointerDispatcher? = null
3538
var sizeChangeListener: ((w: Int, h: Int) -> Unit)? = null
@@ -45,22 +48,13 @@ class RootSheetView(private val context: Context?) :
4548
private val reactContext: ThemedReactContext
4649
get() = context as ThemedReactContext
4750

48-
private fun updateContainerSize() {
49-
sizeChangeListener?.let { it(viewWidth, viewHeight) }
50-
}
51-
5251
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
5352
super.onSizeChanged(w, h, oldw, oldh)
5453

5554
viewWidth = w
5655
viewHeight = h
5756

58-
updateContainerSize()
59-
}
60-
61-
override fun addView(child: View, index: Int, params: LayoutParams) {
62-
super.addView(child, index, params)
63-
updateContainerSize()
57+
sizeChangeListener?.let { it(viewWidth, viewHeight) }
6458
}
6559

6660
override fun handleException(t: Throwable) {

0 commit comments

Comments
 (0)