-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
140 lines (130 loc) · 5.38 KB
/
App.js
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
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import Constants from 'expo-constants';
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native';
import { FontAwesome } from '@expo/vector-icons';
import { NavigationContainer } from '@react-navigation/native';
import { createSharedElementStackNavigator } from 'react-navigation-shared-element';
import { Entypo } from '@expo/vector-icons';
import { FontAwesome5 } from '@expo/vector-icons';
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { LinearGradient } from 'expo-linear-gradient';
import Home from './src/pages/Home';
import Test from './src/pages/Test';
import Details from './src/pages/Details'
const Stack = createSharedElementStackNavigator();
const Tab = createMaterialTopTabNavigator();
const WH = Constants.statusBarHeight;
export default function App() {
function MyTabBar({ state, descriptors, navigation }) {
return (
<LinearGradient start={{x: 0, y: 0}} end={{x: 1, y: 0}} colors={['#A871CE', '#7A5BC1']} style={{flex: 1, width: '100%', alignItems: 'center', maxHeight: 89}}>
<StatusBar style="light" />
<View style={{flex: 1, flexDirection: 'row', paddingTop: 48.5, maxHeight: 100, width: '100%'}}>
{state.routes.map((route, index) => {
const { options } = descriptors[route.key];
const label =
options.tabBarLabel !== undefined
? options.tabBarLabel
: options.title !== undefined
? options.title
: route.name;
const isFocused = state.index === index;
const onPress = () => {
const event = navigation.emit({
type: 'tabPress',
target: route.key,
});
if (!isFocused && !event.defaultPrevented) {
navigation.navigate(route.name);
}
};
const onLongPress = () => {
navigation.emit({
type: 'tabLongPress',
target: route.key,
});
};
return (
<TouchableOpacity
accessibilityRole="button"
accessibilityStates={isFocused ? ['selected'] : []}
accessibilityLabel={options.tabBarAccessibilityLabel}
testID={options.tabBarTestID}
onPress={onPress}
onLongPress={onLongPress}
style={{ flex: 1 , alignItems: 'center'}}
>
{route.name === 'Home' ?<FontAwesome name="ticket" size={24} color={isFocused ? '#FFF': '#C2BAD4'} style={{textAlign: 'center', marginTop: 5}} />
: route.name === 'Event' ? <Entypo name="megaphone" size={24} color={isFocused ? '#FFF': '#C2BAD4'} style={{textAlign: 'center', marginTop: 5}} />
: route.name === 'Mask' ? <FontAwesome5 name="theater-masks" size={24} color={isFocused ? '#FFF': '#C2BAD4'} style={{textAlign: 'center', marginTop: 5}} />
: route.name === 'Film'? <MaterialCommunityIcons name="movie-roll" size={24} color={isFocused ? '#FFF': '#C2BAD4'} style={{textAlign: 'center', marginTop: 5}} />
: <FontAwesome name="play-circle" size={24} color={isFocused ? '#FFF': '#C2BAD4'} style={{textAlign: 'center', marginTop: 5}} />}
{isFocused && <View style={{position: 'absolute', width: 35, marginTop: 39, height: 2, backgroundColor: '#FFF', borderRadius: 10}}></View>}
</TouchableOpacity>
);
})}
</View>
</LinearGradient>
);
}
function MyHome(){
return(
<Tab.Navigator swipeEnabled={false} initialRouteName="Event" tabBar={props => <MyTabBar {...props} />}>
<Tab.Screen name="Home" component={Test} />
<Tab.Screen name="Event" component={Home} />
<Tab.Screen name="Mask" component={Test} />
<Tab.Screen name="Film" component={Test} />
<Tab.Screen name="Play" component={Test} />
</Tab.Navigator>
)
}
return (
<NavigationContainer>
<Stack.Navigator headerMode="none" initialRouteName="Home">
<Stack.Screen name="Home" component={MyHome}
/>
<Stack.Screen name="Details" component={Details}
options={navigation => ({
cardStyleInterpolator: ({current: {progress}}) => {
return{
cardStyle: {
opacity: progress
}
}
}
})}
sharedElementsConfig = {( route ) => {
const { data } = route.params;
return [
{
id: `item.${data.id}.photo`,
animation: 'move',
resize: 'clip',
align: 'center-top'
},
{
id: `item.${data.id}.title`,
animation: 'fade',
resize: 'clip',
align: 'center'
},
{
id: `item.${data.id}.local`,
animation: 'fade',
resize: 'clip',
align: 'center'
},
{
id: `item.${data.id}.description`,
animation: 'fade',
resize: 'clip',
align: 'center'
},
];
}} />
</Stack.Navigator>
</NavigationContainer>
);
}