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

[BUG] ScrollableTabBar's text is not scrollable.

Open jallens opened this issue 10 years ago • 11 comments

When there are too many tabs or the tabs include too many words, the width of the ScrollableTabBar is only equal to the width of the screen.

tmp058f9abc

When there are only a few tabs e.g. 3 tabs, the ScrollableTabBar can be displayed normally.

tmp4d56dffa

@skv-headless

jallens avatar May 30 '16 10:05 jallens

https://appetize.io/embed/6qfv7eydjtm34mhn6qwj2nt3xm?embed=true&screenOnly=false&xdocMsg=true&debug=true&scale=100&deviceColor=black&orientation=portrait&device=iphone6s&osVersion=9.3&deviceId=RGV2aWNlOjU2Y2FjNTExZWQwOTM2MTEwMGRhYTNlNg&platform=ios&width=375&height=668&phoneWidth=416&phoneHeight=870&screenOffsetLeft=21&screenOffsetTop=100&params=%7B%7D it is working in example. Could you share code snippet?

skv-headless avatar May 30 '16 10:05 skv-headless

I found the reason why this bug occurred.

First, I set two tabs. In this case, the ScrollableTabBar did initialized. After I got some data from the server, the data created some tabs in ScrollableTabBar. Then, the bug above came out. It seems dynamically to change the count of ScrollableTabBar, it happened.

I have no idea how to fix it.

@skv-headless

jallens avatar May 30 '16 14:05 jallens

Maybe. I don't use dynamic tab generation. Not sure when I'll be able to take a look

skv-headless avatar May 30 '16 14:05 skv-headless

tmp6eceaf72

code snippet:

import React from 'react';
import {
  StyleSheet,
  Text,
  View,
} from 'react-native';

import ScrollableTabView, { ScrollableTabBar, } from 'react-native-scrollable-tab-view';

export default React.createClass({

  getInitialState() {
    return {
      showMore: false,
    };
  },

  componentDidMount() {
    setTimeout(() => {
      this.setState({
        showMore: true,
      });
    }, 2000);
  },


  renderContents() {
    return [
      <Text key={3} tabLabel='Tab #3 word '>project</Text>,
      <Text key={4} tabLabel='Tab #4 word'>favorite</Text>,
      <Text key={5} tabLabel='Tab #5'>project</Text>,
    ];
  },

  render() {
    return <View style={styles.container}>
      <ScrollableTabView initialPage={0} renderTabBar={() => <ScrollableTabBar />}>
        <Text tabLabel='Tab #1'>My</Text>
        <Text tabLabel='Tab #2 word'>favorite</Text>
        {this.state.showMore && this.renderContents()}
      </ScrollableTabView>
    </View>;
  },
});

const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: 30,
  },
});

jallens avatar May 30 '16 15:05 jallens

<ScrollableTabBar key={this.state.showMore?'1':'0'}/>

stillward avatar Jun 22 '16 08:06 stillward

Is this still an issue?

skv-headless avatar Oct 09 '16 17:10 skv-headless

This appears to be the same problem fixed by https://github.com/skv-headless/react-native-scrollable-tab-view/pull/362

ghuh avatar Oct 09 '16 19:10 ghuh

Cool 👍 Reopen if needed.

skv-headless avatar Oct 13 '16 08:10 skv-headless

//scrollableTabbar.js

hi guys, i encounter this very same problem today ,finally i find a solution ,probably bad, but it works for me

onTabContainerLayout(e) {
    this._tabContainerMeasurements = e.nativeEvent.layout;
    let width = this._tabContainerMeasurements.width;
    if (width < WINDOW_WIDTH) {
      width = WINDOW_WIDTH;
    }
    this.setState({ _containerWidth: width, });   // modify 'width' => null  solved my problem
    this.updateView({value: this.props.scrollValue.__getValue(), });
  },

gagashuai0 avatar Oct 25 '17 10:10 gagashuai0

Hello. @skv-headless if I have something like this

<ScrollableTabView
      style={{ marginTop: 5 }}
      locked={disabled}
      //page={ props.selectedTab }
      //initialPage={ props.selectedTab }
      onChangeTab={props.onSelect}
    //renderTabBar={() => <ScrollableTabBar />}
    >
      {
        tabs.map((tab, i) => (
          <ScrollView
            scrollEventThrottle={16}
            key={i}
            tabLabel={tab.label}
          >
            {tab.content}
          </ScrollView>
        ))
      }
    </ScrollableTabView>
`
I'm not getting the width correclty displayed.. it shows all tabs with a fixed width. To solve this should a create my own toolbar and there set the width?

MaxiSantos avatar Jan 18 '18 22:01 MaxiSantos

Hooo my bad... I didn't realize the component was called ScrollableTabBar. I'm using it and it's scrolling although the animation is stuck sometimes.

MaxiSantos avatar Jan 24 '18 13:01 MaxiSantos