UNPKG

6.54 kBMarkdownView Raw
1![alt tag](./assets/react-native-swippable-modal-banner.png)
2
3# react-native-swippable-modal
4
5---
6
7[![react-native-swippable-modal on npm](https://img.shields.io/npm/v/react-native-swippable-modal.svg?style=flat)](https://www.npmjs.com/package/react-native-swippable-modal) [![react-native-swippable-modal downloads](https://img.shields.io/npm/dm/react-native-swippable-modal)](https://www.npmtrends.com/react-native-swippable-modal) [![react-native-swippable-modal install size](https://packagephobia.com/badge?p=react-native-swippable-modal)](https://packagephobia.com/result?p=react-native-swippable-modal) [![Android](https://img.shields.io/badge/Platform-Android-green?logo=android)](https://www.android.com) [![iOS](https://img.shields.io/badge/Platform-iOS-green?logo=apple)](https://developer.apple.com/ios) [![MIT](https://img.shields.io/badge/License-MIT-green)](https://opensource.org/licenses/MIT)
8
9
10This swippable modal library provides a swipe down modal close feature. Especially same modal contain textInput that too it worked well.
11
12- It also provides an example app and a detailed usage overview of swippable modal
13- It's fully Android and iOS compatible.
14
15## 🎬 [Preview](./example/)
16
17---
18
19| <div style="width:300px"></div> Example |
20| :-------------------------------------: |
21| ![alt tag](./assets/SwippableDemo.gif) |
22
23## Installation
24
25##### 1. Install swippable modal
26
27```bash
28$ npm install react-native-swippable-modal
29# --- or ---
30$ yarn add react-native-swippable-modal
31```
32
33##### 2. Install required dependencies
34
35```bash
36$ npm install react-native-reanimated react-native-gesture-handler
37# --- or ---
38$ yarn add react-native-reanimated react-native-gesture-handler
39```
40
41##### 3. Install cocoapods in the ios project
42
43```bash
44cd ios && pod install
45```
46
47> Note: Make sure to add Reanimated's babel plugin to your `babel.config.js`
48
49```
50module.exports = {
51 ...
52 plugins: [
53 ...
54 'react-native-reanimated/plugin',
55 ],
56 };
57```
58
59#### Usage
60
61---
62
63```jsx
64import React, { createRef } from 'react';
65import { Button, Image, TextInput, View } from 'react-native';
66import {
67 SwippableModal,
68 SwippableModalRefType,
69} from 'react-native-swippable-modal';
70
71const exampleModalRef = createRef<SwippableModalRefType>();
72
73const App = () => {
74 return (
75 <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
76 <Button
77 title="Open Modal"
78 onPress={() => exampleModalRef.current?.show()}
79 />
80 <SwippableModal ref={exampleModalRef} closeThreadSoldValue={100}>
81 <TextInput placeholder={'Example Input'} />
82 <View style={{ height: 150, width: '100%', marginTop: 10 }}>
83 <Image
84 source={{
85 uri: 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/800px-Image_created_with_a_mobile_phone.png',
86 }}
87 style={{ width: '100%', height: '100%' }}
88 resizeMode={'contain'}
89 />
90 </View>
91 </SwippableModal>
92 </View>
93 );
94};
95
96export default App;
97```
98
99#### Properties
100
101---
102
103| Props | Default | Type | Description |
104| :---------------------------------------- | :-------- | :-------------------- | :--------------------------------------------------------- |
105| <strong style="color:red;">ref\*</strong> | modalRef | reference | It is default reference to open modal |
106| children | - | ReactNode | Pass children as ReactNode (Custom UI) |
107| closeThreadSoldValue | 200 | number | It's take number value from where point modal will closed |
108| modalStyle | - | ViewStyle | Modal style |
109| modalBackgroundColor | `#FAFAFA` | `{backgroundColor: string}`| Change modal background color |
110| disableLine | false | boolean | It's used for disable line (Hide line) |
111| modalInnerContainerStyle | - | ViewStyle | Modal inner container style |
112| disableClose | false | boolean | If true, modal will not close if touch out side the modal (only swipe down close allow) |
113| disableBackgroundColor | false | boolean | If pass true, it will change background color `#FFFFFF04` |
114| disableSwipeDown | false | boolean | If true, it will disable gesture swipe down close |
115| panGestureProps | {} | PanGestureHandlerProp | Pan Gesture Props |
116| modalContainerStyle | - | ViewStyle | Modal Container style |
117| modalLineStyle | - | ViewStyle | Modal Line style |
118| showModal | - | function | Default function to open modal |
119| hideModal | - | function | Default function to hide modal |
120| panRef | panRef | reference | Default pan reference to get pan gesture references values |
121
122### Example
123
124A full working example project is here [Example](./example/)
125
126- Install dependencies in example app `cd example && yarn && cd ios/ && pod install && cd ..`
127- Run example app `yarn ios`
128
129---
130
131## Find this library useful? ❤️
132
133Support it by joining [stargazers](https://github.com/DhruvHarsora-FullStackDeveloper/react-native-swippable-modal/stargazers) for this repository.⭐
134
135## 🤝 How to Contribute
136
137We'd love to have you improve this library or fix a problem 💪
138Check out our [Contributing Guide](CONTRIBUTING.md) for ideas on contributing.
139
140## Bugs / Feature requests / Feedbacks
141
142For bugs, feature requests, and discussion please use [GitHub Issues](https://github.com/DhruvHarsora-FullStackDeveloper/react-native-swippable-modal/issues)
143
144### License
145
146- [MIT License](./LICENSE)