ptomasroos / react-native-scrollable-tab-view

Tabbed navigation that you can swipe between, each tab can have its own ScrollView and maintain its own scroll position between swipes. Pleasantly animated. Customizable tab bar
https://www.npmjs.com/package/react-native-scrollable-tab-view
6.94k stars 2.28k forks source link

Disable the tabbar #799

Closed wesleyvandevoorde closed 6 years ago

wesleyvandevoorde commented 6 years ago

I'm currently looking for a way to disable the whole tabbar. So it still shows up but you can't select the tabs nor can swipe between them. Is there any way I can achieve this? Swiping can be disabled with the locked property but I can't find a way to disable taps.

vipinconqsys commented 6 years ago

Any luck @wesleyvandevoorde ?

wesleyvandevoorde commented 6 years ago

@vipinconqsys I couldn't really find a clean solution within this library, that's why I decided to wrap the whole component in a view and disable the pointer-events. Works like a charm

<View style={theme.container} pointerEvents={showContent ? 'auto' : 'none'}>
            <ScrollableTabView
              onChangeTab={this.onChangeTab}
              initialPage={getTabIndex(this.props.tabKey)}
              tabBarTextStyle={styles.title}
              tabBarBackgroundColor={S.COLOR_BLUE_DARK}
              tabBarUnderlineStyle={showContent ? styles.tabIndicator : styles.disabledTabIndicator}
              tabBarActiveTextColor={showContent ? S.COLOR_SECONDARY : S.COLOR_DISABLED_TABS}
              tabBarInactiveTextColor={showContent ? S.COLOR_WHITE : S.COLOR_DISABLED_TEXT}
            >
              {tabLabels.map((tabLabel, index) => (
                this.props.source ?
                  mapping[index] !== 'stations' &&
                  <SearchTabSingle
                    tabLabel={tabLabel}
                    tabKey={mapping[index]}
                    key={mapping[index]}
                    source={this.props.source}
                    page={this.props.page}
                  />
                  :
                  <SearchTab tabLabel={tabLabel} tabKey={mapping[index]} key={mapping[index]} showContent={showContent} />
              ))}
            </ScrollableTabView>
          </View>
vipinconqsys commented 6 years ago

@wesleyvandevoorde I can't understand your sample code likes showContent SearchTabSingle (this.props.source) SearchTabSingle