-
Notifications
You must be signed in to change notification settings - Fork 136
/
feed.tsx
48 lines (40 loc) · 1.22 KB
/
feed.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react';
import { FlatList, View, StyleSheet } from 'react-native';
import { StackNavigationProp } from '@react-navigation/stack';
import { useTheme } from 'react-native-paper';
import { Twitt } from './components/twitt';
import { twitts } from './data';
import { StackNavigatorParamlist } from './types';
type TwittProps = React.ComponentProps<typeof Twitt>;
function renderItem({ item }: { item: TwittProps }) {
return <Twitt {...item} />;
}
function keyExtractor(item: TwittProps) {
return item.id.toString();
}
type Props = {
navigation?: StackNavigationProp<StackNavigatorParamlist>;
};
export const Feed = (props: Props) => {
const theme = useTheme();
const data = twitts.map(twittProps => ({
...twittProps,
onPress: () =>
props.navigation &&
props.navigation.push('Details', {
...twittProps,
}),
}));
return (
<FlatList
contentContainerStyle={{ backgroundColor: theme.colors.background }}
style={{ backgroundColor: theme.colors.background }}
data={data}
renderItem={renderItem}
keyExtractor={keyExtractor}
ItemSeparatorComponent={() => (
<View style={{ height: StyleSheet.hairlineWidth }} />
)}
/>
);
};