@@ -35,6 +35,7 @@ export interface BottomSheetProps extends ScrollViewProps {
35
35
topBorderRadius ?: number ;
36
36
borderWidth ?: number ;
37
37
borderColor ?: string ;
38
+ enableDynamicSizing ?: boolean ;
38
39
onSettle ?: ( index : number ) => void ;
39
40
style ?: StyleProp < ViewStyle > ;
40
41
}
@@ -56,6 +57,7 @@ const BottomSheet = React.forwardRef<BottomSheetComponent, BottomSheetProps>(
56
57
topBorderRadius = 20 ,
57
58
borderWidth = 1 ,
58
59
borderColor,
60
+ enableDynamicSizing = true ,
59
61
onSettle,
60
62
style,
61
63
children,
@@ -92,6 +94,7 @@ const BottomSheet = React.forwardRef<BottomSheetComponent, BottomSheetProps>(
92
94
return (
93
95
< BottomSheetComponent
94
96
ref = { ref }
97
+ enableDynamicSizing = { enableDynamicSizing }
95
98
snapPoints = { mappedSnapPoints }
96
99
index = {
97
100
initialSnapIndex !== undefined
@@ -109,7 +112,13 @@ const BottomSheet = React.forwardRef<BottomSheetComponent, BottomSheetProps>(
109
112
borderWidth,
110
113
borderColor : borderColor ?? theme . colors . border . brand ,
111
114
} }
112
- onChange = { ( index ) => onSettle ?.( mappedSnapPoints . length - index - 1 ) }
115
+ onChange = { ( index ) =>
116
+ // Convert bottom-sheet index to match our top-to-bottom ordering
117
+ // When dynamic sizing is enabled, we don't need to subtract 1 since an extra snap point may be added
118
+ enableDynamicSizing
119
+ ? onSettle ?.( mappedSnapPoints . length - index )
120
+ : onSettle ?.( mappedSnapPoints . length - index - 1 )
121
+ }
113
122
>
114
123
< BottomSheetScrollView
115
124
contentContainerStyle = { [ styles . contentContainerStyle , style ] }
0 commit comments