From 4a83fe4f6e50a5eb8aa41080669f33a6b984c112 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Sat, 25 Jan 2025 18:15:52 +0000 Subject: [PATCH] remove legacy components --- src/alf/atoms.ts | 2 +- src/view/screens/Search/Search.tsx | 193 ++++++++--------------------- 2 files changed, 56 insertions(+), 139 deletions(-) diff --git a/src/alf/atoms.ts b/src/alf/atoms.ts index a7cf6cb3f4..056060092a 100644 --- a/src/alf/atoms.ts +++ b/src/alf/atoms.ts @@ -68,7 +68,7 @@ export const atoms = { * Used for the outermost components on screens, to ensure that they can fill * the screen and extend beyond. */ - // @ts-ignore - web only minHeight string + // @ts-expect-error - web only minHeight string util_screen_outer: [ web({ minHeight: '100vh', diff --git a/src/view/screens/Search/Search.tsx b/src/view/screens/Search/Search.tsx index 26c13165f1..7974d608b6 100644 --- a/src/view/screens/Search/Search.tsx +++ b/src/view/screens/Search/Search.tsx @@ -1,13 +1,12 @@ import React, {useLayoutEffect} from 'react' import { ActivityIndicator, - Image, - ImageStyle, Pressable, StyleProp, StyleSheet, TextInput, View, + ViewStyle, } from 'react-native' import {ScrollView as RNGHScrollView} from 'react-native-gesture-handler' import RNPickerSelect from 'react-native-picker-select' @@ -16,10 +15,6 @@ import Animated, { LinearTransition, } from 'react-native-reanimated' import {AppBskyActorDefs, AppBskyFeedDefs, moderateProfile} from '@atproto/api' -import { - FontAwesomeIcon, - FontAwesomeIconStyle, -} from '@fortawesome/react-native-fontawesome' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import AsyncStorage from '@react-native-async-storage/async-storage' @@ -29,8 +24,6 @@ import {APP_LANGUAGES, LANGUAGES} from '#/lib/../locale/languages' import {createHitslop, HITSLOP_20} from '#/lib/constants' import {HITSLOP_10} from '#/lib/constants' import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' -import {usePalette} from '#/lib/hooks/usePalette' -import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {MagnifyingGlassIcon} from '#/lib/icons' import {makeProfileLink} from '#/lib/routes/links' import {NavigationProp} from '#/lib/routes/types' @@ -58,16 +51,18 @@ import {Post} from '#/view/com/post/Post' import {ProfileCardWithFollowBtn} from '#/view/com/profile/ProfileCard' import {Link} from '#/view/com/util/Link' import {List} from '#/view/com/util/List' -import {Text} from '#/view/com/util/text/Text' +import {UserAvatar} from '#/view/com/util/UserAvatar' import {Explore} from '#/view/screens/Search/Explore' import {SearchLinkCard, SearchProfileCard} from '#/view/shell/desktop/Search' import {makeSearchQuery, parseSearchQuery} from '#/screens/Search/utils' import {atoms as a, native, tokens, useBreakpoints, useTheme, web} from '#/alf' -import {Button, ButtonText} from '#/components/Button' +import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as FeedCard from '#/components/FeedCard' import {SearchInput} from '#/components/forms/SearchInput' import {ChevronBottom_Stroke2_Corner0_Rounded as ChevronDown} from '#/components/icons/Chevron' +import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/Times' import * as Layout from '#/components/Layout' +import {Text} from '#/components/Typography' function Loader() { return ( @@ -80,13 +75,13 @@ function Loader() { } function EmptyState({message, error}: {message: string; error?: string}) { - const pal = usePalette('default') + const t = useTheme() return ( - - {message} + + {message} {error && ( <> @@ -96,13 +91,13 @@ function EmptyState({message, error}: {message: string; error?: string}) { marginVertical: 12, height: 1, width: '100%', - backgroundColor: pal.text.color, + backgroundColor: t.atoms.text.color, opacity: 0.2, }, ]} /> - + Error: {error} @@ -469,10 +464,10 @@ let SearchScreenInner = ({ queryWithParams: string headerHeight: number }): React.ReactNode => { - const pal = usePalette('default') + const t = useTheme() const setMinimalShellMode = useSetMinimalShellMode() const {hasSession} = useSession() - const {isDesktop} = useWebMediaQueries() + const {gtTablet} = useBreakpoints() const [activeTab, setActiveTab] = React.useState(0) const {_} = useLingui() @@ -543,39 +538,29 @@ let SearchScreenInner = ({ ) : ( - - {isDesktop && ( - + {gtTablet && ( + - Search - + + Search + + )} - + } /> - + Find posts and users on Bluesky @@ -1030,17 +1015,17 @@ function SearchHistory({ onRemoveItemClick: (item: string) => void onRemoveProfileClick: (profile: AppBskyActorDefs.ProfileViewBasic) => void }) { - const {isMobile} = useWebMediaQueries() - const pal = usePalette('default') + const {gtMobile} = useBreakpoints() + const t = useTheme() const {_} = useLingui() return ( - + {(searchHistory.length > 0 || selectedProfiles.length > 0) && ( - + Recent Searches )} @@ -1048,7 +1033,7 @@ function SearchHistory({ {selectedProfiles.slice(0, 5).map((profile, index) => ( @@ -1064,7 +1049,7 @@ function SearchHistory({ key={index} style={[ styles.profileItem, - isMobile && styles.profileItemMobile, + !gtMobile && styles.profileItemMobile, ]}> onProfileClick(profile)} - style={styles.profilePressable}> - } - accessibilityIgnoresInvertColors + style={[a.align_center, a.w_full]}> + {sanitizeDisplayName( profile.displayName || profile.handle, @@ -1096,11 +1081,7 @@ function SearchHistory({ onPress={() => onRemoveProfileClick(profile)} hitSlop={createHitslop(6)} style={styles.profileRemoveBtn}> - + ))} @@ -1108,34 +1089,25 @@ function SearchHistory({ )} {searchHistory.length > 0 && ( - + {searchHistory.slice(0, 5).map((historyItem, index) => ( - + onItemClick(historyItem)} hitSlop={HITSLOP_10} - style={[a.flex_1, a.py_sm]}> - {historyItem} + style={[a.flex_1, a.py_md]}> + {historyItem} - onRemoveItemClick(historyItem)} - hitSlop={HITSLOP_10} - style={[a.px_md, a.py_xs, a.justify_center]}> - - + size="small" + variant="ghost" + color="secondary" + shape="round"> + + ))} @@ -1152,41 +1124,6 @@ function scrollToTopWeb() { } const styles = StyleSheet.create({ - headerMenuBtn: { - width: 30, - height: 30, - borderRadius: 30, - marginRight: 6, - alignItems: 'center', - justifyContent: 'center', - }, - headerSearchContainer: { - flex: 1, - flexDirection: 'row', - alignItems: 'center', - borderRadius: 30, - paddingHorizontal: 12, - paddingVertical: 8, - }, - headerSearchIcon: { - marginRight: 6, - alignSelf: 'center', - }, - headerSearchInput: { - flex: 1, - fontSize: 17, - minWidth: 0, - }, - headerCancelBtn: { - paddingLeft: 10, - alignSelf: 'center', - zIndex: -1, - elevation: -1, // For Android - }, - searchHistoryContainer: { - width: '100%', - paddingHorizontal: 12, - }, selectedProfilesContainer: { marginTop: 10, paddingHorizontal: 12, @@ -1203,20 +1140,9 @@ const styles = StyleSheet.create({ profileItemMobile: { width: 70, }, - profilePressable: { - alignItems: 'center', - width: '100%', - }, - profileAvatar: { - width: 60, - height: 60, - borderRadius: 45, - }, profileName: { width: 78, - fontSize: 12, - textAlign: 'center', - marginTop: 5, + marginTop: 6, }, profileRemoveBtn: { position: 'absolute', @@ -1229,13 +1155,4 @@ const styles = StyleSheet.create({ alignItems: 'center', justifyContent: 'center', }, - searchHistoryContent: { - paddingHorizontal: 10, - borderRadius: 8, - }, - searchHistoryTitle: { - fontWeight: '600', - paddingVertical: 12, - paddingHorizontal: 10, - }, })