React-native-tab-view: TabBar Ripple flows outside of tabs

Created on 16 Nov 2017  路  6Comments  路  Source: satya164/react-native-tab-view

Expected behaviour

Ripple on Android should not flow outside of buttons

Actual behaviour

Ripple flows outside of buttons/Tabs

Code sample, screenshots

const Notes = ({ notes, styles }) => {
  return (
    <View style={styles.notesWrapper}>
      <Text style={styles.notesText}>{notes || "No notes"}</Text>
    </View>
  );
};

@inject("themeStore")
@observer
class NotesTabs extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      index: 0,
      routes: [{ key: "1", title: "Business" }, { key: "2", title: "Campaign" }]
    };
  }
  _handleIndexChange = index => this.setState({ index });
  _renderHeader = props => (
    <TabBar
      pressColor={
        this.props.themeStore.theme === "light" ? (
          Colors.secondary
        ) : (
          Colors.primary
        )
      }
      style={{ backgroundColor: "rgba(0,0,0,0)" }}
      indicatorStyle={{ backgroundColor: Colors.primary }}
      labelStyle={{
        color:
          this.props.themeStore.theme === "light"
            ? Colors.secondary
            : Colors.primary
      }}
      {...props}
    />
  );
  _renderScene = ({ route }) => {
    switch (route.key) {
      case "1":
        return (
          <Notes notes={this.props.businessNotes} styles={this.props.styles} />
        );
      case "2":
        return (
          <Notes notes={this.props.campaignNotes} styles={this.props.styles} />
        );
      default:
        return null;
    }
  };
  render() {
    return (
      <TabViewAnimated
        style={{ flex: 1 }}
        navigationState={this.state}
        renderScene={this._renderScene}
        renderHeader={this._renderHeader}
        renderPager={props => <TabViewPagerScroll {...props} />}
        onIndexChange={this._handleIndexChange}
      />
    );
  }
}

kapture 2017-11-15 at 16 46 24

What have you tried

I've tried putting overflow:hidden on everything I can think of, and I basically copied the example. I loaded the example in Expo and it works fine though.

All 6 comments

The ripple effect needs a background color to be clipped. So instead of setting the background color to transparent, you can try setting it to #1D213A and the ripple will get cut off.

Is there a way to cut off the ripple effect while having the background color as transparent?

Set a border maybe.

Thanks, setting a border with width 0 worked.

Hey @agzuniverse,
Where did you set border width 0 ?

I solved my problem on android this way:

renderLabel={({ route, focused }) => (
   <View style={{ flexWrap: "wrap-reverse" }}>
      // YOUR CODE
   </View>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

glennvgastel picture glennvgastel  路  3Comments

jouderianjr picture jouderianjr  路  3Comments

f6m6 picture f6m6  路  3Comments

ashusdn picture ashusdn  路  4Comments

itzsaga picture itzsaga  路  3Comments