import React, {useRef} from 'react' import {View} from 'react-native' import {observer} from 'mobx-react-lite' import BottomSheet from '@gorhom/bottom-sheet' import {useStores} from '../../../state' import {createCustomBackdrop} from '../util/BottomSheetCustomBackdrop' import * as models from '../../../state/models/shell' import * as LinkActionsModal from './LinkActions' import * as SharePostModal from './SharePost.native' import * as ComposePostModal from './ComposePost' import * as EditProfile from './EditProfile' export const Modal = observer(function Modal() { const store = useStores() const bottomSheetRef = useRef(null) const onShareBottomSheetChange = (snapPoint: number) => { if (snapPoint === -1) { store.shell.closeModal() } } const onClose = () => { bottomSheetRef.current?.close() } if (!store.shell.isModalActive) { return } let snapPoints, element if (store.shell.activeModal?.name === 'link-actions') { snapPoints = LinkActionsModal.snapPoints element = ( ) } else if (store.shell.activeModal?.name === 'share-post') { snapPoints = SharePostModal.snapPoints element = ( ) } else if (store.shell.activeModal?.name === 'compose-post') { snapPoints = ComposePostModal.snapPoints element = ( ) } else if (store.shell.activeModal?.name === 'edit-profile') { snapPoints = EditProfile.snapPoints element = ( ) } else { return } return ( {element} ) })