-
Notifications
You must be signed in to change notification settings - Fork 40
/
App.tsx
180 lines (175 loc) · 4.2 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import * as React from 'react'
import { StyleSheet, View, Text } from 'react-native';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import faker from 'faker';
import SectionList from 'react-native-tabs-section-list';
const SECTIONS = [
{
title: 'Burgers',
data: Array(5)
.fill(0)
.map(_ => ({
title: faker.commerce.productName(),
description: faker.lorem.lines(2),
price: faker.commerce.price()
}))
},
{
title: 'Pizza',
data: Array(5)
.fill(0)
.map(_ => ({
title: faker.commerce.productName(),
description: faker.lorem.lines(2),
price: faker.commerce.price()
}))
},
{
title: 'Sushi and rolls',
data: Array(10)
.fill(0)
.map(_ => ({
title: faker.commerce.productName(),
description: faker.lorem.lines(2),
price: faker.commerce.price()
}))
},
{
title: 'Salads',
data: Array(10)
.fill(0)
.map(_ => ({
title: faker.commerce.productName(),
description: faker.lorem.lines(2),
price: faker.commerce.price()
}))
},
{
title: 'Dessert',
data: Array(10)
.fill(0)
.map(_ => ({
title: faker.commerce.productName(),
description: faker.lorem.lines(2),
price: faker.commerce.price()
}))
}
];
class App extends React.Component {
static navigationOptions = {
title: 'Menu',
headerStyle: { borderBottomWidth: 0 }
};
render() {
return (
<View style={styles.container}>
<SectionList
sections={SECTIONS}
keyExtractor={item => item.title}
stickySectionHeadersEnabled={false}
scrollToLocationOffset={50}
tabBarStyle={styles.tabBar}
ItemSeparatorComponent={() => <View style={styles.separator} />}
renderTab={({ title, isActive }) => (
<View
style={[
styles.tabContainer,
{ borderBottomWidth: isActive ? 1 : 0 }
]}
>
<Text
style={[
styles.tabText,
{ color: isActive ? '#090909' : '#9e9e9e' }
]}
>
{title}
</Text>
</View>
)}
renderSectionHeader={({ section }) => (
<View>
<View style={styles.sectionHeaderContainer} />
<Text style={styles.sectionHeaderText}>{section.title}</Text>
</View>
)}
renderItem={({ item }) => (
<View style={styles.itemContainer}>
<View style={styles.itemRow}>
<Text style={styles.itemTitle}>{item.title}</Text>
<Text style={styles.itemPrice}>${item.price}</Text>
</View>
<Text style={styles.itemDescription}>{item.description}</Text>
</View>
)}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f6f6f6'
},
tabBar: {
backgroundColor: '#fff',
borderBottomColor: '#f4f4f4',
borderBottomWidth: 1
},
tabContainer: {
borderBottomColor: '#090909'
},
tabText: {
padding: 15,
color: '#9e9e9e',
fontSize: 18,
fontWeight: '500'
},
separator: {
height: 0.5,
width: '96%',
alignSelf: 'flex-end',
backgroundColor: '#eaeaea'
},
sectionHeaderContainer: {
height: 10,
backgroundColor: '#f6f6f6',
borderTopColor: '#f4f4f4',
borderTopWidth: 1,
borderBottomColor: '#f4f4f4',
borderBottomWidth: 1
},
sectionHeaderText: {
color: '#010101',
backgroundColor: '#fff',
fontSize: 23,
fontWeight: 'bold',
paddingTop: 25,
paddingBottom: 5,
paddingHorizontal: 15
},
itemContainer: {
paddingVertical: 20,
paddingHorizontal: 15,
backgroundColor: '#fff'
},
itemTitle: {
flex: 1,
fontSize: 20,
color: '#131313'
},
itemPrice: {
fontSize: 18,
color: '#131313'
},
itemDescription: {
marginTop: 10,
color: '#b6b6b6',
fontSize: 16
},
itemRow: {
flexDirection: 'row'
}
});
export default createAppContainer(createStackNavigator({ App }));