Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
feat: add integration for paper's bottom navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Aug 8, 2019
1 parent d09f936 commit f3b6d1f
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 127 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"@navigation-ex/stack",
"@navigation-ex/drawer",
"@navigation-ex/bottom-tabs",
"@navigation-ex/material-top-tabs"
"@navigation-ex/material-top-tabs",
"@navigation-ex/material-bottom-tabs"
]
},
"env": { "browser": true, "node": true }
Expand Down
2 changes: 2 additions & 0 deletions packages/example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ module.exports = {

providesModuleNodeModules: [
'@babel/runtime',
'@expo/vector-icons',
'@react-native-community/masked-view',
'react',
'react-native',
'react-native-gesture-handler',
'react-native-reanimated',
'react-native-safe-area-view',
'react-native-screens',
'react-native-paper',
'react-native-tab-view',
'shortid',
],
Expand Down
4 changes: 2 additions & 2 deletions packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"@react-native-community/masked-view": "^0.1.1",
"@expo/vector-icons": "10.0.3",
"expo": "^34.0.1",
"expo-asset": "4.0.0",
"expo-asset": "~6.0.0",
"react": "16.8.3",
"react-dom": "^16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
"react-native-gesture-handler": "~1.3.0",
"react-native-paper": "3.0.0-alpha.3",
"react-native-paper": "^3.0.0-alpha.3",
"react-native-reanimated": "~1.1.0",
"react-native-screens": "1.0.0-alpha.22",
"react-native-tab-view": "2.7.1",
Expand Down
68 changes: 68 additions & 0 deletions packages/example/src/Screens/MaterialBottomTabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import * as React from 'react';
import { StyleSheet } from 'react-native';
import createMaterialBottomTabNavigator from '@navigation-ex/material-bottom-tabs';
import Article from '../Shared/Article';
import Albums from '../Shared/Albums';
import Contacts from '../Shared/Contacts';
import Chat from '../Shared/Chat';

type MaterialBottomTabParams = {
article: undefined;
albums: undefined;
contacts: undefined;
chat: undefined;
};

const MaterialBottomTabs = createMaterialBottomTabNavigator<
MaterialBottomTabParams
>();

export default function MaterialBottomTabsScreen() {
return (
<MaterialBottomTabs.Navigator barStyle={styles.tabBar}>
<MaterialBottomTabs.Screen
name="article"
component={Article}
options={{
tabBarLabel: 'Article',
tabBarIcon: 'chrome-reader-mode',
tabBarColor: '#C9E7F8',
}}
/>
<MaterialBottomTabs.Screen
name="chat"
component={Chat}
options={{
tabBarLabel: 'Chat',
tabBarIcon: 'chat-bubble',
tabBarColor: '#9FD5C9',
tabBarBadge: true,
}}
/>
<MaterialBottomTabs.Screen
name="contacts"
component={Contacts}
options={{
tabBarLabel: 'Contacts',
tabBarIcon: 'contacts',
tabBarColor: '#F7EAA2',
}}
/>
<MaterialBottomTabs.Screen
name="albums"
component={Albums}
options={{
tabBarLabel: 'Albums',
tabBarIcon: 'photo-album',
tabBarColor: '#FAD4D6',
}}
/>
</MaterialBottomTabs.Navigator>
);
}

const styles = StyleSheet.create({
tabBar: {
backgroundColor: 'white',
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@ import Albums from '../Shared/Albums';
import Contacts from '../Shared/Contacts';
import Chat from '../Shared/Chat';

type MaterialTabParams = {
type MaterialTopTabParams = {
albums: undefined;
contacts: undefined;
chat: undefined;
};

const MaterialTabs = createMaterialTopTabNavigator<MaterialTabParams>();
const MaterialTopTabs = createMaterialTopTabNavigator<MaterialTopTabParams>();

export default function MaterialTabsScreen() {
export default function MaterialTopTabsScreen() {
return (
<MaterialTabs.Navigator
<MaterialTopTabs.Navigator
tabBarOptions={{
style: styles.tabBar,
labelStyle: styles.tabLabel,
indicatorStyle: styles.tabIndicator,
}}
>
<MaterialTabs.Screen
<MaterialTopTabs.Screen
name="chat"
component={Chat}
options={{ title: 'Chat' }}
/>
<MaterialTabs.Screen
<MaterialTopTabs.Screen
name="contacts"
component={Contacts}
options={{ title: 'Contacts' }}
/>
<MaterialTabs.Screen
<MaterialTopTabs.Screen
name="albums"
component={Albums}
options={{ title: 'Albums' }}
/>
</MaterialTabs.Navigator>
</MaterialTopTabs.Navigator>
);
}

Expand Down
99 changes: 0 additions & 99 deletions packages/example/src/Shared/Profile.tsx

This file was deleted.

12 changes: 10 additions & 2 deletions packages/example/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import createStackNavigator, {

import SimpleStackScreen from './Screens/SimpleStack';
import BottomTabsScreen from './Screens/BottomTabs';
import MaterialTabsScreen from './Screens/MaterialTabs';
import MaterialTopTabsScreen from './Screens/MaterialTopTabs';
import MaterialBottomTabs from './Screens/MaterialBottomTabs';

YellowBox.ignoreWarnings(['Require cycle:', 'Warning: Async Storage']);

Expand All @@ -30,7 +31,14 @@ type RootStackParamList = {
const SCREENS = {
SimpleStack: { title: 'Simple Stack', component: SimpleStackScreen },
BottomTabs: { title: 'Bottom Tabs', component: BottomTabsScreen },
MaterialTabs: { title: 'Material Tabs', component: MaterialTabsScreen },
MaterialTopTabs: {
title: 'Material Top Tabs',
component: MaterialTopTabsScreen,
},
MaterialBottomTabs: {
title: 'Material Bottom Tabs',
component: MaterialBottomTabs,
},
};

const Drawer = createDrawerNavigator<RootDrawerParamList>();
Expand Down
6 changes: 2 additions & 4 deletions packages/material-top-tabs/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import {
import { TabNavigationState } from '@navigation-ex/routers';

export type MaterialTopTabNavigationEventMap = {
tabPress: {
defaultPrevented: boolean;
preventDefault(): void;
};
refocus: undefined;
tabPress: undefined;
tabLongPress: undefined;
swipeStart: undefined;
swipeEnd: undefined;
Expand Down
Loading

0 comments on commit f3b6d1f

Please sign in to comment.