Navigation Menu

Skip to content

Commit

Permalink
Navigation using the flow router instead of navigator.
Browse files Browse the repository at this point in the history
  • Loading branch information
marano committed Dec 12, 2015
1 parent 5a9851e commit cdc1cde
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
12 changes: 5 additions & 7 deletions app/CountdownMeditationTimer.js
Expand Up @@ -15,17 +15,15 @@ var timer = React.createClass({
mixins: [TimerMixin],
getInitialState: function () {
return {
timerStartedAt: undefined,
timerStartedAt: new Date(),
timeCounter: '00:00'
};
},
componentDidMount: function () {
this.setInterval(
() => {
if (this.state.timerStartedAt) {
var runningFor = moment().diff(this.state.timerStartedAt);
this.setState({ timeCounter: moment(runningFor).format('mm:ss') });
}
var runningFor = moment().diff(this.state.timerStartedAt);
this.setState({ timeCounter: moment(runningFor).format('mm:ss') });
}, 500
);
},
Expand All @@ -36,8 +34,8 @@ var timer = React.createClass({
return (
<View style={styles.container}>
<Text>{this.state.timeCounter}</Text>
<TouchableHighlight onPress={this._startTimer}>
<Text>Start Timer</Text>
<TouchableHighlight>
<Text>Pause</Text>
</TouchableHighlight>
</View>
)
Expand Down
3 changes: 3 additions & 0 deletions app/MeditationTimerSetup.js
Expand Up @@ -2,8 +2,10 @@

var moment = require('moment');
var React = require('react-native');
var { Actions } = require('react-native-router-flux');
var TimerMixin = require('react-timer-mixin');


var {
StyleSheet,
Text,
Expand All @@ -13,6 +15,7 @@ var {

var NavigationTimerSetup = React.createClass({
_start: function () {
Actions.CountdownMeditationTimer();
},
render: function () {
return (
Expand Down
11 changes: 1 addition & 10 deletions app/NewMeditationSession.js
Expand Up @@ -3,19 +3,10 @@
var React = require('react-native');
var MeditationTimerSetup = require('./MeditationTimerSetup');

var {
Navigator,
} = React;

var NewMeditationSession = React.createClass({
render: function () {
return (
<Navigator
initialRoute={{}}
renderScene={(route, navigator) =>
<MeditationTimerSetup />
}
/>
<MeditationTimerSetup />
);
},
});
Expand Down
7 changes: 6 additions & 1 deletion app/index.js
@@ -1,12 +1,17 @@
'use strict';

var React = require('react-native');
var { Router, Route } = require('react-native-router-flux');
var NewMeditationSession = require('./NewMeditationSession');
var CountdownMeditationTimer = require('./CountdownMeditationTimer');

var vijja = React.createClass({
render: function() {
return (
<NewMeditationSession />
<Router hideNavBar={true}>
<Route name="NewMeditationSession" component={NewMeditationSession} initial={true} />
<Route name="CountdownMeditationTimer" component={CountdownMeditationTimer} />
</Router>
);
}
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -8,6 +8,7 @@
"dependencies": {
"moment": "^2.10.6",
"react-native": "^0.16.0",
"react-native-router-flux": "^1.0.5",
"react-timer-mixin": "^0.13.3"
}
}

0 comments on commit cdc1cde

Please sign in to comment.