From 154c34e915231a03e289dd36294592911d9c9900 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 23 Feb 2023 17:22:03 -0600 Subject: Rework modals to support multiple active --- src/view/com/modals/Modal.tsx | 51 +++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 34 deletions(-) (limited to 'src/view/com/modals/Modal.tsx') diff --git a/src/view/com/modals/Modal.tsx b/src/view/com/modals/Modal.tsx index 2529d0d5b..d4c8ada69 100644 --- a/src/view/com/modals/Modal.tsx +++ b/src/view/com/modals/Modal.tsx @@ -5,8 +5,6 @@ import BottomSheet from '@gorhom/bottom-sheet' import {useStores} from 'state/index' import {createCustomBackdrop} from '../util/BottomSheetCustomBackdrop' -import * as models from 'state/models/shell-ui' - import * as ConfirmModal from './Confirm' import * as EditProfileModal from './EditProfile' import * as ServerInputModal from './ServerInput' @@ -32,52 +30,37 @@ export const Modal = observer(function Modal() { store.shell.closeModal() } + const activeModal = React.useMemo( + () => store.shell.activeModals.at(-1), + [store.shell.activeModals], + ) + useEffect(() => { if (store.shell.isModalActive) { bottomSheetRef.current?.expand() } else { bottomSheetRef.current?.close() } - }, [store.shell.isModalActive, bottomSheetRef, store.shell.activeModal?.name]) + }, [store.shell.isModalActive, bottomSheetRef, activeModal?.name]) let snapPoints: (string | number)[] = CLOSED_SNAPPOINTS let element - if (store.shell.activeModal?.name === 'confirm') { + if (activeModal?.name === 'confirm') { snapPoints = ConfirmModal.snapPoints - element = ( - - ) - } else if (store.shell.activeModal?.name === 'edit-profile') { + element = + } else if (activeModal?.name === 'edit-profile') { snapPoints = EditProfileModal.snapPoints - element = ( - - ) - } else if (store.shell.activeModal?.name === 'server-input') { + element = + } else if (activeModal?.name === 'server-input') { snapPoints = ServerInputModal.snapPoints - element = ( - - ) - } else if (store.shell.activeModal?.name === 'report-post') { + element = + } else if (activeModal?.name === 'report-post') { snapPoints = ReportPostModal.snapPoints - element = ( - - ) - } else if (store.shell.activeModal?.name === 'report-account') { + element = + } else if (activeModal?.name === 'report-account') { snapPoints = ReportAccountModal.snapPoints - element = ( - - ) - } else if (store.shell.activeModal?.name === 'delete-account') { + element = + } else if (activeModal?.name === 'delete-account') { snapPoints = DeleteAccountModal.snapPoints element = } else { -- cgit 1.4.1 From bbd0b03a46b1087ecca17219441d060c2be69de2 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 23 Feb 2023 17:29:34 -0600 Subject: Update modal com name --- src/view/com/modals/Modal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/view/com/modals/Modal.tsx') diff --git a/src/view/com/modals/Modal.tsx b/src/view/com/modals/Modal.tsx index d4c8ada69..58dd12e61 100644 --- a/src/view/com/modals/Modal.tsx +++ b/src/view/com/modals/Modal.tsx @@ -16,7 +16,7 @@ import {StyleSheet} from 'react-native' const CLOSED_SNAPPOINTS = ['10%'] -export const Modal = observer(function Modal() { +export const ModalsContainer = observer(function ModalsContainer() { const store = useStores() const bottomSheetRef = useRef(null) const pal = usePalette('default') -- cgit 1.4.1