Export all the things (#1219)

* Initial

* Add missing title

* Fix style and ref issues
This commit is contained in:
Mike Grabowski 2017-04-25 10:53:09 +02:00 committed by Satyajit Sahoo
parent 7bd748a6be
commit c39dd9d45f
8 changed files with 34 additions and 22 deletions

View File

@ -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 => <ScrollView><DrawerView.Items {...props} /></ScrollView>
contentComponent: props => <ScrollView><DrawerItems {...props} /></ScrollView>
}
```
@ -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) => (
<View style={style.container}>
<DrawerView.Items {...props} />
<DrawerItems {...props} />
</View>
);
@ -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

View File

@ -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

View File

@ -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',
};

View File

@ -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,

View File

@ -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() {

View File

@ -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<T: *> extends PureComponent<void, Props, void> {
static Items = DrawerNavigatorItems;
props: Props;
componentWillMount() {

View File

@ -39,8 +39,6 @@ const TITLE_OFFSET = Platform.OS === 'ios' ? 70 : 40;
class Header extends React.PureComponent<void, HeaderProps, HeaderState> {
static HEIGHT = APPBAR_HEIGHT + STATUSBAR_HEIGHT;
static Title = HeaderTitle;
static BackButton = HeaderBackButton;
state = {
widths: {},

View File

@ -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<void, Props, void> {
static TabBarTop = TabBarTop;
static TabBarBottom = TabBarBottom;
props: Props;
_handlePageChanged = (index: number) => {
@ -224,9 +219,6 @@ class TabView extends PureComponent<void, Props, void> {
const TabViewEnhanced = withCachedChildNavigation(TabView);
TabViewEnhanced.TabBarTop = TabBarTop;
TabViewEnhanced.TabBarBottom = TabBarBottom;
export default TabViewEnhanced;
const styles = StyleSheet.create({