Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
24 changes: 24 additions & 0 deletions Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@ export default class Router extends React.Component {

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

if (this.props.dispatch) {
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