From c39dd9d45f60ceebe369750eba0e265aed7290f0 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Tue, 25 Apr 2017 10:53:09 +0200 Subject: [PATCH] Export all the things (#1219) * Initial * Add missing title * Fix style and ref issues --- docs/api/navigators/DrawerNavigator.md | 10 ++++++---- docs/api/navigators/TabNavigator.md | 4 ++-- src/navigators/DrawerNavigator.js | 4 +++- src/navigators/TabNavigator.js | 7 +++++-- src/react-navigation.js | 18 ++++++++++++++++++ src/views/Drawer/DrawerView.js | 3 --- src/views/Header.js | 2 -- src/views/TabView/TabView.js | 8 -------- 8 files changed, 34 insertions(+), 22 deletions(-) diff --git a/docs/api/navigators/DrawerNavigator.md b/docs/api/navigators/DrawerNavigator.md index 794ecf5..aa32395 100644 --- a/docs/api/navigators/DrawerNavigator.md +++ b/docs/api/navigators/DrawerNavigator.md @@ -84,7 +84,7 @@ The route configs object is a mapping from route name to a route config, which t - `drawerWidth` - Width of the drawer - `drawerPosition` - Options are `left` or `right`. Default is `left` position. -- `contentComponent` - Component used to render the content of the drawer, for example, navigation items. Receives the `navigation` prop for the drawer. Defaults to `DrawerView.Items`. For more information, see below. +- `contentComponent` - Component used to render the content of the drawer, for example, navigation items. Receives the `navigation` prop for the drawer. Defaults to `DrawerItems`. For more information, see below. - `contentOptions` - Configure the drawer content, see below. #### Example: @@ -97,7 +97,7 @@ as you can see in the example below. { drawerWidth: 200, drawerPosition: 'right', - contentComponent: props => + contentComponent: props => } ``` @@ -113,9 +113,11 @@ Several options get passed to the underlying router to modify navigation logic: You can easily override the default component used by `react-navigation`: ```js +import { DrawerItems } from 'react-navigation'; + const CustomDrawerContentComponent = (props) => ( - + ); @@ -126,7 +128,7 @@ const styles = StyleSheet.create({ }); ``` -### `contentOptions` for `DrawerView.Items` +### `contentOptions` for `DrawerItems` - `activeTintColor` - label and icon color of the active label - `activeBackgroundColor` - background color of the active label diff --git a/docs/api/navigators/TabNavigator.md b/docs/api/navigators/TabNavigator.md index 2b8cc5d..0ef3561 100644 --- a/docs/api/navigators/TabNavigator.md +++ b/docs/api/navigators/TabNavigator.md @@ -79,8 +79,8 @@ The route configs object is a mapping from route name to a route config, which t ### TabNavigatorConfig -- `tabBarComponent` - component to use as the tab bar, e.g. `TabView.TabBarBottom` -(this is the default on iOS), `TabView.TabBarTop` +- `tabBarComponent` - component to use as the tab bar, e.g. `TabBarBottom` +(this is the default on iOS), `TabBarTop` (this is the default on Android) - `tabBarPosition` - position of the tab bar, can be `'top'` or `'bottom'` - `swipeEnabled` - whether to allow swiping between tabs diff --git a/src/navigators/DrawerNavigator.js b/src/navigators/DrawerNavigator.js index aff24b6..c5788d4 100644 --- a/src/navigators/DrawerNavigator.js +++ b/src/navigators/DrawerNavigator.js @@ -8,6 +8,8 @@ import createNavigationContainer from '../createNavigationContainer'; import TabRouter from '../routers/TabRouter'; import DrawerScreen from '../views/Drawer/DrawerScreen'; import DrawerView from '../views/Drawer/DrawerView'; +import DrawerItems from '../views/Drawer/DrawerNavigatorItems'; + import NavigatorTypes from './NavigatorTypes'; import type { DrawerViewConfig } from '../views/Drawer/DrawerView'; @@ -28,7 +30,7 @@ const DefaultDrawerConfig = { */ drawerWidth: Dimensions.get('window').width - (Platform.OS === 'android' ? 56 : 64), - contentComponent: DrawerView.Items, + contentComponent: DrawerItems, drawerPosition: 'left', }; diff --git a/src/navigators/TabNavigator.js b/src/navigators/TabNavigator.js index 4f1ab46..2a832c2 100644 --- a/src/navigators/TabNavigator.js +++ b/src/navigators/TabNavigator.js @@ -7,6 +7,9 @@ import createNavigator from './createNavigator'; import createNavigationContainer from '../createNavigationContainer'; import TabRouter from '../routers/TabRouter'; import TabView from '../views/TabView/TabView'; +import TabBarTop from '../views/TabView/TabBarTop'; +import TabBarBottom from '../views/TabView/TabBarBottom'; + import NavigatorTypes from './NavigatorTypes'; import type { TabViewConfig } from '../views/TabView/TabView'; @@ -61,14 +64,14 @@ const TabNavigator = ( const Presets = { iOSBottomTabs: { - tabBarComponent: TabView.TabBarBottom, + tabBarComponent: TabBarBottom, tabBarPosition: 'bottom', swipeEnabled: false, animationEnabled: false, lazyLoad: false, }, AndroidTopTabs: { - tabBarComponent: TabView.TabBarTop, + tabBarComponent: TabBarTop, tabBarPosition: 'top', swipeEnabled: true, animationEnabled: true, diff --git a/src/react-navigation.js b/src/react-navigation.js index 6fc7e16..d2cc06c 100644 --- a/src/react-navigation.js +++ b/src/react-navigation.js @@ -51,18 +51,36 @@ module.exports = { get Card() { return require('./views/Card').default; }, + + // Header get Header() { return require('./views/Header').default; }, + get HeaderTitle() { + return require('./views/HeaderTitle').default; + }, get HeaderBackButton() { return require('./views/HeaderBackButton').default; }, + + // DrawerView get DrawerView() { return require('./views/Drawer/DrawerView').default; }, + get DrawerItems() { + return require('./views/Drawer/DrawerNavigatorItems').default; + }, + + // TabView get TabView() { return require('./views/TabView/TabView').default; }, + get TabBarTop() { + return require('./views/TabView/TabBarTop').default; + }, + get TabBarBottom() { + return require('./views/TabView/TabBarBottom').default; + }, // HOCs get withNavigation() { diff --git a/src/views/Drawer/DrawerView.js b/src/views/Drawer/DrawerView.js index 33475d2..0524961 100644 --- a/src/views/Drawer/DrawerView.js +++ b/src/views/Drawer/DrawerView.js @@ -4,7 +4,6 @@ import React, { PureComponent } from 'react'; import DrawerLayout from 'react-native-drawer-layout-polyfill'; import addNavigationHelpers from '../../addNavigationHelpers'; -import DrawerNavigatorItems from './DrawerNavigatorItems'; import DrawerSidebar from './DrawerSidebar'; import type { @@ -42,8 +41,6 @@ type Props = DrawerViewConfig & { * Component that renders the drawer. */ export default class DrawerView extends PureComponent { - static Items = DrawerNavigatorItems; - props: Props; componentWillMount() { diff --git a/src/views/Header.js b/src/views/Header.js index 5726cda..ecbfc97 100644 --- a/src/views/Header.js +++ b/src/views/Header.js @@ -39,8 +39,6 @@ const TITLE_OFFSET = Platform.OS === 'ios' ? 70 : 40; class Header extends React.PureComponent { static HEIGHT = APPBAR_HEIGHT + STATUSBAR_HEIGHT; - static Title = HeaderTitle; - static BackButton = HeaderBackButton; state = { widths: {}, diff --git a/src/views/TabView/TabView.js b/src/views/TabView/TabView.js index 9258d27..4c88f64 100644 --- a/src/views/TabView/TabView.js +++ b/src/views/TabView/TabView.js @@ -8,8 +8,6 @@ import { TabViewPagerScroll, TabViewPagerPan, } from 'react-native-tab-view'; -import TabBarTop from './TabBarTop'; -import TabBarBottom from './TabBarBottom'; import SceneView from '../SceneView'; import withCachedChildNavigation from '../../withCachedChildNavigation'; @@ -68,9 +66,6 @@ switch (Platform.OS) { } class TabView extends PureComponent { - static TabBarTop = TabBarTop; - static TabBarBottom = TabBarBottom; - props: Props; _handlePageChanged = (index: number) => { @@ -224,9 +219,6 @@ class TabView extends PureComponent { const TabViewEnhanced = withCachedChildNavigation(TabView); -TabViewEnhanced.TabBarTop = TabBarTop; -TabViewEnhanced.TabBarBottom = TabBarBottom; - export default TabViewEnhanced; const styles = StyleSheet.create({