Skip to content

Commit

Permalink
navio changes + more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kanzitelli committed Mar 19, 2023
1 parent 2b62af2 commit ea6675e
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 18 deletions.
4 changes: 2 additions & 2 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export default (): JSX.Element => {
}}

// [Tip]
// You can use `initialRouteName` to change root of the app depending on global state changes.
// initialRouteName="AppTabs"
// You can use `root` to change the root of the app depending on global state changes.
// root={isLoggedIn ? 'AuthStack' : 'AppTabs'}
/>
</AppProvider>
</GestureHandlerRootView>
Expand Down
28 changes: 21 additions & 7 deletions src/components/sections/NavioSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ export const NavioSection: React.FC<Props> = ({}) => {
const tabsUpdateOptionsBadge = () =>
navio.tabs.updateOptions('SettingsTab', {tabBarBadge: randomNum()});
const tabsUpdateOptionsTitle = () =>
navio.tabs.updateOptions('SettingsTab', {title: `Random Title ${randomNum()}`});
navio.tabs.updateOptions('SettingsTab', {title: `Random ${randomNum()}`});
const tabsSetRoot = () => navio.tabs.setRoot('AppTabs');
const drawersToggle = () => navio.drawers.toggle();
const drawersJumpTo = () => navio.drawers.jumpTo('Playground');
const drawerUpdateOptions = () => navio.drawers.updateOptions('Main', {title: 'Main (updated)'});

This comment has been minimized.

Copy link
@cj

cj Mar 21, 2023

Eslint (tsserver) throws an error saying the method updateOptions not existing on drawers. The types also show that method as not existing.
image

This comment has been minimized.

Copy link
@kanzitelli

kanzitelli Mar 21, 2023

Author Owner

@cj oh that's weird. are you on v0.0.7?

This comment has been minimized.

Copy link
@cj

cj Mar 21, 2023

Yes - it looks like an editor restart fixed it 😄

const drawersSetRoot = () => navio.drawers.setRoot('MainDrawer');
const modalsShow = () => navio.modals.show('ExampleModal');

Expand Down Expand Up @@ -141,12 +142,25 @@ export const NavioSection: React.FC<Props> = ({}) => {
onPress={drawersJumpTo}
/>
</Row>
<BButton
marginV-s1
size="small"
label={t.do('section.navio.button.drawers.set_root')}
onPress={drawersSetRoot}
/>
<Row>
<BButton
flex
marginV-s1
marginR-s1
size="small"
label={t.do('section.navio.button.drawers.update_title_options')}
onPress={drawerUpdateOptions}
/>

<BButton
flex
marginV-s1
marginL-s1
size="small"
label={t.do('section.navio.button.drawers.set_root')}
onPress={drawersSetRoot}
/>
</Row>

<Text marginT-s2 text60R textColor>
Modals
Expand Down
59 changes: 54 additions & 5 deletions src/navio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const navio = Navio.build({
AuthFlow: ['AuthLogin', 'Example'],
},
tabs: {
// main 3 tabs
AppTabs: {
content: {
MainTab: {
Expand All @@ -92,11 +93,29 @@ export const navio = Navio.build({
},
},
},
},
modals: {
ExampleModal: 'ExampleStack',

// tabs with drawer
// TabsWithDrawer: {
// content: {
// MainTab: {
// stack: 'MainStack',
// options: () => ({
// title: 'Main',
// tabBarIcon: getTabBarIcon('MainTab'),
// }),
// },
// PlaygroundTab: {
// drawer: 'DrawerForTabs',
// options: () => ({
// title: 'Playground',
// tabBarIcon: getTabBarIcon('PlaygroundTab'),
// }),
// },
// },
// },
},
drawers: {
// main drawer
MainDrawer: {
content: {
Main: {
Expand All @@ -105,10 +124,40 @@ export const navio = Navio.build({
drawerType: 'front',
},
},
Example: 'ExampleStack',
Playground: 'PlaygroundStack',
Example: {
stack: ['Example'],
},
Playground: {
stack: 'PlaygroundStack',
},
// Tabs: {
// tabs: 'TabsWithDrawer',
// },
},
},

// drawer inside tabs
// DrawerForTabs: {
// content: {
// FlashList: {
// stack: ['PlaygroundFlashList'],
// options: {
// title: 'Flash List',
// drawerPosition: 'right',
// },
// },
// ExpoImage: {
// stack: ['PlaygroundExpoImage'],
// options: {
// title: 'Expo Image',
// drawerPosition: 'right',
// },
// },
// },
// },
},
modals: {
ExampleModal: 'ExampleStack',
},
root: 'AppTabs',
hooks: [useAppearance],
Expand Down
31 changes: 27 additions & 4 deletions src/screens/playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {useAppearance} from '@app/utils/hooks';
import {Row} from '@app/components/row';
import {Icon} from '@app/components/icon';
import {Section} from '@app/components/section';
import {Alert} from 'react-native';

type SectionData = {
content: {
Expand All @@ -27,8 +28,18 @@ export const Playground: React.FC = observer(() => {
const {auth} = useStores();

// Methods
const shopFlashList = () => navio.push('PlaygroundFlashList');
const shopExpoImage = () => navio.push('PlaygroundExpoImage');
const showFlashList = () => navio.push('PlaygroundFlashList');
const showExpoImage = () => navio.push('PlaygroundExpoImage');
const showDrawerWithTabs = () => {
Alert.alert('Uncomment related code in @app/navio.tsx and @app/screens/playground');
// uncomment related code in navio.tsx and below
// navio.setRoot('drawers', 'MainDrawer');
};
const showTabsWithDrawer = () => {
Alert.alert('Uncomment related code in @app/navio.tsx and @app/screens/playground');
// uncomment related code in navio.tsx and below
// navio.setRoot('tabs', 'TabsWithDrawer');
};

const showAuthFlow = () => {
// logging out from previous session
Expand All @@ -52,13 +63,13 @@ export const Playground: React.FC = observer(() => {
title: 'Flash List',
subtitle: 'by Shopify',
icon: 'list-outline',
onPress: shopFlashList,
onPress: showFlashList,
},
{
title: 'Expo Image',
subtitle: 'by Expo',
icon: 'image-outline',
onPress: shopExpoImage,
onPress: showExpoImage,
},
],
},
Expand All @@ -76,6 +87,18 @@ export const Playground: React.FC = observer(() => {
subtitle: 'Pushes Product Page w/out tabs',
onPress: showProductPage,
},
{
title: 'Drawer with tabs',
icon: 'filter-outline',
subtitle: 'Opens drawer app w/ tabs inside',
onPress: showDrawerWithTabs,
},
{
title: 'Tabs with drawer',
icon: 'log-in-outline',
subtitle: 'Opens app w/ 2 tabs and drawer inside one',
onPress: showTabsWithDrawer,
},
],
},
};
Expand Down
1 change: 1 addition & 0 deletions src/services/translate/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const en = {
drawers: {
toggle: 'Toggle ↔',
jump_to: 'Jump to ↩',
update_title_options: 'Update opts (title)',
set_root: 'Set root ↺',
},
modals: {
Expand Down

0 comments on commit ea6675e

Please sign in to comment.