@@ -35,6 +35,7 @@ export interface BottomSheetProps extends ScrollViewProps {
3535 topBorderRadius ?: number ;
3636 borderWidth ?: number ;
3737 borderColor ?: string ;
38+ enableDynamicSizing ?: boolean ;
3839 onSettle ?: ( index : number ) => void ;
3940 style ?: StyleProp < ViewStyle > ;
4041}
@@ -56,6 +57,7 @@ const BottomSheet = React.forwardRef<BottomSheetComponent, BottomSheetProps>(
5657 topBorderRadius = 20 ,
5758 borderWidth = 1 ,
5859 borderColor,
60+ enableDynamicSizing = true ,
5961 onSettle,
6062 style,
6163 children,
@@ -92,6 +94,7 @@ const BottomSheet = React.forwardRef<BottomSheetComponent, BottomSheetProps>(
9294 return (
9395 < BottomSheetComponent
9496 ref = { ref }
97+ enableDynamicSizing = { enableDynamicSizing }
9598 snapPoints = { mappedSnapPoints }
9699 index = {
97100 initialSnapIndex !== undefined
@@ -109,7 +112,13 @@ const BottomSheet = React.forwardRef<BottomSheetComponent, BottomSheetProps>(
109112 borderWidth,
110113 borderColor : borderColor ?? theme . colors . border . brand ,
111114 } }
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+ }
113122 >
114123 < BottomSheetScrollView
115124 contentContainerStyle = { [ styles . contentContainerStyle , style ] }
0 commit comments