All Projects β†’ grahammendick β†’ Navigation

grahammendick / Navigation

Licence: apache-2.0
Scene-Based Navigation for React and React Native

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Navigation

Android Camera2 Secret Picture Taker
Take pictures πŸ“· secretly (without preview or launching device's camera app) using Android CAMERA2 API
Stars: ✭ 275 (-21.43%)
Mutual labels:  mobile, native
Nat Explorer
An example project using Nat & Weex.
Stars: ✭ 55 (-84.29%)
Mutual labels:  mobile, native
Firebase Instagram
πŸ“Έ Instagram clone with Firebase Cloud Firestore, Expo, and React Native 😁😍
Stars: ✭ 389 (+11.14%)
Mutual labels:  mobile, native
Share Api Polyfill
A polyfill for the sharing that can be used in desktop too, so your users can shere in their twitter, facebook, messenger, linkedin, sms, e-mail, print, telegram or whatsapp.
Stars: ✭ 210 (-40%)
Mutual labels:  mobile, native
Flutter Rust Ffi
Starter project for Flutter plugins willing to access native and synchronous rust code using FFI
Stars: ✭ 330 (-5.71%)
Mutual labels:  mobile, native
Titanium mobile
πŸš€ Native iOS- and Android- Apps with JavaScript
Stars: ✭ 2,553 (+629.43%)
Mutual labels:  mobile, native
Expo
An open-source platform for making universal native apps with React. Expo runs on Android, iOS, and the web.
Stars: ✭ 15,550 (+4342.86%)
Mutual labels:  mobile, native
Keen Slider
The HTML touch slider carousel with the most native feeling
Stars: ✭ 3,097 (+784.86%)
Mutual labels:  mobile, native
Nat
A powerful kit for adding native functionalities to your weex app.
Stars: ✭ 294 (-16%)
Mutual labels:  mobile, native
Vue Router
🚦 The official router for Vue.js.
Stars: ✭ 18,606 (+5216%)
Mutual labels:  router
Vonic
Mobile UI Components, based on Vue.js and ionic CSS. https://wangdahoo.github.io/vonic-documents
Stars: ✭ 3,422 (+877.71%)
Mutual labels:  mobile
Vant
Lightweight Mobile UI Components built on Vue
Stars: ✭ 18,852 (+5286.29%)
Mutual labels:  mobile
Cordova Plugin Device
Apache Cordova Plugin device
Stars: ✭ 327 (-6.57%)
Mutual labels:  mobile
Cordova Plugin Media
Apache Cordova Plugin media
Stars: ✭ 338 (-3.43%)
Mutual labels:  mobile
Weex
A framework for building Mobile cross-platform UI
Stars: ✭ 17,793 (+4983.71%)
Mutual labels:  mobile
App Inspector
App-inspector is a mobile UI viewer in browser.
Stars: ✭ 343 (-2%)
Mutual labels:  native
React Native Carplay
CarPlay with React Native
Stars: ✭ 321 (-8.29%)
Mutual labels:  native
Lotusoot
η΅ζ΄»ηš„ Swift η»„δ»Άθ§£θ€¦ε’Œι€šδΏ‘ε·₯ε…·
Stars: ✭ 324 (-7.43%)
Mutual labels:  router
React Native Redux Crypto Tracker
πŸ’Ž Learn how to build a Redux + React Native cryptocurrency app
Stars: ✭ 351 (+0.29%)
Mutual labels:  mobile
Gradle Play Publisher
GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.
Stars: ✭ 3,690 (+954.29%)
Mutual labels:  mobile

The Navigation router

Scene-Based Navigation for React and React Native

  • Scene-Based Navigation Native apps have always had scene-based navigation. The Navigation router is the first to bring it to the web. You give the Navigation router a list of your scenes. After you navigate to a scene, the Navigation router gets out of your way so you can build your UI however you want.
  • React and React Native You don't need a different routing library for React and React Native anymore. The Navigation router works on both. What's more, it doesn't compromise the UX. On React Native, the navigation is 100% native on Android and iOS. On React, you can have whatever URLs you want.

React

Define Your States

import { StateNavigator } from 'navigation';

const stateNavigator = new StateNavigator([
  { key: 'hello', route: '' },
  { key: 'world' }
]);

You create one State for each scene (page) in your app. You don't need to define your routes yet. The Navigation router generates interim routes. You can define your real routes at any time without changing any code. With scene-based navigation, there aren't any hard-coded Urls for you to update.

Create Your Scenes

const { hello, world } = stateNavigator.states;

hello.renderScene = () => <Hello />;
world.renderScene = () => <World />;

For each scene, you create a component that renders its UI. You map these scene components to their corresponding States. All the other routers for React force you to think in terms of routes. But this is confusing because routes and scenes aren't the same thing. One scene can have more than one route, for example, a master/details page.

Navigate to a Scene

import { NavigationLink } from 'navigation-react';

const Hello = () => (
  <NavigationLink
    stateKey="world"
    navigationData={{ size: 20 }}>
    Hello
  </NavigationLink>
);

The NavigationLink component changes scene. You pass the name of the scene and the data. The Navigation router builds the Url. If you've configured more than one route it uses the best match.

Use the Data

import { NavigationContext } from 'navigation-react';

const World = () => {
  const { data } = useContext(NavigationContext);
  return (
    <div style={{ fontSize: data.size }}>
      World
    </div>
  );
};

In the next scene, you access the data from the NavigationContext. The Navigation router passes strongly-typed data. Here, the size is a number.

React Native

Define Your States

import { StateNavigator } from 'navigation';

const stateNavigator = new StateNavigator([
  { key: 'hello' },
  { key: 'world', trackCrumbTrail: true }
]);

You create one State for each scene (screen) in your app. You can think of the stack of scenes as a trail of breadcrumbs. Each scene is one crumb. Like Hansel and Gretel in the fairy story, the Navigation router drops a crumb every time it visits a scene (if you set 'trackCrumbTrail' to true).

Create Your Scenes

const { hello, world } = stateNavigator.states;

hello.renderScene = () => <Hello />;
world.renderScene = () => <World />;

For each scene, you create a component that renders its UI. You map these scene components to their corresponding States. The Navigation router provides React components to help you build your scenes. All of these components render to the same native primitives as other native apps. For example, the TabBar component renders to a BottomNavigationView on Android and a UITabBarController on iOS.

Navigate to a Scene

import { NavigationContext } from 'navigation-react';

const Hello = () => {
  const { stateNavigator } = useContext(NavigationContext);
  return (
    <Button title="Hello"
      onPress={() => {
        stateNavigator.navigate('world', { size: 20 });
      }} />
  );
};

You use the stateNavigator from the NavigationContext to change scenes. You pass the name of the scene and the data. The navigation is 100% native on Android and iOS.

Use the Data

import { NavigationContext } from 'navigation-react';

const World = () => {
  const { data } = useContext(NavigationContext);
  return (
    <Text style={{ fontSize: data.size }}>
      World
    </Text>
  );
};

In the next scene, you access the data from the NavigationContext. You can return to the 'hello' scene via the Android back button or swiping/pressing back on iOS.

Build

Once you've cloned the repository, you can install the dependencies and run the build:

npm install
npm run build

Running npm test executes the unit tests.
Running npm run package outputs the npm packages inside the build/npm folder.

Thanks to BrowserStack for their help with cross browser testing

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].