Fix sticky header
This commit is contained in:
@@ -453,11 +453,14 @@ function useQueryManager({initialQuery}: {initialQuery: string}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let SearchScreenInner = ({
|
let SearchScreenInner = ({
|
||||||
query: initialQuery,
|
query,
|
||||||
|
queryWithParams,
|
||||||
|
headerHeight,
|
||||||
}: {
|
}: {
|
||||||
query: string
|
query: string
|
||||||
|
queryWithParams: string
|
||||||
|
headerHeight: number
|
||||||
}): React.ReactNode => {
|
}): React.ReactNode => {
|
||||||
const t = useThemeNew()
|
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const setMinimalShellMode = useSetMinimalShellMode()
|
const setMinimalShellMode = useSetMinimalShellMode()
|
||||||
const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled()
|
const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled()
|
||||||
@@ -465,9 +468,6 @@ let SearchScreenInner = ({
|
|||||||
const {isDesktop} = useWebMediaQueries()
|
const {isDesktop} = useWebMediaQueries()
|
||||||
const [activeTab, setActiveTab] = React.useState(0)
|
const [activeTab, setActiveTab] = React.useState(0)
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {gtMobile} = useBreakpoints()
|
|
||||||
|
|
||||||
const {params, query, queryWithParams} = useQueryManager({initialQuery})
|
|
||||||
|
|
||||||
const onPageSelected = React.useCallback(
|
const onPageSelected = React.useCallback(
|
||||||
(index: number) => {
|
(index: number) => {
|
||||||
@@ -517,40 +517,25 @@ let SearchScreenInner = ({
|
|||||||
}, [_, query, queryWithParams, activeTab])
|
}, [_, query, queryWithParams, activeTab])
|
||||||
|
|
||||||
return query ? (
|
return query ? (
|
||||||
<>
|
<Pager
|
||||||
<CenteredView
|
onPageSelected={onPageSelected}
|
||||||
sideBorders={gtMobile}
|
renderTabBar={props => (
|
||||||
style={[
|
<CenteredView
|
||||||
a.pt_sm,
|
sideBorders
|
||||||
isNative && a.pb_xs,
|
style={[
|
||||||
a.px_md,
|
pal.border,
|
||||||
t.atoms.border_contrast_low,
|
pal.view,
|
||||||
]}>
|
styles.tabBarContainer,
|
||||||
<View style={[a.flex_row, a.align_center, a.justify_between, a.gap_sm]}>
|
{top: isWeb ? headerHeight : undefined},
|
||||||
<View style={[{width: 140}]}>
|
]}>
|
||||||
<SearchLanguageDropdown
|
<TabBar items={sections.map(section => section.title)} {...props} />
|
||||||
value={params.lang}
|
</CenteredView>
|
||||||
onChange={params.setLang}
|
)}
|
||||||
/>
|
initialPage={0}>
|
||||||
</View>
|
{sections.map((section, i) => (
|
||||||
</View>
|
<View key={i}>{section.component}</View>
|
||||||
</CenteredView>
|
))}
|
||||||
|
</Pager>
|
||||||
<Pager
|
|
||||||
onPageSelected={onPageSelected}
|
|
||||||
renderTabBar={props => (
|
|
||||||
<CenteredView
|
|
||||||
sideBorders
|
|
||||||
style={[pal.border, pal.view, styles.tabBarContainer]}>
|
|
||||||
<TabBar items={sections.map(section => section.title)} {...props} />
|
|
||||||
</CenteredView>
|
|
||||||
)}
|
|
||||||
initialPage={0}>
|
|
||||||
{sections.map((section, i) => (
|
|
||||||
<View key={i}>{section.component}</View>
|
|
||||||
))}
|
|
||||||
</Pager>
|
|
||||||
</>
|
|
||||||
) : hasSession ? (
|
) : hasSession ? (
|
||||||
<Explore />
|
<Explore />
|
||||||
) : (
|
) : (
|
||||||
@@ -819,59 +804,78 @@ export function SearchScreen(
|
|||||||
[selectedProfiles],
|
[selectedProfiles],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const {params, query, queryWithParams} = useQueryManager({
|
||||||
|
initialQuery: queryParam,
|
||||||
|
})
|
||||||
|
const showFilters = Boolean(query && !showAutocomplete)
|
||||||
|
const headerHeight = HEADER_HEIGHT + (showFilters ? 40 : 0)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={isWeb ? null : {flex: 1}}>
|
<View style={isWeb ? null : {flex: 1}}>
|
||||||
<CenteredView
|
<CenteredView
|
||||||
style={[
|
style={[
|
||||||
a.p_md,
|
a.p_md,
|
||||||
a.pb_0,
|
a.pb_0,
|
||||||
a.flex_row,
|
|
||||||
a.gap_sm,
|
a.gap_sm,
|
||||||
t.atoms.bg,
|
t.atoms.bg,
|
||||||
web({
|
web({
|
||||||
height: HEADER_HEIGHT, // TODO
|
height: headerHeight,
|
||||||
position: 'sticky',
|
position: 'sticky',
|
||||||
top: 0,
|
top: 0,
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
}),
|
}),
|
||||||
]}
|
]}
|
||||||
sideBorders={gtMobile}>
|
sideBorders={gtMobile}>
|
||||||
{!gtMobile && (
|
<View style={[a.flex_row, a.gap_sm]}>
|
||||||
<Button
|
{!gtMobile && (
|
||||||
testID="viewHeaderBackOrMenuBtn"
|
<Button
|
||||||
onPress={onPressMenu}
|
testID="viewHeaderBackOrMenuBtn"
|
||||||
hitSlop={HITSLOP_10}
|
onPress={onPressMenu}
|
||||||
label={_(msg`Menu`)}
|
hitSlop={HITSLOP_10}
|
||||||
accessibilityHint={_(msg`Access navigation links and settings`)}
|
label={_(msg`Menu`)}
|
||||||
size="large"
|
accessibilityHint={_(msg`Access navigation links and settings`)}
|
||||||
variant="solid"
|
size="large"
|
||||||
color="secondary"
|
variant="solid"
|
||||||
shape="square">
|
color="secondary"
|
||||||
<ButtonIcon icon={Menu} size="lg" />
|
shape="square">
|
||||||
</Button>
|
<ButtonIcon icon={Menu} size="lg" />
|
||||||
)}
|
</Button>
|
||||||
<SearchInputBox
|
)}
|
||||||
textInput={textInput}
|
<SearchInputBox
|
||||||
searchText={searchText}
|
textInput={textInput}
|
||||||
showAutocomplete={showAutocomplete}
|
searchText={searchText}
|
||||||
setShowAutocomplete={setShowAutocomplete}
|
showAutocomplete={showAutocomplete}
|
||||||
onChangeText={onChangeText}
|
setShowAutocomplete={setShowAutocomplete}
|
||||||
onSubmit={onSubmit}
|
onChangeText={onChangeText}
|
||||||
onPressClearQuery={onPressClearQuery}
|
onSubmit={onSubmit}
|
||||||
/>
|
onPressClearQuery={onPressClearQuery}
|
||||||
{showAutocomplete && (
|
/>
|
||||||
<Button
|
{showAutocomplete && (
|
||||||
label={_(msg`Cancel search`)}
|
<Button
|
||||||
size="large"
|
label={_(msg`Cancel search`)}
|
||||||
variant="ghost"
|
size="large"
|
||||||
color="secondary"
|
variant="ghost"
|
||||||
style={[a.px_sm]}
|
color="secondary"
|
||||||
onPress={onPressCancelSearch}
|
style={[a.px_sm]}
|
||||||
hitSlop={HITSLOP_10}>
|
onPress={onPressCancelSearch}
|
||||||
<ButtonText>
|
hitSlop={HITSLOP_10}>
|
||||||
<Trans>Cancel</Trans>
|
<ButtonText>
|
||||||
</ButtonText>
|
<Trans>Cancel</Trans>
|
||||||
</Button>
|
</ButtonText>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{query && !showAutocomplete && (
|
||||||
|
<View
|
||||||
|
style={[a.flex_row, a.align_center, a.justify_between, a.gap_sm]}>
|
||||||
|
<View style={[{width: 140}]}>
|
||||||
|
<SearchLanguageDropdown
|
||||||
|
value={params.lang}
|
||||||
|
onChange={params.setLang}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
)}
|
)}
|
||||||
</CenteredView>
|
</CenteredView>
|
||||||
|
|
||||||
@@ -905,7 +909,12 @@ export function SearchScreen(
|
|||||||
display: showAutocomplete ? 'none' : 'flex',
|
display: showAutocomplete ? 'none' : 'flex',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
}}>
|
}}>
|
||||||
<SearchScreenInner key={queryParam} query={queryParam} />
|
<SearchScreenInner
|
||||||
|
key={queryParam}
|
||||||
|
query={query}
|
||||||
|
queryWithParams={queryWithParams}
|
||||||
|
headerHeight={headerHeight}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
@@ -1233,7 +1242,6 @@ const styles = StyleSheet.create({
|
|||||||
tabBarContainer: {
|
tabBarContainer: {
|
||||||
// @ts-ignore web only
|
// @ts-ignore web only
|
||||||
position: isWeb ? 'sticky' : '',
|
position: isWeb ? 'sticky' : '',
|
||||||
top: isWeb ? HEADER_HEIGHT : 0,
|
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
},
|
},
|
||||||
searchHistoryContainer: {
|
searchHistoryContainer: {
|
||||||
|
|||||||
Reference in New Issue
Block a user