@aks-dev/easyui 1.0.126 → 1.0.128

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,138 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-05-17 15:22:06
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-12-21 21:00:43
6
+ * @FilePath: /@aks-dev/easyui/lib/AnimationModal/AnimationModal.tsx
7
+ */
8
+
9
+ import * as React from "react";
10
+ import { View, 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: number) => {
39
+ Animated.timing(animatedValue, {
40
+ toValue: value,
41
+ duration: 350,
42
+ useNativeDriver: true,
43
+ easing: Easing.linear,
44
+ }).start(({ finished }) => {
45
+ /* 动画完成的回调函数 */
46
+ });
47
+ };
48
+
49
+ /**
50
+ * h0: 父容器的高度
51
+ * h1: 子容器的高度
52
+ * @description:
53
+ * @return {*}
54
+ */
55
+ const layoutRef = React.useRef<{ h0: number; h1: number; }>({ h0: 0, h1: 0 })
56
+
57
+ React.useImperativeHandle<unknown, AnimationModalProps.RefAttributes>(ref, () => ({
58
+ show,
59
+ hide,
60
+ target: targetRef.current
61
+ }), [])
62
+ const targetRef = React.useRef<any>()
63
+
64
+ const show = async () => {
65
+ dispatch({ display: 'flex' })
66
+ await utils.sleep(50)
67
+ timing(-layoutRef.current?.h1)
68
+ }
69
+ const hide = async () => {
70
+ timing(0)
71
+ await utils.sleep(50)
72
+ dispatch({ display: 'none' })
73
+ }
74
+
75
+ return (
76
+ <View
77
+ style={Object.assign({ display: state.display }, styles.container, props.style)}
78
+ {...PanResponder.create({
79
+ onStartShouldSetPanResponder: (e, gestureState) => {
80
+ let pageY = e.nativeEvent.pageY
81
+ let topY = height - layoutRef.current.h1
82
+ if (pageY <= topY && !mask) {
83
+ return true
84
+ }
85
+ return false
86
+ },
87
+ onPanResponderGrant: (e, gestureState) => {
88
+ // console.log({e})
89
+ let pageY = e.nativeEvent.pageY
90
+ let topY = height - layoutRef.current.h1
91
+ if (pageY <= topY && !mask) {
92
+ e.stopPropagation()
93
+ hide()
94
+ }
95
+ }
96
+ }).panHandlers}
97
+ >
98
+ <Animated.View
99
+ style={Object.assign({}, styles.wrapper, { transform: [{ translateY: animatedValue }] })}
100
+ onLayout={e => {
101
+ let target: LayoutRectangle = e.nativeEvent.layout
102
+ layoutRef.current.h1 = target.height
103
+ }}
104
+ >
105
+ {props.children}
106
+ </Animated.View>
107
+ </View>
108
+ )
109
+ })
110
+
111
+
112
+
113
+ const styles = StyleSheet.create({
114
+ container: {
115
+ position: 'absolute',
116
+ left: 0,
117
+ right: 0,
118
+ top: 0,
119
+ bottom: 0,
120
+ zIndex: 999,
121
+ // display: 'flex',
122
+ flexDirection: 'column',
123
+ backgroundColor: '#00000055',
124
+ overflow: 'hidden',
125
+ },
126
+ wrapper: {
127
+ position: 'absolute',
128
+ display: 'flex',
129
+ flexDirection: 'column',
130
+ // backgroundColor: 'pink',
131
+ width: '100%',
132
+ top: '100%'
133
+ },
134
+ empty: {
135
+ flex: 1, position: 'relative',
136
+ // backgroundColor: 'cyan'
137
+ }
138
+ })
@@ -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.128",
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'