Skip to content

Commit

Permalink
internal improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kanzitelli committed Feb 15, 2023
1 parent 26ba499 commit 627e416
Show file tree
Hide file tree
Showing 4 changed files with 563 additions and 236 deletions.
103 changes: 90 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,63 @@ const navio = Navio.build({
},
},
root: 'AppTabs',
options: {
tab: {
// default tab's options
headerShown: false,
});

export default () => <navio.Root />;
```

</details>

### Drawer

<details>
<summary>Show code</summary>

```tsx
import {Navio} from 'rn-navio';

const navio = Navio.build({
screens: {
Home: () => (
<>
<Text>Home</Text>
<Button title="Push" onPress={() => navio.push('Example')} />
<Button title="Push stack" onPress={() => navio.stacks.push('HomeStack')} />
<Button title="Set Root - Stack" onPress={() => navio.stacks.setRoot('HomeStack')} />
<Button title="Set Root - Tabs" onPress={() => navio.setRoot('tabs', 'AppTabs')} />
</>
),
Example: () => (
<>
<Text>Example</Text>
<Button title="Go back" onPress={() => navio.goBack()} />
</>
),
Settings: {
component: () => (
<>
<Text>Settings</Text>
<Button title="Jump to tab" onPress={() => navio.tabs.jumpTo('HomeTab')} />
</>
),
options: () => ({
headerTitleStyle: {color: 'red'},
}),
},
},
stacks: {
HomeStack: ['Home', 'Example'],
},
drawers: {
AppDrawer: {
content: {
Main: 'HomeStack',
Playground: ['Playground'],
Settings: ['Settings'],
},
},
},
root: 'AppDrawer',
});

export default () => <navio.Root />;
Expand Down Expand Up @@ -216,6 +267,7 @@ type Stack =
| ScreenName[]
| {
screens: ScreenName[];
containerOptions?: ContainerOptions;
navigatorProps?: NativeStackNavigatorProps;
};
```
Expand Down Expand Up @@ -253,6 +305,7 @@ type Tabs = Record<string, Tab>;

type Tab = {
content: Record<string, ContentValue>;
containerOptions?: ContainerOptions;
navigatorProps?: any;
};

Expand Down Expand Up @@ -302,6 +355,7 @@ type Drawers = Record<string, Drawer>;

type Drawer = {
content: Record<string, ContentValue>;
containerOptions?: ContainerOptions;
navigatorProps?: any;
};

Expand Down Expand Up @@ -391,15 +445,29 @@ const navio = Navio.build({

### Default options

Default options that will be applied per each `Stacks`'s, `Tabs`'s or `Drawer`'s screens generated within the app.
Default options that will be applied per each `Stacks`'s, `Tabs`'s, `Drawer`'s, or `Modal`'s screens and containers generated within the app.

`Note` All containers and `Tabs`'s and `Drawer`'s screens options have `headerShown: false` by default (in order to hide unnecessary navigation headers). You can always change them which might be useful if you want to have a native `< Back` button when hiding tabs (pushing new `Stack`).

#### Definition

```tsx
type DefaultOptions = {
stack?: NativeStackNavigationOptions;
tab?: BottomTabNavigationOptions;
drawer?: DrawerNavigationOptions;
stacks?: {
screen?: StackScreenOptions;
container?: ContainerOptions;
};
tabs?: {
screen?: TabScreenOptions;
container?: ContainerOptions;
};
drawers?: {
screen?: DrawerScreenOptions;
container?: ContainerOptions;
};
modals?: {
container?: ContainerOptions;
};
};
```

Expand All @@ -408,12 +476,21 @@ type DefaultOptions = {
```tsx
const navio = Navio.build({
defaultOptions: {
stack: {
headerShadowVisible: false,
headerTintColor: Colors.primary,
stacks: {
screen: {
headerShadowVisible: false,
headerTintColor: Colors.primary,
},
container: {
headerShown: true,
},
},
tabs: {
screen: tabDefaultOptions,
},
drawer: {
screen: drawerDefaultOptions,
},
tab: tabDefaultOptions,
drawer: drawerDefaultOptions,
},
});
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rn-navio",
"version": "0.0.2",
"version": "0.0.5-rc.7",
"description": "🧭 Navigation library for React Native (Expo). Build once, navigate from anywhere to everywhere!",
"author": "Batyr <dev@batyr.io>",
"homepage": "https://github.com/kanzitelli/rn-navio",
Expand Down
Loading

0 comments on commit 627e416

Please sign in to comment.