1
0
mirror of https://github.com/tooot-app/app synced 2025-04-18 20:27:40 +02:00
Zhiyuan Zheng 2021-01-10 13:35:46 +01:00
parent 541e2a5601
commit fdce172c57
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
4 changed files with 71 additions and 65 deletions

View File

@ -52,7 +52,7 @@ const TimelineContent: React.FC<Props> = ({
emojis={status.emojis} emojis={status.emojis}
mentions={status.mentions} mentions={status.mentions}
tags={status.tags} tags={status.tags}
numberOfLines={numberOfLines} numberOfLines={highlighted ? 999 : numberOfLines}
disableDetails={disableDetails} disableDetails={disableDetails}
/> />
)} )}

View File

@ -5,7 +5,6 @@ import TimelineDefault from '@root/components/Timelines/Timeline/Default'
import hookSearch from '@utils/queryHooks/search' import hookSearch from '@utils/queryHooks/search'
import { StyleConstants } from '@utils/styles/constants' import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import { debounce } from 'lodash'
import React, { useCallback, useEffect, useMemo, useState } from 'react' import React, { useCallback, useEffect, useMemo, useState } from 'react'
import { import {
KeyboardAvoidingView, KeyboardAvoidingView,
@ -16,53 +15,19 @@ import {
View View
} from 'react-native' } from 'react-native'
import { Chase } from 'react-native-animated-spinkit' import { Chase } from 'react-native-animated-spinkit'
import { TextInput } from 'react-native-gesture-handler'
const ScreenSharedSearch: React.FC = () => { export interface Props {
searchTerm: string | undefined
}
const ScreenSharedSearch: React.FC<Props> = ({ searchTerm }) => {
const navigation = useNavigation() const navigation = useNavigation()
const { theme } = useTheme() const { theme } = useTheme()
const [searchTerm, setSearchTerm] = useState<string | undefined>()
const { status, data, refetch } = hookSearch({ const { status, data, refetch } = hookSearch({
term: searchTerm, term: searchTerm,
options: { enabled: false } options: { enabled: false }
}) })
useEffect(() => {
const updateHeaderRight = () =>
navigation.setOptions({
headerCenter: () => (
<View style={styles.searchBar}>
<Text
style={{ ...StyleConstants.FontStyle.M, color: theme.primary }}
>
</Text>
<TextInput
style={[
styles.textInput,
{
color: theme.primary
}
]}
autoFocus
onChangeText={onChangeText}
autoCapitalize='none'
autoCorrect={false}
clearButtonMode='never'
keyboardType='web-search'
onSubmitEditing={({ nativeEvent: { text } }) =>
setSearchTerm(text)
}
placeholder={'些什么'}
placeholderTextColor={theme.secondary}
returnKeyType='go'
/>
</View>
)
})
return updateHeaderRight()
}, [])
const [setctionData, setSectionData] = useState< const [setctionData, setSectionData] = useState<
{ title: string; data: any }[] { title: string; data: any }[]
>([]) >([])
@ -89,12 +54,6 @@ const ScreenSharedSearch: React.FC = () => {
[data] [data]
) )
const onChangeText = useCallback(
debounce(text => setSearchTerm(text), 1000, {
trailing: true
}),
[]
)
useEffect(() => { useEffect(() => {
if (searchTerm) { if (searchTerm) {
refetch() refetch()
@ -233,20 +192,8 @@ const styles = StyleSheet.create({
base: { base: {
minHeight: '100%' minHeight: '100%'
}, },
searchBar: {
flexBasis: '80%',
flexDirection: 'row',
alignItems: 'center'
},
textInput: {
...StyleConstants.FontStyle.M,
paddingLeft: StyleConstants.Spacing.XS,
marginBottom:
(StyleConstants.Font.LineHeight.M - StyleConstants.Font.Size.M) / 2
},
emptyBase: { emptyBase: {
marginVertical: StyleConstants.Spacing.Global.PagePadding, marginVertical: StyleConstants.Spacing.Global.PagePadding,
// paddingHorizontal: StyleConstants.Spacing.Global.PagePadding
alignItems: 'center' alignItems: 'center'
}, },
loading: { flex: 1, alignItems: 'center' }, loading: { flex: 1, alignItems: 'center' },

View File

@ -9,8 +9,13 @@ import ScreenSharedImagesViewer from '@screens/Shared/ImagesViewer'
import ScreenSharedRelationships from '@screens/Shared/Relationships' import ScreenSharedRelationships from '@screens/Shared/Relationships'
import ScreenSharedSearch from '@screens/Shared/Search' import ScreenSharedSearch from '@screens/Shared/Search'
import ScreenSharedToot from '@screens/Shared/Toot' import ScreenSharedToot from '@screens/Shared/Toot'
import React from 'react' import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
import { debounce } from 'lodash'
import React, { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { StyleSheet, Text, View } from 'react-native'
import { TextInput } from 'react-native-gesture-handler'
import { NativeStackNavigationOptions } from 'react-native-screens/lib/typescript' import { NativeStackNavigationOptions } from 'react-native-screens/lib/typescript'
import { import {
NativeStackNavigationEventMap, NativeStackNavigationEventMap,
@ -69,8 +74,17 @@ const sharedScreens = (
}: NativeStackNavigatorProps) => JSX.Element }: NativeStackNavigatorProps) => JSX.Element
> >
) => { ) => {
const { theme } = useTheme()
const { t } = useTranslation() const { t } = useTranslation()
const [searchTerm, setSearchTerm] = useState<string>()
const onChangeText = useCallback(
debounce(text => setSearchTerm(text), 1000, {
trailing: true
}),
[]
)
return [ return [
<Stack.Screen <Stack.Screen
key='Screen-Shared-Account' key='Screen-Shared-Account'
@ -134,11 +148,42 @@ const sharedScreens = (
<Stack.Screen <Stack.Screen
key='Screen-Shared-Search' key='Screen-Shared-Search'
name='Screen-Shared-Search' name='Screen-Shared-Search'
component={ScreenSharedSearch}
options={({ navigation }: any) => ({ options={({ navigation }: any) => ({
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} /> headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />,
// https://github.com/react-navigation/react-navigation/issues/6746#issuecomment-583897436
headerCenter: () => (
<View style={styles.searchBar}>
<Text
style={{ ...StyleConstants.FontStyle.M, color: theme.primary }}
>
</Text>
<TextInput
style={[
styles.textInput,
{
color: theme.primary
}
]}
autoFocus
onChangeText={onChangeText}
autoCapitalize='none'
autoCorrect={false}
clearButtonMode='never'
keyboardType='web-search'
onSubmitEditing={({ nativeEvent: { text } }) =>
setSearchTerm(text)
}
placeholder={'些什么'}
placeholderTextColor={theme.secondary}
returnKeyType='go'
/>
</View>
)
})} })}
/>, >
{() => <ScreenSharedSearch searchTerm={searchTerm} />}
</Stack.Screen>,
<Stack.Screen <Stack.Screen
key='Screen-Shared-Toot' key='Screen-Shared-Toot'
name='Screen-Shared-Toot' name='Screen-Shared-Toot'
@ -151,4 +196,18 @@ const sharedScreens = (
] ]
} }
const styles = StyleSheet.create({
searchBar: {
flexBasis: '80%',
flexDirection: 'row',
alignItems: 'center'
},
textInput: {
...StyleConstants.FontStyle.M,
paddingLeft: StyleConstants.Spacing.XS,
marginBottom:
(StyleConstants.Font.LineHeight.M - StyleConstants.Font.Size.M) / 2
}
})
export default sharedScreens export default sharedScreens

View File

@ -3,13 +3,13 @@ const Base = 4
export const StyleConstants = { export const StyleConstants = {
Font: { Font: {
Size: { S: 14, M: 16, L: 18 }, Size: { S: 14, M: 16, L: 18 },
LineHeight: { S: 20, M: 22, L: 26 }, LineHeight: { S: 20, M: 22, L: 30 },
Weight: { Bold: '600' as '600' } Weight: { Bold: '600' as '600' }
}, },
FontStyle: { FontStyle: {
S: { fontSize: 14, lineHeight: 20 }, S: { fontSize: 14, lineHeight: 20 },
M: { fontSize: 16, lineHeight: 22 }, M: { fontSize: 16, lineHeight: 22 },
L: { fontSize: 20, lineHeight: 26 } L: { fontSize: 20, lineHeight: 30 }
}, },
Spacing: { Spacing: {