1- import * as React from ' react' ;
2- import type { PropsWithChildren } from ' react' ;
1+ import * as React from " react" ;
2+ import type { PropsWithChildren } from " react" ;
33import {
44 Dimensions ,
55 KeyboardAvoidingView ,
@@ -10,14 +10,15 @@ import {
1010 Pressable ,
1111 ScrollViewProps ,
1212 StyleSheet ,
13+ useWindowDimensions ,
1314 View ,
1415 ViewStyle ,
15- } from ' react-native' ;
16+ } from " react-native" ;
1617import {
1718 GestureDetector ,
1819 GestureHandlerRootView ,
1920 ScrollView ,
20- } from ' react-native-gesture-handler' ;
21+ } from " react-native-gesture-handler" ;
2122import Animated , {
2223 runOnJS ,
2324 SharedValue ,
@@ -26,11 +27,11 @@ import Animated, {
2627 useReducedMotion ,
2728 useSharedValue ,
2829 withTiming ,
29- } from ' react-native-reanimated' ;
30- import { useBottomSheetGestureHandler } from ' ../hooks/useBottomSheetGestureHandler' ;
31- import { useKeyboard } from ' ../hooks/useKeyboard' ;
30+ } from " react-native-reanimated" ;
31+ import { useBottomSheetGestureHandler } from " ../hooks/useBottomSheetGestureHandler" ;
32+ import { useKeyboard } from " ../hooks/useKeyboard" ;
3233
33- const AnimaCore = require ( ' @react-native-ama/core' ) ;
34+ const AnimaCore = require ( " @react-native-ama/core" ) ;
3435
3536export type BottomSheetProps = {
3637 animationDuration ?: number ;
@@ -40,7 +41,7 @@ export type BottomSheetProps = {
4041 closeActionAccessibilityLabel : string ;
4142 closeDistance ?: number ;
4243 footerComponent ?: React . ReactElement ;
43- handleComponent ?: React . ReactElement | ' none' ;
44+ handleComponent ?: React . ReactElement | " none" ;
4445 handleStyle ?: ViewStyle | ViewStyle [ ] ;
4546 headerComponent ?: React . ReactElement ;
4647 maxHeight ?: number ;
@@ -54,14 +55,14 @@ export type BottomSheetProps = {
5455 hasScrollableContent ?: boolean ;
5556 scrollViewProps ?: Omit <
5657 ScrollViewWrapperProps ,
57- ' testID' | ' maxScrollViewHeight'
58+ " testID" | " maxScrollViewHeight"
5859 > ;
5960 testID ?: string ;
6061 topInset : number ;
6162 visible : boolean ;
6263 ref ?: React . RefObject < BottomSheetActions > ;
6364 shouldHandleKeyboardEvents ?: boolean ;
64- supportedOrientations ?: ModalProps [ ' supportedOrientations' ] ;
65+ supportedOrientations ?: ModalProps [ " supportedOrientations" ] ;
6566 isOverlayAccessible ?: boolean ;
6667} ;
6768
@@ -70,9 +71,8 @@ export type BottomSheetActions = {
7071 isVisible : ( ) => boolean ;
7172} ;
7273
73- const DEFAULT_MAX_HEIGHT = Dimensions . get ( 'window' ) . height * 0.9 ;
74- const isIOS = Platform . OS === 'ios' ;
75- const SCREEN_HEIGHT = Dimensions . get ( 'screen' ) . height ;
74+ const isIOS = Platform . OS === "ios" ;
75+ const SCREEN_HEIGHT = Dimensions . get ( "screen" ) . height ;
7676
7777export const BottomSheet = React . forwardRef <
7878 BottomSheetActions ,
@@ -100,7 +100,7 @@ export const BottomSheet = React.forwardRef<
100100 overlayOpacity = 1 ,
101101 footerComponent,
102102 avoidKeyboard,
103- maxHeight = DEFAULT_MAX_HEIGHT ,
103+ maxHeight : propMaxHeight ,
104104 minVelocityToClose = 1000 ,
105105 topInset,
106106 onBottomSheetHidden,
@@ -128,6 +128,8 @@ export const BottomSheet = React.forwardRef<
128128 shouldHandleKeyboardEvents
129129 ) ;
130130 const shouldReduceMotion = useReducedMotion ( ) ;
131+ const { height } = useWindowDimensions ( ) ;
132+ const maxHeight = propMaxHeight ?? height * 0.9 ;
131133
132134 const duration = shouldReduceMotion ? 0 : animationDuration ;
133135
@@ -187,7 +189,19 @@ export const BottomSheet = React.forwardRef<
187189 }
188190 ) ;
189191 }
190- } , [ duration , autoCloseDelay , isModalVisible , onBottomSheetHidden , onClose , onTimeout , translateY , visible , dragOpacity , overlayOpacity , contentHeight . value ] ) ;
192+ } , [
193+ duration ,
194+ autoCloseDelay ,
195+ isModalVisible ,
196+ onBottomSheetHidden ,
197+ onClose ,
198+ onTimeout ,
199+ translateY ,
200+ visible ,
201+ dragOpacity ,
202+ overlayOpacity ,
203+ contentHeight . value ,
204+ ] ) ;
191205
192206 React . useEffect ( ( ) => {
193207 isMounted . current = true ;
@@ -219,11 +233,11 @@ export const BottomSheet = React.forwardRef<
219233 useDerivedValue ( ( ) => {
220234 const maxScrollHeight = Math . ceil (
221235 maxHeight -
222- keyboardFinalHeight . value -
223- footerHeight -
224- headerHeight -
225- handleHeight -
226- topInset
236+ keyboardFinalHeight . value -
237+ footerHeight -
238+ headerHeight -
239+ handleHeight -
240+ topInset
227241 ) ;
228242
229243 if (
@@ -294,7 +308,7 @@ export const BottomSheet = React.forwardRef<
294308 testID = { `${ testID } -overlay-button` }
295309 accessible = { isOverlayAccessible && ! persistent }
296310 importantForAccessibility = {
297- persistent ? ' no-hide-descendants' : ' yes'
311+ persistent ? " no-hide-descendants" : " yes"
298312 }
299313 accessibilityElementsHidden = { persistent }
300314 onAccessibilityTap = { maybeCloseBottomSheet }
@@ -327,14 +341,14 @@ export const BottomSheet = React.forwardRef<
327341 setHandleHeight ( event . nativeEvent . layout . height ) ;
328342 } }
329343 >
330- { handleComponent === ' none'
344+ { handleComponent === " none"
331345 ? null
332346 : handleComponent ?? (
333- < View
334- style = { [ styles . line , handleStyle ] }
335- testID = { `${ testID } -line` }
336- />
337- ) }
347+ < View
348+ style = { [ styles . line , handleStyle ] }
349+ testID = { `${ testID } -line` }
350+ />
351+ ) }
338352 </ View >
339353 < View
340354 onLayout = { ( event ) => {
@@ -372,7 +386,7 @@ const BottomSheetKeyboardAvoidingView = ({
372386} : React . PropsWithChildren < { } > ) => {
373387 return (
374388 < KeyboardAvoidingView
375- behavior = { Platform . OS === ' ios' ? ' padding' : undefined }
389+ behavior = { Platform . OS === " ios" ? " padding" : undefined }
376390 pointerEvents = "box-none"
377391 style = { { flex : 1 } }
378392 >
@@ -457,30 +471,30 @@ const FragmentWrapper: React.FC<React.PropsWithChildren<any>> = ({
457471
458472const styles = StyleSheet . create ( {
459473 overlay : {
460- backgroundColor : ' rgba(0, 0, 0, 0.5)' ,
474+ backgroundColor : " rgba(0, 0, 0, 0.5)" ,
461475 flex : 1 ,
462476 } ,
463477 closeButton : {
464478 flex : 1 ,
465479 } ,
466480 contentWrapper : {
467- flexDirection : ' column' ,
481+ flexDirection : " column" ,
468482 flex : 1 ,
469- position : ' absolute' ,
483+ position : " absolute" ,
470484 bottom : 0 ,
471- alignSelf : ' flex-end' ,
472- width : ' 100%' ,
485+ alignSelf : " flex-end" ,
486+ width : " 100%" ,
473487 } ,
474488 content : {
475- width : ' 100%' ,
476- backgroundColor : ' #fff' ,
489+ width : " 100%" ,
490+ backgroundColor : " #fff" ,
477491 flex : 1 ,
478492 } ,
479493 line : {
480494 width : 48 ,
481495 height : 4 ,
482- backgroundColor : ' grey' ,
483- alignSelf : ' center' ,
496+ backgroundColor : " grey" ,
497+ alignSelf : " center" ,
484498 marginBottom : 24 ,
485499 borderRadius : 2 ,
486500 marginTop : 12 ,
0 commit comments