rilyu / teaset

A UI library for react native, provides 20+ pure JS(ES6) components, focusing on content display and action control.
MIT License
2.94k stars 481 forks source link

Segmented View navigation with other button #366

Open tanz98 opened 5 years ago

tanz98 commented 5 years ago

Hi all, i don't have no idea to make navigation to other segmented sheet with other button. So the case is i have button confirmation in sheet 1, when i click that button i want navigating to sheet 2 anyway to implement that case?

yangfanyu commented 5 years ago

i found the same question

yangfanyu commented 5 years ago

now i found how to fix it. the lib has no bug,but the example has a little question

example/views/SegmentedBarExample.js :

onCarouselChange(index) {
        // index != this.state.activeIndex && this.setState({activeIndex: index});// bug code
        //i change to:
        if (index != this.state.activeIndex) {
            if (this.refs.segmentedbar) {
                this.refs.segmentedbar.activeIndex = index;//this line sync segmentbar and carousel
            }
        }
    }

then add this ref

 <SegmentedBar
          ........
          ref='segmentedbar'
          ........
        >

i test, it works, but the anim was wrong。may be extends the class SegmentedBar is a good way.