Skip to content

Commit

Permalink
fix(android): corner radius & auto size bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lodev09 committed Feb 5, 2025
1 parent 744905a commit 8ac8d37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
* Setup background color and corner radius.
*/
fun setupBackground() {
val outerRadii = FloatArray(8) { cornerRadius }
val outerRadii = floatArrayOf(
cornerRadius, cornerRadius,
cornerRadius, cornerRadius,
0f, 0f,
0f, 0f
)

val background = ShapeDrawable(RoundRectShape(outerRadii, null, null))

// Use current background color
Expand Down
14 changes: 4 additions & 10 deletions android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.lodev09.truesheet.core

import android.annotation.SuppressLint
import android.content.Context
import android.util.Log
import android.view.MotionEvent
import android.view.View
import com.facebook.react.config.ReactFeatureFlags
Expand Down Expand Up @@ -30,6 +31,8 @@ class RootSheetView(private val context: Context?) :
private var viewWidth = 0
private var viewHeight = 0

private var hasUpdatedSize = false

private val jSTouchDispatcher = JSTouchDispatcher(this)
private var jSPointerDispatcher: JSPointerDispatcher? = null
var sizeChangeListener: ((w: Int, h: Int) -> Unit)? = null
Expand All @@ -45,22 +48,13 @@ class RootSheetView(private val context: Context?) :
private val reactContext: ThemedReactContext
get() = context as ThemedReactContext

private fun updateContainerSize() {
sizeChangeListener?.let { it(viewWidth, viewHeight) }
}

override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)

viewWidth = w
viewHeight = h

updateContainerSize()
}

override fun addView(child: View, index: Int, params: LayoutParams) {
super.addView(child, index, params)
updateContainerSize()
sizeChangeListener?.let { it(viewWidth, viewHeight) }
}

override fun handleException(t: Throwable) {
Expand Down

0 comments on commit 8ac8d37

Please sign in to comment.