···11import React, {useRef, useEffect} from 'react'
22import {StyleSheet} from 'react-native'
33-import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context'
33+import {SafeAreaView} from 'react-native-safe-area-context'
44import BottomSheet from '@gorhom/bottom-sheet'
55import {createCustomBackdrop} from '../util/BottomSheetCustomBackdrop'
66import {usePalette} from 'lib/hooks/usePalette'
77-import {timeout} from 'lib/async/timeout'
88-import {navigate} from '../../../Navigation'
99-import once from 'lodash.once'
107118import {useModals, useModalControls} from '#/state/modals'
1212-import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
139import * as ConfirmModal from './Confirm'
1410import * as EditProfileModal from './EditProfile'
1515-import * as ProfilePreviewModal from './ProfilePreview'
1611import * as ServerInputModal from './ServerInput'
1712import * as RepostModal from './Repost'
1813import * as SelfLabelModal from './SelfLabel'
···5045 const {closeModal} = useModalControls()
5146 const bottomSheetRef = useRef<BottomSheet>(null)
5247 const pal = usePalette('default')
5353- const safeAreaInsets = useSafeAreaInsets()
5454-5548 const activeModal = activeModals[activeModals.length - 1]
56495757- const navigateOnce = once(navigate)
5858-5959- // It seems like the bottom sheet bugs out when this callback changes.
6060- const onBottomSheetAnimate = useNonReactiveCallback(
6161- (_fromIndex: number, toIndex: number) => {
6262- if (activeModal?.name === 'profile-preview' && toIndex === 1) {
6363- // begin loading the profile screen behind the scenes
6464- navigateOnce('Profile', {name: activeModal.did})
6565- }
6666- },
6767- )
6850 const onBottomSheetChange = async (snapPoint: number) => {
6951 if (snapPoint === -1) {
7052 closeModal()
7171- } else if (activeModal?.name === 'profile-preview' && snapPoint === 1) {
7272- await navigateOnce('Profile', {name: activeModal.did})
7373- // There is no particular callback for when the view has actually been presented.
7474- // This delay gives us a decent chance the navigation has flushed *and* images have loaded.
7575- // It's acceptable because the data is already being fetched + it usually takes longer anyway.
7676- // TODO: Figure out why avatar/cover don't always show instantly from cache.
7777- await timeout(200)
7878- closeModal()
7953 }
8054 }
5555+8156 const onClose = () => {
8257 bottomSheetRef.current?.close()
8358 closeModal()
···9166 }
9267 }, [isModalActive, bottomSheetRef, activeModal?.name])
93689494- let needsSafeTopInset = false
9569 let snapPoints: (string | number)[] = DEFAULT_SNAPPOINTS
9670 let element
9771 if (activeModal?.name === 'confirm') {
···10074 } else if (activeModal?.name === 'edit-profile') {
10175 snapPoints = EditProfileModal.snapPoints
10276 element = <EditProfileModal.Component {...activeModal} />
103103- } else if (activeModal?.name === 'profile-preview') {
104104- snapPoints = ProfilePreviewModal.snapPoints
105105- element = <ProfilePreviewModal.Component {...activeModal} />
106106- needsSafeTopInset = true // Need to align with the target profile screen.
10777 } else if (activeModal?.name === 'server-input') {
10878 snapPoints = ServerInputModal.snapPoints
10979 element = <ServerInputModal.Component {...activeModal} />
···200170 )
201171 }
202172203203- const topInset = needsSafeTopInset ? safeAreaInsets.top - HANDLE_HEIGHT : 0
204173 return (
205174 <BottomSheet
206175 ref={bottomSheetRef}
207176 snapPoints={snapPoints}
208208- topInset={topInset}
209177 handleHeight={HANDLE_HEIGHT}
210178 index={isModalActive ? 0 : -1}
211179 enablePanDownToClose
···216184 }
217185 handleIndicatorStyle={{backgroundColor: pal.text.color}}
218186 handleStyle={[styles.handle, pal.view]}
219219- onAnimate={onBottomSheetAnimate}
220187 onChange={onBottomSheetChange}>
221188 {element}
222189 </BottomSheet>
-3
src/view/com/modals/Modal.web.tsx
···99import type {Modal as ModalIface} from '#/state/modals'
1010import * as ConfirmModal from './Confirm'
1111import * as EditProfileModal from './EditProfile'
1212-import * as ProfilePreviewModal from './ProfilePreview'
1312import * as ServerInputModal from './ServerInput'
1413import * as ReportModal from './report/Modal'
1514import * as AppealLabelModal from './AppealLabel'
···8584 element = <ConfirmModal.Component {...modal} />
8685 } else if (modal.name === 'edit-profile') {
8786 element = <EditProfileModal.Component {...modal} />
8888- } else if (modal.name === 'profile-preview') {
8989- element = <ProfilePreviewModal.Component {...modal} />
9087 } else if (modal.name === 'server-input') {
9188 element = <ServerInputModal.Component {...modal} />
9289 } else if (modal.name === 'report') {