react-native-bottom-sheet-behavior icon indicating copy to clipboard operation
react-native-bottom-sheet-behavior copied to clipboard

STATE_HIDDEN not working

Open kisubs opened this issue 8 years ago • 6 comments

STATE_HIDDEN renders the same view as STATE_COLLAPSED. `<CoordinatorLayout style={{flex: 1}}> <View style={{ flex: 1, backgroundColor: 'transparent' }}></View> <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>`

kisubs avatar May 31 '17 17:05 kisubs

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.

cesardeazevedo avatar Jun 02 '17 09:06 cesardeazevedo

Thanks for the information!

kisubs avatar Jun 02 '17 16:06 kisubs

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

mikeevstropov avatar Dec 20 '17 13:12 mikeevstropov

@mikeevstropov did you enabled hideable={true}?

cesardeazevedo avatar Dec 20 '17 13:12 cesardeazevedo

@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 avatar Dec 20 '17 13:12 mikeevstropov

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

mikeevstropov avatar Dec 20 '17 13:12 mikeevstropov