0.3.2 • Published 1 year ago

rnn-screens v0.3.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

☣️ Experiment This is an experimental library and may have breaking changes in the future.

Goal

The goal of RNN Screens is to provide React Native developers with more simplified and predictable Navigation. It's built on top of React Native Navigation.

Quick start

Starters

  1. starters-dev/rnn-with-expo - minimalistic starter with React Native Navigation, Expo Modules and RNN Screens.

  2. rnn-starter - more advanced starter that is powered by cli-rn, React Native Navigation, Expo Modules, RNN Screens, RN UI lib, MMKV, Mobx, Reanimated 2, Dark Mode, Localization, Notifications, Permissions, and much more.

Bare RNN

1. Install React Native Navigation and RNN Screens

> yarn add react-native-navigation rnn-screens
> npx rnn-link
> npx pod-install

If you had problems installing RNN, please follow more detailed tutorial

2. Build screen components

import {generateRNNScreens, Root, BottomTabs, Screen, ScreenComponent} from 'rnn-screens';

// src/screens/main.tsx
export const Main: ScreenComponent = ({componentId}) => {
  return <>...</>;
};

// src/screens/settings.tsx
type SettingsProps = {type: 'push' | 'show'};
export const Settings: ScreenComponent<SettingsProps> = ({componentId, type}) => {
  return <>...</>;
};

3. Describe screens

// src/screens/index.tsx

import {generateRNNScreens} from 'rnn-screens';
import {Main} from './main';
import {Settings} from './settings';

export const screens = generateRNNScreens({
  Main: {
    component: Main,
    options: {
      topBar: {title: {text: 'Home'}},
    },
  },
  Settings: {
    component: Settings,
    options: {
      topBar: {title: {text: 'Settings'}},
    },
  },
});

4. Build root component

// App.tsx

// single screen app
export const App = () => Root(Screen(screens.get('Main')));

// tab based app
export const TabsApp = () =>
  Root(
    BottomTabs([
      Screen(screens.get('Main')),
      Screen(screens.get('Settings'))
    ])
  );

5. Update index.js

// index.js

import {registerRootComponent} from 'rnn-screens';
import {App} from './App';

registerRootComponent(App);

6. Navigate with predictability

// navigate from any screen

// push screen
screens.push(componentId, 'Settings');

// show modal
screens.show('Settings');

// push screen with passProps
screens.push<SettingsProps>(componentId, 'Settings', {type: 'push'});

// use RNN Navigation instance
screens.N.dismissAllModals();

Enhancements

Feel free to open an issue for suggestions.

Credits

Thanks to the React Native Navigation team @ Wix!

License

This project is MIT licensed

0.3.2

1 year ago

0.3.1-rc2

2 years ago

0.3.1-rc1

2 years ago

0.3.1-rc0

2 years ago

0.3.0

2 years ago

0.3.1

2 years ago

0.2.0-rc.19

2 years ago

0.2.0-rc.18

2 years ago

0.2.0-rc.17

2 years ago

0.2.0-rc.16

2 years ago

0.2.0-rc.15

2 years ago

0.2.0-rc.14

2 years ago

0.2.0-rc.13

2 years ago

0.2.0-rc.12

2 years ago

0.2.0-rc.11

2 years ago

0.2.0-rc.10

2 years ago

0.2.0-rc.7

2 years ago

0.2.0-rc.6

2 years ago

0.2.0-rc.9

2 years ago

0.2.0-rc.8

2 years ago

0.2.0-rc.5

2 years ago

0.2.0-rc.21

2 years ago

0.2.0-rc.20

2 years ago

0.2.0

2 years ago

0.2.0-rc.3

2 years ago

0.2.0-rc.2

2 years ago

0.2.0-rc.4

2 years ago

0.2.0-rc.1

2 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago