tsrntemp 1.1.2 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/template/.node-version +1 -1
- package/template/.prettierrc.js +15 -7
- package/template/Gemfile +6 -6
- package/template/Gemfile.lock +98 -0
- package/template/android/app/src/main/java/com/template/MainActivity.java +35 -40
- package/template/android/gradlew +234 -234
- package/template/ios/Podfile.lock +652 -0
- package/template/ios/template.xcodeproj/project.pbxproj +704 -702
- package/template/ios/template.xcworkspace/contents.xcworkspacedata +10 -0
- package/template/package.json +50 -49
- package/template/src/config/color.ts +37 -37
- package/template/src/config/routeArr.ts +25 -0
- package/template/src/pages/Home/index.tsx +24 -14
- package/template/src/pages/Login/index.tsx +58 -0
- package/template/src/pages/Mine/index.tsx +27 -14
- package/template/src/route/BottomTab.tsx +42 -9
- package/template/src/route/RouteContainer.tsx +152 -24
- package/template/src/types/RouteParamList.ts +4 -3
- package/template/src/utils/request.ts +5 -6
- package/template/src/utils/storage.ts +13 -15
- package/template/yarn.lock +1344 -1228
- package/template/.ruby-version +0 -1
- package/template/jest.config.js +0 -4
- package/template/src/config/routeConfig.ts +0 -11
- package/template/src/types/RoteConfig.ts +0 -9
package/template/package.json
CHANGED
@@ -1,49 +1,50 @@
|
|
1
|
-
{
|
2
|
-
"name": "template",
|
3
|
-
"version": "0.0.1",
|
4
|
-
"private": true,
|
5
|
-
"scripts": {
|
6
|
-
"android": "react-native run-android",
|
7
|
-
"ios": "react-native run-ios",
|
8
|
-
"lint": "eslint .",
|
9
|
-
"start": "react-native start",
|
10
|
-
"test": "jest"
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
"@react-
|
15
|
-
"@react-navigation/
|
16
|
-
"@react-navigation/native
|
17
|
-
"react": "
|
18
|
-
"react
|
19
|
-
"react-native
|
20
|
-
"react-native-
|
21
|
-
"react-native-
|
22
|
-
"react-native-
|
23
|
-
"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
"@babel/
|
28
|
-
"@babel/
|
29
|
-
"@babel/
|
30
|
-
"@
|
31
|
-
"@
|
32
|
-
"@
|
33
|
-
"@types/
|
34
|
-
"@types/react
|
35
|
-
"
|
36
|
-
"babel-
|
37
|
-
"babel-plugin-
|
38
|
-
"
|
39
|
-
"
|
40
|
-
"
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"react-
|
44
|
-
"
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
}
|
1
|
+
{
|
2
|
+
"name": "template",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"private": true,
|
5
|
+
"scripts": {
|
6
|
+
"android": "react-native run-android",
|
7
|
+
"ios": "react-native run-ios --simulator 'iPhone 14'",
|
8
|
+
"lint": "eslint .",
|
9
|
+
"start": "react-native start",
|
10
|
+
"test": "jest",
|
11
|
+
"icon": "npx iconfont-rn"
|
12
|
+
},
|
13
|
+
"dependencies": {
|
14
|
+
"@react-native-async-storage/async-storage": "^1.18.1",
|
15
|
+
"@react-navigation/bottom-tabs": "^6.5.7",
|
16
|
+
"@react-navigation/native": "^6.1.6",
|
17
|
+
"@react-navigation/native-stack": "^6.9.12",
|
18
|
+
"react": "18.2.0",
|
19
|
+
"react-native": "0.71.8",
|
20
|
+
"react-native-safe-area-context": "^4.5.3",
|
21
|
+
"react-native-screens": "^3.20.0",
|
22
|
+
"react-native-size-matters": "^0.4.0",
|
23
|
+
"react-native-svg": "^13.9.0",
|
24
|
+
"umi-request": "^1.4.0"
|
25
|
+
},
|
26
|
+
"devDependencies": {
|
27
|
+
"@babel/core": "^7.20.0",
|
28
|
+
"@babel/plugin-proposal-decorators": "^7.22.3",
|
29
|
+
"@babel/preset-env": "^7.20.0",
|
30
|
+
"@babel/runtime": "^7.20.0",
|
31
|
+
"@react-native-community/eslint-config": "^3.2.0",
|
32
|
+
"@tsconfig/react-native": "^2.0.2",
|
33
|
+
"@types/jest": "^29.2.1",
|
34
|
+
"@types/react": "^18.0.24",
|
35
|
+
"@types/react-test-renderer": "^18.0.0",
|
36
|
+
"babel-jest": "^29.2.1",
|
37
|
+
"babel-plugin-module-resolver": "^5.0.0",
|
38
|
+
"babel-plugin-transform-remove-console": "^6.9.4",
|
39
|
+
"eslint": "^8.19.0",
|
40
|
+
"jest": "^29.2.1",
|
41
|
+
"metro-react-native-babel-preset": "0.73.9",
|
42
|
+
"prettier": "^2.4.1",
|
43
|
+
"react-native-iconfont-cli": "^2.2.4",
|
44
|
+
"react-test-renderer": "18.2.0",
|
45
|
+
"typescript": "4.8.4"
|
46
|
+
},
|
47
|
+
"jest": {
|
48
|
+
"preset": "react-native"
|
49
|
+
}
|
50
|
+
}
|
@@ -11,10 +11,10 @@ export default {
|
|
11
11
|
600: '#0891b2',
|
12
12
|
700: '#0e7490',
|
13
13
|
800: '#155e75',
|
14
|
-
900: '#164e63'
|
14
|
+
900: '#164e63',
|
15
15
|
},
|
16
16
|
secondary: {
|
17
|
-
50: '
|
17
|
+
50: '#fdf2f8',
|
18
18
|
100: '#fce7f3',
|
19
19
|
200: '#fbcfe8',
|
20
20
|
300: '#f9a8d4',
|
@@ -35,19 +35,19 @@ export default {
|
|
35
35
|
600: '#059669',
|
36
36
|
700: '#047857',
|
37
37
|
800: '#065f46',
|
38
|
-
900: '#064e3b'
|
38
|
+
900: '#064e3b',
|
39
39
|
},
|
40
40
|
danger: {
|
41
41
|
50: '#fff1f2',
|
42
|
-
100: '
|
43
|
-
200: '
|
42
|
+
100: '#ffe4e6',
|
43
|
+
200: '#fecdd3',
|
44
44
|
300: '#fda4af',
|
45
45
|
400: '#fb7185',
|
46
46
|
500: '#f43f5e',
|
47
47
|
600: '#e11d48',
|
48
48
|
700: '#be123c',
|
49
49
|
800: '#9f1239',
|
50
|
-
900: '
|
50
|
+
900: '#881337',
|
51
51
|
},
|
52
52
|
error: {
|
53
53
|
50: '#fef2f2',
|
@@ -59,7 +59,7 @@ export default {
|
|
59
59
|
600: '#dc2626',
|
60
60
|
700: '#b91c1c',
|
61
61
|
800: '#991b1b',
|
62
|
-
900: '#7f1d1d'
|
62
|
+
900: '#7f1d1d',
|
63
63
|
},
|
64
64
|
success: {
|
65
65
|
50: '#f0fdf4',
|
@@ -71,7 +71,7 @@ export default {
|
|
71
71
|
600: '#16a34a',
|
72
72
|
700: '#15803d',
|
73
73
|
800: '#166534',
|
74
|
-
900: '#14532d'
|
74
|
+
900: '#14532d',
|
75
75
|
},
|
76
76
|
warning: {
|
77
77
|
50: '#fff7ed',
|
@@ -83,7 +83,7 @@ export default {
|
|
83
83
|
600: '#ea580c',
|
84
84
|
700: '#c2410c',
|
85
85
|
800: '#9a3412',
|
86
|
-
900: '#7c2d12'
|
86
|
+
900: '#7c2d12',
|
87
87
|
},
|
88
88
|
|
89
89
|
muted: {
|
@@ -96,7 +96,7 @@ export default {
|
|
96
96
|
600: '#525252',
|
97
97
|
700: '#404040',
|
98
98
|
800: '#262626',
|
99
|
-
900: '#171717'
|
99
|
+
900: '#171717',
|
100
100
|
},
|
101
101
|
|
102
102
|
info: {
|
@@ -109,7 +109,7 @@ export default {
|
|
109
109
|
600: '#0284c7',
|
110
110
|
700: '#0369a1',
|
111
111
|
800: '#075985',
|
112
|
-
900: '#0c4a6e'
|
112
|
+
900: '#0c4a6e',
|
113
113
|
},
|
114
114
|
|
115
115
|
light: {
|
@@ -122,7 +122,7 @@ export default {
|
|
122
122
|
600: '#57534e',
|
123
123
|
700: '#44403c',
|
124
124
|
800: '#292524',
|
125
|
-
900: '#1c1917'
|
125
|
+
900: '#1c1917',
|
126
126
|
},
|
127
127
|
rose: {
|
128
128
|
50: '#fff1f2',
|
@@ -134,7 +134,7 @@ export default {
|
|
134
134
|
600: '#e11d48',
|
135
135
|
700: '#be123c',
|
136
136
|
800: '#9f1239',
|
137
|
-
900: '#881337'
|
137
|
+
900: '#881337',
|
138
138
|
},
|
139
139
|
pink: {
|
140
140
|
50: '#fdf2f8',
|
@@ -146,7 +146,7 @@ export default {
|
|
146
146
|
600: '#db2777',
|
147
147
|
700: '#be185d',
|
148
148
|
800: '#9d174d',
|
149
|
-
900: '#831843'
|
149
|
+
900: '#831843',
|
150
150
|
},
|
151
151
|
fuchsia: {
|
152
152
|
50: '#fdf4ff',
|
@@ -158,7 +158,7 @@ export default {
|
|
158
158
|
600: '#c026d3',
|
159
159
|
700: '#a21caf',
|
160
160
|
800: '#86198f',
|
161
|
-
900: '#701a75'
|
161
|
+
900: '#701a75',
|
162
162
|
},
|
163
163
|
purple: {
|
164
164
|
50: '#faf5ff',
|
@@ -170,7 +170,7 @@ export default {
|
|
170
170
|
600: '#9333ea',
|
171
171
|
700: '#7e22ce',
|
172
172
|
800: '#6b21a8',
|
173
|
-
900: '#581c87'
|
173
|
+
900: '#581c87',
|
174
174
|
},
|
175
175
|
violet: {
|
176
176
|
50: '#f5f3ff',
|
@@ -182,7 +182,7 @@ export default {
|
|
182
182
|
600: '#7c3aed',
|
183
183
|
700: '#6d28d9',
|
184
184
|
800: '#5b21b6',
|
185
|
-
900: '#4c1d95'
|
185
|
+
900: '#4c1d95',
|
186
186
|
},
|
187
187
|
indigo: {
|
188
188
|
50: '#eef2ff',
|
@@ -194,7 +194,7 @@ export default {
|
|
194
194
|
600: '#4f46e5',
|
195
195
|
700: '#4338ca',
|
196
196
|
800: '#3730a3',
|
197
|
-
900: '#312e81'
|
197
|
+
900: '#312e81',
|
198
198
|
},
|
199
199
|
blue: {
|
200
200
|
50: '#eff6ff',
|
@@ -206,7 +206,7 @@ export default {
|
|
206
206
|
600: '#2563eb',
|
207
207
|
700: '#1d4ed8',
|
208
208
|
800: '#1e40af',
|
209
|
-
900: '#1e3a8a'
|
209
|
+
900: '#1e3a8a',
|
210
210
|
},
|
211
211
|
lightBlue: {
|
212
212
|
50: '#f0f9ff',
|
@@ -218,7 +218,7 @@ export default {
|
|
218
218
|
600: '#0284c7',
|
219
219
|
700: '#0369a1',
|
220
220
|
800: '#075985',
|
221
|
-
900: '#0c4a6e'
|
221
|
+
900: '#0c4a6e',
|
222
222
|
},
|
223
223
|
darkBlue: {
|
224
224
|
50: '#dbf4ff',
|
@@ -230,7 +230,7 @@ export default {
|
|
230
230
|
600: '#005db4',
|
231
231
|
700: '#004282',
|
232
232
|
800: '#002851',
|
233
|
-
900: '#000e21'
|
233
|
+
900: '#000e21',
|
234
234
|
},
|
235
235
|
cyan: {
|
236
236
|
50: '#ecfeff',
|
@@ -242,7 +242,7 @@ export default {
|
|
242
242
|
600: '#0891b2',
|
243
243
|
700: '#0e7490',
|
244
244
|
800: '#155e75',
|
245
|
-
900: '#164e63'
|
245
|
+
900: '#164e63',
|
246
246
|
},
|
247
247
|
teal: {
|
248
248
|
50: '#f0fdfa',
|
@@ -254,7 +254,7 @@ export default {
|
|
254
254
|
600: '#0d9488',
|
255
255
|
700: '#0f766e',
|
256
256
|
800: '#115e59',
|
257
|
-
900: '#134e4a'
|
257
|
+
900: '#134e4a',
|
258
258
|
},
|
259
259
|
emerald: {
|
260
260
|
50: '#ecfdf5',
|
@@ -266,7 +266,7 @@ export default {
|
|
266
266
|
600: '#059669',
|
267
267
|
700: '#047857',
|
268
268
|
800: '#065f46',
|
269
|
-
900: '#064e3b'
|
269
|
+
900: '#064e3b',
|
270
270
|
},
|
271
271
|
green: {
|
272
272
|
50: '#f0fdf4',
|
@@ -278,7 +278,7 @@ export default {
|
|
278
278
|
600: '#16a34a',
|
279
279
|
700: '#15803d',
|
280
280
|
800: '#166534',
|
281
|
-
900: '#14532d'
|
281
|
+
900: '#14532d',
|
282
282
|
},
|
283
283
|
lime: {
|
284
284
|
50: '#f7fee7',
|
@@ -290,7 +290,7 @@ export default {
|
|
290
290
|
600: '#65a30d',
|
291
291
|
700: '#4d7c0f',
|
292
292
|
800: '#3f6212',
|
293
|
-
900: '#365314'
|
293
|
+
900: '#365314',
|
294
294
|
},
|
295
295
|
yellow: {
|
296
296
|
50: '#fefce8',
|
@@ -302,7 +302,7 @@ export default {
|
|
302
302
|
600: '#ca8a04',
|
303
303
|
700: '#a16207',
|
304
304
|
800: '#854d0e',
|
305
|
-
900: '#713f12'
|
305
|
+
900: '#713f12',
|
306
306
|
},
|
307
307
|
amber: {
|
308
308
|
50: '#fffbeb',
|
@@ -314,7 +314,7 @@ export default {
|
|
314
314
|
600: '#d97706',
|
315
315
|
700: '#b45309',
|
316
316
|
800: '#92400e',
|
317
|
-
900: '#78350f'
|
317
|
+
900: '#78350f',
|
318
318
|
},
|
319
319
|
orange: {
|
320
320
|
50: '#fff7ed',
|
@@ -326,7 +326,7 @@ export default {
|
|
326
326
|
600: '#ea580c',
|
327
327
|
700: '#c2410c',
|
328
328
|
800: '#9a3412',
|
329
|
-
900: '#7c2d12'
|
329
|
+
900: '#7c2d12',
|
330
330
|
},
|
331
331
|
red: {
|
332
332
|
50: '#fef2f2',
|
@@ -338,7 +338,7 @@ export default {
|
|
338
338
|
600: '#dc2626',
|
339
339
|
700: '#b91c1c',
|
340
340
|
800: '#991b1b',
|
341
|
-
900: '#7f1d1d'
|
341
|
+
900: '#7f1d1d',
|
342
342
|
},
|
343
343
|
warmGray: {
|
344
344
|
50: '#fafaf9',
|
@@ -350,7 +350,7 @@ export default {
|
|
350
350
|
600: '#57534e',
|
351
351
|
700: '#44403c',
|
352
352
|
800: '#292524',
|
353
|
-
900: '#1c1917'
|
353
|
+
900: '#1c1917',
|
354
354
|
},
|
355
355
|
trueGray: {
|
356
356
|
50: '#fafafa',
|
@@ -362,7 +362,7 @@ export default {
|
|
362
362
|
600: '#525252',
|
363
363
|
700: '#404040',
|
364
364
|
800: '#262626',
|
365
|
-
900: '#171717'
|
365
|
+
900: '#171717',
|
366
366
|
},
|
367
367
|
gray: {
|
368
368
|
50: '#fafafa',
|
@@ -374,7 +374,7 @@ export default {
|
|
374
374
|
600: '#52525b',
|
375
375
|
700: '#3f3f46',
|
376
376
|
800: '#27272a',
|
377
|
-
900: '#18181b'
|
377
|
+
900: '#18181b',
|
378
378
|
},
|
379
379
|
coolGray: {
|
380
380
|
50: '#f9fafb',
|
@@ -386,7 +386,7 @@ export default {
|
|
386
386
|
600: '#4b5563',
|
387
387
|
700: '#374151',
|
388
388
|
800: '#1f2937',
|
389
|
-
900: '#111827'
|
389
|
+
900: '#111827',
|
390
390
|
},
|
391
391
|
blueGray: {
|
392
392
|
50: '#f8fafc',
|
@@ -410,6 +410,6 @@ export default {
|
|
410
410
|
600: '#d4d4d8',
|
411
411
|
700: '#e4e4e7',
|
412
412
|
800: '#f4f4f5',
|
413
|
-
900: '#fafafa'
|
414
|
-
}
|
415
|
-
}
|
413
|
+
900: '#fafafa',
|
414
|
+
},
|
415
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import {StackParamList} from 'types/RouteParamList';
|
3
|
+
import {RouteProp} from '@react-navigation/core/lib/typescript/src/types';
|
4
|
+
import {NativeStackNavigationOptions} from '@react-navigation/native-stack';
|
5
|
+
import BottomTab, {getCurentTabName} from 'route/BottomTab';
|
6
|
+
|
7
|
+
type RoutesConfig = {
|
8
|
+
name: keyof StackParamList;
|
9
|
+
component: React.ComponentType<any>;
|
10
|
+
options?:
|
11
|
+
| NativeStackNavigationOptions
|
12
|
+
| ((props: {
|
13
|
+
route: RouteProp<StackParamList, keyof StackParamList>;
|
14
|
+
navigation: any;
|
15
|
+
}) => NativeStackNavigationOptions);
|
16
|
+
};
|
17
|
+
const RouteArr: RoutesConfig[] = [
|
18
|
+
{
|
19
|
+
name: 'BottomTab',
|
20
|
+
component: BottomTab,
|
21
|
+
options: ({route}) => getCurentTabName(route),
|
22
|
+
},
|
23
|
+
];
|
24
|
+
|
25
|
+
export default RouteArr;
|
@@ -1,18 +1,28 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
2
|
+
import {View, Text} from 'react-native';
|
3
|
+
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
4
|
+
import {BottomTabScreenProps} from '@react-navigation/bottom-tabs';
|
5
|
+
import {BottomTabParamList} from 'types/RouteParamList';
|
3
6
|
|
4
|
-
|
5
|
-
|
6
|
-
super(props);
|
7
|
-
}
|
7
|
+
const Home: React.FC<BottomTabScreenProps<BottomTabParamList>> = () => {
|
8
|
+
const insets = useSafeAreaInsets();
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
);
|
16
|
-
}
|
17
|
-
}
|
10
|
+
return (
|
11
|
+
<View
|
12
|
+
style={{
|
13
|
+
flex: 1,
|
14
|
+
justifyContent: 'space-between',
|
15
|
+
alignItems: 'center',
|
18
16
|
|
17
|
+
// Paddings to handle safe area
|
18
|
+
paddingTop: insets.top,
|
19
|
+
paddingBottom: insets.bottom,
|
20
|
+
paddingLeft: insets.left,
|
21
|
+
paddingRight: insets.right,
|
22
|
+
}}>
|
23
|
+
<Text>Home Component</Text>
|
24
|
+
</View>
|
25
|
+
);
|
26
|
+
};
|
27
|
+
|
28
|
+
export default Home;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import {
|
3
|
+
View,
|
4
|
+
TextInput,
|
5
|
+
StyleSheet,
|
6
|
+
TouchableOpacity,
|
7
|
+
Text,
|
8
|
+
} from 'react-native';
|
9
|
+
import color from 'config/color';
|
10
|
+
import {AuthContext} from 'route/RouteContainer';
|
11
|
+
|
12
|
+
const Login: React.FC = () => {
|
13
|
+
const {signIn} = React.useContext(AuthContext);
|
14
|
+
return (
|
15
|
+
<View style={styles.content}>
|
16
|
+
<TextInput placeholder="Username" style={[styles.input]} />
|
17
|
+
<TextInput
|
18
|
+
placeholder="Password"
|
19
|
+
secureTextEntry
|
20
|
+
style={[styles.input]}
|
21
|
+
/>
|
22
|
+
<TouchableOpacity
|
23
|
+
style={styles.btn}
|
24
|
+
onPress={() => signIn({userInfo: 'xxx'})}>
|
25
|
+
<Text style={styles.text}>登录</Text>
|
26
|
+
</TouchableOpacity>
|
27
|
+
</View>
|
28
|
+
);
|
29
|
+
};
|
30
|
+
|
31
|
+
const styles = StyleSheet.create({
|
32
|
+
content: {
|
33
|
+
flex: 1,
|
34
|
+
padding: 16,
|
35
|
+
justifyContent: 'center',
|
36
|
+
},
|
37
|
+
input: {
|
38
|
+
margin: 8,
|
39
|
+
padding: 10,
|
40
|
+
borderRadius: 3,
|
41
|
+
borderWidth: StyleSheet.hairlineWidth,
|
42
|
+
borderColor: color.primary[400],
|
43
|
+
},
|
44
|
+
button: {
|
45
|
+
margin: 8,
|
46
|
+
},
|
47
|
+
text: {
|
48
|
+
textAlign: 'center',
|
49
|
+
margin: 8,
|
50
|
+
},
|
51
|
+
btn: {
|
52
|
+
backgroundColor: color.primary[400],
|
53
|
+
marginTop: 16,
|
54
|
+
borderRadius: 5,
|
55
|
+
},
|
56
|
+
});
|
57
|
+
|
58
|
+
export default Login;
|
@@ -1,19 +1,32 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
2
|
+
import {View, Text, TouchableOpacity} from 'react-native';
|
3
|
+
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
4
|
+
import {AuthContext} from 'route/RouteContainer';
|
5
|
+
import {BottomTabScreenProps} from '@react-navigation/bottom-tabs';
|
6
|
+
import {BottomTabParamList} from 'types/RouteParamList';
|
3
7
|
|
8
|
+
const Mine: React.FC<BottomTabScreenProps<BottomTabParamList>> = () => {
|
9
|
+
const insets = useSafeAreaInsets();
|
10
|
+
const {signOut} = React.useContext(AuthContext);
|
4
11
|
|
12
|
+
return (
|
13
|
+
<View
|
14
|
+
style={{
|
15
|
+
flex: 1,
|
16
|
+
justifyContent: 'space-between',
|
17
|
+
alignItems: 'center',
|
5
18
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
}
|
19
|
+
// Paddings to handle safe area
|
20
|
+
paddingTop: insets.top,
|
21
|
+
paddingBottom: insets.bottom,
|
22
|
+
paddingLeft: insets.left,
|
23
|
+
paddingRight: insets.right,
|
24
|
+
}}>
|
25
|
+
<TouchableOpacity onPress={signOut}>
|
26
|
+
<Text>退出登录</Text>
|
27
|
+
</TouchableOpacity>
|
28
|
+
</View>
|
29
|
+
);
|
30
|
+
};
|
19
31
|
|
32
|
+
export default Mine;
|
@@ -1,31 +1,64 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
3
|
-
import {
|
2
|
+
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
|
3
|
+
import {BottomTabParamList, StackParamList} from 'types/RouteParamList';
|
4
4
|
import Home from 'pages/Home';
|
5
5
|
import Mine from 'pages/Mine';
|
6
6
|
import IconFont from 'iconfont';
|
7
7
|
import color from 'config/color';
|
8
|
+
import {getFocusedRouteNameFromRoute} from '@react-navigation/native';
|
9
|
+
import {RouteProp} from '@react-navigation/core/lib/typescript/src/types';
|
10
|
+
import {NativeStackNavigationOptions} from '@react-navigation/native-stack';
|
8
11
|
|
9
12
|
const Tab = createBottomTabNavigator<BottomTabParamList>();
|
10
13
|
|
14
|
+
export function getCurentTabName(
|
15
|
+
route: RouteProp<StackParamList>,
|
16
|
+
): NativeStackNavigationOptions {
|
17
|
+
let routeName = getFocusedRouteNameFromRoute(route) ?? '首页';
|
18
|
+
switch (routeName) {
|
19
|
+
case 'Home':
|
20
|
+
routeName = '首页';
|
21
|
+
break;
|
22
|
+
case 'Mine':
|
23
|
+
routeName = '我的';
|
24
|
+
break;
|
25
|
+
default:
|
26
|
+
routeName = '首页';
|
27
|
+
break;
|
28
|
+
}
|
29
|
+
return {
|
30
|
+
headerTitle: routeName,
|
31
|
+
};
|
32
|
+
}
|
11
33
|
|
12
34
|
const BottomTab: React.FC = () => {
|
13
35
|
return (
|
14
36
|
<Tab.Navigator
|
15
|
-
screenOptions={{
|
16
|
-
|
37
|
+
screenOptions={{
|
38
|
+
tabBarActiveTintColor: color.primary[400],
|
39
|
+
headerShown: false,
|
40
|
+
}}
|
41
|
+
backBehavior={'none'}>
|
17
42
|
<Tab.Screen
|
18
43
|
name={'Home'}
|
19
44
|
component={Home}
|
20
|
-
options={{
|
45
|
+
options={{
|
46
|
+
tabBarIcon: ({color, size}) => (
|
47
|
+
<IconFont name="index" size={size} color={color} />
|
48
|
+
),
|
49
|
+
}}
|
21
50
|
/>
|
22
51
|
<Tab.Screen
|
23
52
|
name={'Mine'}
|
24
53
|
component={Mine}
|
25
|
-
options={{
|
54
|
+
options={{
|
55
|
+
tabBarIcon: ({color, size}) => (
|
56
|
+
<IconFont name="mine" size={size} color={color} />
|
57
|
+
),
|
58
|
+
}}
|
26
59
|
/>
|
27
60
|
</Tab.Navigator>
|
28
|
-
)
|
29
|
-
}
|
61
|
+
);
|
62
|
+
};
|
30
63
|
|
31
|
-
export default BottomTab
|
64
|
+
export default BottomTab;
|