ptomasroos / react-native-tab-navigator

A tab bar that switches between scenes, written in JS for cross-platform support
MIT License
2.4k stars 415 forks source link

hide tabbar?still there...but tiny #11

Closed superlbr closed 6 years ago

superlbr commented 8 years ago

image And I was not that sure wether it's the right place. image And I was just want to hide after navigator.push...

timzaak commented 8 years ago

+1

ide commented 8 years ago

Good catch -- there needs to be overflow: hidden set as well.

Here's a complete example:

'use strict';

let React = require('react-native');
let {
  AppRegistry,
  Image,
  StatusBarIOS,
  StyleSheet,
  Text,
  TouchableOpacity,
  View,
} = React;
let TabNavigator = require('react-native-tab-navigator');

class HiddenTabBarDemo extends React.Component {
  constructor(props, context) {
    super(props, context);
    this.state = {
      selectedTab: 'home',
      showTabBar: true,
    };
  }

  render() {
    let tabBarStyle = {};
    let sceneStyle = {};
    if (!this.state.showTabBar) {
      tabBarStyle.height = 0;
      tabBarStyle.overflow = 'hidden';
      sceneStyle.paddingBottom = 0;
    }

    return (
      <TabNavigator tabBarStyle={tabBarStyle} sceneStyle={sceneStyle}>
        <TabNavigator.Item
          selected={this.state.selectedTab === 'home'}
          title="Home"
          onPress={() => this.setState({ selectedTab: 'home' })}>
          <View style={styles.scene}>
            <TouchableOpacity onPress={this._toggleTabBarVisibility.bind(this)}>
              <Text style={styles.button}>
                {this.state.showTabBar ? 'Hide Tab Bar' : 'Show Tab Bar'}
              </Text>
            </TouchableOpacity>
          </View>
        </TabNavigator.Item>
        <TabNavigator.Item
          selected={this.state.selectedTab === 'profile'}
          title="Profile"
          onPress={() => this.setState({ selectedTab: 'profile' })}>
          <View style={styles.scene}>
            <Text style={{ color: '#fff' }}>Profile</Text>
          </View>
        </TabNavigator.Item>
      </TabNavigator>
    );
  }

  _toggleTabBarVisibility() {
    this.setState(state => ({
      showTabBar: !state.showTabBar,
    }));
  }
}

let styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
  },
  scene: {
    backgroundColor: '#1e2127',
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  button: {
    color: '#007aff',
    fontWeight: '600',
  },
});

StatusBarIOS.setStyle('light-content');

AppRegistry.registerComponent('main', () => HiddenTabBarDemo);
timzaak commented 8 years ago

@ide the complete example does not work in Android. image

superlbr commented 8 years ago

@ide hi,I don't think it's a complete example for newcomer.Need to pass props from children component or next porps....:p

superlbr commented 8 years ago

@ide update ReadMe.md first,hah...

zhuchaowe commented 8 years ago

hide the tabbar with the tabbarheight:0 and overflow:hidden works in IOS,but not work in android.

Any suggestions?

hezheop commented 8 years ago

that works in IOS, but not work in android. @ide,thx,what can i do ?

ide commented 8 years ago

This isn't urgent for our team so we are currently not looking into this.

timzaak commented 8 years ago

8 may be a temp solution.

https://github.com/timzaak/react-native-tab-navigator/tree/visible-fullscreen-Feather this branch is OK

cnjon commented 8 years ago

+1

moxiaobei2 commented 8 years ago

I change my mind ,and set tabBarStyle.opacity=0 is worked for android.

ptomasroos commented 6 years ago

Will close since this issue is more than a year, feel free to a open a new if this is still a issue.