npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-swipe-down-modal

v1.0.2

Published

Swipable bottom drawer component like Instagram's comment component.

Downloads

11

Readme

react-native-swipe-down-modal

Swipable bottom drawer component like Instagram's comment component.

  • Easy to use
  • Easy to customize
  • Smooth animation
  • No dependency
  • Works perfect with scrollview and flatlist
  • Swipable and unswipable modes

Originated to this package: react-native-swipe-modal-up-down

swipable-modal-demo

Getting Started

$ npm install react-native-swipe-down-modal

Usage

import SwipeDownModal from 'react-native-swipe-down-modal';

  const SwipeDownTestScreen = () => {

    const [visible, setVisible] = useState(false)


    return (
        <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
            <SwipeDownModal
                visible={visible}
                onClose={() => setVisible(false)}
            >
                <View
                    style={{
                        justifyContent: 'center',
                        alignItems: 'center',
                        flex: 1
                    }}>
                    <Text>Hello world</Text>
                </View>
            </SwipeDownModal>
            <Button
                title='Press to open'
                onPress={() => setVisible(true)}
            />
        </View>
    )

}

export default SwipeDownTestScreen;

Using customized header, customized style and closing programmatically

const SwipeDownTestScreen = () => {

    const [visible, setVisible] = useState(false)

    return (
        <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
            <SwipeDownModal
                visible={visible}
                onClose={() => setVisible(false)}
                backgroundColor={'rgba(0,0,0,.5)'}
                drawerBackgroundColor={'green'}
                borderTopRadius={20}
                swipeDisabled={true}
                marginTop={Dimensions.get("screen").height - 500}
                customHeader={
                    <View
                        style={{
                            height: 70,
                            padding: 10,
                            borderBottomColor: 'yellow',
                            borderBottomWidth: 3,
                            alignItems: 'center',
                            justifyContent: 'center'
                        }}>
                        <Text>Foo</Text>
                        <TouchableOpacity
                            style={{
                                width: 32,
                                height: 32,
                                borderRadius: 16,
                                backgroundColor: 'black',
                                alignItems: 'center',
                                justifyContent: 'center',
                                right: 20,
                                top: 20,
                                position: 'absolute'
                            }}
                            onPress={() => setVisible(false)}
                        >
                            <Text style={{ color: 'wheat' }}>X</Text>
                        </TouchableOpacity>
                    </View>
                }
            >
                <View
                    style={{
                        justifyContent: 'center',
                        alignItems: 'center',
                        flex: 1
                    }}>
                    <Text>Hello world</Text>
                </View>
            </SwipeDownModal>
            <Button
                title='Press to open'
                onPress={() => setVisible(true)}
            />
        </View>
    )

}


export default SwipeDownTestScreen

Ekran_Kaydı_2023-04-18_14_00_42_AdobeExpress

Detailed styling and customizing

const SwipeDownTestScreen = () => {

    const [visible, setVisible] = useState(false)

    return (
        <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
            <SwipeDownModal
                visible={visible}
                onClose={() => setVisible(false)}
                backgroundColor={'rgba(0,0,0,.5)'}
                borderTopRadius={20}
                marginTop={Dimensions.get("screen").height - 600}
                drawerBackgroundColor='transparent'
                customHeader={
                    <View
                        style={{
                            height: 60,
                            margin: 20,
                            backgroundColor: 'white',
                            alignItems: 'center',
                            justifyContent: 'center',
                            borderRadius: 5,
                            borderTopRightRadius: 15,
                            borderBottomLeftRadius: 15,
                            overflow: 'hidden'
                        }}>
                        <Text style={{ fontSize: 30, color: 'red' }}>Title</Text>
                        <TouchableOpacity
                            style={{
                                backgroundColor: 'black',
                                alignItems: 'center',
                                justifyContent: 'center',
                                right: 0,
                                position: 'absolute',
                                width: 50,
                                height: '100%',
                                borderBottomLeftRadius: 15,
                            }}
                            onPress={() => setVisible(false)}
                        >
                           <Text style={{ color: 'wheat', fontSize: 20 }}>X</Text>
                        </TouchableOpacity>
                    </View>
                }
            >
                <View
                    style={{
                        justifyContent: 'center',
                        alignItems: 'center',
                        flex: 1,
                        margin: 20,
                        marginTop: 30,
                        marginBottom: 50,
                        borderRadius: 20,
                        backgroundColor: 'wheat'
                    }}>
                    <Text style={{ fontSize: 30 }}>Hello world</Text>
                </View>
            </SwipeDownModal>
            <Button
                title='Press to open'
                onPress={() => setVisible(true)}
            />
        </View>
    )

}


export default SwipeDownTestScreen

Ekran_Kaydı_2023-04-18_14_50_05_AdobeExpress

props

Prop | Type | Default | Description ------------- | ------------- | ------------- | ------------- duration | number | 200 | Duration of swipe animation in milliseconds onClose | func | () => null | The function will be called after the modal closed customHeader | react element | null | Custom header element visible | boolean | false | Modal visibility swipeThreshold | number | 15 | Minimum dy value to trigger swipe animation marginTop | number | 71 | Margin to top of the screen. See image description. If you want to give certain height you can calculate it like this: marginTop={Dimensions.get("screen").height - yourHeight} swipableHeight | number | height of header component | Height of the area capturing the swipe. Outside of this area will not capture finger moves. See image description backgroundColor | color string | 'rgba(0, 0, 0, .9)' | Color of the empty area between the modal body and the top of the screen headerHeight | number | 40 | Height of the default header. This prop will take effect only if customHeader prop is null borderTopRadius | number | 38 | Border top right and left radius of drawer section drawerBackgroundColor | color string | '#ffffff' | Background color of drawer section swipeDisabled | boolean | false | When true, finger moves will not be captured

Image description

Adsız drawio (3)