@aks-dev/easyui 1.0.79 → 1.0.80
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.
- package/lib/Hud/AlertBottomView/AlertBottomView.tsx +227 -0
- package/lib/Hud/AlertBottomView/index.ts +42 -0
- package/lib/Hud/AlertView/AlertView.tsx +4 -4
- package/lib/Hud/AlertView/index.ts +5 -5
- package/lib/Hud/Hud.tsx +11 -5
- package/lib/Hud/index.ts +3 -3
- package/package.json +1 -1
- package/src/index.ts +2 -6
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { View, Text, StyleSheet, Platform, StatusBar, TouchableOpacity, } from 'react-native'
|
|
3
|
+
import Modal from 'react-native-modal'
|
|
4
|
+
|
|
5
|
+
import { px2dp, deviceWidth } from '../../../screen/px2dp'
|
|
6
|
+
import { px2sp } from '../../../screen/px2sp'
|
|
7
|
+
|
|
8
|
+
import { AlertBottomViewOptions, AlertBottomViewCurrent } from '.'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
type State = {
|
|
13
|
+
visible: boolean;
|
|
14
|
+
|
|
15
|
+
} & Omit<AlertBottomViewOptions, 'cancel' | 'confirm'>
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export default React.forwardRef<AlertBottomViewCurrent, {}>((_, ref) => {
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const defaultState: Partial<State> = {
|
|
25
|
+
visible: false,
|
|
26
|
+
cancelText: '取消',
|
|
27
|
+
confirmText: '确定',
|
|
28
|
+
}
|
|
29
|
+
const [state, setState] = React.useState<Partial<State>>(defaultState)
|
|
30
|
+
const cancelCallbackRef = React.useRef<Function>();
|
|
31
|
+
const confirmCallbackRef = React.useRef<Function>();
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
React.useImperativeHandle<unknown, AlertBottomViewCurrent>(ref, () => ({
|
|
36
|
+
show: async (options: Partial<AlertBottomViewOptions>) => {
|
|
37
|
+
|
|
38
|
+
setState(Object.assign({}, defaultState, { visible: true }, options))
|
|
39
|
+
cancelCallbackRef.current = options.cancel;
|
|
40
|
+
confirmCallbackRef.current = options.confirm;
|
|
41
|
+
|
|
42
|
+
},
|
|
43
|
+
hide
|
|
44
|
+
}), [])
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const hide = async () => {
|
|
48
|
+
setState(defaultState)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (Platform.OS == 'android') {
|
|
54
|
+
if (state.visible) {
|
|
55
|
+
StatusBar.setBackgroundColor('black')
|
|
56
|
+
StatusBar.setBarStyle('light-content')
|
|
57
|
+
} else {
|
|
58
|
+
StatusBar.setBackgroundColor('transparent')
|
|
59
|
+
StatusBar.setBarStyle('dark-content')
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}, [state.visible])
|
|
64
|
+
return (
|
|
65
|
+
<Modal
|
|
66
|
+
hideModalContentWhileAnimating={true}//通过隐藏模态内容直到动画完成来增强性能
|
|
67
|
+
useNativeDriver={true}//定义动画是否应使用本机驱动程序
|
|
68
|
+
animationIn='slideInUp'
|
|
69
|
+
animationOut='slideOutDown'
|
|
70
|
+
onBackButtonPress={() => {
|
|
71
|
+
//按下Android后退按钮时调用
|
|
72
|
+
hide()
|
|
73
|
+
}}
|
|
74
|
+
onBackdropPress={() => {
|
|
75
|
+
//按下背景时调用
|
|
76
|
+
hide()
|
|
77
|
+
}}
|
|
78
|
+
isVisible={state.visible}
|
|
79
|
+
style={{ margin: 0 }}
|
|
80
|
+
>
|
|
81
|
+
<View style={styles.container}>
|
|
82
|
+
<View style={[styles.wrapper, state.wrapperStyle]}>
|
|
83
|
+
{state.title && <Text style={styles.titleText}>{state.title}</Text>}
|
|
84
|
+
<View style={[state.contentContainerStyle]}>
|
|
85
|
+
{(() => {
|
|
86
|
+
if (typeof state.content == 'string') return <Text style={styles.contentText}>{state.content}</Text>
|
|
87
|
+
if (React.isValidElement(state.content)) return state.content;
|
|
88
|
+
return <View />
|
|
89
|
+
})()}
|
|
90
|
+
</View>
|
|
91
|
+
{
|
|
92
|
+
(state.cancelText || state.confirmText) &&
|
|
93
|
+
<View style={styles.action}>
|
|
94
|
+
{state.cancelText &&
|
|
95
|
+
<TouchableOpacity
|
|
96
|
+
style={[styles.cancel, { marginRight: state.confirmText ? px2dp(15) : 0 }, state.cancelContainerStyle]}
|
|
97
|
+
activeOpacity={0.8}
|
|
98
|
+
onPress={() => {
|
|
99
|
+
hide()
|
|
100
|
+
cancelCallbackRef.current && cancelCallbackRef.current()
|
|
101
|
+
cancelCallbackRef.current = undefined;
|
|
102
|
+
|
|
103
|
+
}}>
|
|
104
|
+
<Text style={[styles.cancelText, state.cancelTextStyle]}>{state.cancelText}</Text>
|
|
105
|
+
</TouchableOpacity>
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
{state.confirmText &&
|
|
109
|
+
<TouchableOpacity
|
|
110
|
+
style={[styles.confirm, { marginLeft: state.cancelText ? px2dp(15) : 0 }, state.confirmContainerStyle]}
|
|
111
|
+
activeOpacity={0.8}
|
|
112
|
+
onPress={() => {
|
|
113
|
+
hide()
|
|
114
|
+
confirmCallbackRef.current && confirmCallbackRef.current()
|
|
115
|
+
confirmCallbackRef.current = undefined;
|
|
116
|
+
}}>
|
|
117
|
+
<Text style={[styles.confirmText, state.confirmTextStyle]}>{state.confirmText}</Text>
|
|
118
|
+
</TouchableOpacity>
|
|
119
|
+
}
|
|
120
|
+
</View>
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
</View>
|
|
124
|
+
|
|
125
|
+
</View>
|
|
126
|
+
</Modal>
|
|
127
|
+
)
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
export const alertBottomViewRef = React.createRef<AlertBottomViewCurrent>();
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
export const showAlertBottomModal = (props: Partial<AlertBottomViewOptions>) => {
|
|
137
|
+
alertBottomViewRef.current?.show(props)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
// const sleep = (msec?: number) => {
|
|
143
|
+
// return new Promise(resolve => {
|
|
144
|
+
// setTimeout(resolve, msec || 350);
|
|
145
|
+
// });
|
|
146
|
+
// }
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
const styles = StyleSheet.create({
|
|
151
|
+
container: {
|
|
152
|
+
display: 'flex',
|
|
153
|
+
flexGrow: 1,
|
|
154
|
+
justifyContent: 'flex-end',
|
|
155
|
+
alignItems: 'center',
|
|
156
|
+
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
wrapper: {
|
|
160
|
+
flexGrow: 0,
|
|
161
|
+
flexShrink: 0,
|
|
162
|
+
width: '100%',
|
|
163
|
+
backgroundColor: 'white',
|
|
164
|
+
overflow: 'hidden',
|
|
165
|
+
borderTopLeftRadius: px2dp(10),
|
|
166
|
+
borderTopRightRadius: px2dp(10),
|
|
167
|
+
display: 'flex',
|
|
168
|
+
padding: px2dp(15),
|
|
169
|
+
},
|
|
170
|
+
titleText: {
|
|
171
|
+
maxWidth: deviceWidth - px2dp(30),
|
|
172
|
+
fontSize: px2sp(18),
|
|
173
|
+
marginBottom: px2dp(20),
|
|
174
|
+
// backgroundColor: 'red',
|
|
175
|
+
textAlign: 'center',
|
|
176
|
+
fontWeight: 'bold',
|
|
177
|
+
color: '#1A1A1A'
|
|
178
|
+
},
|
|
179
|
+
contentText: {
|
|
180
|
+
maxWidth: deviceWidth - px2dp(30),
|
|
181
|
+
marginBottom: px2dp(20),
|
|
182
|
+
minHeight: px2dp(40),
|
|
183
|
+
flexGrow: 0,
|
|
184
|
+
flexShrink: 1,
|
|
185
|
+
width: undefined,
|
|
186
|
+
fontSize: px2sp(15),
|
|
187
|
+
// backgroundColor: 'red',
|
|
188
|
+
color: '#1A1A1A',
|
|
189
|
+
textAlign: 'center'
|
|
190
|
+
},
|
|
191
|
+
action: {
|
|
192
|
+
display: 'flex',
|
|
193
|
+
flexDirection: 'row',
|
|
194
|
+
justifyContent: 'space-between',
|
|
195
|
+
alignItems: 'center',
|
|
196
|
+
// backgroundColor:"red"
|
|
197
|
+
},
|
|
198
|
+
cancel: {
|
|
199
|
+
width: '40%',
|
|
200
|
+
height: px2dp(44),
|
|
201
|
+
display: 'flex',
|
|
202
|
+
justifyContent: 'center',
|
|
203
|
+
alignItems: 'center',
|
|
204
|
+
borderRadius: px2dp(10),
|
|
205
|
+
borderWidth: px2dp(1),
|
|
206
|
+
borderColor: '#A3A9CC'
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
confirm: {
|
|
210
|
+
width: '40%',
|
|
211
|
+
height: px2dp(44),
|
|
212
|
+
display: 'flex',
|
|
213
|
+
justifyContent: 'center',
|
|
214
|
+
alignItems: 'center',
|
|
215
|
+
backgroundColor: '#2763FF',
|
|
216
|
+
borderRadius: px2dp(10)
|
|
217
|
+
},
|
|
218
|
+
cancelText: {
|
|
219
|
+
fontSize: px2sp(15),
|
|
220
|
+
color: '#A3A9CC',
|
|
221
|
+
|
|
222
|
+
},
|
|
223
|
+
confirmText: {
|
|
224
|
+
fontSize: px2sp(15),
|
|
225
|
+
color: 'white'
|
|
226
|
+
},
|
|
227
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: shiguo
|
|
3
|
+
* @Date: 2022-04-22 17:30:32
|
|
4
|
+
* @LastEditors: shiguo
|
|
5
|
+
* @LastEditTime: 2022-07-12 19:39:48
|
|
6
|
+
* @FilePath: /@aks-dev/easyui/lib/Hud/AlertBottomView/index.ts
|
|
7
|
+
*/
|
|
8
|
+
import * as React from 'react'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import { StyleProp, ViewStyle, TextStyle } from 'react-native'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export declare type AlertBottomViewOptions = {
|
|
15
|
+
title: string;
|
|
16
|
+
wrapperStyle: StyleProp<ViewStyle>;
|
|
17
|
+
content: string | React.ReactElement;
|
|
18
|
+
contentContainerStyle:StyleProp<ViewStyle>;
|
|
19
|
+
cancelText: string;
|
|
20
|
+
cancelContainerStyle: StyleProp<ViewStyle>;
|
|
21
|
+
cancelTextStyle: StyleProp<TextStyle>;
|
|
22
|
+
cancel: () => void;
|
|
23
|
+
confirmText: string;
|
|
24
|
+
confirmContainerStyle: StyleProp<ViewStyle>;
|
|
25
|
+
confirmTextStyle: StyleProp<TextStyle>;
|
|
26
|
+
confirm: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export declare const showAlertBottomModal: (props: Partial<AlertBottomViewOptions>) => void;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export declare type AlertBottomViewCurrent = {
|
|
35
|
+
show: (options: Partial<AlertBottomViewOptions>) => void;
|
|
36
|
+
hide: () => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
export declare const AlertBottomView: React.ForwardRefExoticComponent<React.PropsWithoutRef<{}> & React.RefAttributes<AlertBottomViewCurrent>>;
|
|
41
|
+
|
|
42
|
+
export declare const AlertBottomViewRef: React.RefObject<AlertBottomViewCurrent>
|
|
@@ -5,14 +5,14 @@ import { View, Text, StyleSheet, Platform, Modal, StatusBar, TouchableOpacity, A
|
|
|
5
5
|
import { px2dp, deviceWidth } from '../../../screen/px2dp'
|
|
6
6
|
import { px2sp } from '../../../screen/px2sp'
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { AlertViewOptions, AlertViewCurrent } from '.'
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
type State = {
|
|
13
13
|
visible: boolean;
|
|
14
14
|
|
|
15
|
-
} & Omit<
|
|
15
|
+
} & Omit<AlertViewOptions, 'cancel' | 'confirm'>
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -33,7 +33,7 @@ export default React.forwardRef<AlertViewCurrent, {}>((_, ref) => {
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
React.useImperativeHandle<unknown, AlertViewCurrent>(ref, () => ({
|
|
36
|
-
show: async (options: Partial<
|
|
36
|
+
show: async (options: Partial<AlertViewOptions>) => {
|
|
37
37
|
|
|
38
38
|
setState(Object.assign({}, defaultState, { visible: true }, options))
|
|
39
39
|
cancelCallbackRef.current = options.cancel;
|
|
@@ -138,7 +138,7 @@ export const alertViewRef = React.createRef<AlertViewCurrent>();
|
|
|
138
138
|
|
|
139
139
|
|
|
140
140
|
|
|
141
|
-
export const showAlertModal = (props: Partial<
|
|
141
|
+
export const showAlertModal = (props: Partial<AlertViewOptions>) => {
|
|
142
142
|
alertViewRef.current?.show(props)
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @Author: shiguo
|
|
3
3
|
* @Date: 2022-04-22 17:30:32
|
|
4
4
|
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-
|
|
6
|
-
* @FilePath: /@aks/easyui/lib/
|
|
5
|
+
* @LastEditTime: 2022-07-12 19:06:29
|
|
6
|
+
* @FilePath: /cmwy-device-app/node_modules/@aks-dev/easyui/lib/Hud/AlertView/index.ts
|
|
7
7
|
*/
|
|
8
8
|
import * as React from 'react'
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ import * as React from 'react'
|
|
|
11
11
|
import { StyleProp, ViewStyle, TextStyle } from 'react-native'
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
export declare type
|
|
14
|
+
export declare type AlertViewOptions = {
|
|
15
15
|
title: string;
|
|
16
16
|
content: string | React.ReactElement;
|
|
17
17
|
wrapperStyle: StyleProp<ViewStyle>;
|
|
@@ -26,12 +26,12 @@ export declare type Options = {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
export declare const showAlertModal: (props: Partial<
|
|
29
|
+
export declare const showAlertModal: (props: Partial<AlertViewOptions>) => void;
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
export declare type AlertViewCurrent = {
|
|
34
|
-
show: (options: Partial<
|
|
34
|
+
show: (options: Partial<AlertViewOptions>) => void;
|
|
35
35
|
hide: () => void;
|
|
36
36
|
}
|
|
37
37
|
|
package/lib/Hud/Hud.tsx
CHANGED
|
@@ -2,14 +2,19 @@
|
|
|
2
2
|
* @Author: shiguo
|
|
3
3
|
* @Date: 2022-04-24 14:10:04
|
|
4
4
|
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-
|
|
6
|
-
* @FilePath: /@aks/easyui/lib/Hud/Hud.tsx
|
|
5
|
+
* @LastEditTime: 2022-07-12 19:12:37
|
|
6
|
+
* @FilePath: /cmwy-device-app/node_modules/@aks-dev/easyui/lib/Hud/Hud.tsx
|
|
7
7
|
*/
|
|
8
8
|
import * as React from 'react'
|
|
9
9
|
// import { StyleSheet } from 'react-native'
|
|
10
10
|
import {
|
|
11
11
|
alertViewRef, default as AlertView, showAlertModal
|
|
12
12
|
} from './AlertView/AlertView'
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
alertBottomViewRef, default as AlertBottomView, showAlertBottomModal
|
|
16
|
+
} from './AlertBottomView/AlertBottomView'
|
|
17
|
+
|
|
13
18
|
import {
|
|
14
19
|
hideLoading, Loading, loadingRef, showLoading
|
|
15
20
|
} from './Loading/Loading'
|
|
@@ -34,8 +39,8 @@ export const Hud: React.FC<{}> = () => React.cloneElement(
|
|
|
34
39
|
[
|
|
35
40
|
<Loading key="hud-0" ref={loadingRef} />,
|
|
36
41
|
<Toast key="hud-1" ref={toastRef} />,
|
|
37
|
-
<AlertView key="hud-2" ref={alertViewRef}
|
|
38
|
-
|
|
42
|
+
<AlertView key="hud-2" ref={alertViewRef} />,
|
|
43
|
+
<AlertBottomView key="hud-3" ref={alertBottomViewRef} />
|
|
39
44
|
]
|
|
40
45
|
)
|
|
41
46
|
|
|
@@ -44,5 +49,6 @@ export {
|
|
|
44
49
|
showAlertModal,
|
|
45
50
|
showToast,
|
|
46
51
|
showLoading,
|
|
47
|
-
hideLoading
|
|
52
|
+
hideLoading,
|
|
53
|
+
showAlertBottomModal,
|
|
48
54
|
}
|
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-
|
|
6
|
-
* @FilePath: /@aks/easyui/lib/Hud/index.ts
|
|
5
|
+
* @LastEditTime: 2022-07-12 19:14:17
|
|
6
|
+
* @FilePath: /cmwy-device-app/node_modules/@aks-dev/easyui/lib/Hud/index.ts
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
|
|
@@ -13,6 +13,6 @@ import * as React from 'react'
|
|
|
13
13
|
export * from './AlertView'
|
|
14
14
|
export * from './Loading'
|
|
15
15
|
export * from './Toast'
|
|
16
|
-
|
|
16
|
+
export * from './AlertBottomView'
|
|
17
17
|
|
|
18
18
|
export declare const Hud: React.FC<{}>
|
package/package.json
CHANGED
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-12
|
|
6
|
+
* @LastEditTime: 2022-07-12 19:38:05
|
|
7
7
|
* @FilePath: /@aks-dev/easyui/src/index.ts
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -13,10 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
export * from '../lib/Badge/Badge'
|
|
16
|
-
// export type { BadgeProps } from '../lib/Badge'
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
export { Hud, showLoading, hideLoading, showToast, showAlertModal } from '../lib/Hud/Hud'
|
|
17
|
+
export { Hud, showLoading, hideLoading, showToast, showAlertModal,showAlertBottomModal } from '../lib/Hud/Hud'
|
|
20
18
|
|
|
21
19
|
export * from '../lib/Modal/Modal'
|
|
22
20
|
|
|
@@ -29,11 +27,9 @@ export { RefreshState } from '../lib/RefreshList'
|
|
|
29
27
|
|
|
30
28
|
|
|
31
29
|
export { default as TableCell } from '../lib/TableCell/TableCell'
|
|
32
|
-
// export type { TableCellProps } from '../lib/TableCell'
|
|
33
30
|
|
|
34
31
|
|
|
35
32
|
export { default as TextInputArea } from '../lib/TextInputArea/TextInputArea'
|
|
36
|
-
// export type { TextInputAreaCurrent, TextInputAreaProps } from '../lib/TextInputArea'
|
|
37
33
|
|
|
38
34
|
|
|
39
35
|
export { default as WithLoadingContainer } from '../lib/WithLoadingContainer/WithLoadingContainer'
|