@aks-dev/easyui 1.0.126 → 1.0.127

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.
@@ -0,0 +1,132 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-05-17 15:22:06
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-12-21 18:13:33
6
+ * @FilePath: /aks-fire-app/node_modules/@aks-dev/easyui/lib/AnimationModal/AnimationModal.tsx
7
+ */
8
+
9
+ import * as React from "react";
10
+ import { Animated, Easing, LayoutRectangle, PanResponder, StyleSheet, useWindowDimensions } from 'react-native';
11
+ import type { AnimationModalProps } from '.';
12
+ import * as utils from '../../utils/lazy';
13
+ type State = {
14
+ display: 'flex' | 'none';
15
+ }
16
+ type StateReducerProps = (state: State, action: Partial<State>) => State
17
+
18
+
19
+ export const AnimationModal: React.ForwardRefExoticComponent<
20
+ React.PropsWithoutRef<AnimationModalProps>
21
+ & React.RefAttributes<AnimationModalProps.RefAttributes>
22
+ >
23
+ = React.forwardRef((props, ref) => {
24
+ const {
25
+ animationType = 'from-bottom',
26
+ mask = false
27
+ } = props || {}
28
+
29
+ const {height} = useWindowDimensions()
30
+
31
+ const [state, dispatch] = React.useReducer<StateReducerProps>(
32
+ (state, action) => ({ ...state, ...action }),
33
+ {
34
+ display: 'none'
35
+ })
36
+
37
+ const animatedValue = React.useRef(new Animated.Value(0)).current;
38
+ const timing = (value) => {
39
+ Animated.timing(animatedValue, {
40
+ toValue: value,
41
+ duration: 350,
42
+ useNativeDriver: true,
43
+ easing: Easing.linear,
44
+ }).start(({ finished }) => {
45
+ /* 动画完成的回调函数 */
46
+ console.log({ finished })
47
+ });
48
+ };
49
+
50
+ /**
51
+ * h0: 父容器的高度
52
+ * h1: 子容器的高度
53
+ * @description:
54
+ * @return {*}
55
+ */
56
+ const layoutRef = React.useRef<{ h0: number; h1: number; }>({ h0: 0, h1: 0 })
57
+
58
+ React.useImperativeHandle<unknown, AnimationModalProps.RefAttributes>(ref, () => ({
59
+ show,
60
+ hide,
61
+ target: targetRef.current
62
+ }), [])
63
+ const targetRef = React.useRef<any>()
64
+
65
+ const show = async () => {
66
+ dispatch({ display: 'flex' })
67
+ await utils.sleep(50)
68
+ timing(-layoutRef.current?.h1)
69
+ }
70
+ const hide = async () => {
71
+ timing(0)
72
+ await utils.sleep(50)
73
+ dispatch({ display: 'none' })
74
+ }
75
+
76
+ return (
77
+ <Animated.View
78
+ style={Object.assign({ display: state.display }, styles.container, props.style)}
79
+ {...PanResponder.create({
80
+ onStartShouldSetPanResponder: () => true,
81
+ onPanResponderGrant: (e, gestureState) => {
82
+ // console.log({e})
83
+ let pageY = e.nativeEvent.pageY
84
+ let topY = height - layoutRef.current.h1
85
+ if (pageY <= topY && !mask) {
86
+ e.stopPropagation()
87
+ hide()
88
+ }
89
+ }
90
+ }).panHandlers}
91
+ >
92
+ <Animated.View
93
+ style={Object.assign({}, styles.wrapper, { transform: [{ translateY: animatedValue }] })}
94
+ onLayout={e => {
95
+ let target: LayoutRectangle = e.nativeEvent.layout
96
+ layoutRef.current.h1 = target.height
97
+ }}
98
+ >
99
+ {props.children}
100
+ </Animated.View>
101
+ </Animated.View>
102
+ )
103
+ })
104
+
105
+
106
+
107
+ const styles = StyleSheet.create({
108
+ container: {
109
+ position: 'absolute',
110
+ left: 0,
111
+ right: 0,
112
+ top: 0,
113
+ bottom: 0,
114
+ zIndex: 999,
115
+ // display: 'flex',
116
+ flexDirection: 'column',
117
+ backgroundColor: '#00000055',
118
+ overflow: 'hidden',
119
+ },
120
+ wrapper: {
121
+ position: 'absolute',
122
+ display: 'flex',
123
+ flexDirection: 'column',
124
+ // backgroundColor: 'pink',
125
+ width: '100%',
126
+ top: '100%'
127
+ },
128
+ empty: {
129
+ flex: 1, position: 'relative',
130
+ // backgroundColor: 'cyan'
131
+ }
132
+ })
@@ -0,0 +1,39 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-05-18 17:26:41
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
7
+ */
8
+ import { StyleProp, ViewStyle } from 'react-native';
9
+
10
+
11
+ export type AnimationModalProps = {
12
+ children: React.ReactNode;
13
+ /**
14
+ * 动画方向,默认 'from-bottom'
15
+ * center-in 动画暂未实现
16
+ */
17
+ animationType?: 'from-bottom' | 'center-in';
18
+ /**
19
+ * 是否有遮罩,默认没有
20
+ */
21
+ mask?: boolean;
22
+ style?:Pick<StyleProp<ViewStyle>,'backgroundColor'>;
23
+ }
24
+
25
+
26
+ declare namespace AnimationModalProps {
27
+ type RefAttributes = {
28
+ show: (target?:any) => void;
29
+ hide: () => void;
30
+ target:any
31
+ }
32
+ }
33
+
34
+
35
+
36
+ export declare const AnimationModal: React.ForwardRefExoticComponent<
37
+ React.PropsWithoutRef<AnimationModalProps>
38
+ & React.RefAttributes<AnimationModalProps.RefAttributes>
39
+ >;
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-24 14:27:02
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-10-28 12:10:20
5
+ * @LastEditTime: 2022-12-21 15:36:06
6
6
  * @FilePath: /@aks-dev/easyui/lib/Hud/PopoverView/PopoverView.tsx
7
7
  */
8
8
  import React, { useImperativeHandle, useState } from 'react';
@@ -60,7 +60,7 @@ const styles = StyleSheet.create({
60
60
  container: {
61
61
  ...StyleSheet.absoluteFillObject,
62
62
  display: 'flex',
63
-
63
+
64
64
  // backgroundColor:'red'
65
65
  },
66
66
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aks-dev/easyui",
3
- "version": "1.0.126",
3
+ "version": "1.0.127",
4
4
  "description": "工具箱",
5
5
  "main": "./src/index.ts",
6
6
  "typings": "./src/index.d.ts",
package/src/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-26 11:44:22
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-07-15 12:36:37
5
+ * @LastEditTime: 2022-12-21 18:15:26
6
6
  * @FilePath: /@aks-dev/easyui/src/index.d.ts
7
7
  */
8
8
 
@@ -43,6 +43,8 @@ export * from '../lib/RichText'
43
43
  export * from '../lib/DottedLine'
44
44
 
45
45
  export * from '../lib/MenuView'
46
+ export * from '../lib/AnimationModal'
47
+
46
48
 
47
49
  /// 工具
48
50
  import * as utils from '../utils'
package/src/index.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * @Author: shiguo
4
4
  * @Date: 2022-04-13 12:47:34
5
5
  * @LastEditors: shiguo
6
- * @LastEditTime: 2022-11-18 19:10:43
6
+ * @LastEditTime: 2022-12-21 18:15:37
7
7
  * @FilePath: /@aks-dev/easyui/src/index.ts
8
8
  */
9
9
 
@@ -54,6 +54,10 @@ export { default as DottedLine } from '../lib/DottedLine/DottedLine'
54
54
 
55
55
  export { default as MenuView } from '../lib/MenuView/MenuView'
56
56
 
57
+
58
+ export { AnimationModal } from '../lib/AnimationModal/AnimationModal'
59
+
60
+
57
61
  /// 全局适配
58
62
  export * from '../screen/px2dp'
59
63
  export * from '../screen/px2sp'