Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STATE_HIDDEN not working #26

Open
kisubs opened this issue May 31, 2017 · 6 comments
Open

STATE_HIDDEN not working #26

kisubs opened this issue May 31, 2017 · 6 comments

Comments

@kisubs
Copy link

kisubs commented May 31, 2017

STATE_HIDDEN renders the same view as STATE_COLLAPSED.
`<CoordinatorLayout style={{flex: 1}}>
<View style={{ flex: 1, backgroundColor: 'transparent' }}>
<BottomSheetBehavior

        ref='bottomSheet'
        peekHeight={70}
        hideable={true}
        state={BottomSheetBehavior.STATE_HIDDEN}>
        <View style={{backgroundColor: '#4389f2'}}>
          <View style={{padding: 26}}>
            <Text>BottomSheetBehavior!</Text>
          </View>
          <View style={{height: 200, backgroundColor: '#fff'}} />
        </View>
      </BottomSheetBehavior>
      <FloatingActionButton autoAnchor ref="fab" />
    </CoordinatorLayout>`
@cesardeazevedo
Copy link
Owner

Hi, Thanks for report.

There's a issue with the @ReactProps order, it setting the state before checking the hideable prop as true, i am still trying to figure out.

But you can set the STATE_HIDDEN on the componentDidMount as follows

componentDidMount() {
  this.bottomSheet.setBottomSheetState(BottomSheetBehavior.STATE_HIDDEN)
}

render() {
  <BottomSheetBehavior ref={ref => {this.bottomSheet = ref}}></BottomSheetBehavior>
}

I also do not recommend you manage the bottom sheet state directly on the state prop, because it's hard to control, you should manage with the setBottomSheetState method.

@kisubs
Copy link
Author

kisubs commented Jun 2, 2017

Thanks for the information!

@mikeevstropov
Copy link

this.bottomSheet.setBottomSheetState(BottomSheetBehavior.STATE_HIDDEN)
Should it work to hide a sheet programmatically?
I think im doing something wrong

@cesardeazevedo
Copy link
Owner

@mikeevstropov did you enabled hideable={true}?

@mikeevstropov
Copy link

mikeevstropov commented Dec 20, 2017

@cesardeazevedo Yes. But im using NestedScrollView

hideBottomSheet() {
    if (this.bottomSheet)
        this.bottomSheet.setBottomSheetState(
            BottomSheetBehavior.STATE_HIDDEN
        )
}
<BottomSheetBehavior
    hideable={true}
    peekHeight={110}
    ref={ref => this.bottomSheet = ref}>
    <NestedScrollView ref={ref => this.nestedScroll = ref}>
        { child }
    </NestedScrollView>
</BottomSheetBehavior>

@mikeevstropov
Copy link

@cesardeazevedo Im sorry. Its my mistake. Method works correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants