tooot/src/components/Timelines/Timeline/Shared/HeaderDefault.tsx

65 lines
1.8 KiB
TypeScript
Raw Normal View History

2020-12-13 14:04:25 +01:00
import { StyleConstants } from '@utils/styles/constants'
2021-01-12 00:12:44 +01:00
import React from 'react'
import { StyleSheet, View } from 'react-native'
import HeaderSharedAccount from './HeaderShared/Account'
2021-01-01 23:10:47 +01:00
import HeaderSharedApplication from './HeaderShared/Application'
import HeaderSharedCreated from './HeaderShared/Created'
import HeaderSharedVisibility from './HeaderShared/Visibility'
2021-01-07 19:13:09 +01:00
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
2021-01-11 21:36:57 +01:00
import HeaderSharedMuted from './HeaderShared/Muted'
2021-01-12 00:12:44 +01:00
import HeaderActions from './HeaderActions/Root'
2020-10-25 01:35:41 +02:00
2020-10-31 21:04:46 +01:00
export interface Props {
2021-01-07 19:13:09 +01:00
queryKey?: QueryKeyTimeline
2020-12-03 01:28:56 +01:00
status: Mastodon.Status
2020-10-31 21:04:46 +01:00
}
2021-01-12 00:12:44 +01:00
const TimelineHeaderDefault: React.FC<Props> = ({ queryKey, status }) => {
2020-10-25 01:35:41 +02:00
return (
2020-12-12 22:19:18 +01:00
<View style={styles.base}>
2021-01-01 23:10:47 +01:00
<View style={styles.accountAndMeta}>
<HeaderSharedAccount account={status.account} />
2020-12-13 01:24:25 +01:00
<View style={styles.meta}>
2021-01-01 23:10:47 +01:00
<HeaderSharedCreated created_at={status.created_at} />
<HeaderSharedVisibility visibility={status.visibility} />
2021-01-11 21:36:57 +01:00
<HeaderSharedMuted muted={status.muted} />
2021-01-01 23:10:47 +01:00
<HeaderSharedApplication application={status.application} />
2020-12-13 01:24:25 +01:00
</View>
2020-10-25 01:35:41 +02:00
</View>
2020-12-03 01:28:56 +01:00
2021-01-19 01:13:45 +01:00
{queryKey ? (
<HeaderActions
queryKey={queryKey}
status={status}
url={status.url || status.uri}
type='status'
/>
) : null}
2020-10-25 01:35:41 +02:00
</View>
)
}
const styles = StyleSheet.create({
2020-12-12 22:19:18 +01:00
base: {
flex: 1,
flexDirection: 'row'
2020-12-13 01:24:25 +01:00
},
2021-01-01 23:10:47 +01:00
accountAndMeta: {
2021-01-24 02:25:43 +01:00
flex: 5
2020-10-25 01:35:41 +02:00
},
meta: {
2020-11-23 00:07:32 +01:00
flexDirection: 'row',
2020-11-29 18:08:31 +01:00
alignItems: 'center',
2020-11-30 00:24:53 +01:00
marginTop: StyleConstants.Spacing.XS,
marginBottom: StyleConstants.Spacing.S
2020-10-25 01:35:41 +02:00
},
created_at: {
...StyleConstants.FontStyle.S
2020-10-25 01:35:41 +02:00
}
})
2021-01-11 21:36:57 +01:00
export default React.memo(
TimelineHeaderDefault,
(prev, next) => prev.status.muted !== next.status.muted
)