Skip to content

Commit

Permalink
change first screen to MainScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
kdnakt committed May 5, 2018
1 parent 3367f6c commit 6d09431
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const routes = {
};

const config = {
initialRouteName: 'Timer',
initialRouteName: 'Main',
};

const App = StackNavigator(routes, config);
Expand Down
20 changes: 19 additions & 1 deletion src/MainScreen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import {
Button,
Text,
View,
} from 'react-native';
Expand All @@ -20,7 +21,8 @@ class MainScreen extends Component<{}> {
super();
this.state = {
bestRecord: null,
}
};
this.navigate = this.navigate.bind(this);
}

componentWillMount() {
Expand All @@ -34,6 +36,10 @@ class MainScreen extends Component<{}> {
});
}

navigate(key) {
this.props.navigation.navigate(key);
}

render() {
const bestRecord = this.state.bestRecord;
return (
Expand All @@ -44,6 +50,18 @@ class MainScreen extends Component<{}> {
<Text>
{bestRecord ? `Best Record: ${bestRecord} seconds` : null}
</Text>
<Button
title={"Timer"}
onPress={() => this.navigate("Timer")}
/>
<Button
title={"Log"}
onPress={() => this.navigate("Log")}
/>
<Button
title={"Config"}
onPress={() => this.navigate("Config")}
/>
</View>
)
}
Expand Down

0 comments on commit 6d09431

Please sign in to comment.