-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathApp.tsx
More file actions
197 lines (188 loc) · 4.02 KB
/
Copy pathApp.tsx
File metadata and controls
197 lines (188 loc) · 4.02 KB
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { useNavigator, withNavigationItem } from 'hybrid-navigation';
import Lottie from 'lottie-react-native';
import { DemoItem, DemoList, demoTheme } from './demo/components/DemoKit';
interface Item extends DemoItem {
title: string;
routeName: string;
count: number;
}
const data: Array<Item> = [
{
title: 'NestedScroll',
routeName: 'NestedScroll',
subtitle: '吸顶、视差、分页和列表协同',
badge: '4 页',
count: 4,
accentColor: demoTheme.colors.green,
},
{
title: 'PullToRefresh',
routeName: 'PullToRefresh',
subtitle: '下拉刷新、分页容器和嵌套滚动',
badge: '10 页',
count: 10,
accentColor: demoTheme.colors.cyan,
},
{
title: 'BottomSheet',
routeName: 'BottomSheet',
subtitle: '半屏面板、遮罩、输入和列表',
badge: '5 页',
count: 5,
accentColor: demoTheme.colors.indigo,
},
{
title: 'Keyboard Insets',
routeName: 'Keyboard',
subtitle: '输入框避让、聊天面板和 Modal',
badge: '5 页',
count: 5,
accentColor: demoTheme.colors.orange,
},
{
title: 'Overlay',
routeName: 'Overlay',
subtitle: 'Toast、Alert 和悬浮入口',
badge: '3 页',
count: 3,
accentColor: demoTheme.colors.violet,
},
{
title: 'Image Crop',
routeName: 'ImageCropDemo',
subtitle: '头像、矩形裁剪和主体检测',
badge: '3 项',
count: 3,
accentColor: demoTheme.colors.rose,
},
{
title: 'Activity Indicator',
routeName: 'ActivityIndicator',
subtitle: 'Android 原生 Loading 指示器',
badge: '1 页',
count: 1,
accentColor: demoTheme.colors.blue,
},
{
title: 'WheelPicker',
routeName: 'WheelPicker',
subtitle: '城市与时间滚轮选择器',
badge: '1 页',
count: 1,
accentColor: demoTheme.colors.amber,
},
];
const totalScreens = data.reduce((sum, item) => sum + item.count, 0);
function App() {
const navigator = useNavigator();
return (
<DemoList
title="MyUiDemo"
subtitle="React Native 原生 UI 组件实验室"
eyebrow="Component Gallery"
data={data}
accentColor={demoTheme.colors.indigo}
headerMedia={<Header />}
onItemPress={item => navigator.push(item.routeName)}
/>
);
}
function Header() {
return (
<View>
<View style={styles.lottieStage}>
<Lottie
style={styles.lottie}
source={require('assets/trilo-3.json')}
autoPlay
loop
speed={1}
/>
<Lottie
style={styles.lottie}
source={require('assets/trilo-4.json')}
autoPlay
loop
speed={1}
/>
<Lottie
style={styles.lottie}
source={require('assets/trilo-5.json')}
autoPlay
loop
speed={1}
/>
</View>
<View style={styles.metrics}>
<Metric label="组件库" value={data.length} />
<Metric label="演示页" value={totalScreens} />
<Metric label="RN" value="0.84" last />
</View>
</View>
);
}
function Metric({
label,
value,
last = false,
}: {
label: string;
value: string | number;
last?: boolean;
}) {
return (
<View style={[styles.metric, !last && styles.metricSpacing]}>
<Text style={styles.metricValue}>{value}</Text>
<Text style={styles.metricLabel}>{label}</Text>
</View>
);
}
export default withNavigationItem({})(App);
const styles = StyleSheet.create({
lottieStage: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#FFFFFF',
borderRadius: 8,
borderWidth: StyleSheet.hairlineWidth,
borderColor: '#E4E7EC',
paddingVertical: 10,
},
lottie: {
height: 92,
width: 92,
},
metrics: {
flexDirection: 'row',
marginTop: 10,
},
metric: {
flex: 1,
height: 64,
backgroundColor: '#FFFFFF',
borderRadius: 8,
borderWidth: StyleSheet.hairlineWidth,
borderColor: '#E4E7EC',
alignItems: 'center',
justifyContent: 'center',
},
metricSpacing: {
marginRight: 8,
},
metricValue: {
color: '#121826',
fontSize: 20,
lineHeight: 25,
fontWeight: '800',
letterSpacing: 0,
},
metricLabel: {
color: '#667085',
fontSize: 12,
lineHeight: 16,
marginTop: 2,
},
});