0.3.1 • Published 2 years ago

react-native-bottomsheet-reanimated v0.3.1

Weekly downloads
172
License
MIT
Repository
github
Last release
2 years ago

Would you like to support me?


:warning: IMPORTANT: This Library has been deprecated in favor of react-native-bottom-sheet because this Library is using Reanimated V1

react-native-bottomsheet-reanimated

Highly configurable component imitating native bottom sheet behavior, with fully native 60 FPS animations!

Built from scratch with react-native-interactable-reanimated and react-native-reanimated.

Usable with Expo with no extra native dependencies!

npm.ionpm.ionpm.io

Installation

Open a Terminal in the project root and run:

yarn add react-native-bottomsheet-reanimated react-native-interactable-reanimated

or if you use npm:

npm install react-native-bottomsheet-reanimated

If you are using Expo, you are done.

If you don't use Expo, install and link react-native-gesture-handler and react-native-reanimated.

Usage

import BottomSheet from 'react-native-bottomsheet-reanimated';

class Example extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <BottomSheet
          keyboardAware
          bottomSheerColor="#FFFFFF"
          ref="BottomSheet"
          initialPosition={'50%'} //200, 300
          snapPoints={['50%', '100%']}
          isBackDrop={true}
          isBackDropDismissByPress={true}
          isRoundBorderWithTipHeader={true}
          // backDropColor="red"
          // isModal
          // containerStyle={{backgroundColor:"red"}}
          // tipStyle={{backgroundColor:"red"}}
          // headerStyle={{backgroundColor:"red"}}
          // bodyStyle={{backgroundColor:"red",flex:1}}
          header={
            <View>
              <Text style={styles.text}>Header</Text>
            </View>
          }
          body={
            <View style={styles.body}>
              <Text style={styles.text}>Body</Text>
            </View>
          }
        />
      </View>
    );
  }
}

Props

namerequireddefaultdescription
keyboardAwarenofalsetrue will avoid current snap when keyboard will open.
overDragnotruefalse will disable overdrag of last snap, false will also disable bounce' andisModal`.
keyboardAwareExtraSnapHeightno0when keyboardAware=true and this is for adding extra space in snap when keyboard open
keyboardAwareDragnofalsewhen keyboardAware=true and this is used for enable or disable drag when keyboard open
onChangeKeyboardAwareSnapnowhen keyboardAware=true then it give keyboard awareview snap. onChangeKeyboardAwareSnap: (previousSnap: number,nextSnap: number,keyboardHeight: number) => void;
snapPointsyesE.g. [300, 200, 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.
bodynoMethod for rendering scrollable content of bottom sheet.
headernoMethod for rendering non-scrollable header of bottom sheet.
isBackDropnofalsefor show backdrop behind the bottom sheet.
isBackDropDismissByPressnofalseenable to move bottomsheet to first snappoint by pressing backdrop.
isRoundBorderWithTipHeadernofalsegive round with tip header style to bottomsheet.
isModalnofalseto make bottom sheet like modal.
bounceno0.5for increase or decrease bounce effect
isAnimatedYFromParentnoIf true then give animated value to animatedValueY props.
animatedValueYnoIf isAnimatedYFromParent will be true then it will give animtedY value to animatedValueY props.
bottomSheerColorno#fffffffor background color of bottom sheet.
tipStylenofor change style of tip. it is dependted on isRoundBorderWithTipHeader.
headerStylenofor change style of header.
bodyStylenofor change style of body.
dragEnablednotruefor enable/disable drag
tipHeaderRadiusno12for tip header border radius
onClosenoMethod call when bottomsheet close
containerStylenofor change style of container
bodyContainerStylenofor change style of body container
onChangeSnapnoMethod call when change any snap

Methods

snapTo(index)

Imperative method on for snapping to snap point in given index. E.g.

// Snap to the snap point at index 0 (e.g. 450 in [450, 300, 0])
this.refs.BottomSheet.current.snapTo(0);

Here this.refs.BottomSheet refers to the ref passed to the BottomSheet component.

Example

More complex examples can be found in the Example folder. To view the examples in the Expo app, open a Terminal and run:

yarn
cd Example
yarn
expo start

Contributors ✨

Thanks goes to these wonderful people (emoji key):

0.3.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.1.1

2 years ago

0.0.44

3 years ago

0.0.42

3 years ago

0.0.43

3 years ago

0.0.40

3 years ago

0.0.41

3 years ago

0.0.37

3 years ago

0.0.38

3 years ago

0.0.39

3 years ago

0.0.35

3 years ago

0.0.36

3 years ago

0.0.34

3 years ago

0.0.32

3 years ago

0.0.33

3 years ago

0.0.31

3 years ago

0.0.30

3 years ago

0.0.29

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.26

3 years ago

0.0.27

3 years ago

0.0.28

3 years ago

0.0.23

3 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.18

4 years ago

0.0.19

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

1.0.0

4 years ago