JungHsuan / react-native-collapsible-tabview

This is only an implementation of tabview with collapsible header.
MIT License
284 stars 60 forks source link

How to keep navigation header on top? #24

Closed ydhnwb closed 2 years ago

ydhnwb commented 3 years ago

I have navigation header for showing back button and title. I just want to keep this on top and not get replaced by collapsed header or the tabs.

ydhnwb commented 3 years ago

I want the white header (back button and title) is keep on top, while the green will be scrollable. I copied your code on ScrollableHeader and just add this

    <SafeAreaView style={styles.container}>
      <Header title="Detail Bahan Baku" />

      <View style={{flex: 1}}>
        {renderTabView()}
        {renderHeader()}
      </View>
    </SafeAreaView>
JungHsuan commented 2 years ago

Hi @ydhnwb, do you mean that you don't want the collapsed header or the tabs view scroll over on top of the <Header/>?

ydhnwb commented 2 years ago

Yes. I want header to keep on top, and the tab will hanging below the header when it scrolled Screenshot_1647403019 Screenshot_1647403024

JungHsuan commented 2 years ago

Is this what you attempt to achieve? Simulator Screen Recording - iPhone 13 - 2022-03-16 at 12 35 55

ydhnwb commented 2 years ago

yes, exactly like that

JungHsuan commented 2 years ago

Here is my example code:

const Header = ({title}) => {
  return (
    <View
      style={{
        backgroundColor: 'white',
        height: 65,
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'center',
      }}>
      <Text style={{fontSize: 20}}>{title}</Text>
    </View>
  );
};

const App = () => {
  return (
    <SafeAreaView style={{flex: 1}}>
      <Header title="Detail Material" />
      <CollapsibleTabView />
    </SafeAreaView>
  );
};

For: CollapsibleTabView, I simply copy my collapibleTabView.js and modify the style like this:

  return (
    <View style={{flex: 1, overflow: 'hidden'}}>
      {renderTabView()}
      {renderHeader()}
    </View>
  );

By adding overflow: 'hidden' to prevent the header from renderHeader() scroll over on top of the navigation bar.

ydhnwb commented 2 years ago

Thank you very much. I'll try to implement that