Fixed auto navigate action for tabbar

This commit is contained in:
Mustafa Buyukcelebi 2019-10-04 11:02:33 +03:00
parent a927c70f77
commit 7ca33bfb70
3 changed files with 16 additions and 28 deletions

View File

@ -2,15 +2,10 @@ import EStyleSheet from 'react-native-extended-stylesheet';
export default EStyleSheet.create({ export default EStyleSheet.create({
wrapper: { wrapper: {
flexDirection: 'row',
height: 56,
width: '$deviceWidth', width: '$deviceWidth',
backgroundColor: '$primaryBackgroundColor', position: 'absolute',
borderTopWidth: 0.1, bottom: 0,
shadowOpacity: 0.1, left: 0,
elevation: 10, zIndex: 99999,
},
safeArea: {
backgroundColor: '$primaryBackgroundColor',
}, },
}); });

View File

@ -71,20 +71,12 @@ class BottomTabBarView extends PureComponent {
} = this.props; } = this.props;
return ( return (
<SafeAreaView <SafeAreaView style={styles.wrapper}>
style={{
position: 'absolute',
bottom: 0,
left: 0,
zIndex: 99999,
width: Dimensions.get('window').width,
}}
>
<TabBar <TabBar
selectedIndex={0} selectedIndex={index}
circleBackgroundColor="#357ce6" circleBackgroundColor="#357ce6"
backgroundColor="#f6f6f6" backgroundColor="#f6f6f6"
onChange={index => this._jumpTo(routes[index])} onChange={i => this._jumpTo(routes[i])}
activeTintColor={activeTintColor} activeTintColor={activeTintColor}
inactiveTintColor={inactiveTintColor} inactiveTintColor={inactiveTintColor}
> >

View File

@ -1,11 +1,4 @@
import { import { StyleSheet, View, TouchableHighlight, Animated, Dimensions } from 'react-native';
StyleSheet,
View,
TouchableHighlight,
Animated,
Dimensions,
SafeAreaView,
} from 'react-native';
import React, { Component } from 'react'; import React, { Component } from 'react';
import Svg, { Circle, Path } from 'react-native-svg'; import Svg, { Circle, Path } from 'react-native-svg';
@ -58,6 +51,14 @@ export default class TabBar extends Component {
}); });
} }
componentDidUpdate(prevProps) {
const { selectedIndex } = this.props;
if (prevProps.selectedIndex !== selectedIndex) {
this._onPress(selectedIndex);
}
}
_onPress = (i, disabled) => { _onPress = (i, disabled) => {
const { onChange } = this.props; const { onChange } = this.props;
if (!disabled) { if (!disabled) {