mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Move screen options into each screen
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
import menuAccount from '@components/contextMenu/account'
|
import menuAccount from '@components/contextMenu/account'
|
||||||
import menuShare from '@components/contextMenu/share'
|
import menuShare from '@components/contextMenu/share'
|
||||||
import { HeaderRight } from '@components/Header'
|
import { HeaderLeft, HeaderRight } from '@components/Header'
|
||||||
import Timeline from '@components/Timeline'
|
import Timeline from '@components/Timeline'
|
||||||
import TimelineDefault from '@components/Timeline/Default'
|
import TimelineDefault from '@components/Timeline/Default'
|
||||||
import SegmentedControl from '@react-native-community/segmented-control'
|
import SegmentedControl from '@react-native-community/segmented-control'
|
||||||
@ -33,6 +33,12 @@ const TabSharedAccount: React.FC<TabSharedStackScreenProps<'Tab-Shared-Account'>
|
|||||||
const mAccount = menuAccount({ type: 'account', openChange: true, account })
|
const mAccount = menuAccount({ type: 'account', openChange: true, account })
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
navigation.setOptions({
|
navigation.setOptions({
|
||||||
|
headerTransparent: true,
|
||||||
|
headerStyle: {
|
||||||
|
backgroundColor: `rgba(255, 255, 255, 0)`
|
||||||
|
},
|
||||||
|
title: '',
|
||||||
|
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} background />,
|
||||||
headerRight: () => {
|
headerRight: () => {
|
||||||
return (
|
return (
|
||||||
<DropdownMenu.Root>
|
<DropdownMenu.Root>
|
||||||
|
@ -10,7 +10,7 @@ import { StyleConstants } from '@utils/styles/constants'
|
|||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { SectionList, Text, View } from 'react-native'
|
import { SectionList, View } from 'react-native'
|
||||||
|
|
||||||
const TabSharedAccountInLists: React.FC<
|
const TabSharedAccountInLists: React.FC<
|
||||||
TabSharedStackScreenProps<'Tab-Shared-Account-In-Lists'>
|
TabSharedStackScreenProps<'Tab-Shared-Account-In-Lists'>
|
||||||
@ -27,7 +27,6 @@ const TabSharedAccountInLists: React.FC<
|
|||||||
navigation.setOptions({
|
navigation.setOptions({
|
||||||
presentation: 'modal',
|
presentation: 'modal',
|
||||||
title: t('shared.accountInLists.name', { username: account.username }),
|
title: t('shared.accountInLists.name', { username: account.username }),
|
||||||
headerLeft: () => null,
|
|
||||||
headerRight: () => {
|
headerRight: () => {
|
||||||
return (
|
return (
|
||||||
<HeaderRight
|
<HeaderRight
|
||||||
@ -49,8 +48,8 @@ const TabSharedAccountInLists: React.FC<
|
|||||||
id: 'out',
|
id: 'out',
|
||||||
title: t('shared.accountInLists.notInLists'),
|
title: t('shared.accountInLists.notInLists'),
|
||||||
data:
|
data:
|
||||||
listsQuery.data?.filter(
|
listsQuery?.data?.filter(
|
||||||
({ id }) => !accountInListsQuery.data?.filter(d => d.id === id).length
|
({ id }) => !accountInListsQuery?.data?.filter(d => d.id === id)?.length
|
||||||
) || []
|
) || []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1,27 +1,57 @@
|
|||||||
|
import { HeaderLeft } from '@components/Header'
|
||||||
|
import { ParseEmojis } from '@components/Parse'
|
||||||
|
import CustomText from '@components/Text'
|
||||||
import Timeline from '@components/Timeline'
|
import Timeline from '@components/Timeline'
|
||||||
import TimelineDefault from '@components/Timeline/Default'
|
import TimelineDefault from '@components/Timeline/Default'
|
||||||
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
||||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||||
import React from 'react'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
|
import React, { useEffect } from 'react'
|
||||||
|
import { Trans } from 'react-i18next'
|
||||||
|
|
||||||
const TabSharedAttachments: React.FC<
|
const TabSharedAttachments: React.FC<TabSharedStackScreenProps<'Tab-Shared-Attachments'>> = ({
|
||||||
TabSharedStackScreenProps<'Tab-Shared-Attachments'>
|
navigation,
|
||||||
> = ({
|
|
||||||
route: {
|
route: {
|
||||||
params: { account }
|
params: { account }
|
||||||
}
|
}
|
||||||
}) => {
|
}) => {
|
||||||
|
const { colors } = useTheme()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
navigation.setOptions({
|
||||||
|
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} background />,
|
||||||
|
headerTitle: () => (
|
||||||
|
<CustomText numberOfLines={1}>
|
||||||
|
<Trans
|
||||||
|
i18nKey='screenTabs:shared.attachments.name'
|
||||||
|
components={[
|
||||||
|
<ParseEmojis
|
||||||
|
content={account.display_name || account.username}
|
||||||
|
emojis={account.emojis}
|
||||||
|
fontBold
|
||||||
|
/>,
|
||||||
|
<CustomText
|
||||||
|
fontStyle='M'
|
||||||
|
style={{ color: colors.primaryDefault }}
|
||||||
|
fontWeight='Bold'
|
||||||
|
/>
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</CustomText>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
const queryKey: QueryKeyTimeline = [
|
const queryKey: QueryKeyTimeline = [
|
||||||
'Timeline',
|
'Timeline',
|
||||||
{ page: 'Account_Attachments', account: account.id }
|
{ page: 'Account_Attachments', account: account.id }
|
||||||
]
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Timeline
|
<Timeline
|
||||||
queryKey={queryKey}
|
queryKey={queryKey}
|
||||||
customProps={{
|
customProps={{
|
||||||
renderItem: ({ item }) => (
|
renderItem: ({ item }) => <TimelineDefault item={item} queryKey={queryKey} />
|
||||||
<TimelineDefault item={item} queryKey={queryKey} />
|
|
||||||
)
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import haptics from '@components/haptics'
|
import haptics from '@components/haptics'
|
||||||
import { HeaderRight } from '@components/Header'
|
import { HeaderLeft, HeaderRight } from '@components/Header'
|
||||||
import { displayMessage } from '@components/Message'
|
import { displayMessage } from '@components/Message'
|
||||||
import Timeline from '@components/Timeline'
|
import Timeline from '@components/Timeline'
|
||||||
import TimelineDefault from '@components/Timeline/Default'
|
import TimelineDefault from '@components/Timeline/Default'
|
||||||
@ -18,6 +18,13 @@ const TabSharedHashtag: React.FC<TabSharedStackScreenProps<'Tab-Shared-Hashtag'>
|
|||||||
params: { hashtag }
|
params: { hashtag }
|
||||||
}
|
}
|
||||||
}) => {
|
}) => {
|
||||||
|
useEffect(() => {
|
||||||
|
navigation.setOptions({
|
||||||
|
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />,
|
||||||
|
title: `#${decodeURIComponent(hashtag)}`
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Hashtag', hashtag }]
|
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Hashtag', hashtag }]
|
||||||
|
|
||||||
const { theme } = useTheme()
|
const { theme } = useTheme()
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { HeaderLeft } from '@components/Header'
|
||||||
import Icon from '@components/Icon'
|
import Icon from '@components/Icon'
|
||||||
import { ParseEmojis } from '@components/Parse'
|
import { ParseEmojis } from '@components/Parse'
|
||||||
import ComponentSeparator from '@components/Separator'
|
import ComponentSeparator from '@components/Separator'
|
||||||
@ -9,7 +10,8 @@ import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
|||||||
import { useStatusHistory } from '@utils/queryHooks/statusesHistory'
|
import { useStatusHistory } from '@utils/queryHooks/statusesHistory'
|
||||||
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 React from 'react'
|
import React, { useEffect } from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import { View } from 'react-native'
|
import { View } from 'react-native'
|
||||||
import { ScrollView } from 'react-native-gesture-handler'
|
import { ScrollView } from 'react-native-gesture-handler'
|
||||||
|
|
||||||
@ -23,6 +25,7 @@ const ContentView = ({
|
|||||||
last: boolean
|
last: boolean
|
||||||
}) => {
|
}) => {
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View
|
<View
|
||||||
@ -37,16 +40,11 @@ const ContentView = ({
|
|||||||
) : null}
|
) : null}
|
||||||
{history.poll
|
{history.poll
|
||||||
? history.poll.options.map((option, index) => (
|
? history.poll.options.map((option, index) => (
|
||||||
<View
|
<View key={index} style={{ flex: 1, paddingVertical: StyleConstants.Spacing.S }}>
|
||||||
key={index}
|
|
||||||
style={{ flex: 1, paddingVertical: StyleConstants.Spacing.S }}
|
|
||||||
>
|
|
||||||
<View style={{ flex: 1, flexDirection: 'row' }}>
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||||
<Icon
|
<Icon
|
||||||
style={{
|
style={{
|
||||||
paddingTop:
|
paddingTop: StyleConstants.Font.LineHeight.M - StyleConstants.Font.Size.M,
|
||||||
StyleConstants.Font.LineHeight.M -
|
|
||||||
StyleConstants.Font.Size.M,
|
|
||||||
marginRight: StyleConstants.Spacing.S
|
marginRight: StyleConstants.Spacing.S
|
||||||
}}
|
}}
|
||||||
name='Circle'
|
name='Circle'
|
||||||
@ -54,17 +52,13 @@ const ContentView = ({
|
|||||||
color={colors.disabled}
|
color={colors.disabled}
|
||||||
/>
|
/>
|
||||||
<CustomText style={{ flex: 1 }}>
|
<CustomText style={{ flex: 1 }}>
|
||||||
<ParseEmojis
|
<ParseEmojis content={option.title} emojis={history.poll?.emojis} />
|
||||||
content={option.title}
|
|
||||||
emojis={history.poll?.emojis}
|
|
||||||
/>
|
|
||||||
</CustomText>
|
</CustomText>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
))
|
))
|
||||||
: null}
|
: null}
|
||||||
{Array.isArray(history.media_attachments) &&
|
{Array.isArray(history.media_attachments) && history.media_attachments.length ? (
|
||||||
history.media_attachments.length ? (
|
|
||||||
<TimelineAttachment status={history} />
|
<TimelineAttachment status={history} />
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
@ -73,15 +67,22 @@ const ContentView = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const TabSharedHistory: React.FC<
|
const TabSharedHistory: React.FC<TabSharedStackScreenProps<'Tab-Shared-History'>> = ({
|
||||||
TabSharedStackScreenProps<'Tab-Shared-History'>
|
navigation,
|
||||||
> = ({
|
|
||||||
route: {
|
route: {
|
||||||
params: { id }
|
params: { id }
|
||||||
}
|
}
|
||||||
}) => {
|
}) => {
|
||||||
|
const { t } = useTranslation('screenTabs')
|
||||||
const { data } = useStatusHistory({ id })
|
const { data } = useStatusHistory({ id })
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
navigation.setOptions({
|
||||||
|
title: t('shared.history.name'),
|
||||||
|
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
{data && data.length > 0
|
{data && data.length > 0
|
||||||
@ -90,12 +91,7 @@ const TabSharedHistory: React.FC<
|
|||||||
.reverse()
|
.reverse()
|
||||||
.map((d, i) =>
|
.map((d, i) =>
|
||||||
i !== 0 ? (
|
i !== 0 ? (
|
||||||
<ContentView
|
<ContentView key={i} history={d} first={i === 1} last={i === data.length - 1} />
|
||||||
key={i}
|
|
||||||
history={d}
|
|
||||||
first={i === 1}
|
|
||||||
last={i === data.length - 1}
|
|
||||||
/>
|
|
||||||
) : null
|
) : null
|
||||||
)
|
)
|
||||||
: null}
|
: null}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import ComponentAccount from '@components/Account'
|
import ComponentAccount from '@components/Account'
|
||||||
import ComponentHashtag from '@components/Hashtag'
|
import ComponentHashtag from '@components/Hashtag'
|
||||||
|
import { HeaderLeft } from '@components/Header'
|
||||||
import ComponentSeparator from '@components/Separator'
|
import ComponentSeparator from '@components/Separator'
|
||||||
import CustomText from '@components/Text'
|
import CustomText from '@components/Text'
|
||||||
import TimelineDefault from '@components/Timeline/Default'
|
import TimelineDefault from '@components/Timeline/Default'
|
||||||
@ -7,18 +8,80 @@ import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
|||||||
import { useSearchQuery } from '@utils/queryHooks/search'
|
import { useSearchQuery } 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 React, { useCallback, useMemo } from 'react'
|
import { debounce } from 'lodash'
|
||||||
|
import React, { useCallback, useEffect, useMemo } from 'react'
|
||||||
import { Trans, useTranslation } from 'react-i18next'
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
import { KeyboardAvoidingView, Platform, SectionList, StyleSheet, View } from 'react-native'
|
import {
|
||||||
|
KeyboardAvoidingView,
|
||||||
|
Platform,
|
||||||
|
SectionList,
|
||||||
|
StyleSheet,
|
||||||
|
TextInput,
|
||||||
|
View
|
||||||
|
} from 'react-native'
|
||||||
import { Circle } from 'react-native-animated-spinkit'
|
import { Circle } from 'react-native-animated-spinkit'
|
||||||
|
|
||||||
const TabSharedSearch: React.FC<TabSharedStackScreenProps<'Tab-Shared-Search'>> = ({
|
const TabSharedSearch: React.FC<TabSharedStackScreenProps<'Tab-Shared-Search'>> = ({
|
||||||
|
navigation,
|
||||||
route: {
|
route: {
|
||||||
params: { text }
|
params: { text }
|
||||||
}
|
}
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation('screenTabs')
|
const { t } = useTranslation('screenTabs')
|
||||||
const { colors } = useTheme()
|
const { colors, mode } = useTheme()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
navigation.setOptions({
|
||||||
|
...(Platform.OS === 'ios'
|
||||||
|
? {
|
||||||
|
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />
|
||||||
|
}
|
||||||
|
: { headerLeft: () => null }),
|
||||||
|
headerTitle: () => {
|
||||||
|
const onChangeText = debounce((text: string) => navigation.setParams({ text }), 1000, {
|
||||||
|
trailing: true
|
||||||
|
})
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flexBasis: '80%',
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextInput
|
||||||
|
editable={false}
|
||||||
|
style={{
|
||||||
|
fontSize: StyleConstants.Font.Size.M,
|
||||||
|
color: colors.primaryDefault
|
||||||
|
}}
|
||||||
|
defaultValue={t('shared.search.header.prefix')}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
accessibilityRole='search'
|
||||||
|
keyboardAppearance={mode}
|
||||||
|
style={{
|
||||||
|
fontSize: StyleConstants.Font.Size.M,
|
||||||
|
flex: 1,
|
||||||
|
color: colors.primaryDefault,
|
||||||
|
paddingLeft: StyleConstants.Spacing.XS
|
||||||
|
}}
|
||||||
|
autoFocus
|
||||||
|
onChangeText={onChangeText}
|
||||||
|
autoCapitalize='none'
|
||||||
|
autoCorrect={false}
|
||||||
|
clearButtonMode='never'
|
||||||
|
keyboardType='web-search'
|
||||||
|
onSubmitEditing={({ nativeEvent: { text } }) => navigation.setParams({ text })}
|
||||||
|
placeholder={t('shared.search.header.placeholder')}
|
||||||
|
placeholderTextColor={colors.secondary}
|
||||||
|
returnKeyType='go'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
const mapKeyToTranslations = {
|
const mapKeyToTranslations = {
|
||||||
accounts: t('shared.search.sections.accounts'),
|
accounts: t('shared.search.sections.accounts'),
|
||||||
|
@ -1,24 +1,34 @@
|
|||||||
|
import { HeaderLeft } from '@components/Header'
|
||||||
import Timeline from '@components/Timeline'
|
import Timeline from '@components/Timeline'
|
||||||
import TimelineDefault from '@components/Timeline/Default'
|
import TimelineDefault from '@components/Timeline/Default'
|
||||||
import { useNavigation } from '@react-navigation/native'
|
|
||||||
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
||||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import { FlatList } from 'react-native'
|
import { FlatList } from 'react-native'
|
||||||
import { InfiniteQueryObserver, useQueryClient } from 'react-query'
|
import { InfiniteQueryObserver, useQueryClient } from 'react-query'
|
||||||
|
|
||||||
const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||||
|
navigation,
|
||||||
route: {
|
route: {
|
||||||
params: { toot, rootQueryKey }
|
params: { toot, rootQueryKey }
|
||||||
}
|
}
|
||||||
}) => {
|
}) => {
|
||||||
|
const { t } = useTranslation('screenTabs')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
navigation.setOptions({
|
||||||
|
title: t('shared.toot.name'),
|
||||||
|
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Toot', toot: toot.id }]
|
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Toot', toot: toot.id }]
|
||||||
|
|
||||||
const flRef = useRef<FlatList>(null)
|
const flRef = useRef<FlatList>(null)
|
||||||
|
|
||||||
const [itemsLength, setItemsLength] = useState(0)
|
const [itemsLength, setItemsLength] = useState(0)
|
||||||
const scrolled = useRef(false)
|
const scrolled = useRef(false)
|
||||||
const navigation = useNavigation()
|
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const observer = new InfiniteQueryObserver(queryClient, {
|
const observer = new InfiniteQueryObserver(queryClient, {
|
||||||
queryKey,
|
queryKey,
|
||||||
|
@ -1,27 +1,34 @@
|
|||||||
import ComponentAccount from '@components/Account'
|
import ComponentAccount from '@components/Account'
|
||||||
|
import { HeaderLeft } from '@components/Header'
|
||||||
import ComponentSeparator from '@components/Separator'
|
import ComponentSeparator from '@components/Separator'
|
||||||
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
||||||
import { QueryKeyUsers, useUsersQuery } from '@utils/queryHooks/users'
|
import { QueryKeyUsers, useUsersQuery } from '@utils/queryHooks/users'
|
||||||
import React, { useCallback } from 'react'
|
import React, { useCallback, useEffect } from 'react'
|
||||||
import { StyleSheet } from 'react-native'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { FlatList } from 'react-native-gesture-handler'
|
import { FlatList } from 'react-native-gesture-handler'
|
||||||
|
|
||||||
const TabSharedUsers = React.memo(
|
const TabSharedUsers: React.FC<TabSharedStackScreenProps<'Tab-Shared-Users'>> = ({
|
||||||
({ route: { params } }: TabSharedStackScreenProps<'Tab-Shared-Users'>) => {
|
navigation,
|
||||||
|
route: { params }
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation('screenTabs')
|
||||||
|
useEffect(() => {
|
||||||
|
navigation.setOptions({
|
||||||
|
title: t(`shared.users.${params.reference}.${params.type}`, { count: params.count }),
|
||||||
|
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
const queryKey: QueryKeyUsers = ['Users', params]
|
const queryKey: QueryKeyUsers = ['Users', params]
|
||||||
const { data, hasNextPage, fetchNextPage, isFetchingNextPage } =
|
const { data, hasNextPage, fetchNextPage, isFetchingNextPage } = useUsersQuery({
|
||||||
useUsersQuery({
|
|
||||||
...queryKey[1],
|
...queryKey[1],
|
||||||
options: {
|
options: {
|
||||||
getPreviousPageParam: firstPage =>
|
getPreviousPageParam: firstPage =>
|
||||||
firstPage.links?.prev && { since_id: firstPage.links.next },
|
firstPage.links?.prev && { since_id: firstPage.links.next },
|
||||||
getNextPageParam: lastPage =>
|
getNextPageParam: lastPage => lastPage.links?.next && { max_id: lastPage.links.next }
|
||||||
lastPage.links?.next && { max_id: lastPage.links.next }
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const flattenData = data?.pages
|
const flattenData = data?.pages ? data.pages.flatMap(page => [...page.body]) : []
|
||||||
? data.pages.flatMap(page => [...page.body])
|
|
||||||
: []
|
|
||||||
|
|
||||||
const onEndReached = useCallback(
|
const onEndReached = useCallback(
|
||||||
() => hasNextPage && !isFetchingNextPage && fetchNextPage(),
|
() => hasNextPage && !isFetchingNextPage && fetchNextPage(),
|
||||||
@ -32,10 +39,10 @@ const TabSharedUsers = React.memo(
|
|||||||
<FlatList
|
<FlatList
|
||||||
windowSize={7}
|
windowSize={7}
|
||||||
data={flattenData}
|
data={flattenData}
|
||||||
style={styles.flatList}
|
style={{
|
||||||
renderItem={({ item }) => (
|
minHeight: '100%'
|
||||||
<ComponentAccount account={item} />
|
}}
|
||||||
)}
|
renderItem={({ item }) => <ComponentAccount account={item} />}
|
||||||
onEndReached={onEndReached}
|
onEndReached={onEndReached}
|
||||||
onEndReachedThreshold={0.75}
|
onEndReachedThreshold={0.75}
|
||||||
ItemSeparatorComponent={ComponentSeparator}
|
ItemSeparatorComponent={ComponentSeparator}
|
||||||
@ -45,14 +52,6 @@ const TabSharedUsers = React.memo(
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
() => true
|
|
||||||
)
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
flatList: {
|
|
||||||
minHeight: '100%'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export default TabSharedUsers
|
export default TabSharedUsers
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import { HeaderCenter, HeaderLeft } from '@components/Header'
|
|
||||||
import { ParseEmojis } from '@components/Parse'
|
|
||||||
import CustomText from '@components/Text'
|
|
||||||
import { createNativeStackNavigator } from '@react-navigation/native-stack'
|
import { createNativeStackNavigator } from '@react-navigation/native-stack'
|
||||||
import TabSharedAccount from '@screens/Tabs/Shared/Account'
|
import TabSharedAccount from '@screens/Tabs/Shared/Account'
|
||||||
import TabSharedAttachments from '@screens/Tabs/Shared/Attachments'
|
import TabSharedAttachments from '@screens/Tabs/Shared/Attachments'
|
||||||
@ -9,13 +6,9 @@ import TabSharedHistory from '@screens/Tabs/Shared/History'
|
|||||||
import TabSharedSearch from '@screens/Tabs/Shared/Search'
|
import TabSharedSearch from '@screens/Tabs/Shared/Search'
|
||||||
import TabSharedToot from '@screens/Tabs/Shared/Toot'
|
import TabSharedToot from '@screens/Tabs/Shared/Toot'
|
||||||
import TabSharedUsers from '@screens/Tabs/Shared/Users'
|
import TabSharedUsers from '@screens/Tabs/Shared/Users'
|
||||||
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import { debounce } from 'lodash'
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Trans, useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Platform, TextInput, View } from 'react-native'
|
|
||||||
import TabSharedAccountInLists from './AccountInLists'
|
import TabSharedAccountInLists from './AccountInLists'
|
||||||
|
|
||||||
const TabShared = ({ Stack }: { Stack: ReturnType<typeof createNativeStackNavigator> }) => {
|
const TabShared = ({ Stack }: { Stack: ReturnType<typeof createNativeStackNavigator> }) => {
|
||||||
@ -23,167 +16,35 @@ const TabShared = ({ Stack }: { Stack: ReturnType<typeof createNativeStackNaviga
|
|||||||
const { t } = useTranslation('screenTabs')
|
const { t } = useTranslation('screenTabs')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack.Group
|
<Stack.Group>
|
||||||
screenOptions={({ navigation }) => ({
|
|
||||||
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
key='Tab-Shared-Account'
|
key='Tab-Shared-Account'
|
||||||
name='Tab-Shared-Account'
|
name='Tab-Shared-Account'
|
||||||
component={TabSharedAccount}
|
component={TabSharedAccount}
|
||||||
options={({
|
|
||||||
navigation,
|
|
||||||
route: {
|
|
||||||
params: { account }
|
|
||||||
}
|
|
||||||
}: TabSharedStackScreenProps<'Tab-Shared-Account'>) => {
|
|
||||||
return {
|
|
||||||
headerTransparent: true,
|
|
||||||
headerStyle: {
|
|
||||||
backgroundColor: `rgba(255, 255, 255, 0)`
|
|
||||||
},
|
|
||||||
title: '',
|
|
||||||
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} background />
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
key='Tab-Shared-Account-In-Lists'
|
key='Tab-Shared-Account-In-Lists'
|
||||||
name='Tab-Shared-Account-In-Lists'
|
name='Tab-Shared-Account-In-Lists'
|
||||||
component={TabSharedAccountInLists}
|
component={TabSharedAccountInLists}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
key='Tab-Shared-Attachments'
|
key='Tab-Shared-Attachments'
|
||||||
name='Tab-Shared-Attachments'
|
name='Tab-Shared-Attachments'
|
||||||
component={TabSharedAttachments}
|
component={TabSharedAttachments}
|
||||||
options={({
|
|
||||||
route: {
|
|
||||||
params: { account }
|
|
||||||
}
|
|
||||||
}: TabSharedStackScreenProps<'Tab-Shared-Attachments'>) => {
|
|
||||||
return {
|
|
||||||
headerTitle: () => (
|
|
||||||
<CustomText numberOfLines={1}>
|
|
||||||
<Trans
|
|
||||||
i18nKey='screenTabs:shared.attachments.name'
|
|
||||||
components={[
|
|
||||||
<ParseEmojis
|
|
||||||
content={account.display_name || account.username}
|
|
||||||
emojis={account.emojis}
|
|
||||||
fontBold
|
|
||||||
/>,
|
|
||||||
<CustomText
|
|
||||||
fontStyle='M'
|
|
||||||
style={{ color: colors.primaryDefault }}
|
|
||||||
fontWeight='Bold'
|
|
||||||
/>
|
/>
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</CustomText>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
key='Tab-Shared-Hashtag'
|
key='Tab-Shared-Hashtag'
|
||||||
name='Tab-Shared-Hashtag'
|
name='Tab-Shared-Hashtag'
|
||||||
component={TabSharedHashtag}
|
component={TabSharedHashtag}
|
||||||
options={({ route }: TabSharedStackScreenProps<'Tab-Shared-Hashtag'>) => ({
|
|
||||||
title: `#${decodeURIComponent(route.params.hashtag)}`
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
key='Tab-Shared-History'
|
key='Tab-Shared-History'
|
||||||
name='Tab-Shared-History'
|
name='Tab-Shared-History'
|
||||||
component={TabSharedHistory}
|
component={TabSharedHistory}
|
||||||
options={{ title: t('screenTabs:shared.history.name') }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Stack.Screen
|
|
||||||
key='Tab-Shared-Search'
|
|
||||||
name='Tab-Shared-Search'
|
|
||||||
component={TabSharedSearch}
|
|
||||||
options={({ navigation }: TabSharedStackScreenProps<'Tab-Shared-Search'>) => ({
|
|
||||||
...(Platform.OS === 'ios'
|
|
||||||
? {
|
|
||||||
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />
|
|
||||||
}
|
|
||||||
: { headerLeft: () => null }),
|
|
||||||
headerTitle: () => {
|
|
||||||
const onChangeText = debounce((text: string) => navigation.setParams({ text }), 1000, {
|
|
||||||
trailing: true
|
|
||||||
})
|
|
||||||
return (
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
flexBasis: '80%',
|
|
||||||
flexDirection: 'row',
|
|
||||||
alignItems: 'center'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TextInput
|
|
||||||
editable={false}
|
|
||||||
style={{
|
|
||||||
fontSize: StyleConstants.Font.Size.M,
|
|
||||||
color: colors.primaryDefault
|
|
||||||
}}
|
|
||||||
defaultValue={t('shared.search.header.prefix')}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
accessibilityRole='search'
|
|
||||||
keyboardAppearance={mode}
|
|
||||||
style={{
|
|
||||||
fontSize: StyleConstants.Font.Size.M,
|
|
||||||
flex: 1,
|
|
||||||
color: colors.primaryDefault,
|
|
||||||
paddingLeft: StyleConstants.Spacing.XS
|
|
||||||
}}
|
|
||||||
autoFocus
|
|
||||||
onChangeText={onChangeText}
|
|
||||||
autoCapitalize='none'
|
|
||||||
autoCorrect={false}
|
|
||||||
clearButtonMode='never'
|
|
||||||
keyboardType='web-search'
|
|
||||||
onSubmitEditing={({ nativeEvent: { text } }) => navigation.setParams({ text })}
|
|
||||||
placeholder={t('shared.search.header.placeholder')}
|
|
||||||
placeholderTextColor={colors.secondary}
|
|
||||||
returnKeyType='go'
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Stack.Screen
|
|
||||||
key='Tab-Shared-Toot'
|
|
||||||
name='Tab-Shared-Toot'
|
|
||||||
component={TabSharedToot}
|
|
||||||
options={{ title: t('shared.toot.name') }}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Stack.Screen
|
|
||||||
key='Tab-Shared-Users'
|
|
||||||
name='Tab-Shared-Users'
|
|
||||||
component={TabSharedUsers}
|
|
||||||
options={({
|
|
||||||
route: {
|
|
||||||
params: { reference, type, count }
|
|
||||||
}
|
|
||||||
}: TabSharedStackScreenProps<'Tab-Shared-Users'>) => ({
|
|
||||||
title: t(`shared.users.${reference}.${type}`, { count }),
|
|
||||||
...(Platform.OS === 'android' && {
|
|
||||||
headerCenter: () => (
|
|
||||||
<HeaderCenter content={t(`shared.users.${reference}.${type}`, { count })} />
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
|
<Stack.Screen key='Tab-Shared-Search' name='Tab-Shared-Search' component={TabSharedSearch} />
|
||||||
|
<Stack.Screen key='Tab-Shared-Toot' name='Tab-Shared-Toot' component={TabSharedToot} />
|
||||||
|
<Stack.Screen key='Tab-Shared-Users' name='Tab-Shared-Users' component={TabSharedUsers} />
|
||||||
</Stack.Group>
|
</Stack.Group>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user