1.0.0 • Published 3 years ago

react-native-bottomsheet-utrain v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

react-native-bottomsheet-utrain

Cross platform scrollable bottom sheet for both Android and iOS. That integrates with all core scrollable components from React Native

  • Light weight component
  • Customize whatever you like
  • Smooth animation
  • Support drag down gesture
npm.io

Installation

Open a Terminal in the project root and run:

yarn add react-native-bottomsheet-utrain

or if you use npm:

npm install react-native-bottomsheet-utrain

Install and link react-native-gesture-handler and react-native-reanimated.

Usage

import { Dimensions, Platform } from 'react-native'
import BottomSheet from 'react-native-bottomsheet-utrain';
const refBottom = React.useRef();
const HEIGHT = Dimensions.get('screen').height;
const snapPoints = [50, HEIGHT / 2, '70%', '100%'];

class Example extends React.Component {
  render() {
    return (
      <View style={{flex: 1}}>
      <BottomSheet
       ref={refBottom}
          borderRadius={10}
          bottomSheerColor="#FFFFFF"
          ref="BottomSheet"
          snapPoints={snapPoints}
          enabledGestureInteraction={true}
          enabledContentGestureInteraction={true}
          enabledContentTapInteraction={true}
          enabledInnerScrolling={true}
          renderHeader={
            <View>
              <Text style={styles.text}>Header View</Text>
            </View>
          }
          renderContent={
            <View style={styles.body}>
              <Text style={styles.text}>Body View</Text>
            </View>
          }
        />
      </View>
    );
  }
}

Props

namerequireddefaultdescription
snapPointsyesE.g. [100, 300, 0]. Points for snapping of bottom sheet coomponent. They define distance from bottom of the screen. Might be number or percent (as string e.g. '20%') for points or percents of screen height from bottom. Note: Array values must be in descending order.
initialPositionno0Determines initial position point of bottom sheet. The value outside of snap points.
renderContentnoMethod for rendering scrollable content of bottom sheet.
renderHeadernoMethod for rendering scrollable header of bottom sheet.
headerPositionnonumberReanimated node which holds position of bottom sheet's header (in dp)
contentPositionnonumberReanimated node which holds position of bottom sheet;s content (in dp).
onOpenStartno() => nullFunction to execute when the panel is opened
onCloseStartno() => nullFunction to execute when the panel is closed
enabledGestureInteractionnofalseDefines if bottom sheet could be scrollable by gesture. Defaults to true.

Contributors ✨

Thanks goes to these wonderful people: