Skip to content

Commit

Permalink
fix: align units of sheet corner radius in different callsites (#2378)
Browse files Browse the repository at this point in the history
## Description

Before this PR, when updating corner size after initial render different
unit (pixel) has been used opposed to
`dp` used during initial render. This PR align this behaviour so that
`dp` is always used.


## Changes

* Calculate appropriate value in `Screen.onSheetDetentChange` function

## Test code and steps to reproduce

`Test1649`

## Checklist

- [x] Included code example that can be used to test this change
- [ ] Ensured that CI passes
  • Loading branch information
kkafar authored Oct 3, 2024
1 parent bf83e4b commit 9075f42
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions android/src/main/java/com/swmansion/rnscreens/Screen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.fragment.app.Fragment
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.facebook.react.bridge.GuardedRunnable
import com.facebook.react.bridge.ReactContext
import com.facebook.react.uimanager.PixelUtil
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.UIManagerModule
import com.facebook.react.uimanager.events.EventDispatcher
Expand Down Expand Up @@ -441,12 +442,13 @@ class Screen(
return
}
(background as MaterialShapeDrawable?)?.let {
val resolvedCornerRadius = PixelUtil.toDIPFromPixel(sheetCornerRadius)
it.shapeAppearanceModel =
ShapeAppearanceModel
.Builder()
.apply {
setTopLeftCorner(CornerFamily.ROUNDED, sheetCornerRadius)
setTopRightCorner(CornerFamily.ROUNDED, sheetCornerRadius)
setTopLeftCorner(CornerFamily.ROUNDED, resolvedCornerRadius)
setTopRightCorner(CornerFamily.ROUNDED, resolvedCornerRadius)
}.build()
}
}
Expand Down

0 comments on commit 9075f42

Please sign in to comment.