-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
118 lines (106 loc) Β· 3.37 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
import { View, ScrollView } from "react-native";
import React, { Component, Fragment } from "react";
import { Text, Header } from "native-base";
import globalStyles from "./src/styles";
import DataScreen from "./src/screens/DataScreen";
import ErrorScreen from "./src/screens/ErrorScreen";
import ExercisesScreen from "./src/screens/ExercisesScreen";
import LoginScreen from "./src/screens/LoginScreen";
import MainScreen from "./src/screens/MainScreen";
import SelectExerciseScreen from "./src/screens/SelectExerciseScreen";
import SettingsScreen from "./src/screens/SettingsScreen";
import SimpleTextComponent from "./src/components/SimpleTextComponent";
import Navigator from "./src/components/Navigator";
import { Font } from "expo";
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
activeView: "loginScreen",
username: "",
password: "",
selectedMuscleGroup: ""
};
}
async UNSAFE_componentWillMount() {
await Font.loadAsync({
Roboto: require("native-base/Fonts/Roboto.ttf"),
Ionicons: require("@expo/vector-icons/fonts/Ionicons.ttf")
});
}
setUsername = username => {
this.setState({ username });
};
setPassword = password => {
this.setState({ password });
};
setActiveView = screenName => {
this.setState({ activeView: screenName });
};
setSelectedMuscleGroup = selectedMuscleGroup => {
this.setState({ selectedMuscleGroup });
};
handleSignout = () => {
this.setState({ username: "", password: "", activeView: "loginScreen" });
};
renderActiveView = () => {
switch (this.state.activeView) {
case "loginScreen":
return (
<View style={{ width: "100%" }}>
{/* <Text> {JSON.stringify(this.state)}</Text> */}
<LoginScreen
callback_setUsername={this.setUsername}
callback_setPassword={this.setPassword}
callback_setActiveView={this.setActiveView}
/>
</View>
);
case "exercisesScreen":
return (
<View style={{ width: "100%" }}>
<ExercisesScreen
selectedMuscleGroup={this.state.selectedMuscleGroup}
callback_setActiveView={this.setActiveView}
/>
</View>
);
case "selectExerciseScreen":
return (
<SelectExerciseScreen
callback_setActiveView={this.setActiveView}
callback_setSelectedMuscleGroup={this.setSelectedMuscleGroup}
/>
);
case "dataScreen":
return <DataScreen />;
case "settingsScreen":
return <SettingsScreen callback_signOut={this.handleSignout} />;
case "mainScreen":
return <MainScreen />;
case "testScreen":
return (
<Fragment>
<Text style={[globalStyles.textInput]}>Hello</Text>
<SimpleTextComponent name="Kaitlyn" />
</Fragment>
);
default:
return <ErrorScreen />;
}
};
render() {
return (
<View style={globalStyles.screenContainer}>
<View style={[globalStyles.container]}>{this.renderActiveView()}</View>(
{this.state.activeView !== "loginScreen" && (
<Navigator
callback_setActiveView={this.setActiveView}
activeView={this.state.activeView}
/>
)}
)
</View>
);
}
}