From fbf8e5fa1426ae441d2d162dce2602ea21363597 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Fri, 9 Dec 2022 11:22:19 -0600 Subject: [PATCH] Add main menu button --- src/state/models/shell-ui.ts | 6 +++--- src/view/com/util/ViewHeader.tsx | 26 ++++++++++++++------------ src/view/com/util/ViewSelector.tsx | 3 --- src/view/shell/mobile/index.tsx | 19 +++++++++++-------- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/state/models/shell-ui.ts b/src/state/models/shell-ui.ts index 6777aa7b..bb4bf1ff 100644 --- a/src/state/models/shell-ui.ts +++ b/src/state/models/shell-ui.ts @@ -67,7 +67,7 @@ export interface ComposerOpts { } export class ShellUiModel { - isViewControllingSwipes = false + isMainMenuOpen = false isModalActive = false activeModal: | ConfirmModel @@ -82,8 +82,8 @@ export class ShellUiModel { makeAutoObservable(this) } - setViewControllingSwipes(v: boolean) { - this.isViewControllingSwipes = v + setMainMenuOpen(v: boolean) { + this.isMainMenuOpen = v } openModal( diff --git a/src/view/com/util/ViewHeader.tsx b/src/view/com/util/ViewHeader.tsx index 12aa86a4..2f0e5043 100644 --- a/src/view/com/util/ViewHeader.tsx +++ b/src/view/com/util/ViewHeader.tsx @@ -28,6 +28,9 @@ export const ViewHeader = observer(function ViewHeader({ const onPressBack = () => { store.nav.tab.goBack() } + const onPressMenu = () => { + store.shell.setMainMenuOpen(true) + } const onPressCompose = () => { store.shell.openComposer({onPost}) } @@ -40,21 +43,20 @@ export const ViewHeader = observer(function ViewHeader({ console.log(e) }) } + const canGoBack = store.nav.tab.canGoBack return ( <> - {store.nav.tab.canGoBack ? ( - - - - ) : undefined} + + + {title} {subtitle ? ( diff --git a/src/view/com/util/ViewSelector.tsx b/src/view/com/util/ViewSelector.tsx index f3925497..b2d69571 100644 --- a/src/view/com/util/ViewSelector.tsx +++ b/src/view/com/util/ViewSelector.tsx @@ -44,9 +44,6 @@ export function ViewSelector({ } const onPressSelection = (index: number) => setSelectedIndex(index) useEffect(() => { - store.shell.setViewControllingSwipes( - Boolean(swipeEnabled) && selectedIndex > 0, - ) onSelectView?.(selectedIndex) }, [selectedIndex]) diff --git a/src/view/shell/mobile/index.tsx b/src/view/shell/mobile/index.tsx index ef54af17..04c4c469 100644 --- a/src/view/shell/mobile/index.tsx +++ b/src/view/shell/mobile/index.tsx @@ -110,7 +110,6 @@ const Btn = ({ export const MobileShell: React.FC = observer(() => { const store = useStores() - const [isMenuActive, setMenuActive] = useState(false) const [isTabsSelectorActive, setTabsSelectorActive] = useState(false) const scrollElRef = useRef() const winDim = useWindowDimensions() @@ -123,8 +122,8 @@ export const MobileShell: React.FC = observer(() => { const screenRenderDesc = constructScreenRenderDesc(store.nav) const onPressHome = () => { - if (isMenuActive) { - setMenuActive(false) + if (store.shell.isMainMenuOpen) { + store.shell.setMainMenuOpen(false) } if (store.nav.tab.fixedTabPurpose === 0) { if (store.nav.tab.current.url === '/') { @@ -140,8 +139,8 @@ export const MobileShell: React.FC = observer(() => { } } const onPressNotifications = () => { - if (isMenuActive) { - setMenuActive(false) + if (store.shell.isMainMenuOpen) { + store.shell.setMainMenuOpen(false) } if (store.nav.tab.fixedTabPurpose === 1) { store.nav.tab.fixedTabReset() @@ -211,6 +210,7 @@ export const MobileShell: React.FC = observer(() => { // navigation swipes // = + const isMenuActive = store.shell.isMainMenuOpen const canSwipeLeft = store.nav.tab.canGoBack || !isMenuActive const canSwipeRight = isMenuActive const onNavSwipeEnd = (dx: number) => { @@ -218,11 +218,11 @@ export const MobileShell: React.FC = observer(() => { if (store.nav.tab.canGoBack) { store.nav.tab.goBack() } else { - setMenuActive(true) + store.shell.setMainMenuOpen(true) } } else if (dx > 0) { if (isMenuActive) { - setMenuActive(false) + store.shell.setMainMenuOpen(false) } } } @@ -349,7 +349,10 @@ export const MobileShell: React.FC = observer(() => { )} - setMenuActive(false)} /> + store.shell.setMainMenuOpen(false)} + />