|
1 | 1 | # react-native-ma-modal |
2 | | -完全使用ts实现的RN弹窗组件,支持自定义动画 |
3 | 2 |
|
4 | | -<img src="./screenshot/overlay.gif" width="250" /> |
| 3 | +This component is a react-native popup component implemented using TypeScript, which supports custom animations as well as customizable popup content. |
5 | 4 |
|
6 | | -## 安装 |
7 | | -在使用之前请先安装`react-native-reanimated`和`react-native-gesture-handle` |
8 | | -``` |
9 | | -npm install react-native-reanimated react-native-gesture-handler |
10 | | -``` |
11 | | -并正确配置项目,详情请参考: |
12 | | -- [react-native-reanimated](https://github.com/software-mansion/react-native-reanimated) |
13 | | -- [react-native-gesture-handler](https://github.com/software-mansion/react-native-gesture-handler) |
14 | 5 |
|
15 | | -安装`react-native-ma-modal` |
16 | | -``` |
17 | | -npm install react-native-ma-modal |
18 | | -``` |
19 | 6 |
|
20 | | -## 使用 |
21 | | -在App的入口,使用`ModalProvider` |
| 7 | +| <img src="./screenshot/opacity.gif" width="250"> | <img src="./screenshot/scale.gif" width="250"> |<img src="./screenshot/drawer.gif" width="250"> | |
| 8 | +|-|-|-| |
| 9 | +| <img src="./screenshot/trans-1.gif" width="250"> | <img src="./screenshot/trans-2.gif" width="250"> | <img src="./screenshot/eas.svg" width="250"> | |
22 | 10 |
|
23 | | -```javascript |
24 | | -import { ModalProvider, modalRef } from 'react-native-ma-modal'; |
| 11 | +## install |
25 | 12 |
|
26 | | -export default function App() { |
27 | | - return ( |
28 | | - <ModalProvider ref={modalRef}> |
29 | | - <NavigationContainer ref={navigationRef}> |
30 | | - <Index /> |
31 | | - </NavigationContainer> |
32 | | - </ModalProvider> |
33 | | - ); |
34 | | -} |
35 | | -``` |
36 | | -### 组件内函数式调用 |
37 | | -```javascript |
38 | | -import { useModal } from 'react-native-ma-modal'; |
| 13 | +Before using it, please install react-native-reanimated and react-native-gesture-handler first. |
39 | 14 |
|
40 | | -export default function Example() { |
41 | | - const { add, remove } = useModal(); |
42 | | - return ( |
43 | | - <View> |
44 | | - <Button |
45 | | - onPress={() => { |
46 | | - add(<Text>Modal视图</Text>); |
47 | | - }} |
48 | | - > |
49 | | - <Text>添加弹窗</Text> |
50 | | - </Button> |
51 | | - <Button onPress={remove}> |
52 | | - <Text>删除弹窗</Text> |
53 | | - </Button> |
54 | | - </View> |
55 | | - ) |
56 | | -} |
57 | 15 | ``` |
58 | | -### 在函数内使用 |
59 | | -```javascript |
60 | | -import { ModalUtil } from 'react-native-ma-modal'; |
| 16 | +npm install react-native-reanimated react-native-gesture-handler |
| 17 | +``` |
| 18 | +And properly configure the project. For details, please refer to: |
| 19 | +- [react-native-reanimated](https://github.com/software-mansion/react-native-reanimated) |
| 20 | +- [react-native-gesture-handler](https://github.com/software-mansion/react-native-gesture-handler) |
61 | 21 |
|
62 | | -const show = () => { |
63 | | - ModalUtil.add(<Text>Modal视图</Text>) |
64 | | -} |
| 22 | +install`react-native-ma-modal` |
65 | 23 | ``` |
66 | | -### Modal组件 |
67 | | -```javascript |
68 | | -export default function Example() { |
69 | | - const [isVisible, setVisible] = useState(false); |
70 | | - |
71 | | - return ( |
72 | | - <Modal isVisible={isVisible}> |
73 | | - <Text>Modal视图</Text> |
74 | | - </Modal> |
75 | | - ) |
76 | | -} |
| 24 | +npm install react-native-ma-modal |
77 | 25 | ``` |
78 | | -### Modal的弹出效果 |
79 | | -目前有几种弹出效果 |
80 | | -- 渐变效果:`OpacityContainer` |
81 | | -- 平移效果:`TranslateContainer` |
82 | | -- 抽屉效果:`DrawerContainer` |
83 | | -- 缩放效果:`ScaleContainer` |
84 | | - |
85 | | -更多示例请参照[Demo](https://github.com/mahaaoo/react-native-ma-modal/blob/main/example/src/Home.tsx) |
86 | | - |
87 | | -## Expo Demo |
88 | | -Scan the QR code with Expo Go (Android) or the Camera app |
89 | 26 |
|
90 | | -<img src="./screenshot/expo.png" width="250" /> |
| 27 | +## usage |
| 28 | +For usage examples, please refer to |
| 29 | +[Demo](https://github.com/mahaaoo/react-native-ma-modal/blob/main/example/src/Home.tsx) |
0 commit comments