mobile-navigation-controller

Navigator for JavaScript mobile app, This will help you to manage your pages history in the app and change pages with animation.


Keywords
navigator cordova, react.cordova navigator, react.cordova manager_pages, pages-manager, navigator, mobile, mobile-navigator, WebView navigator controller, navigator-controller, cordova, ionic, WebView App, back on swipe right, web application, manage-pages, historyPages, PhoneGap, jqm, back-button-android
License
ISC
Install
npm install mobile-navigation-controller@1.4.6

Documentation

mobile-navigation-controller

It's manager for your pages like mobile app.



I dedicate a considerable amount of my free time to developing and maintaining this plugin, along with my other Open Source software. To help ensure this Cli is kept updated, new features are added and bugfixes are implemented quickly, please donate a couple of dollars (or a little more if you can stretch) as this will help me to afford to dedicate time to its maintenance. Please consider donating if you're using this plugin in an app that makes you money, if you're being paid to make the app, if you're asking for new features or priority bug fixes.


import Navigator from 'mobile-navigation-controller';


For example: In the render function return
<Navigator onRef={ref => (this.navigatorRef = ref)} >


         <MyHomePage key="home" levelPage={0} />

          <AboutPage key="about"
           levelPage={1}
            transitionIn="fadeInRight"
            transitionOut= "fadeOutLeft"
           />


 </Navigator>

Note: prop levelPage important to manage the returs (from back button) in the structure of a tree

To change page you get the ref and do:

this.navigatorRef.changePage("about");

the option to changePage it's:

this.navigatorRef.changePage(
                goToPage //Required
              ,{options}// Not requred
              );
options = {  animatioPageIn:"fadeInRight" // have defult
            , animationPageOut:"fadeOutLeft" // have defult
            , timeAnimationInMS:integer // defult=250(ms)
            , callbackFun:function
            , props:{}
              }

*animationIn and animationOut need name animate from here
*the animate.css includ in this package

use with react-router

import React from "react";

import Navigator from "react.cordova-navigation_controller";

import { BrowserRouter as Router, Route, useParams } from "react-router-dom";

export default function Root() {
  return (
    <Router>
      <Route path={["/:key", "/"]}>
        <App />
      </Route>
    </Router>
  );
}

const App = (props) => {
  const { key } = useParams();

  return (
    <Navigator routerKey={key} changeRoute={false}>
      <HomePage key="home" levelPage={0} />

      <Page2 key="page2" levelPage={1} />
    </Navigator>
  );
};

Options:

Navigator props

prop type required defult node
onRef required - onRef={ref => (this.navigatorRef = ref)}
key string required -
height string or integer optional "100%"
onChangePage function optional - (nowPageKey,levelAction) => { ... }
beforBack function optional - For android backbutton only. beforBack={() =>{ ( do something and return false to stop back page process or retun true. )}}
beforChangePage function optional - (goToPageKey,levelAction) => { ... }
changeRoute boolean optional true (on cordova native platforms => false) Determines whether to change the URL to the component key
homePageKey string optional The key of the first child
*levelAction return "Out" or "In" or "SameLevel"

Child props

prop type required defult node
levelPage integer required - important!
backgroundColor string optional #fff
height string or integer optional "100%"
backOnSwipeRight boolean optional false May be problematic with css "padding-left"
transitionIn string optional -
transitionOut string optional -
animationTimeInMS integer optional -
kill boolean optional -
alwaysLive boolean optional false Don't kill the child. Life is always in the background

Check what is page now

const nowPage= this.navigatorRef.nowPage;

Get the historyPages list

const historyPages= this.navigatorRef.historyPages();

Get the listLevelPages list

const listLevelPages= this.navigatorRef.listLevelPages();

Back 1 page history

this.navigatorRef.back();

or

this.navigatorRef.back({options...});

options => { animationIn:integer // have defult , animationOut:string // have defult , timeAnimationInMS:integer // defult=250(ms) , callbackFun:function , props:{...} }

Check if the mangerPages is busy

const navigator_busy= this.navigatorRef.busy;

*busy return boolean



If you have any problem, please let us know here, and we will make an effort to resolve it soon

Feel free to editing the code yourself: go to src/index.js

Credit: Arik Wald

Credit animated: animate.css -https://daneden.github.io/animate.css/