-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
76 lines (72 loc) · 2.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
import React, { useRef } from "react";
//Allows navigation
import { NavigationContainer } from "@react-navigation/native";
import * as SecureStore from "expo-secure-store";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import Login from "./screens/Login.js";
import MyTrainings from "./screens/MyTrainings.js";
import WorkoutDetails from "./screens/WorkoutDetails.js";
import { createContext } from "react";
import AddWorkout from "./screens/AddWorkout.js";
import { custom } from "./styles/styles.js";
import Loading from "./screens/Loading.js";
import { LogBox, TouchableOpacity, Text } from "react-native";
import EditWorkoutDay from "./screens/EditWorkoutDay.js";
//Ignore all warnings
LogBox.ignoreAllLogs();
//Navigation into the app
const Stack = createNativeStackNavigator();
//Creating the context
export const appContext = createContext();
export default function App() {
const glbEmail = useRef("");
return (
<appContext.Provider value={glbEmail}>
<Initialize styles={custom.container} />
</appContext.Provider>
);
}
function Initialize() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Loading"
component={Loading}
/>
<Stack.Screen
name="Login"
component={Login}
/>
<Stack.Screen
name="MyTrainings"
component={MyTrainings}
options={({ navigation }) => ({
headerRight: () => (
<TouchableOpacity onPress={() => logout(navigation)}>
<Text style={{ ...custom.text, color: "black", fontSize: 15 }}>
Logout
</Text>
</TouchableOpacity>
)
})}
/>
<Stack.Screen name="WorkoutDetails" component={WorkoutDetails} />
<Stack.Screen name="AddWorkout" component={AddWorkout} />
<Stack.Screen name="EditWorkoutDay" component={EditWorkoutDay} />
</Stack.Navigator>
</NavigationContainer>
);
}
const logout = (navigation) => {
SecureStore.deleteItemAsync("email")
.then(() => {
SecureStore.deleteItemAsync("pwd").then(() => {
console.log("Logout");
navigation.replace("Login");
});
})
.catch((err) => {
console.log(err);
});
};