-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tsx
208 lines (186 loc) · 6.24 KB
/
index.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/**
* If you are not familiar with React Navigation, refer to the "Fundamentals" guide:
* https://reactnavigation.org/docs/getting-started
*
*/
import { FontAwesome, Ionicons } from '@expo/vector-icons';
import { BottomTabBar, createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { NavigationContainer, DefaultTheme, DarkTheme } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { ColorSchemeName, Pressable, View, Text, StyleSheet } from 'react-native';
import Colors from '../constants/Colors';
import useColorScheme from '../hooks/useColorScheme';
import ModalScreen from '../screens/ModalScreen';
import NotFoundScreen from '../screens/NotFoundScreen';
import TabOneScreen from '../screens/TabOneScreen';
import TabTwoScreen from '../screens/TabTwoScreen';
import { Reserva, RootStackParamList, RootTabParamList, RootTabScreenProps } from '../types';
import LinkingConfiguration from './LinkingConfiguration';
import { AntDesign } from '@expo/vector-icons';
import AddReserva from '../screens/AddEditReservaScreen';
import FloatingActionButton from '../components/FloatingActionButton';
import { createContext, useState } from 'react';
export default function Navigation({ colorScheme }: { colorScheme: ColorSchemeName }) {
return (
<NavigationContainer
linking={LinkingConfiguration}
theme={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
<RootNavigator />
</NavigationContainer>
);
}
/**
* A root stack navigator is often used for displaying modals on top of all other content.
* https://reactnavigation.org/docs/modal
*/
const Stack = createNativeStackNavigator<RootStackParamList>();
function RootNavigator() {
return (
<Stack.Navigator>
<Stack.Screen name="Root" component={BottomTabNavigator} options={{ headerShown: false }} />
<Stack.Screen name="NotFound" component={NotFoundScreen} options={{ title: 'Oops!' }} />
<Stack.Group screenOptions={{ presentation: 'modal' }}>
<Stack.Screen name="Modal" component={ModalScreen} />
<Stack.Screen name="AddReserva" component={AddReserva} options={{ title: 'Añadir o Editar Reserva' }} />
</Stack.Group>
</Stack.Navigator>
);
}
/**
* A bottom tab navigator displays tab buttons on the bottom of the display to switch screens.
* https://reactnavigation.org/docs/bottom-tab-navigator
*/
const BottomTab = createBottomTabNavigator<RootTabParamList>();
function BottomTabNavigator() {
const colorScheme = useColorScheme();
const [pressed, setPressed] = useState(false);
const handlePressIn = () => {
console.log("press");
setPressed(true);
};
const handlePressOut = () => {
setPressed(false);
};
return (
<BottomTab.Navigator
initialRouteName="TabOne"
screenOptions={{
tabBarShowLabel: true,
tabBarLabelStyle: {
fontSize: 10,
marginBottom: 8,
},
tabBarIconStyle: {
},
tabBarStyle: {
position: "absolute",
width: "70%",
bottom: 10,
left: 20,
right: 20,
borderColor: Colors[colorScheme].borderColor,
borderTopWidth: 0,
backgroundColor: "white",
borderRadius: 15,
height: 60,
shadowColor: '#dbdbdb',
shadowOffset: {
width: 0,
height: 0,
},
shadowOpacity: 0.7,
shadowRadius: 6.5,
elevation: 5,
},
}}
>
<BottomTab.Screen
name="TabOne"
component={TabOneScreen}
options={({ navigation }: RootTabScreenProps<'TabOne'>) => ({
title: 'Inicio',
tabBarIcon: ({ color }) => <AntDesign name="home" size={24} color={color} />,
headerRight: () => (
<Pressable
onPress={() => navigation.navigate('Modal')}
style={({ pressed }) => ({
opacity: pressed ? 0.5 : 1,
})}>
<AntDesign
name="setting"
size={20}
color={Colors[colorScheme].text}
style={{ marginRight: 15 }}
/>
</Pressable>
),
// headerLeft: () => (
// <View>
// <Text style={{ marginLeft: 10, fontSize: 8, textAlign: 'center' }}>GURE </Text>
// <Text style={{ marginLeft: 10, fontSize: 10, textAlign: 'center' }}>AMETSA</Text>
// </View>
// ),
})}
/>
{/* <BottomTab.Screen
name="AddReserva"
component={AddReserva}
options={({ navigation }: RootTabScreenProps<'AddReserva'>) => ({
title: "",
tabBarIcon: ({ color }) => <Ionicons name="ios-person-add-outline" size={24} color={color} />,
tabBarButton: (props) =>
<Pressable className="flex items-center justify-center" style={[styles.button, {
backgroundColor: Colors[colorScheme].backgroundCalendar,
}, pressed && styles.buttonPress]}
onPress={() => navigation.navigate('AddReserva')}
onPressIn={handlePressIn}
onPressOut={handlePressOut}>
<AntDesign name="adduser" size={32} color="white" />
</Pressable>,
})
}
/> */}
<BottomTab.Screen
name="TabTwo"
component={TabTwoScreen}
options={{
title: 'Configuración',
tabBarIcon: ({ color }) => <AntDesign name="setting" size={24} color={color} />,
}}
/>
</BottomTab.Navigator>
);
}
/**
* You can explore the built-in icon families and icons on the web at https://icons.expo.fyi/
*/
function TabBarIcon(props: {
name: React.ComponentProps<typeof FontAwesome>['name'];
color: string;
}) {
return <FontAwesome size={30} style={{ marginBottom: -3 }} {...props} />;
}
const styles = StyleSheet.create({
button: {
display: "flex",
justifyContent: "center",
alignItems: "center",
width: 60,
height: 60,
borderRadius: 30,
position: 'absolute',
bottom: 60,
right: 10,
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 5,
},
shadowOpacity: 0.34,
shadowRadius: 6.27,
elevation: 10,
},
buttonPress: {
opacity: 0.5,
},
});