Devnetik / react-native-better-navigator

react-native navigator wrapper on steroids

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Map*ToRoute methods should call props method to map something to the current route

maluramichael opened this issue · comments

e.g. The mapLeftButtonToRoute could call a prop mapLeftButtonToRoute. This way it is possible to handle the left button inside the app component.

mapLeftButtonToRoute(route, navigator, index, navState) {
    // check route static methods for a left button
    var navigatorItem = this.callRouteFunction('navigationBarLeftButton', route, navigator, index, navState);
    if (navigatorItem) {
        return navigatorItem;
    }

    // check props for a left button
    if (this.props.mapLeftButtonToRoute) {
        navigatorItem = mapLeftButtonToRoute(route, navigator, index, navState);
        if (navigatorItem) {
            return navigatorItem;
        }
    }

    // default to a simple back button
    if (index > 0) {
        return <BackButton onPress={this.onPressBackButton}/>;
    }

    // just in case nothing handles the left button we return a empty view
    return <View/>;
}