Skip to content

Commit 905c1a5

Browse files
authored
fix(Android): missing content when using flex for formsheet contents (#2748)
## Description Fixing the styles applied to the content in screens with `formSheet` presentation. Currently when using `flex: 1` on the content of the sheet it might cause the content to disappear. This PR mitigates that. ## Changes When not in `fitToContents` mode we apply `flex: 1` to content wrapper. ## Test code and steps to reproduce `TestFormSheet` - notice that the contents has `flex: 1` and it displays correctly. ## Checklist - [x] Included code example that can be used to test this change - [ ] Ensured that CI passes
1 parent 2adbd41 commit 905c1a5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/components/ScreenStackItem.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function ScreenStackItem(
3232
activityState,
3333
shouldFreeze,
3434
stackPresentation,
35+
sheetAllowedDetents,
3536
contentStyle,
3637
style,
3738
screenId,
@@ -71,7 +72,9 @@ function ScreenStackItem(
7172
stackPresentation === 'formSheet'
7273
? Platform.OS === 'ios'
7374
? styles.absolute
74-
: null
75+
: sheetAllowedDetents === 'fitToContents'
76+
? null
77+
: styles.container
7578
: styles.container,
7679
contentStyle,
7780
]}
@@ -136,6 +139,7 @@ function ScreenStackItem(
136139
shouldFreeze={shouldFreeze}
137140
stackPresentation={stackPresentation}
138141
hasLargeHeader={headerConfig?.largeTitle ?? false}
142+
sheetAllowedDetents={sheetAllowedDetents}
139143
style={[style, internalScreenStyle]}
140144
{...rest}>
141145
{isHeaderInModal ? (

src/native-stack/views/NativeStackView.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ const MaybeNestedStack = ({
7171
options,
7272
route,
7373
stackPresentation,
74+
sheetAllowedDetents,
7475
children,
7576
internalScreenStyle,
7677
}: {
7778
options: NativeStackNavigationOptions;
7879
route: Route<string>;
7980
stackPresentation: StackPresentationTypes;
81+
sheetAllowedDetents: NativeStackNavigationOptions['sheetAllowedDetents'];
8082
children: React.ReactNode;
8183
internalScreenStyle?: Pick<ViewStyle, 'backgroundColor'>;
8284
}) => {
@@ -108,7 +110,9 @@ const MaybeNestedStack = ({
108110
stackPresentation === 'formSheet'
109111
? Platform.OS === 'ios'
110112
? styles.absoluteFillNoBottom
111-
: null
113+
: sheetAllowedDetents === 'fitToContents'
114+
? null
115+
: styles.container
112116
: styles.container,
113117
stackPresentation !== 'transparentModal' &&
114118
stackPresentation !== 'containedTransparentModal' && {
@@ -150,6 +154,7 @@ const MaybeNestedStack = ({
150154
<Screen
151155
enabled
152156
isNativeStack
157+
sheetAllowedDetents={sheetAllowedDetents}
153158
hasLargeHeader={hasLargeHeader}
154159
style={[StyleSheet.absoluteFill, internalScreenStyle]}>
155160
<HeaderHeightContext.Provider value={headerHeight}>
@@ -438,6 +443,7 @@ const RouteView = ({
438443
<MaybeNestedStack
439444
options={options}
440445
route={route}
446+
sheetAllowedDetents={sheetAllowedDetents}
441447
stackPresentation={stackPresentation}
442448
internalScreenStyle={internalScreenStyle}>
443449
{renderScene()}

0 commit comments

Comments
 (0)