From 257573cd9c2a70d29df4ef5bdd503eea4ae411fe Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 24 Sep 2024 10:22:13 -0500 Subject: [PATCH] Dialog --- src/view/screens/Search/Search.tsx | 316 ++++++++++++++++------------- 1 file changed, 177 insertions(+), 139 deletions(-) diff --git a/src/view/screens/Search/Search.tsx b/src/view/screens/Search/Search.tsx index e954fd1c14..90ac6acdcc 100644 --- a/src/view/screens/Search/Search.tsx +++ b/src/view/screens/Search/Search.tsx @@ -22,7 +22,6 @@ import {useLingui} from '@lingui/react' import AsyncStorage from '@react-native-async-storage/async-storage' import {useFocusEffect, useNavigation} from '@react-navigation/native' -import {LANGUAGES} from '#/lib/../locale/languages' import {useAnalytics} from '#/lib/analytics/analytics' import {createHitslop} from '#/lib/constants' import {HITSLOP_10} from '#/lib/constants' @@ -37,6 +36,7 @@ import { SearchTabNavigatorParams, } from '#/lib/routes/types' import {augmentSearchQuery} from '#/lib/strings/helpers' +import {LANGUAGES} from '#/locale/languages' import {logger} from '#/logger' import {isNative, isWeb} from '#/platform/detection' import {listenSoftReset} from '#/state/events' @@ -61,11 +61,13 @@ import {Explore} from '#/view/screens/Search/Explore' import {SearchLinkCard, SearchProfileCard} from '#/view/shell/desktop/Search' import {atoms as a, useBreakpoints, useTheme as useThemeNew, web} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' +import * as Dialog from '#/components/Dialog' import * as FeedCard from '#/components/FeedCard' import * as TextField from '#/components/forms/TextField' import {ChevronBottom_Stroke2_Corner0_Rounded as ChevronDown} from '#/components/icons/Chevron' import {MagnifyingGlass2_Stroke2_Corner0_Rounded as MagnifyingGlass} from '#/components/icons/MagnifyingGlass2' import {Menu_Stroke2_Corner0_Rounded as Menu} from '#/components/icons/Menu' +import {SettingsGear2_Stroke2_Corner0_Rounded as Gear} from '#/components/icons/SettingsGear2' import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' import {Text as NewText} from '#/components/Typography' @@ -409,8 +411,14 @@ function SearchLanguageDropdown({ ) } -let SearchScreenInner = ({query}: {query?: string}): React.ReactNode => { - const t = useThemeNew() +let SearchScreenInner = ({ + queryWithoutLanguage, + queryWithLanguage, +}: { + query?: string + queryWithoutLanguage: string + queryWithLanguage: string +}): React.ReactNode => { const pal = usePalette('default') const setMinimalShellMode = useSetMinimalShellMode() const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled() @@ -418,14 +426,6 @@ let SearchScreenInner = ({query}: {query?: string}): React.ReactNode => { const {isDesktop} = useWebMediaQueries() const [activeTab, setActiveTab] = React.useState(0) const {_} = useLingui() - const {gtMobile} = useBreakpoints() - - const {contentLanguages} = useLanguagePrefs() - const [language, setLanguage] = React.useState( - parseLanguageFromQuery(query || '') || contentLanguages[0], - ) - const queryWithoutLang = sanitizeLangFromQuery(query || '') - const queryWithLang = queryWithoutLang + ` lang:${language}` const onPageSelected = React.useCallback( (index: number) => { @@ -437,13 +437,13 @@ let SearchScreenInner = ({query}: {query?: string}): React.ReactNode => { ) const sections = React.useMemo(() => { - if (!queryWithoutLang) return [] + if (!queryWithoutLanguage) return [] return [ { title: _(msg`Top`), component: ( @@ -453,7 +453,7 @@ let SearchScreenInner = ({query}: {query?: string}): React.ReactNode => { title: _(msg`Latest`), component: ( @@ -463,7 +463,7 @@ let SearchScreenInner = ({query}: {query?: string}): React.ReactNode => { title: _(msg`People`), component: ( ), @@ -472,49 +472,29 @@ let SearchScreenInner = ({query}: {query?: string}): React.ReactNode => { title: _(msg`Feeds`), component: ( ), }, ] - }, [_, queryWithoutLang, queryWithLang, activeTab]) + }, [_, queryWithoutLanguage, queryWithLanguage, activeTab]) - return queryWithoutLang ? ( - <> - - - - Language: - - - - - - - - ( - - section.title)} {...props} /> - - )} - initialPage={0}> - {sections.map((section, i) => ( - {section.component} - ))} - - + return queryWithoutLanguage ? ( + ( + + section.title)} {...props} /> + + )} + initialPage={0}> + {sections.map((section, i) => ( + {section.component} + ))} + ) : hasSession ? ( ) : ( @@ -784,95 +764,153 @@ export function SearchScreen( [selectedProfiles], ) - return ( - - - {!gtMobile && ( - - )} - - {showAutocomplete && ( - - )} - + const {contentLanguages} = useLanguagePrefs() + const [language, setLanguage] = React.useState( + parseLanguageFromQuery(queryParam || '') || contentLanguages[0], + ) + const queryWithoutLanguage = sanitizeLangFromQuery(queryParam || '') + const queryWithLanguage = queryWithoutLanguage + ` lang:${language}` + const control = Dialog.useDialogControl() - - {searchText.length > 0 ? ( - + + + + + + + Advanced search + + + For more tips and tricks, check out this blog post. + + + + + + + + + + + + + {!gtMobile && ( + + )} + + + + {showAutocomplete && ( + + )} + {searchText && !showAutocomplete && ( + + )} + + + + {searchText.length > 0 ? ( + + ) : ( + + )} + + + - ) : ( - - )} + - - - - + ) } @@ -897,7 +935,7 @@ let SearchInputBox = ({ const t = useThemeNew() return ( - +