Skip to content

Commit 5397478

Browse files
committed
fix: allow bottom sheet view to resize it self when its content resized
1 parent 0715f03 commit 5397478

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/components/bottomSheetView/BottomSheetView.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import React, { memo, useEffect, useCallback } from 'react';
2-
import type { LayoutChangeEvent } from 'react-native';
3-
import Animated from 'react-native-reanimated';
1+
import React, { memo, useEffect, useCallback, useMemo } from 'react';
2+
import { type LayoutChangeEvent, View } from 'react-native';
43
import { SCROLLABLE_TYPE } from '../../constants';
54
import {
65
useBottomSheetContentContainerStyle,
76
useBottomSheetInternal,
87
} from '../../hooks';
98
import { print } from '../../utilities';
9+
import { styles } from './styles';
1010
import type { BottomSheetViewProps } from './types';
1111

1212
function BottomSheetViewComponent({
1313
focusHook: useFocusHook = useEffect,
1414
enableFooterMarginAdjustment = false,
1515
onLayout,
16-
style,
16+
style: _providedStyle,
1717
children,
1818
...rest
1919
}: BottomSheetViewProps) {
@@ -29,7 +29,11 @@ function BottomSheetViewComponent({
2929
//#region styles
3030
const containerStyle = useBottomSheetContentContainerStyle(
3131
enableFooterMarginAdjustment,
32-
style
32+
_providedStyle
33+
);
34+
const style = useMemo(
35+
() => [containerStyle, styles.container],
36+
[containerStyle]
3337
);
3438
//#endregion
3539

@@ -69,9 +73,9 @@ function BottomSheetViewComponent({
6973

7074
//render
7175
return (
72-
<Animated.View {...rest} onLayout={handleLayout} style={containerStyle}>
76+
<View {...rest} onLayout={handleLayout} style={style}>
7377
{children}
74-
</Animated.View>
78+
</View>
7579
);
7680
}
7781

src/components/bottomSheetView/styles.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { StyleSheet } from 'react-native';
22

33
export const styles = StyleSheet.create({
44
container: {
5-
// flex: 1,
5+
position: 'absolute',
6+
left: 0,
7+
top: 0,
8+
right: 0,
69
},
710
});

0 commit comments

Comments
 (0)