@aks-dev/easyui 1.0.131 → 1.0.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,12 +2,12 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-05-17 15:22:06
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-12-22 11:06:15
5
+ * @LastEditTime: 2022-12-22 11:57:30
6
6
  * @FilePath: /@aks-dev/easyui/lib/AnimationModal/AnimationModal.tsx
7
7
  */
8
8
 
9
9
  import * as React from "react";
10
- import { View, Animated, Easing, LayoutRectangle, PanResponder, StyleSheet, useWindowDimensions } from 'react-native';
10
+ import { View, Animated, Easing, LayoutRectangle, PanResponder, StyleSheet, useWindowDimensions, BackHandler } from 'react-native';
11
11
  import type { AnimationModalProps } from '.';
12
12
  import * as utils from '../../utils/lazy';
13
13
  type State = {
@@ -46,8 +46,6 @@ export const AnimationModal: React.ForwardRefExoticComponent<
46
46
  });
47
47
  };
48
48
 
49
-
50
-
51
49
  const layoutRef = React.useRef<{
52
50
  /**:父容器的高度 */
53
51
  h0: number;
@@ -55,7 +53,6 @@ export const AnimationModal: React.ForwardRefExoticComponent<
55
53
  h1: number;
56
54
  }>({ h0: 0, h1: 0 })
57
55
 
58
-
59
56
  React.useImperativeHandle<unknown, AnimationModalProps.RefAttributes>(ref, () => ({
60
57
  show,
61
58
  hide,
@@ -63,8 +60,7 @@ export const AnimationModal: React.ForwardRefExoticComponent<
63
60
  }), [])
64
61
  const targetRef = React.useRef<any>()
65
62
 
66
- const show = async (target?: any) => {
67
- targetRef.current = target
63
+ const show = async () => {
68
64
  dispatch({ display: 'flex' })
69
65
  await utils.sleep(50)
70
66
  timing(-layoutRef.current?.h1)
@@ -75,6 +71,17 @@ export const AnimationModal: React.ForwardRefExoticComponent<
75
71
  dispatch({ display: 'none' })
76
72
  }
77
73
 
74
+
75
+ React.useEffect(() => {
76
+ let addEventListener = BackHandler.addEventListener("hardwareBackPress", ()=>{
77
+ return state.display == 'flex'
78
+ })
79
+ return () => {
80
+ addEventListener.remove()
81
+ }
82
+ }, [state.display])
83
+
84
+
78
85
  return (
79
86
  <View
80
87
  style={Object.assign({ display: state.display }, styles.container, props.style)}
@@ -2,8 +2,8 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-05-18 17:26:41
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-12-21 18:13:47
6
- * @FilePath: /aks-fire-app/node_modules/@aks-dev/easyui/lib/AnimationModal/index.d.ts
5
+ * @LastEditTime: 2022-12-22 11:17:17
6
+ * @FilePath: /@aks-dev/easyui/lib/AnimationModal/index.d.ts
7
7
  */
8
8
  import { StyleProp, ViewStyle } from 'react-native';
9
9
 
@@ -13,6 +13,7 @@ export type AnimationModalProps = {
13
13
  /**
14
14
  * 动画方向,默认 'from-bottom'
15
15
  * center-in 动画暂未实现
16
+ * @deprecated
16
17
  */
17
18
  animationType?: 'from-bottom' | 'center-in';
18
19
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aks-dev/easyui",
3
- "version": "1.0.131",
3
+ "version": "1.0.133",
4
4
  "description": "工具箱",
5
5
  "main": "./src/index.ts",
6
6
  "typings": "./src/index.d.ts",