Skip to content

Commit 6ee072d

Browse files
authored
fix tabview.android issues (#643)
1 parent 4ac6ff7 commit 6ee072d

File tree

1 file changed

+15
-26
lines changed

1 file changed

+15
-26
lines changed

views/components/tabbed-view/index.android.js

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// @flow
22
import React from 'react'
33
import { StyleSheet, Platform, Dimensions } from 'react-native'
4-
import { TabViewAnimated, TabBarTop } from 'react-native-tab-view'
4+
import { TabViewAnimated, TabBar } from 'react-native-tab-view'
55
import * as c from '../colors'
66
import type { TabbedViewPropsType } from './types'
7-
import { TabbedViewPropTypes } from './types'
87
import {tracker} from '../../../analytics'
98

109
const styles = StyleSheet.create({
@@ -26,8 +25,6 @@ const styles = StyleSheet.create({
2625
})
2726

2827
export default class TabbedView extends React.Component {
29-
static propTypes = TabbedViewPropTypes
30-
3128
state = {
3229
index: 0,
3330
}
@@ -42,28 +39,20 @@ export default class TabbedView extends React.Component {
4239
}
4340

4441
_renderHeader = props => {
45-
if (this.props.tabs.length > 2) {
46-
return (
47-
<TabBarTop
48-
{...props}
49-
scrollEnabled={true}
50-
indicatorStyle={styles.indicator}
51-
style={styles.tabbar}
52-
labelStyle={styles.label}
53-
/>
54-
)
55-
} else {
56-
return (
57-
<TabBarTop
58-
{...props}
59-
scrollEnabled={true}
60-
indicatorStyle={styles.indicator}
61-
style={styles.tabbar}
62-
labelStyle={styles.label}
63-
tabWidth={Dimensions.get('window').width / 2}
64-
/>
65-
)
66-
}
42+
const tabStyle = this.props.tabs.length <= 2
43+
? {width: Dimensions.get('window').width / 2}
44+
: undefined
45+
46+
return (
47+
<TabBar
48+
{...props}
49+
scrollEnabled={true}
50+
indicatorStyle={[styles.indicator]}
51+
style={styles.tabbar}
52+
labelStyle={styles.label}
53+
tabStyle={tabStyle}
54+
/>
55+
)
6756
}
6857

6958
_renderScene = ({ route }) => {

0 commit comments

Comments
 (0)