From 21542c4a77a51bfcd6c2f48801559f901f504181 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 17 Oct 2024 03:43:10 +0300 Subject: Clean up drawer (#5761) * clean up drawer * add a lil bit of padding * Drawer nits (#5778) * Avi stuff * Rm SafeAreaView, not working on Android * Dividers and spacing * Fix count on android, ended up refactoring the whole MenuItem * Litttttle more space * Improve NavSignupCard * format nit --------- Co-authored-by: Samuel Newman --------- Co-authored-by: Eric Bailey --- src/view/shell/Drawer.tsx | 558 ++++++++++++++++++++-------------------------- 1 file changed, 243 insertions(+), 315 deletions(-) (limited to 'src/view/shell/Drawer.tsx') diff --git a/src/view/shell/Drawer.tsx b/src/view/shell/Drawer.tsx index 51375dd32..c6ae955a8 100644 --- a/src/view/shell/Drawer.tsx +++ b/src/view/shell/Drawer.tsx @@ -1,26 +1,17 @@ import React, {ComponentProps} from 'react' -import { - Linking, - SafeAreaView, - ScrollView, - StyleProp, - StyleSheet, - TouchableOpacity, - View, - ViewStyle, -} from 'react-native' -import {FontAwesomeIconStyle} from '@fortawesome/react-native-fontawesome' +import {Linking, ScrollView, TouchableOpacity, View} from 'react-native' +import {useSafeAreaInsets} from 'react-native-safe-area-context' import {msg, Plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {StackActions, useNavigation} from '@react-navigation/native' import {FEEDBACK_FORM_URL, HELP_DESK_URL} from '#/lib/constants' +import {PressableScale} from '#/lib/custom-animations/PressableScale' import {useNavigationTabState} from '#/lib/hooks/useNavigationTabState' -import {usePalette} from '#/lib/hooks/usePalette' import {getTabState, TabState} from '#/lib/routes/helpers' import {NavigationProp} from '#/lib/routes/types' -import {colors, s} from '#/lib/styles' -import {useTheme} from '#/lib/ThemeContext' +import {sanitizeHandle} from '#/lib/strings/handles' +import {colors} from '#/lib/styles' import {isWeb} from '#/platform/detection' import {emitSoftReset} from '#/state/events' import {useKawaiiMode} from '#/state/preferences/kawaii' @@ -29,12 +20,12 @@ import {useProfileQuery} from '#/state/queries/profile' import {SessionAccount, useSession} from '#/state/session' import {useSetDrawerOpen} from '#/state/shell' import {formatCount} from '#/view/com/util/numeric/format' -import {Text} from '#/view/com/util/text/Text' import {UserAvatar} from '#/view/com/util/UserAvatar' import {NavSignupCard} from '#/view/shell/NavSignupCard' import {atoms as a} from '#/alf' -import {useTheme as useAlfTheme} from '#/alf' +import {useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' +import {Divider} from '#/components/Divider' import { Bell_Filled_Corner0_Rounded as BellFilled, Bell_Stroke2_Corner0_Rounded as Bell, @@ -50,15 +41,19 @@ import { } from '#/components/icons/HomeOpen' import {MagnifyingGlass_Filled_Stroke2_Corner0_Rounded as MagnifyingGlassFilled} from '#/components/icons/MagnifyingGlass' import {MagnifyingGlass2_Stroke2_Corner0_Rounded as MagnifyingGlass} from '#/components/icons/MagnifyingGlass2' -import {Message_Stroke2_Corner0_Rounded as Message} from '#/components/icons/Message' +import { + Message_Stroke2_Corner0_Rounded as Message, + Message_Stroke2_Corner0_Rounded_Filled as MessageFilled, +} from '#/components/icons/Message' import {SettingsGear2_Stroke2_Corner0_Rounded as Settings} from '#/components/icons/SettingsGear2' import { UserCircle_Filled_Corner0_Rounded as UserCircleFilled, UserCircle_Stroke2_Corner0_Rounded as UserCircle, } from '#/components/icons/UserCircle' -import {TextLink} from '../com/util/Link' +import {InlineLinkText} from '#/components/Link' +import {Text} from '#/components/Typography' -const iconWidth = 28 +const iconWidth = 26 let DrawerProfileCard = ({ account, @@ -68,7 +63,7 @@ let DrawerProfileCard = ({ onPressProfile: () => void }): React.ReactNode => { const {_, i18n} = useLingui() - const pal = usePalette('default') + const t = useTheme() const {data: profile} = useProfileQuery({did: account.did}) return ( @@ -76,62 +71,52 @@ let DrawerProfileCard = ({ testID="profileCardButton" accessibilityLabel={_(msg`Profile`)} accessibilityHint={_(msg`Navigates to your profile`)} - onPress={onPressProfile}> + onPress={onPressProfile} + style={[a.gap_sm]}> - - {profile?.displayName || account.handle} - - - @{account.handle} - - - - - - {formatCount(i18n, profile?.followersCount ?? 0)} - {' '} - - + + + {profile?.displayName || account.handle} - - · - - - - - {formatCount(i18n, profile?.followsCount ?? 0)} - {' '} - - + + {sanitizeHandle(account.handle, '@')} + + + + {formatCount(i18n, profile?.followersCount ?? 0)} + {' '} + + {' '} + ·{' '} + + + {formatCount(i18n, profile?.followsCount ?? 0)} + {' '} + + + ) } @@ -139,14 +124,19 @@ DrawerProfileCard = React.memo(DrawerProfileCard) export {DrawerProfileCard} let DrawerContent = ({}: {}): React.ReactNode => { - const theme = useTheme() - const t = useAlfTheme() - const pal = usePalette('default') + const t = useTheme() const {_} = useLingui() + const insets = useSafeAreaInsets() const setDrawerOpen = useSetDrawerOpen() const navigation = useNavigation() - const {isAtHome, isAtSearch, isAtFeeds, isAtNotifications, isAtMyProfile} = - useNavigationTabState() + const { + isAtHome, + isAtSearch, + isAtFeeds, + isAtNotifications, + isAtMyProfile, + isAtMessages, + } = useNavigationTabState() const {hasSession, currentAccount} = useSession() const kawaii = useKawaiiMode() @@ -187,6 +177,11 @@ let DrawerContent = ({}: {}): React.ReactNode => { [onPressTab], ) + const onPressMessages = React.useCallback( + () => onPressTab('Messages'), + [onPressTab], + ) + const onPressNotifications = React.useCallback( () => onPressTab('Notifications'), [onPressTab], @@ -228,89 +223,91 @@ let DrawerContent = ({}: {}): React.ReactNode => { // = return ( - - - - {hasSession && currentAccount ? ( - - - - ) : ( - - - - )} - - {hasSession ? ( - <> - - - - - - - - - - ) : ( - <> - - - - - )} - - - - - + + {hasSession && currentAccount ? ( + + ) : ( + + + + )} + + + + {hasSession ? ( + <> + + + + - + + - {kawaii && ( - + + + ) : ( + <> + + + + + )} + + + + + + Terms of Service + + + Privacy Policy + + {kawaii && ( + + Logo by{' '} - - - )} - - - - - + + @sawaratsuki.bsky.social + + + + )} + + - - + ) } @@ -325,8 +322,17 @@ let DrawerFooter = ({ onPressHelp: () => void }): React.ReactNode => { const {_} = useLingui() + const insets = useSafeAreaInsets() return ( - +