From f6769b283fe83d7abbc0545077b3dca978184eed Mon Sep 17 00:00:00 2001 From: John Fawcett Date: Wed, 12 Apr 2023 20:27:55 -0500 Subject: Mobile Web (#427) * WIP * WIP * Fix header offset on web * Remove debug * Fix web mobile feed and FAB layout * Fix modals on mobile web * Remove dead code * Remove ios config that shouldnt be committed now * Move bottom bar into its own folder * Fix web drawer navigation and state behaviors * Remove dark mode toggle from web drawer for now * Fix search on mobile web * Fix the logged out splash screen on mobile web * Fixes to detox simulator --------- Co-authored-by: Paul Frazee --- src/Navigation.tsx | 2 +- src/lib/hooks/useMinimalShellMode.tsx | 32 +++ src/lib/hooks/useNavigationTabState.ts | 13 ++ src/lib/hooks/useNavigationTabState.web.ts | 13 ++ src/lib/hooks/useWebMediaQueries.tsx | 8 + src/view/com/auth/SplashScreen.web.tsx | 48 ++--- src/view/com/pager/FeedsTabBar.tsx | 70 +------ src/view/com/pager/FeedsTabBar.web.tsx | 8 + src/view/com/pager/FeedsTabBarMobile.tsx | 69 +++++++ src/view/com/util/FAB.tsx | 71 ------- src/view/com/util/FAB.web.tsx | 8 - src/view/com/util/Toast.web.tsx | 5 +- src/view/com/util/fab/FAB.tsx | 1 + src/view/com/util/fab/FAB.web.tsx | 14 ++ src/view/com/util/fab/FABInner.tsx | 72 +++++++ src/view/screens/Home.tsx | 5 +- src/view/screens/Profile.tsx | 2 +- src/view/screens/Search.web.tsx | 21 +- src/view/screens/SearchMobile.tsx | 195 ++++++++++++++++++ src/view/shell/BottomBar.tsx | 278 -------------------------- src/view/shell/Composer.web.tsx | 3 +- src/view/shell/Drawer.tsx | 68 +++---- src/view/shell/bottom-bar/BottomBar.tsx | 198 ++++++++++++++++++ src/view/shell/bottom-bar/BottomBarStyles.tsx | 61 ++++++ src/view/shell/bottom-bar/BottomBarWeb.tsx | 101 ++++++++++ src/view/shell/index.web.tsx | 43 +++- 26 files changed, 900 insertions(+), 509 deletions(-) create mode 100644 src/lib/hooks/useMinimalShellMode.tsx create mode 100644 src/lib/hooks/useNavigationTabState.ts create mode 100644 src/lib/hooks/useNavigationTabState.web.ts create mode 100644 src/lib/hooks/useWebMediaQueries.tsx create mode 100644 src/view/com/pager/FeedsTabBarMobile.tsx delete mode 100644 src/view/com/util/FAB.tsx delete mode 100644 src/view/com/util/FAB.web.tsx create mode 100644 src/view/com/util/fab/FAB.tsx create mode 100644 src/view/com/util/fab/FAB.web.tsx create mode 100644 src/view/com/util/fab/FABInner.tsx create mode 100644 src/view/screens/SearchMobile.tsx delete mode 100644 src/view/shell/BottomBar.tsx create mode 100644 src/view/shell/bottom-bar/BottomBar.tsx create mode 100644 src/view/shell/bottom-bar/BottomBarStyles.tsx create mode 100644 src/view/shell/bottom-bar/BottomBarWeb.tsx (limited to 'src') diff --git a/src/Navigation.tsx b/src/Navigation.tsx index c10a9c249..648859f16 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -14,7 +14,7 @@ import { FlatNavigatorParams, AllNavigatorParams, } from 'lib/routes/types' -import {BottomBar} from './view/shell/BottomBar' +import {BottomBar} from './view/shell/bottom-bar/BottomBar' import {buildStateObject} from 'lib/routes/helpers' import {State, RouteParams} from 'lib/routes/types' import {colors} from 'lib/styles' diff --git a/src/lib/hooks/useMinimalShellMode.tsx b/src/lib/hooks/useMinimalShellMode.tsx new file mode 100644 index 000000000..e28a0e884 --- /dev/null +++ b/src/lib/hooks/useMinimalShellMode.tsx @@ -0,0 +1,32 @@ +import React from 'react' +import {useStores} from 'state/index' +import {Animated} from 'react-native' +import {useAnimatedValue} from 'lib/hooks/useAnimatedValue' + +export function useMinimalShellMode() { + const store = useStores() + const minimalShellInterp = useAnimatedValue(0) + const footerMinimalShellTransform = { + transform: [{translateY: Animated.multiply(minimalShellInterp, 100)}], + } + + React.useEffect(() => { + if (store.shell.minimalShellMode) { + Animated.timing(minimalShellInterp, { + toValue: 1, + duration: 100, + useNativeDriver: true, + isInteraction: false, + }).start() + } else { + Animated.timing(minimalShellInterp, { + toValue: 0, + duration: 100, + useNativeDriver: true, + isInteraction: false, + }).start() + } + }, [minimalShellInterp, store.shell.minimalShellMode]) + + return {footerMinimalShellTransform} +} diff --git a/src/lib/hooks/useNavigationTabState.ts b/src/lib/hooks/useNavigationTabState.ts new file mode 100644 index 000000000..8afc799eb --- /dev/null +++ b/src/lib/hooks/useNavigationTabState.ts @@ -0,0 +1,13 @@ +import {useNavigationState} from '@react-navigation/native' +import {getTabState, TabState} from 'lib/routes/helpers' + +export function useNavigationTabState() { + return useNavigationState(state => { + return { + isAtHome: getTabState(state, 'Home') !== TabState.Outside, + isAtSearch: getTabState(state, 'Search') !== TabState.Outside, + isAtNotifications: + getTabState(state, 'Notifications') !== TabState.Outside, + } + }) +} diff --git a/src/lib/hooks/useNavigationTabState.web.ts b/src/lib/hooks/useNavigationTabState.web.ts new file mode 100644 index 000000000..d0173aa0f --- /dev/null +++ b/src/lib/hooks/useNavigationTabState.web.ts @@ -0,0 +1,13 @@ +import {useNavigationState} from '@react-navigation/native' +import {getCurrentRoute} from 'lib/routes/helpers' + +export function useNavigationTabState() { + return useNavigationState(state => { + let currentRoute = state ? getCurrentRoute(state).name : 'Home' + return { + isAtHome: currentRoute === 'Home', + isAtSearch: currentRoute === 'Search', + isAtNotifications: currentRoute === 'Notifications', + } + }) +} diff --git a/src/lib/hooks/useWebMediaQueries.tsx b/src/lib/hooks/useWebMediaQueries.tsx new file mode 100644 index 000000000..441585442 --- /dev/null +++ b/src/lib/hooks/useWebMediaQueries.tsx @@ -0,0 +1,8 @@ +import {useMediaQuery} from 'react-responsive' + +export function useWebMediaQueries() { + const isDesktop = useMediaQuery({ + query: '(min-width: 1230px)', + }) + return {isDesktop} +} diff --git a/src/view/com/auth/SplashScreen.web.tsx b/src/view/com/auth/SplashScreen.web.tsx index a20f2d49e..7fac5a8c0 100644 --- a/src/view/com/auth/SplashScreen.web.tsx +++ b/src/view/com/auth/SplashScreen.web.tsx @@ -7,8 +7,7 @@ import {s, colors} from 'lib/styles' import {usePalette} from 'lib/hooks/usePalette' import {useStores} from 'state/index' import {CenteredView} from '../util/Views' -import {isDesktopWeb, isMobileWeb} from 'platform/detection' -import {HelpTip} from './util/HelpTip' +import {isMobileWeb} from 'platform/detection' export const SplashScreen = ({ onPressSignin, @@ -40,24 +39,22 @@ export const SplashScreen = ({ See what's next - {isDesktopWeb && ( - - - - Create a new account - - - - Sign in - - - )} + + + + Create a new account + + + + Sign in + + {' '} to try the beta before it's publicly available. - {isMobileWeb && ( - <> - - - - - )}