Skip to content

Commit c49845f

Browse files
author
Alex Jankowiak
committed
fix(android): center routed sheets at the Material form-sheet width
1 parent e70c651 commit c49845f

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎android/src/main/java/com/swmansion/rnscreens/legacy/stack/views/ScreensCoordinatorLayout.kt‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.swmansion.rnscreens.legacy.stack.views
22

33
import android.content.Context
4+
import android.view.Gravity
45
import android.view.WindowInsets
56
import android.view.animation.Animation
67
import android.view.animation.AnimationSet
@@ -113,6 +114,23 @@ internal class ScreensCoordinatorLayout(
113114

114115
override fun shouldDelayChildPressedState(): Boolean = fragment.screen.usesFormSheetPresentation()
115116

117+
override fun onMeasure(
118+
widthMeasureSpec: Int,
119+
heightMeasureSpec: Int,
120+
) {
121+
if (fragment.screen.usesFormSheetPresentation()) {
122+
// Match the Material width used by the standalone FormSheet dialog.
123+
val params = fragment.screen.layoutParams as LayoutParams
124+
params.width =
125+
minOf(
126+
MeasureSpec.getSize(widthMeasureSpec),
127+
resources.getDimensionPixelSize(com.google.android.material.R.dimen.material_bottom_sheet_max_width),
128+
)
129+
params.gravity = Gravity.CENTER_HORIZONTAL
130+
}
131+
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
132+
}
133+
116134
override fun onLayout(
117135
changed: Boolean,
118136
l: Int,

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-screens",
3-
"version": "5.0.0-t3.45",
3+
"version": "5.0.0-t3.46",
44
"description": "Native navigation primitives for your React Native app.",
55
"scripts": {
66
"submodules": "git submodule update --init --recursive && (cd react-navigation && yarn && yarn build && cd ../)",

‎scripts/pack-t3.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if (run('git', ['status', '--porcelain']).trim()) {
2020
}
2121
run('git', ['merge-base', '--is-ancestor', pkg.t3Fork.upstreamCommit, 'HEAD']);
2222
const provenance = {
23-
repository: 'https://github.com/juliusmarminge/react-native-screens',
23+
repository: 'https://github.com/PixPMusic/react-native-screens',
2424
commit: run('git', ['rev-parse', 'HEAD']).trim(),
2525
upstreamCommit: pkg.t3Fork.upstreamCommit,
2626
version: pkg.version,

0 commit comments

Comments
 (0)