-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
89 lines (70 loc) · 2.82 KB
/
App.js
File metadata and controls
89 lines (70 loc) · 2.82 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
import Constants from 'expo-constants';
import React, { useState } from 'react';
import { NavigationContainer } from '@react-navigation/native'
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"
import CurrentWorkout from "./current_workout/CurrentWorkout"
import Activities from "./Activities"
import { FontAwesome5, MaterialCommunityIcons, Entypo } from '@expo/vector-icons';
import {View, ActivityIndicator} from "react-native"
import api from './api'
import Settings from './Settings';
import UpsertRoutine from './UpsertRoutine';
const Tab = createBottomTabNavigator();
export default function App() {
const [workouts,setWorkouts] = useState([])
const [machines,setMachines] = useState([])
const [setupComplete,setSetupComplete] = useState(false)
React.useEffect( () => {
const setup = async () => {
await api.validateDB()
await api.seedDB();
const machines = await api.machines.get();
setMachines(machines);
await refreshWorkouts();
setSetupComplete(true);
}
setSetupComplete(false);
setup();
},[]);
const refreshWorkouts = async () => {
const newWorkouts = await api.workouts.get().catch( e => console.log(e));
setWorkouts(newWorkouts);
}
if (!setupComplete || !machines || !workouts) {
return <View style={{flex: 1, justifyContent: "center", alignContent: "center"}}><ActivityIndicator size="large" /></View>
}
return (
<View style={{flex: 1, marginTop: Constants.statusBarHeight}}>
<NavigationContainer>
<Tab.Navigator
screenOptions={
( {route} ) => ({
tabBarIcon: ({focused, color, size}) => {
if (route.name === 'Current Workout') {
return <MaterialCommunityIcons name="dumbbell" size={size} color={color}/>
} else if (route.name === 'Activities') {
return <FontAwesome5 name="dumbbell" size={size} color={color}/>
} else if (route.name === 'Track') {
return <Entypo name="line-graph" size={size} color={color} />
}
return <MaterialCommunityIcons name="settings" size={size} color={color} />
}
})
}>
<Tab.Screen name="Current Workout"
children={ () => <CurrentWorkout workouts={workouts} machines={machines} refreshWorkouts={refreshWorkouts}/>}
/>
<Tab.Screen name="Activities"
children={ () => <Activities workouts={workouts} machines={machines}/>} />
<Tab.Screen name="Track"
children = { () => <Activities workouts={workouts} machines={machines}/>}
/>
<Tab.Screen name="Settings"
component={Settings}
/>
</Tab.Navigator>
</NavigationContainer>
</View>
);
}
//options={{headerTitle: () => <Header headerDisplay="PFTracker" />}