2022-12-03 16:50:54 +01:00
|
|
|
import { HeaderLeft } from '@components/Header'
|
2022-04-29 23:57:18 +02:00
|
|
|
import Icon from '@components/Icon'
|
|
|
|
import { ParseEmojis } from '@components/Parse'
|
|
|
|
import ComponentSeparator from '@components/Separator'
|
2022-05-07 00:52:32 +02:00
|
|
|
import CustomText from '@components/Text'
|
2022-04-29 23:57:18 +02:00
|
|
|
import TimelineAttachment from '@components/Timeline/Shared/Attachment'
|
|
|
|
import TimelineContent from '@components/Timeline/Shared/Content'
|
2022-12-03 21:14:00 +01:00
|
|
|
import StatusContext from '@components/Timeline/Shared/Context'
|
2022-04-29 23:57:18 +02:00
|
|
|
import HeaderSharedCreated from '@components/Timeline/Shared/HeaderShared/Created'
|
|
|
|
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
|
|
|
import { useStatusHistory } from '@utils/queryHooks/statusesHistory'
|
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
|
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
2022-12-03 16:50:54 +01:00
|
|
|
import React, { useEffect } from 'react'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
2022-12-03 21:14:00 +01:00
|
|
|
import { FlatList, View } from 'react-native'
|
2022-04-29 23:57:18 +02:00
|
|
|
|
2022-12-03 21:14:00 +01:00
|
|
|
const ContentView: React.FC<{ item: Mastodon.StatusHistory }> = ({ item }) => {
|
2022-04-29 23:57:18 +02:00
|
|
|
const { colors } = useTheme()
|
2022-12-03 16:50:54 +01:00
|
|
|
|
2022-04-29 23:57:18 +02:00
|
|
|
return (
|
2022-12-03 21:14:00 +01:00
|
|
|
// @ts-ignore
|
|
|
|
<StatusContext.Provider value={{ status: item, disableOnPress: true }}>
|
|
|
|
<HeaderSharedCreated created_at={item.created_at} />
|
|
|
|
<TimelineContent />
|
|
|
|
{item.poll?.options.map((option, index) => (
|
|
|
|
<View key={index} style={{ flex: 1, paddingVertical: StyleConstants.Spacing.XS }}>
|
|
|
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
|
|
|
<Icon
|
|
|
|
style={{
|
|
|
|
paddingTop: StyleConstants.Font.LineHeight.M - StyleConstants.Font.Size.M,
|
|
|
|
marginRight: StyleConstants.Spacing.S
|
|
|
|
}}
|
|
|
|
name='Circle'
|
|
|
|
size={StyleConstants.Font.Size.M}
|
|
|
|
color={colors.disabled}
|
|
|
|
/>
|
|
|
|
<CustomText style={{ flex: 1 }}>
|
|
|
|
<ParseEmojis content={option.title} emojis={item.poll?.emojis} />
|
|
|
|
</CustomText>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
))}
|
|
|
|
<TimelineAttachment />
|
|
|
|
</StatusContext.Provider>
|
2022-04-29 23:57:18 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:50:54 +01:00
|
|
|
const TabSharedHistory: React.FC<TabSharedStackScreenProps<'Tab-Shared-History'>> = ({
|
|
|
|
navigation,
|
2022-04-29 23:57:18 +02:00
|
|
|
route: {
|
|
|
|
params: { id }
|
|
|
|
}
|
|
|
|
}) => {
|
2022-12-03 16:50:54 +01:00
|
|
|
const { t } = useTranslation('screenTabs')
|
2022-04-29 23:57:18 +02:00
|
|
|
const { data } = useStatusHistory({ id })
|
|
|
|
|
2022-12-03 16:50:54 +01:00
|
|
|
useEffect(() => {
|
|
|
|
navigation.setOptions({
|
|
|
|
title: t('shared.history.name'),
|
|
|
|
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />
|
|
|
|
})
|
|
|
|
}, [])
|
|
|
|
|
2022-04-29 23:57:18 +02:00
|
|
|
return (
|
2022-12-03 21:14:00 +01:00
|
|
|
<FlatList
|
|
|
|
style={{ flex: 1, minHeight: '100%', padding: StyleConstants.Spacing.Global.PagePadding }}
|
|
|
|
data={
|
|
|
|
data && data.length > 0
|
|
|
|
? data
|
|
|
|
.slice(0)
|
|
|
|
.reverse()
|
|
|
|
.filter((_, index) => index !== 0)
|
|
|
|
: []
|
|
|
|
}
|
|
|
|
renderItem={({ item }) => <ContentView item={item} />}
|
|
|
|
ItemSeparatorComponent={() => (
|
|
|
|
<ComponentSeparator
|
|
|
|
extraMarginLeft={0}
|
|
|
|
style={{ marginVertical: StyleConstants.Spacing.Global.PagePadding }}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
2022-04-29 23:57:18 +02:00
|
|
|
)
|
2022-12-03 21:14:00 +01:00
|
|
|
|
|
|
|
// return (
|
|
|
|
// <ScrollView>
|
|
|
|
// {data && data.length > 0
|
|
|
|
// ? data
|
|
|
|
// .slice(0)
|
|
|
|
// .reverse()
|
|
|
|
// .map((d, i) =>
|
|
|
|
// i !== 0 ? (
|
|
|
|
// <ContentView key={i} history={d} first={i === 1} last={i === data.length - 1} />
|
|
|
|
// ) : null
|
|
|
|
// )
|
|
|
|
// : null}
|
|
|
|
// </ScrollView>
|
|
|
|
// )
|
2022-04-29 23:57:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export default TabSharedHistory
|