@aks-dev/easyui 1.0.98 → 1.0.101

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.
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react'
2
- import { View, Text, StyleSheet, Platform, StatusBar, TouchableOpacity, } from 'react-native'
2
+ import { View, Text, StyleSheet, Platform, StatusBar, TouchableOpacity,Dimensions } from 'react-native'
3
3
  import Modal from 'react-native-modal'
4
4
 
5
5
  import { px2dp, deviceWidth } from '../../../screen/px2dp'
@@ -77,6 +77,7 @@ export default React.forwardRef<AlertBottomViewCurrent, {}>((_, ref) => {
77
77
  }}
78
78
  isVisible={state.visible}
79
79
  style={{ margin: 0 }}
80
+ deviceHeight={Dimensions.get('screen').height}
80
81
  >
81
82
  <View style={styles.container}>
82
83
  <View style={[styles.wrapper, state.wrapperStyle]}>
@@ -0,0 +1,176 @@
1
+ import * as React from 'react'
2
+ import { Dimensions, Platform, StatusBar, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
3
+ import Modal from 'react-native-modal'
4
+ import { AlertSheetViewOptions, AlertSheetViewRefAttributes } from '.'
5
+ import { px2dp } from '../../../screen/px2dp'
6
+ import { px2sp } from '../../../screen/px2sp'
7
+
8
+
9
+
10
+
11
+
12
+ type State = {
13
+ visible: boolean;
14
+ } & AlertSheetViewOptions
15
+
16
+
17
+
18
+
19
+
20
+ export default React.forwardRef<AlertSheetViewRefAttributes, {}>((_, ref) => {
21
+
22
+
23
+ const defaultState: Partial<State> = {
24
+ visible: false,
25
+ actions: []
26
+ }
27
+ const [state, setState] = React.useState<Partial<State>>(defaultState)
28
+
29
+ React.useImperativeHandle<unknown, AlertSheetViewRefAttributes>(ref, () => ({
30
+ show: async (options: Partial<AlertSheetViewOptions>) => {
31
+ setState(Object.assign({}, defaultState, { visible: true }, options))
32
+ },
33
+ hide
34
+ }), [])
35
+
36
+
37
+ const hide = async () => {
38
+ setState(defaultState)
39
+ }
40
+
41
+
42
+ React.useEffect(() => {
43
+ if (Platform.OS == 'android') {
44
+ if (state.visible) {
45
+ StatusBar.setBackgroundColor('black')
46
+ StatusBar.setBarStyle('light-content')
47
+ } else {
48
+ StatusBar.setBackgroundColor('transparent')
49
+ StatusBar.setBarStyle('dark-content')
50
+ }
51
+ }
52
+
53
+ }, [state.visible])
54
+ return (
55
+ <Modal
56
+ hideModalContentWhileAnimating={true}//通过隐藏模态内容直到动画完成来增强性能
57
+ useNativeDriver={true}//定义动画是否应使用本机驱动程序
58
+ animationIn='slideInUp'
59
+ animationOut='slideOutDown'
60
+ onBackButtonPress={() => {
61
+ //按下Android后退按钮时调用
62
+ hide()
63
+ }}
64
+ onBackdropPress={() => {
65
+ //按下背景时调用
66
+ hide()
67
+ }}
68
+ isVisible={state.visible}
69
+ deviceHeight={Dimensions.get('screen').height}
70
+ style={{ margin: 0}}
71
+ >
72
+ <View style={styles.container}>
73
+ <View style={[styles.wrapper]}>
74
+ <View style={styles.itemContainer}>
75
+ {state.actions?.map((i, idx) =>
76
+ <TouchableOpacity
77
+
78
+ key={`sg-action-${idx}`}
79
+ style={[styles.item]}
80
+ activeOpacity={1}
81
+ onPress={() => i.onClick && i.onClick()}>
82
+ <Text style={[styles.itemText,{color:i.color}]} numberOfLines={2}>{i.text}</Text>
83
+ </TouchableOpacity>
84
+ )}
85
+ </View>
86
+
87
+
88
+
89
+ <TouchableOpacity
90
+ style={[styles.cancel]}
91
+ activeOpacity={1}
92
+ onPress={() => {
93
+ hide()
94
+ }}>
95
+ <Text style={[styles.cancelText]}>取消</Text>
96
+ </TouchableOpacity>
97
+ </View>
98
+
99
+ </View>
100
+ </Modal>
101
+ )
102
+ })
103
+
104
+
105
+
106
+ export const alertSheetViewRef = React.createRef<AlertSheetViewRefAttributes>();
107
+
108
+
109
+
110
+ export const showAlertSheetModal = (props: Partial<AlertSheetViewOptions>) => {
111
+ alertSheetViewRef.current?.show(props)
112
+ }
113
+
114
+
115
+
116
+
117
+
118
+
119
+ const styles = StyleSheet.create({
120
+ container: {
121
+ display: 'flex',
122
+ flexGrow: 1,
123
+ justifyContent: 'flex-end',
124
+ alignItems: 'center',
125
+
126
+ },
127
+
128
+ wrapper: {
129
+ flexGrow: 0,
130
+ flexShrink: 0,
131
+ width: '100%',
132
+ // backgroundColor: 'pink',
133
+ overflow: 'hidden',
134
+ borderTopLeftRadius: px2dp(10),
135
+ borderTopRightRadius: px2dp(10),
136
+ display: 'flex',
137
+ padding: px2dp(15),
138
+ },
139
+
140
+ cancel: {
141
+ height: px2dp(50),
142
+ display: 'flex',
143
+ justifyContent: 'center',
144
+ alignItems: 'center',
145
+ borderRadius: px2dp(10),
146
+ backgroundColor: 'white',
147
+ marginTop: px2dp(15),
148
+ },
149
+ cancelText: {
150
+ fontSize: px2sp(15),
151
+ color: '#2763FF',
152
+
153
+ },
154
+
155
+ itemContainer: {
156
+ display: 'flex',
157
+ borderRadius: px2dp(10),
158
+ overflow: 'hidden',
159
+ backgroundColor:'#f1f1f1'
160
+ },
161
+ item: {
162
+ height: px2dp(50),
163
+ display: 'flex',
164
+ justifyContent: 'center',
165
+ alignItems: 'center',
166
+
167
+ backgroundColor: 'white',
168
+ marginTop: px2dp(0.5)
169
+ },
170
+ itemText: {
171
+ fontSize: px2sp(12),
172
+ color: '#666666',
173
+
174
+ },
175
+
176
+ })
@@ -0,0 +1,35 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-04-22 17:30:32
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-09-09 10:11:11
6
+ * @FilePath: /cmwy-device-app/node_modules/@aks-dev/easyui/lib/Hud/AlertSheetView/index.ts
7
+ */
8
+ import * as React from 'react';
9
+ import { ColorValue } from 'react-native';
10
+
11
+
12
+
13
+ type ActionSheet = {
14
+ text: string;
15
+ color?: ColorValue | undefined;
16
+ onClick?: () => void;
17
+ }
18
+ export declare type AlertSheetViewOptions = {
19
+ actions:ActionSheet[];
20
+ }
21
+
22
+
23
+ export declare const showAlertSheetModal: (props: Partial<AlertSheetViewOptions>) => void;
24
+
25
+
26
+
27
+ export declare type AlertSheetViewRefAttributes = {
28
+ show: (options: Partial<AlertSheetViewOptions>) => void;
29
+ hide: () => void;
30
+ }
31
+
32
+
33
+ export declare const AlertSheetView: React.ForwardRefExoticComponent<React.PropsWithoutRef<{}> & React.RefAttributes<AlertSheetViewRefAttributes>>;
34
+
35
+ export declare const AlertSheetViewRef: React.RefObject<AlertSheetViewRefAttributes>
package/lib/Hud/Hud.tsx CHANGED
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-24 14:10:04
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-07-15 09:58:50
5
+ * @LastEditTime: 2022-09-09 09:55:01
6
6
  * @FilePath: /cmwy-device-app/node_modules/@aks-dev/easyui/lib/Hud/Hud.tsx
7
7
  */
8
8
  import * as React from 'react'
@@ -14,6 +14,9 @@ import {
14
14
  import {
15
15
  alertBottomViewRef, default as AlertBottomView, showAlertBottomModal
16
16
  } from './AlertBottomView/AlertBottomView'
17
+ import {
18
+ alertSheetViewRef, default as AlertSheetView, showAlertSheetModal
19
+ } from './AlertSheetView/AlertSheetView'
17
20
 
18
21
  import {
19
22
  hideLoading, Loading, loadingRef, showLoading
@@ -25,7 +28,7 @@ import {
25
28
  } from './Toast/Toast'
26
29
 
27
30
 
28
- import {showPopoverView,hidePopoverView,popoverViewRef,PopoverView} from './PopoverView/PopoverView'
31
+ import { showPopoverView, hidePopoverView, popoverViewRef, PopoverView } from './PopoverView/PopoverView'
29
32
 
30
33
 
31
34
 
@@ -42,8 +45,9 @@ export const Hud: React.FC<{}> = () => React.cloneElement(
42
45
  <Loading key="hud-0" ref={loadingRef} />,
43
46
  <Toast key="hud-1" ref={toastRef} />,
44
47
  <AlertView key="hud-2" ref={alertViewRef} />,
45
- <AlertBottomView key="hud-3" ref={alertBottomViewRef} />,
46
- <PopoverView key="hud-4" ref={popoverViewRef}/>,
48
+ <AlertBottomView key="hud-3-0" ref={alertBottomViewRef} />,
49
+ <AlertSheetView key="hud-3-1" ref={alertSheetViewRef} />,
50
+ <PopoverView key="hud-4" ref={popoverViewRef} />,
47
51
  ]
48
52
  )
49
53
 
@@ -51,9 +55,9 @@ export const Hud: React.FC<{}> = () => React.cloneElement(
51
55
  export {
52
56
  showAlertModal,
53
57
  showToast,
54
- showLoading,
55
- hideLoading,
58
+ showLoading, hideLoading,
56
59
  showAlertBottomModal,
57
- showPopoverView,
58
- hidePopoverView
60
+ showAlertSheetModal,
61
+ showPopoverView, hidePopoverView
62
+
59
63
  }
@@ -2,8 +2,8 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2021-04-27 10:38:04
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-08-04 10:43:06
6
- * @FilePath: /@aks-dev/easyui/lib/Hud/Toast/Toast.tsx
5
+ * @LastEditTime: 2022-05-12 11:33:40
6
+ * @FilePath: /@aks/easyui/lib/Easy-Hud/Toast/Toast.tsx
7
7
  */
8
8
  import React, { useImperativeHandle, useState, useRef } from 'react';
9
9
  import { View, StyleSheet, Text, Dimensions, Animated, Easing } from 'react-native';
@@ -16,7 +16,6 @@ const errorMsg = '(^_^)∠※ 送你一束小花'
16
16
  export const Toast = React.forwardRef<ToastCurrent, {}>((_, ref) => {
17
17
  const [tipText, setTipText] = useState(errorMsg);
18
18
  const fade = useRef(new Animated.Value(0)).current;
19
- const [tipTheme, setTipTheme] = useState<'black' | 'white'>('black')
20
19
 
21
20
  const fadeAnimation = Animated.sequence([
22
21
  Animated.timing(fade, {
@@ -35,9 +34,8 @@ export const Toast = React.forwardRef<ToastCurrent, {}>((_, ref) => {
35
34
  ])
36
35
 
37
36
  useImperativeHandle<unknown, ToastCurrent>(ref, () => ({
38
- showToast: (content: string, theme?: 'black' | 'white') => {
37
+ showToast: (content: string) => {
39
38
  setTipText(content || errorMsg)
40
- setTipTheme(theme ? theme : 'black')
41
39
  fadeAnimation.reset()
42
40
  fadeAnimation.start()
43
41
  },
@@ -45,8 +43,8 @@ export const Toast = React.forwardRef<ToastCurrent, {}>((_, ref) => {
45
43
 
46
44
  return (
47
45
  <Animated.View style={{ ...styles.toastContainer, opacity: fade }}>
48
- <View style={[styles.toastTipsContainer, { backgroundColor: tipTheme == 'black' ? '#00000088' : '#ffffff88' }]}>
49
- <Text numberOfLines={5} style={[styles.toastTitle, { color: tipTheme ? 'white' : 'black'}]}>{tipText} </Text>
46
+ <View style={styles.toastTipsContainer}>
47
+ <Text numberOfLines={5} style={{ ...styles.toastTitle, }}>{tipText} </Text>
50
48
  </View>
51
49
  </Animated.View>
52
50
 
@@ -55,7 +53,7 @@ export const Toast = React.forwardRef<ToastCurrent, {}>((_, ref) => {
55
53
 
56
54
  export const toastRef = React.createRef<ToastCurrent>();
57
55
 
58
- export const showToast = (content: string, theme?: 'black' | 'white') => toastRef.current?.showToast(content, theme)
56
+ export const showToast = (content: string) => toastRef.current?.showToast(content)
59
57
 
60
58
 
61
59
 
@@ -2,8 +2,8 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-18 19:18:03
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-08-04 09:51:29
6
- * @FilePath: /@aks-dev/easyui/lib/Hud/Toast/index.ts
5
+ * @LastEditTime: 2022-05-12 11:33:32
6
+ * @FilePath: /@aks/easyui/lib/Easy-Hud/Toast/index.ts
7
7
  */
8
8
  import * as React from 'react'
9
9
 
@@ -11,10 +11,10 @@ import * as React from 'react'
11
11
 
12
12
 
13
13
  export declare type ToastCurrent = {
14
- showToast: (content: string, theme?: 'black' | 'white') => void;
14
+ showToast: (content: string) => void;
15
15
  }
16
16
 
17
- export declare const showToast: (content: string, theme?: 'black' | 'white') => void;
17
+ export declare const showToast: (content: string) => void;
18
18
 
19
19
 
20
20
  export declare const toastRef: React.RefObject<ToastCurrent>;
package/lib/Hud/index.ts CHANGED
@@ -2,8 +2,8 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-24 14:14:42
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-07-15 12:40:12
6
- * @FilePath: /@aks-dev/easyui/lib/Hud/index.ts
5
+ * @LastEditTime: 2022-09-09 09:55:43
6
+ * @FilePath: /cmwy-device-app/node_modules/@aks-dev/easyui/lib/Hud/index.ts
7
7
  */
8
8
 
9
9
 
@@ -14,6 +14,6 @@ export * from './AlertView'
14
14
  export * from './Loading'
15
15
  export * from './Toast'
16
16
  export * from './AlertBottomView'
17
+ export * from './AlertSheetView'
17
18
  export * from './PopoverView'
18
-
19
19
  export declare const Hud: React.FC<{}>
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-24 13:56:47
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-07-14 11:56:11
5
+ * @LastEditTime: 2022-09-07 18:37:00
6
6
  * @FilePath: /@aks-dev/easyui/lib/TextInputArea/TextInputArea.tsx
7
7
  */
8
8
  import React from 'react'
@@ -11,9 +11,9 @@ import {px2dp} from '../../screen/px2dp'
11
11
  import {px2sp} from '../../screen/px2sp'
12
12
 
13
13
 
14
- import type { TextInputAreaProps, TextInputAreaCurrent } from '.'
14
+ import type { TextInputAreaProps ,TextInputAreaRefAttributes} from '.'
15
15
 
16
- export default React.forwardRef<TextInputAreaCurrent, Partial<TextInputAreaProps>>((props, ref) => {
16
+ export default React.forwardRef<TextInputAreaRefAttributes, Partial<TextInputAreaProps>>((props, ref) => {
17
17
  const { defaultValue, placeholder, maxLength = 200, on, ...rest } = props
18
18
 
19
19
  const [value, setValue] = React.useState<string | undefined>(defaultValue)
@@ -23,7 +23,7 @@ export default React.forwardRef<TextInputAreaCurrent, Partial<TextInputAreaProps
23
23
  }, [defaultValue])
24
24
 
25
25
 
26
- React.useImperativeHandle<unknown,TextInputAreaCurrent>(ref, () => ({
26
+ React.useImperativeHandle<unknown,TextInputAreaRefAttributes>(ref, () => ({
27
27
  value: value,
28
28
  }), [value])
29
29
 
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-24 13:59:32
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-07-14 11:56:00
5
+ * @LastEditTime: 2022-09-07 18:38:10
6
6
  * @FilePath: /@aks-dev/easyui/lib/TextInputArea/index.ts
7
7
  */
8
8
  import * as React from 'react'
@@ -21,13 +21,11 @@ export type TextInputAreaProps = {
21
21
  } & TextInputProps
22
22
 
23
23
 
24
-
25
-
26
- export type TextInputAreaCurrent = {
24
+ export type TextInputAreaRefAttributes = {
27
25
  value: string | undefined;
28
26
  }
29
27
 
30
28
 
31
- export declare const TextInputArea: React.ForwardRefExoticComponent<React.PropsWithoutRef<Partial<TextInputAreaProps>> & React.RefAttributes<TextInputAreaCurrent>>;
29
+ export declare const TextInputArea: React.ForwardRefExoticComponent<React.PropsWithoutRef<Partial<TextInputAreaProps>> & React.RefAttributes<TextInputAreaRefAttributes>>;
32
30
 
33
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aks-dev/easyui",
3
- "version": "1.0.98",
3
+ "version": "1.0.101",
4
4
  "description": "移动端App开发工具包",
5
5
  "main": "./src/index.ts",
6
6
  "typings": "./src/index.d.ts",
@@ -10,8 +10,7 @@
10
10
  "keywords": [
11
11
  "react",
12
12
  "react-native",
13
- "easyui",
14
- "爱科森开发"
13
+ "easyui"
15
14
  ],
16
15
  "files": [
17
16
  "/android",
package/screen/px2dp.ts CHANGED
@@ -2,15 +2,15 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-18 14:32:25
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-07-14 20:19:39
5
+ * @LastEditTime: 2022-09-09 10:35:02
6
6
  * @FilePath: /@aks-dev/easyui/screen/px2dp.ts
7
7
  */
8
8
  import { Dimensions, Platform, StatusBar } from 'react-native';
9
9
 
10
10
 
11
11
  // 设备宽度,单位 dp
12
- export const deviceWidth = Dimensions.get('window').width; //设备的宽度
13
- export const deviceHeight = Dimensions.get('window').height; //设备的高度
12
+ export const deviceWidth = Dimensions.get('screen').width; //设备的宽度
13
+ export const deviceHeight = Dimensions.get('screen').height; //设备的高度
14
14
  export const isAndroid = Platform.OS === "android"
15
15
  export const isIos = Platform.OS === 'ios'
16
16
  export const isiPhoneX = isIos && (deviceHeight > 736)
@@ -43,7 +43,7 @@ export const statusBarHeight = (() => {
43
43
 
44
44
 
45
45
 
46
- export const navigationBarHeight = (() => {
46
+ export const navigationBarHeight = ( () => {
47
47
  if (isAndroid) return 56
48
48
  return 44
49
49
  })()
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-07-15 12:40:31
6
+ * @LastEditTime: 2022-09-09 10:37:09
7
7
  * @FilePath: /@aks-dev/easyui/src/index.ts
8
8
  */
9
9
 
@@ -14,7 +14,15 @@
14
14
 
15
15
  export * from '../lib/Badge/Badge'
16
16
 
17
- export { Hud, showLoading, hideLoading, showToast, showAlertModal, showAlertBottomModal, showPopoverView, hidePopoverView } from '../lib/Hud/Hud'
17
+ export {
18
+ Hud,
19
+ showLoading, hideLoading,
20
+ showToast,
21
+ showAlertModal,
22
+ showAlertBottomModal,
23
+ showAlertSheetModal,
24
+ showPopoverView, hidePopoverView
25
+ } from '../lib/Hud/Hud'
18
26
 
19
27
  export * from '../lib/Modal/Modal'
20
28
 
package/utils/lazy.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-27 18:17:54
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-07-11 15:59:49
5
+ * @LastEditTime: 2022-08-25 17:02:22
6
6
  * @FilePath: /@aks-dev/easyui/utils/lazy.ts
7
7
  */
8
8
  import type { SyncLoopCallBack } from '.'
@@ -17,7 +17,7 @@ export const sleep = (msec?: number) => {
17
17
 
18
18
 
19
19
  export const randomcolor = () => {
20
- return `rgba(${Math.round(Math.random() * 255)},${Math.round(Math.random() * 255)},${Math.round(Math.random() * 255)},${Math.random()})`
20
+ return `rgba(${Math.round(Math.random() * 255)},${Math.round(Math.random() * 255)},${Math.round(Math.random() * 255)},${1})`
21
21
  }
22
22
 
23
23