-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
83 lines (77 loc) · 1.83 KB
/
App.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import React from 'react';
import {
FlatList,
ImageBackground,
ListRenderItemInfo,
StyleSheet,
Text,
} from 'react-native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { Spacer } from 'react-native-spacer-view';
import {
BASE_UNIT,
DEFAULT_PADDING,
IMG_ASPECT_RATIO,
ITEMS,
type Item,
} from './constants';
function ListHeader() {
return (
<>
<Spacer safeTop height={DEFAULT_PADDING} />
<Text style={styles.listHeader}>Cool Bandz List</Text>
<Spacer height={BASE_UNIT} />
</>
);
}
export default function App() {
const renderItem = ({ item }: ListRenderItemInfo<Item>) => (
<ImageBackground style={styles.itemContainer} source={{ uri: item.image }}>
<Text style={styles.title}>{item.title}</Text>
<Text style={styles.subtitle}>{item.subtitle}</Text>
</ImageBackground>
);
const renderSeparator = () => <Spacer height={DEFAULT_PADDING} />;
return (
<SafeAreaProvider>
<FlatList
style={styles.container}
data={ITEMS}
renderItem={renderItem}
ItemSeparatorComponent={renderSeparator}
ListHeaderComponent={<ListHeader />}
ListFooterComponent={<Spacer safeBottom height={DEFAULT_PADDING * 2} />}
/>
</SafeAreaProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingHorizontal: DEFAULT_PADDING,
},
itemContainer: {
alignSelf: 'stretch',
aspectRatio: IMG_ASPECT_RATIO,
borderRadius: BASE_UNIT,
padding: DEFAULT_PADDING,
overflow: 'hidden',
justifyContent: 'flex-end',
},
listHeader: {
fontSize: 32,
fontWeight: '800',
},
title: {
color: 'white',
fontSize: 24,
lineHeight: 32,
fontWeight: '700',
},
subtitle: {
color: 'white',
fontSize: 16,
letterSpacing: -0.05,
lineHeight: 24,
},
});