Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Commit

Permalink
breaking: remove <TabBarBottom />
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jul 2, 2016
1 parent a623d7e commit 858801b
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 66 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ The package exposes the following components,

It accepts the following props,
- `pressColor` - color for material ripple (Android > 5.0 only)
- `renderIcon` - callback which receives the current scene and returns a React Element to be used as a icon
- `renderLabel` - callback which receives the current scene and returns a React Element to be used as a label
- `renderIndicator` - callback which receives the current scene and returns a React Element to be used as a indicator
- `renderIcon` - optiona; callback which receives the current scene and returns a React Element to be used as a icon
- `renderLabel` - optional callback which receives the current scene and returns a React Element to be used as a label
- `renderIndicator` - optional callback which receives the current scene and returns a React Element to be used as a indicator
- `tabStyle` - style object for the tab
- `indicatorStyle` - style object for the tab indicator

Expand All @@ -122,8 +122,3 @@ The package exposes the following components,
It accepts the following props in addition to the props accepted by `<TabBar />`,
- `renderLabel` - optional callback which receives the current scene and returns a React Element to be used as a label
- `indicatorStyle` - style object for the tab indicator

- `<TabBarTop />` - material design themed bottom tab bar

It accepts the following props in addition to the props accepted by `<TabBar />`,
- `renderLabel` - optional callback which receives the current scene and returns a React Element to be used as a label
4 changes: 2 additions & 2 deletions example/src/BottomBarIconExample.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { View, Image, StyleSheet } from 'react-native';
import { TabViewAnimated, TabViewPage, TabBarBottom } from 'react-native-tab-view';
import { TabViewAnimated, TabViewPage, TabBar } from 'react-native-tab-view';

const styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -53,7 +53,7 @@ export default class TopBarIconExample extends Component {

_renderFooter = (props) => {
return (
<TabBarBottom
<TabBar
{...props}
pressColor='rgba(0, 0, 0, .2)'
renderIcon={this._renderIcon}
Expand Down
8 changes: 6 additions & 2 deletions example/src/BottomBarIconTextExample.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { View, Image, StyleSheet } from 'react-native';
import { TabViewAnimated, TabViewPage, TabBarBottom } from 'react-native-tab-view';
import { TabViewAnimated, TabViewPage, TabBar } from 'react-native-tab-view';

const styles = StyleSheet.create({
container: {
Expand All @@ -14,6 +14,9 @@ const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
tab: {
padding: 0,
},
});

export default class TopBarIconExample extends Component {
Expand Down Expand Up @@ -53,10 +56,11 @@ export default class TopBarIconExample extends Component {

_renderFooter = (props) => {
return (
<TabBarBottom
<TabBar
{...props}
pressColor='rgba(0, 0, 0, .2)'
renderIcon={this._renderIcon}
tabStyle={styles.tab}
style={styles.tabbar}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions example/src/NoAnimationExample.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { View, Image, StyleSheet } from 'react-native';
import { TabViewAnimated, TabViewPage, TabBarBottom } from 'react-native-tab-view';
import { TabViewAnimated, TabViewPage, TabBar } from 'react-native-tab-view';

const styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -53,7 +53,7 @@ export default class TopBarIconExample extends Component {

_renderFooter = (props) => {
return (
<TabBarBottom
<TabBar
{...props}
pressColor='rgba(0, 0, 0, .2)'
renderIcon={this._renderIcon}
Expand Down
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export { default as TabViewAnimated } from './src/TabViewAnimated';
export { default as TabViewPage } from './src/TabViewPage';
export { default as TabBar } from './src/TabBar';
export { default as TabBarTop } from './src/TabBarTop';
export { default as TabBarBottom } from './src/TabBarBottom';
21 changes: 17 additions & 4 deletions src/TabBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Animated,
StyleSheet,
View,
Text,
} from 'react-native';
import shallowCompare from 'react-addons-shallow-compare';
import TouchableItem from './TouchableItem';
Expand All @@ -18,6 +19,10 @@ const styles = StyleSheet.create({
flexWrap: 'nowrap',
elevation: 4,
},
tablabel: {
color: 'white',
margin: 8,
},
tab: {
flex: 1,
},
Expand All @@ -29,16 +34,20 @@ const styles = StyleSheet.create({
},
});

type DefaultProps = {
renderLabel: (scene: Scene) => ?React.Element<any>;
}

type Props = SceneRendererProps & {
pressColor?: string;
renderLabel: (scene: Scene) => React.Element<any>;
renderIcon: (scene: Scene) => React.Element<any>;
renderIndicator: (props: SceneRendererProps) => React.Element<any>;
renderLabel?: (scene: Scene) => ?React.Element<any>;
renderIcon?: (scene: Scene) => ?React.Element<any>;
renderIndicator?: (props: SceneRendererProps) => ?React.Element<any>;
tabStyle?: any;
style?: any;
}

export default class TabBarTop extends Component<void, Props, void> {
export default class TabBarTop extends Component<DefaultProps, Props, void> {
static propTypes = {
...SceneRendererPropType,
pressColor: TouchableItem.propTypes.pressColor,
Expand All @@ -49,6 +58,10 @@ export default class TabBarTop extends Component<void, Props, void> {
style: View.propTypes.style,
};

static defaultProps = {
renderLabel: ({ route }) => route.title ? <Text style={styles.tablabel}>{route.title}</Text> : null,
};

shouldComponentUpdate(nextProps: Props, nextState: void) {
return shallowCompare(this, nextProps, nextState);
}
Expand Down
46 changes: 0 additions & 46 deletions src/TabBarBottom.js

This file was deleted.

1 change: 0 additions & 1 deletion src/TabBarTop.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import type { Scene, SceneRendererProps } from './TabViewTypeDefinitions';
const styles = StyleSheet.create({
tablabel: {
color: 'white',
fontSize: 14,
margin: 8,
},
indicator: {
Expand Down

0 comments on commit 858801b

Please sign in to comment.