Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lynndylanhurley committed Feb 11, 2016
1 parent 4457af0 commit c2fec74
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const BEFORE_POP = 'BEFORE_ROUTER_POP';
const AFTER_POP = 'AFTER_ROUTER_POP';
const BEFORE_DISMISS = 'BEFORE_ROUTER_DISMISS';
const AFTER_DISMISS = 'AFTER_ROUTER_DISMISS';
const AFTER_FOCUS = 'AFTER_ROUTER_FOCUS';
const BEFORE_FOCUS = 'BEFORE_ROUTER_FOCUS';

function isNumeric(n){
return !isNaN(parseFloat(n)) && isFinite(n);
Expand Down Expand Up @@ -152,4 +154,6 @@ actions.BEFORE_POP = BEFORE_POP;
actions.AFTER_POP = AFTER_POP;
actions.BEFORE_DISMISS = BEFORE_DISMISS;
actions.AFTER_DISMISS = AFTER_DISMISS;
actions.BEFORE_FOCUS = BEFORE_FOCUS;
actions.AFTER_FOCUS = AFTER_FOCUS;
export default actions;
22 changes: 22 additions & 0 deletions Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ export default class Router extends React.Component {

componentDidMount(){
this.router.delegate = this.refs.router;

this.router.delegate.refs.nav.navigationContext.addListener('willfocus', function (ev) {
let name = ev.data.route.name;
let title = ev.data.route.title;

this.props.dispatch({
type: Actions.BEFORE_FOCUS,
name: name,
title: title
});
}.bind(this));

this.router.delegate.refs.nav.navigationContext.addListener('didfocus', function (ev) {
let name = ev.data.route.name;
let title = ev.data.route.title;

this.props.dispatch({
type: Actions.AFTER_FOCUS,
name: name,
title: title
});
}.bind(this));
}

render(){
Expand Down

0 comments on commit c2fec74

Please sign in to comment.