diff --git a/native/components/connect-farcaster-bottom-sheet.react.js b/native/components/connect-farcaster-bottom-sheet.react.js --- a/native/components/connect-farcaster-bottom-sheet.react.js +++ b/native/components/connect-farcaster-bottom-sheet.react.js @@ -1,17 +1,25 @@ // @flow +import invariant from 'invariant'; import * as React from 'react'; import { View, StyleSheet } from 'react-native'; +import { useSafeAreaInsets } from 'react-native-safe-area-context'; import FarcasterPrompt from './farcaster-prompt.react.js'; import FarcasterWebView, { type FarcasterWebViewState, } from './farcaster-web-view.react.js'; import RegistrationButton from '../account/registration/registration-button.react.js'; +import { BottomSheetContext } from '../bottom-sheet/bottom-sheet-provider.react.js'; import BottomSheet from '../bottom-sheet/bottom-sheet.react.js'; import type { RootNavigationProp } from '../navigation/root-navigator.react.js'; import type { NavigationRoute } from '../navigation/route-names.js'; +const bottomSheetPaddingTop = 32; +const farcasterPromptHeight = 350; +const marginBottom = 40; +const buttonHeight = 48; + type Props = { +navigation: RootNavigationProp<'ConnectFarcasterBottomSheet'>, +route: NavigationRoute<'ConnectFarcasterBottomSheet'>, @@ -24,6 +32,22 @@ const bottomSheetRef = React.useRef(null); + const bottomSheetContext = React.useContext(BottomSheetContext); + invariant(bottomSheetContext, 'bottomSheetContext should be set'); + const { setContentHeight } = bottomSheetContext; + + const insets = useSafeAreaInsets(); + + React.useLayoutEffect(() => { + setContentHeight( + bottomSheetPaddingTop + + farcasterPromptHeight + + marginBottom + + buttonHeight + + insets.bottom, + ); + }, [insets.bottom, setContentHeight]); + const [webViewState, setWebViewState] = React.useState('closed');