react-native-tab-view icon indicating copy to clipboard operation
react-native-tab-view copied to clipboard

SafeAreaView not working with TabBar

Open steoo opened this issue 8 years ago • 9 comments

To support iPhone X I should use SafeAreaView ( https://reactnavigation.org/docs/en/handling-iphonex.html ) but when used with TabBar it doesn't work

render() {
    return (
     <SafeAreaView>
        <TabView
            style={this.props.style}
            navigationState={this.state}
            renderScene={this._renderScene}
            renderTabBar={this._renderTabBar}
            tabBarPosition="bottom"
            onIndexChange={this._handleIndexChange}
            swipeEnabled={false}
        />
     </SafeAreaView>
    );
}

if used like this nothing is shown on video

steoo avatar Nov 08 '18 17:11 steoo

What do you mean by it does not work? Also you probably want to wrap TabBar in SafeAreaView instead of the whole TabView

satya164 avatar Nov 08 '18 17:11 satya164

It does not show anything on video, the TabBar is not visible and neither the Scenes

steoo avatar Nov 08 '18 17:11 steoo

You probably need flex: 1 on the SafeAreaView. Anyway, you should wrap the individual scenes and TabBar in SafeAreaView instead of the whole TabView.

satya164 avatar Nov 08 '18 17:11 satya164

Going to try it. The problem is that the TabView goes under the "software" button

screenshot 2018-11-08 at 18 31 53

steoo avatar Nov 08 '18 17:11 steoo

Setting flex: 1 on SafeAreaView did the trick, thank you :)

steoo avatar Nov 08 '18 17:11 steoo

@steoo close the issue if it is resolved

ishigamii avatar Nov 14 '18 10:11 ishigamii

thanks! flex: 1 resolved my problem 👍

originalix avatar Mar 30 '19 08:03 originalix

@steoo this fixed the issue flex: 1, long live steoooo ✅

Champkinz avatar Oct 27 '19 03:10 Champkinz

flex: 1 not working!!!

Below is my code

return (
           <SafeAreaView style={styles.container}>
               <Text style={styles.headerText}>
                   {`Courses: ${userCourses.length}`}
               </Text>
               <FlatList
                   data={userCourses}
                   keyExtractor={(item, index) => index.toString()}
                   renderItem={({ item }) => (
                       <UserCourse userCourseInfo={item} onCourseItemClick={()=>{
                           this.onCourseItemClick(item)
                       }} />
                   )}
               />
           <TabBar
               tabs={[
                   {
                   icon: 'ios-home',
                   title: 'Home',
                   onPress: this.selectTab,
                   isActive: this.state.activeTab === 0,
                   },
                   {
                   icon: 'ios-book',
                   title: 'Courses',
                   onPress: this.selectTab,
                   isActive: this.state.activeTab === 1,
                   },
                   {
                   icon: 'ios-clock',
                   title: 'Moments',
                   onPress: this.selectTab,
                   isActive: this.state.activeTab === 2,
                   },
                   {
                   icon: 'ios-notifications',
                   title: 'Notifications',
                   onPress: this.selectTab,
                   isActive: this.state.activeTab === 3,
                   
                   },
               ]}
           />
           </SafeAreaView>
       );

const styles = StyleSheet.create({
   loadingContainer: {
       flex: 1,
       backgroundColor: '#fff',
       alignItems: 'center',
       justifyContent: 'center',
   },
   container: {
       flex: 1,
       backgroundColor: '#fff'
   },
   headerText: {
       marginTop: 10,
       alignSelf: 'center'
   },
   item: {
       padding: 10,
       fontSize: 18,
       height: 44,
   },
   paddingBottom50: {
       bottom: 50,
   }
});


hemantbavle1 avatar Dec 11 '19 18:12 hemantbavle1