Skip to content

Commit 57c196c

Browse files
committed
fix: allowed content max height be applied for dynamic sizing
1 parent 8017fb6 commit 57c196c

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

src/components/bottomSheet/BottomSheet.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ type BottomSheet = BottomSheetMethods;
8989

9090
const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
9191
function BottomSheet(props, ref) {
92-
//#region validate props
93-
usePropsValidator(props);
94-
//#endregion
95-
9692
//#region extract props
9793
const {
9894
// animations configurations
@@ -161,6 +157,16 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
161157
} = props;
162158
//#endregion
163159

160+
//#region validate props
161+
usePropsValidator({
162+
index: _providedIndex,
163+
snapPoints: _providedSnapPoints,
164+
enableDynamicSizing,
165+
topInset,
166+
bottomInset,
167+
});
168+
//#endregion
169+
164170
//#region layout variables
165171
/**
166172
* This variable is consider an internal variable,

src/components/bottomSheetScrollable/createBottomSheetScrollableComponent.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export function createBottomSheetScrollableComponent<T, P>(
6161
animatedFooterHeight,
6262
animatedContentHeight,
6363
animatedScrollableState,
64+
enableDynamicSizing,
6465
} = useBottomSheetInternal();
6566
//#endregion
6667

@@ -89,7 +90,9 @@ export function createBottomSheetScrollableComponent<T, P>(
8990
//#region callbacks
9091
const handleContentSizeChange = useStableCallback(
9192
(contentWidth: number, contentHeight: number) => {
92-
animatedContentHeight.value = contentHeight;
93+
if (enableDynamicSizing) {
94+
animatedContentHeight.value = contentHeight;
95+
}
9396

9497
if (onContentSizeChange) {
9598
onContentSizeChange(contentWidth, contentHeight);

src/hooks/useNormalizedSnapPoints.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import Animated, {
1+
import {
2+
SharedValue,
23
useDerivedValue,
34
useSharedValue,
45
} from 'react-native-reanimated';
@@ -23,12 +24,12 @@ import {
2324
*/
2425
export const useNormalizedSnapPoints = (
2526
snapPoints: BottomSheetProps['snapPoints'],
26-
containerHeight: Animated.SharedValue<number>,
27-
contentHeight: Animated.SharedValue<number>,
28-
handleHeight: Animated.SharedValue<number>,
27+
containerHeight: SharedValue<number>,
28+
contentHeight: SharedValue<number>,
29+
handleHeight: SharedValue<number>,
2930
enableDynamicSizing: BottomSheetProps['enableDynamicSizing'],
3031
maxDynamicContentSize: BottomSheetProps['maxDynamicContentSize']
31-
): [Animated.SharedValue<number[]>, Animated.SharedValue<number>] => {
32+
): [SharedValue<number[]>, SharedValue<number>] => {
3233
const dynamicSnapPointIndex = useSharedValue<number>(-1);
3334
const normalizedSnapPoints = useDerivedValue(() => {
3435
// early exit, if container layout is not ready
@@ -87,7 +88,6 @@ export const useNormalizedSnapPoints = (
8788
_normalizedSnapPoints.indexOf(dynamicSnapPoint);
8889

8990
return _normalizedSnapPoints;
90-
}, [snapPoints]);
91-
91+
}, [snapPoints, enableDynamicSizing, maxDynamicContentSize]);
9292
return [normalizedSnapPoints, dynamicSnapPointIndex];
9393
};

src/hooks/usePropsValidator.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export const usePropsValidator = ({
1414
enableDynamicSizing,
1515
topInset,
1616
bottomInset,
17-
}: BottomSheetProps) => {
17+
}: Pick<
18+
BottomSheetProps,
19+
'index' | 'snapPoints' | 'enableDynamicSizing' | 'topInset' | 'bottomInset'
20+
>) => {
1821
useMemo(() => {
1922
//#region snap points
2023
const _snapPoints = snapPoints

0 commit comments

Comments
 (0)