@aks-dev/easyui 1.0.182 → 1.0.184
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/dist/components/AnimationModal/AnimationModal.js +15 -19
- package/dist/components/Badge/Badge.js +13 -18
- package/dist/components/DottedLine/DottedLine.js +7 -10
- package/dist/components/Echarts/EchartsView.js +14 -18
- package/dist/components/Echarts/helper.js +2 -7
- package/dist/components/Hud/AlertBottomView/AlertBottomView.js +56 -61
- package/dist/components/Hud/AlertSheetView/AlertSheetView.js +42 -47
- package/dist/components/Hud/AlertView/AlertView.js +55 -60
- package/dist/components/Hud/Hud.js +17 -31
- package/dist/components/Hud/Loading/Loading.js +21 -27
- package/dist/components/Hud/PopoverView/PopoverView.js +16 -22
- package/dist/components/Hud/Scanner/Scanner.js +108 -114
- package/dist/components/Hud/Toast/Toast.js +22 -27
- package/dist/components/MenuView/MenuView.js +31 -34
- package/dist/components/Modal/Modal.js +1 -6
- package/dist/components/MutiPictureView/MutiPictureView.js +35 -38
- package/dist/components/PictureViewer/PictureViewer.js +12 -17
- package/dist/components/RefreshList/RefreshList.js +47 -51
- package/dist/components/RichText/RichText.js +17 -20
- package/dist/components/StickHeaderView/StickHeaderView.js +7 -10
- package/dist/components/TableCell/TableCell.js +29 -32
- package/dist/components/TextInputArea/TextInputArea.js +25 -28
- package/dist/components/WithLoadingContainer/WithLoadingContainer.js +20 -24
- package/dist/index.js +19 -51
- package/dist/jsbridge/RNEasyui.js +11 -18
- package/dist/jsbridge/UpgradeModule.js +8 -14
- package/dist/jsbridge/index.js +2 -5
- package/dist/screen/index.js +2 -5
- package/dist/screen/px2dp.js +14 -18
- package/dist/screen/px2sp.js +5 -9
- package/dist/screen/text-fit.js +7 -10
- package/dist/utils/index.js +2 -5
- package/dist/utils/lazy.js +25 -50
- package/dist/utils/mode.js +8 -13
- package/package.json +3 -3
- package/readme.md +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* @Author: shiguo
|
|
4
3
|
* @Date: 2022-05-17 15:22:06
|
|
@@ -6,32 +5,29 @@
|
|
|
6
5
|
* @LastEditTime: 2023-09-27 15:17:15
|
|
7
6
|
* @FilePath: /@aks-dev/easyui/lib/AnimationModal/AnimationModal.tsx
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const React = tslib_1.__importStar(require("react"));
|
|
13
|
-
const react_native_1 = require("react-native");
|
|
14
|
-
const utils = tslib_1.__importStar(require("../../utils/lazy"));
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { View, Animated, Easing, PanResponder, StyleSheet, useWindowDimensions, BackHandler, } from "react-native";
|
|
10
|
+
import * as utils from "../../utils/lazy";
|
|
15
11
|
// type State = {
|
|
16
12
|
// display: 'flex' | 'none';
|
|
17
13
|
// }
|
|
18
14
|
// type StateReducerProps = (state: State, action: Partial<State>) => State
|
|
19
|
-
|
|
15
|
+
export const AnimationModal = React.forwardRef((props, ref) => {
|
|
20
16
|
const { animationType = "from-bottom", mask = false } = props || {};
|
|
21
|
-
const { height } =
|
|
17
|
+
const { height } = useWindowDimensions();
|
|
22
18
|
// const [state, dispatch] = React.useReducer<StateReducerProps>(
|
|
23
19
|
// (state, action) => ({ ...state, ...action }),
|
|
24
20
|
// {
|
|
25
21
|
// display: 'none'
|
|
26
22
|
// })
|
|
27
23
|
const [display, setDisplay] = useCallbackState("none");
|
|
28
|
-
const animatedValue = React.useRef(new
|
|
24
|
+
const animatedValue = React.useRef(new Animated.Value(0)).current;
|
|
29
25
|
const timing = (value) => {
|
|
30
|
-
|
|
26
|
+
Animated.timing(animatedValue, {
|
|
31
27
|
toValue: value,
|
|
32
28
|
duration: 350,
|
|
33
29
|
useNativeDriver: true,
|
|
34
|
-
easing:
|
|
30
|
+
easing: Easing.ease,
|
|
35
31
|
}).start(({ finished }) => {
|
|
36
32
|
/* 动画完成的回调函数 */
|
|
37
33
|
});
|
|
@@ -72,16 +68,16 @@ exports.AnimationModal = React.forwardRef((props, ref) => {
|
|
|
72
68
|
return init();
|
|
73
69
|
};
|
|
74
70
|
React.useEffect(() => {
|
|
75
|
-
let addEventListener =
|
|
71
|
+
let addEventListener = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
76
72
|
return display == "flex";
|
|
77
73
|
});
|
|
78
74
|
return () => {
|
|
79
75
|
addEventListener.remove();
|
|
80
76
|
};
|
|
81
77
|
}, [display]);
|
|
82
|
-
return (<
|
|
78
|
+
return (<View style={Object.assign({
|
|
83
79
|
display: display,
|
|
84
|
-
}, styles.container, props.style)} {...
|
|
80
|
+
}, styles.container, props.style)} {...PanResponder.create({
|
|
85
81
|
onStartShouldSetPanResponder: (e, gestureState) => {
|
|
86
82
|
let pageY = e.nativeEvent.pageY;
|
|
87
83
|
let topY = height - layoutRef.current.h1;
|
|
@@ -100,7 +96,7 @@ exports.AnimationModal = React.forwardRef((props, ref) => {
|
|
|
100
96
|
}
|
|
101
97
|
},
|
|
102
98
|
}).panHandlers}>
|
|
103
|
-
<
|
|
99
|
+
<Animated.View style={Object.assign({}, styles.wrapper, {
|
|
104
100
|
transform: [{ translateY: animatedValue }],
|
|
105
101
|
})}
|
|
106
102
|
// onLayout={e => {
|
|
@@ -109,10 +105,10 @@ exports.AnimationModal = React.forwardRef((props, ref) => {
|
|
|
109
105
|
// }}
|
|
110
106
|
ref={viewRef}>
|
|
111
107
|
{props.children}
|
|
112
|
-
</
|
|
113
|
-
</
|
|
108
|
+
</Animated.View>
|
|
109
|
+
</View>);
|
|
114
110
|
});
|
|
115
|
-
const styles =
|
|
111
|
+
const styles = StyleSheet.create({
|
|
116
112
|
container: {
|
|
117
113
|
position: "absolute",
|
|
118
114
|
left: 0,
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Badge = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
1
|
/*
|
|
6
2
|
* @Author: shiguo
|
|
7
3
|
* @Date: 2022-04-21 14:40:29
|
|
@@ -9,32 +5,31 @@ const tslib_1 = require("tslib");
|
|
|
9
5
|
* @LastEditTime: 2022-07-08 15:40:21
|
|
10
6
|
* @FilePath: /@aks-dev/easyui/lib/Badge/Badge.tsx
|
|
11
7
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const Badge = (props) => {
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { View, Text } from "react-native";
|
|
10
|
+
import { px2dp } from "../../screen/px2dp";
|
|
11
|
+
import { px2sp } from "../../screen/px2sp";
|
|
12
|
+
export const Badge = (props) => {
|
|
17
13
|
if (isNaN(+props.count) || Number(props.count) == 0)
|
|
18
|
-
return <
|
|
19
|
-
return (<
|
|
14
|
+
return <View />;
|
|
15
|
+
return (<View style={[
|
|
20
16
|
{
|
|
21
17
|
flexGrow: 0,
|
|
22
18
|
flexShrink: 1,
|
|
23
19
|
zIndex: 1,
|
|
24
20
|
// paddingHorizontal: px2dp(0),
|
|
25
|
-
height:
|
|
26
|
-
minWidth:
|
|
27
|
-
borderRadius:
|
|
21
|
+
height: px2dp(16),
|
|
22
|
+
minWidth: px2dp(16),
|
|
23
|
+
borderRadius: px2dp(8),
|
|
28
24
|
justifyContent: "center",
|
|
29
25
|
alignItems: "center",
|
|
30
26
|
backgroundColor: "red",
|
|
31
27
|
},
|
|
32
28
|
props.style,
|
|
33
29
|
]}>
|
|
34
|
-
<
|
|
30
|
+
<Text style={{ fontSize: px2sp(12), color: "white", textAlign: "center" }}>
|
|
35
31
|
{" "}
|
|
36
32
|
{Number(props.count) > 99 ? "+99" : props.count}{" "}
|
|
37
|
-
</
|
|
38
|
-
</
|
|
33
|
+
</Text>
|
|
34
|
+
</View>);
|
|
39
35
|
};
|
|
40
|
-
exports.Badge = Badge;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
1
|
/*
|
|
5
2
|
* @Author: shiguo
|
|
6
3
|
* @Date: 2022-07-12 15:30:19
|
|
@@ -8,25 +5,25 @@ const tslib_1 = require("tslib");
|
|
|
8
5
|
* @LastEditTime: 2022-07-12 15:33:06
|
|
9
6
|
* @FilePath: /@aks-dev/easyui/lib/DottedLine/DottedLine.tsx
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { StyleSheet, View } from "react-native";
|
|
10
|
+
export default (props) => {
|
|
14
11
|
const { vertical = false, dottedColor, dottedCount = 200, ...rest } = props;
|
|
15
12
|
const arrs = Array.from({ length: dottedCount }, (k, v) => v);
|
|
16
|
-
return (<
|
|
13
|
+
return (<View style={{
|
|
17
14
|
...styles.container,
|
|
18
15
|
flexDirection: vertical ? "column" : "row",
|
|
19
16
|
...rest.style,
|
|
20
17
|
}}>
|
|
21
18
|
{arrs.map((item, index) => {
|
|
22
|
-
return (<
|
|
19
|
+
return (<View key={`dotted-${index}`} style={{
|
|
23
20
|
...(vertical ? styles.dotted_vertical : styles.dotted_horizontal),
|
|
24
21
|
...(dottedColor && { backgroundColor: dottedColor }),
|
|
25
22
|
}}/>);
|
|
26
23
|
})}
|
|
27
|
-
</
|
|
24
|
+
</View>);
|
|
28
25
|
};
|
|
29
|
-
const styles =
|
|
26
|
+
const styles = StyleSheet.create({
|
|
30
27
|
container: {
|
|
31
28
|
display: "flex",
|
|
32
29
|
flexGrow: 1,
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.echarts = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
1
|
/*
|
|
6
2
|
* @Author: shiguo
|
|
7
3
|
* @Date: 2022-05-05 14:52:53
|
|
@@ -9,10 +5,10 @@ const tslib_1 = require("tslib");
|
|
|
9
5
|
* @LastEditTime: 2023-01-03 17:50:43
|
|
10
6
|
* @FilePath: /@aks-dev/easyui/lib/Echarts/EchartsView.tsx
|
|
11
7
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { StyleSheet, View, } from "react-native";
|
|
10
|
+
import { WebView } from "react-native-webview";
|
|
11
|
+
import { getHtml, toString } from "./helper";
|
|
16
12
|
// type Reducer = (prevState: State, action: Partial<State>) => State;
|
|
17
13
|
const EchartsView = (props) => {
|
|
18
14
|
const [state, dispatch] = React.useReducer((prevState, ...args) => Object.assign({}, prevState, ...args), {
|
|
@@ -58,7 +54,7 @@ const EchartsView = (props) => {
|
|
|
58
54
|
instance = echarts.init(document.getElementById('main'));
|
|
59
55
|
}
|
|
60
56
|
instance.clear();
|
|
61
|
-
instance.setOption(${
|
|
57
|
+
instance.setOption(${toString(props.option)});
|
|
62
58
|
})();
|
|
63
59
|
`;
|
|
64
60
|
WebViewRef.current?.injectJavaScript(run);
|
|
@@ -110,12 +106,12 @@ const EchartsView = (props) => {
|
|
|
110
106
|
// })();
|
|
111
107
|
// `
|
|
112
108
|
// }
|
|
113
|
-
return (<
|
|
114
|
-
<
|
|
109
|
+
return (<View style={[styles.container, props.style]} ref={containerRef}>
|
|
110
|
+
<WebView ref={WebViewRef} originWhitelist={["*"]} useWebKit={true} // ios使用最新webkit内核渲染
|
|
115
111
|
allowUniversalAccessFromFileURLs={true} geolocationEnabled={true} mixedContentMode={"always"} renderLoading={() => {
|
|
116
112
|
if (props.renderLoading)
|
|
117
113
|
return props.renderLoading();
|
|
118
|
-
return (<
|
|
114
|
+
return (<View style={{
|
|
119
115
|
backgroundColor: props.style?.backgroundColor || "transparent",
|
|
120
116
|
}}/>);
|
|
121
117
|
}} // 设置空View,修复ioswebview闪白
|
|
@@ -136,20 +132,20 @@ const EchartsView = (props) => {
|
|
|
136
132
|
console.log("onError", e);
|
|
137
133
|
}} source={{
|
|
138
134
|
baseUrl: "",
|
|
139
|
-
html:
|
|
135
|
+
html: getHtml({
|
|
140
136
|
backgroundColor: props.style?.backgroundColor || "transparent",
|
|
141
137
|
}),
|
|
142
138
|
}}/>
|
|
143
|
-
</
|
|
139
|
+
</View>);
|
|
144
140
|
};
|
|
145
|
-
const styles =
|
|
141
|
+
const styles = StyleSheet.create({
|
|
146
142
|
container: {
|
|
147
143
|
display: "flex",
|
|
148
144
|
flexGrow: 0,
|
|
149
145
|
backgroundColor: "white",
|
|
150
146
|
},
|
|
151
147
|
});
|
|
152
|
-
|
|
148
|
+
export default EchartsView;
|
|
153
149
|
// React.memo(EchartsView)
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
import * as echarts from "echarts/core";
|
|
151
|
+
export { echarts };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* @Author: shiguo
|
|
4
3
|
* @Date: 2022-05-05 15:56:21
|
|
@@ -6,9 +5,7 @@
|
|
|
6
5
|
* @LastEditTime: 2023-01-03 17:02:57
|
|
7
6
|
* @FilePath: /@aks-dev/easyui/lib/Echarts/helper.tsx
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
exports.toString = exports.getHtml = void 0;
|
|
11
|
-
const getHtml = (props) => {
|
|
8
|
+
export const getHtml = (props) => {
|
|
12
9
|
return `
|
|
13
10
|
<!DOCTYPE html>
|
|
14
11
|
<html>
|
|
@@ -45,13 +42,12 @@ const getHtml = (props) => {
|
|
|
45
42
|
</html>
|
|
46
43
|
`;
|
|
47
44
|
};
|
|
48
|
-
exports.getHtml = getHtml;
|
|
49
45
|
/**
|
|
50
46
|
* https://res.actiiot.com/echarts/5.0.2/echarts.min.js
|
|
51
47
|
*
|
|
52
48
|
* https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.1/echarts.min.js
|
|
53
49
|
*/
|
|
54
|
-
const toString = (obj) => {
|
|
50
|
+
export const toString = (obj) => {
|
|
55
51
|
let result = JSON.stringify(obj, function (key, val) {
|
|
56
52
|
// 对function进行特殊处理
|
|
57
53
|
if (typeof val === 'function') {
|
|
@@ -65,5 +61,4 @@ const toString = (obj) => {
|
|
|
65
61
|
} while (result.indexOf('~ha~') >= 0);
|
|
66
62
|
return result;
|
|
67
63
|
};
|
|
68
|
-
exports.toString = toString;
|
|
69
64
|
///.replace(/\\n/g, '')
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const react_native_modal_1 = tslib_1.__importDefault(require("react-native-modal"));
|
|
8
|
-
const px2dp_1 = require("../../../screen/px2dp");
|
|
9
|
-
const px2sp_1 = require("../../../screen/px2sp");
|
|
10
|
-
exports.default = React.forwardRef((_, ref) => {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, Text, StyleSheet, Platform, StatusBar, TouchableOpacity, Dimensions, } from "react-native";
|
|
3
|
+
import Modal from "react-native-modal";
|
|
4
|
+
import { px2dp, deviceWidth } from "../../../screen/px2dp";
|
|
5
|
+
import { px2sp } from "../../../screen/px2sp";
|
|
6
|
+
export default React.forwardRef((_, ref) => {
|
|
11
7
|
const defaultState = {
|
|
12
8
|
visible: false,
|
|
13
9
|
cancelText: "取消",
|
|
@@ -28,18 +24,18 @@ exports.default = React.forwardRef((_, ref) => {
|
|
|
28
24
|
setState(defaultState);
|
|
29
25
|
};
|
|
30
26
|
React.useEffect(() => {
|
|
31
|
-
if (
|
|
27
|
+
if (Platform.OS == "android") {
|
|
32
28
|
if (state.visible) {
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
StatusBar.setBackgroundColor("black");
|
|
30
|
+
StatusBar.setBarStyle("light-content");
|
|
35
31
|
}
|
|
36
32
|
else {
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
StatusBar.setBackgroundColor("transparent");
|
|
34
|
+
StatusBar.setBarStyle("dark-content");
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
37
|
}, [state.visible]);
|
|
42
|
-
return (<
|
|
38
|
+
return (<Modal hideModalContentWhileAnimating={true} //通过隐藏模态内容直到动画完成来增强性能
|
|
43
39
|
useNativeDriver={true} //定义动画是否应使用本机驱动程序
|
|
44
40
|
animationIn="slideInUp" animationOut="slideOutDown" onBackButtonPress={() => {
|
|
45
41
|
//按下Android后退按钮时调用
|
|
@@ -47,63 +43,62 @@ exports.default = React.forwardRef((_, ref) => {
|
|
|
47
43
|
}} onBackdropPress={() => {
|
|
48
44
|
//按下背景时调用
|
|
49
45
|
hide();
|
|
50
|
-
}} isVisible={state.visible} style={{ margin: 0 }} deviceHeight={
|
|
51
|
-
<
|
|
52
|
-
<
|
|
53
|
-
{state.title && <
|
|
54
|
-
<
|
|
46
|
+
}} isVisible={state.visible} style={{ margin: 0 }} deviceHeight={Dimensions.get("screen").height}>
|
|
47
|
+
<View style={styles.container}>
|
|
48
|
+
<View style={[styles.wrapper, state.wrapperStyle]}>
|
|
49
|
+
{state.title && <Text style={styles.titleText}>{state.title}</Text>}
|
|
50
|
+
<View style={[state.contentContainerStyle]}>
|
|
55
51
|
{(() => {
|
|
56
52
|
if (typeof state.content == "string")
|
|
57
|
-
return <
|
|
53
|
+
return <Text style={styles.contentText}>{state.content}</Text>;
|
|
58
54
|
if (React.isValidElement(state.content))
|
|
59
55
|
return state.content;
|
|
60
|
-
return <
|
|
56
|
+
return <View />;
|
|
61
57
|
})()}
|
|
62
|
-
</
|
|
63
|
-
{(state.cancelText || state.confirmText) && (<
|
|
64
|
-
{state.cancelText && (<
|
|
58
|
+
</View>
|
|
59
|
+
{(state.cancelText || state.confirmText) && (<View style={styles.action}>
|
|
60
|
+
{state.cancelText && (<TouchableOpacity style={[
|
|
65
61
|
styles.cancel,
|
|
66
|
-
{ marginRight: state.confirmText ?
|
|
62
|
+
{ marginRight: state.confirmText ? px2dp(15) : 0 },
|
|
67
63
|
state.cancelContainerStyle,
|
|
68
64
|
]} activeOpacity={0.8} onPress={() => {
|
|
69
65
|
hide();
|
|
70
66
|
cancelCallbackRef.current && cancelCallbackRef.current();
|
|
71
67
|
cancelCallbackRef.current = undefined;
|
|
72
68
|
}}>
|
|
73
|
-
<
|
|
69
|
+
<Text style={[styles.cancelText, state.cancelTextStyle]}>
|
|
74
70
|
{state.cancelText}
|
|
75
|
-
</
|
|
76
|
-
</
|
|
71
|
+
</Text>
|
|
72
|
+
</TouchableOpacity>)}
|
|
77
73
|
|
|
78
|
-
{state.confirmText && (<
|
|
74
|
+
{state.confirmText && (<TouchableOpacity style={[
|
|
79
75
|
styles.confirm,
|
|
80
|
-
{ marginLeft: state.cancelText ?
|
|
76
|
+
{ marginLeft: state.cancelText ? px2dp(15) : 0 },
|
|
81
77
|
state.confirmContainerStyle,
|
|
82
78
|
]} activeOpacity={0.8} onPress={() => {
|
|
83
79
|
hide();
|
|
84
80
|
confirmCallbackRef.current && confirmCallbackRef.current();
|
|
85
81
|
confirmCallbackRef.current = undefined;
|
|
86
82
|
}}>
|
|
87
|
-
<
|
|
83
|
+
<Text style={[styles.confirmText, state.confirmTextStyle]}>
|
|
88
84
|
{state.confirmText}
|
|
89
|
-
</
|
|
90
|
-
</
|
|
91
|
-
</
|
|
92
|
-
</
|
|
93
|
-
</
|
|
94
|
-
</
|
|
85
|
+
</Text>
|
|
86
|
+
</TouchableOpacity>)}
|
|
87
|
+
</View>)}
|
|
88
|
+
</View>
|
|
89
|
+
</View>
|
|
90
|
+
</Modal>);
|
|
95
91
|
});
|
|
96
|
-
|
|
97
|
-
const showAlertBottomModal = (props) => {
|
|
98
|
-
|
|
92
|
+
export const alertBottomViewRef = React.createRef();
|
|
93
|
+
export const showAlertBottomModal = (props) => {
|
|
94
|
+
alertBottomViewRef.current?.show(props);
|
|
99
95
|
};
|
|
100
|
-
exports.showAlertBottomModal = showAlertBottomModal;
|
|
101
96
|
// const sleep = (msec?: number) => {
|
|
102
97
|
// return new Promise(resolve => {
|
|
103
98
|
// setTimeout(resolve, msec || 350);
|
|
104
99
|
// });
|
|
105
100
|
// }
|
|
106
|
-
const styles =
|
|
101
|
+
const styles = StyleSheet.create({
|
|
107
102
|
container: {
|
|
108
103
|
display: "flex",
|
|
109
104
|
flexGrow: 1,
|
|
@@ -116,28 +111,28 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
116
111
|
width: "100%",
|
|
117
112
|
backgroundColor: "white",
|
|
118
113
|
overflow: "hidden",
|
|
119
|
-
borderTopLeftRadius:
|
|
120
|
-
borderTopRightRadius:
|
|
114
|
+
borderTopLeftRadius: px2dp(10),
|
|
115
|
+
borderTopRightRadius: px2dp(10),
|
|
121
116
|
display: "flex",
|
|
122
|
-
padding:
|
|
117
|
+
padding: px2dp(15),
|
|
123
118
|
},
|
|
124
119
|
titleText: {
|
|
125
|
-
maxWidth:
|
|
126
|
-
fontSize:
|
|
127
|
-
marginBottom:
|
|
120
|
+
maxWidth: deviceWidth - px2dp(30),
|
|
121
|
+
fontSize: px2sp(18),
|
|
122
|
+
marginBottom: px2dp(20),
|
|
128
123
|
// backgroundColor: 'red',
|
|
129
124
|
textAlign: "center",
|
|
130
125
|
fontWeight: "bold",
|
|
131
126
|
color: "#1A1A1A",
|
|
132
127
|
},
|
|
133
128
|
contentText: {
|
|
134
|
-
maxWidth:
|
|
135
|
-
marginBottom:
|
|
136
|
-
minHeight:
|
|
129
|
+
maxWidth: deviceWidth - px2dp(30),
|
|
130
|
+
marginBottom: px2dp(20),
|
|
131
|
+
minHeight: px2dp(40),
|
|
137
132
|
flexGrow: 0,
|
|
138
133
|
flexShrink: 1,
|
|
139
134
|
width: undefined,
|
|
140
|
-
fontSize:
|
|
135
|
+
fontSize: px2sp(15),
|
|
141
136
|
// backgroundColor: 'red',
|
|
142
137
|
color: "#1A1A1A",
|
|
143
138
|
textAlign: "center",
|
|
@@ -151,29 +146,29 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
151
146
|
},
|
|
152
147
|
cancel: {
|
|
153
148
|
width: "40%",
|
|
154
|
-
height:
|
|
149
|
+
height: px2dp(44),
|
|
155
150
|
display: "flex",
|
|
156
151
|
justifyContent: "center",
|
|
157
152
|
alignItems: "center",
|
|
158
|
-
borderRadius:
|
|
159
|
-
borderWidth:
|
|
153
|
+
borderRadius: px2dp(10),
|
|
154
|
+
borderWidth: px2dp(1),
|
|
160
155
|
borderColor: "#A3A9CC",
|
|
161
156
|
},
|
|
162
157
|
confirm: {
|
|
163
158
|
width: "40%",
|
|
164
|
-
height:
|
|
159
|
+
height: px2dp(44),
|
|
165
160
|
display: "flex",
|
|
166
161
|
justifyContent: "center",
|
|
167
162
|
alignItems: "center",
|
|
168
163
|
backgroundColor: "#2763FF",
|
|
169
|
-
borderRadius:
|
|
164
|
+
borderRadius: px2dp(10),
|
|
170
165
|
},
|
|
171
166
|
cancelText: {
|
|
172
|
-
fontSize:
|
|
167
|
+
fontSize: px2sp(15),
|
|
173
168
|
color: "#A3A9CC",
|
|
174
169
|
},
|
|
175
170
|
confirmText: {
|
|
176
|
-
fontSize:
|
|
171
|
+
fontSize: px2sp(15),
|
|
177
172
|
color: "white",
|
|
178
173
|
},
|
|
179
174
|
});
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const react_native_modal_1 = tslib_1.__importDefault(require("react-native-modal"));
|
|
8
|
-
const px2dp_1 = require("../../../screen/px2dp");
|
|
9
|
-
const px2sp_1 = require("../../../screen/px2sp");
|
|
10
|
-
exports.default = React.forwardRef((_, ref) => {
|
|
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 { px2dp } from "../../../screen/px2dp";
|
|
5
|
+
import { px2sp } from "../../../screen/px2sp";
|
|
6
|
+
export default React.forwardRef((_, ref) => {
|
|
11
7
|
const defaultState = {
|
|
12
8
|
visible: false,
|
|
13
9
|
actions: [],
|
|
@@ -23,18 +19,18 @@ exports.default = React.forwardRef((_, ref) => {
|
|
|
23
19
|
setState(defaultState);
|
|
24
20
|
};
|
|
25
21
|
React.useEffect(() => {
|
|
26
|
-
if (
|
|
22
|
+
if (Platform.OS == "android") {
|
|
27
23
|
if (state.visible) {
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
StatusBar.setBackgroundColor("black");
|
|
25
|
+
StatusBar.setBarStyle("light-content");
|
|
30
26
|
}
|
|
31
27
|
else {
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
StatusBar.setBackgroundColor("transparent");
|
|
29
|
+
StatusBar.setBarStyle("dark-content");
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
32
|
}, [state.visible]);
|
|
37
|
-
return (<
|
|
33
|
+
return (<Modal hideModalContentWhileAnimating={true} //通过隐藏模态内容直到动画完成来增强性能
|
|
38
34
|
useNativeDriver={true} //定义动画是否应使用本机驱动程序
|
|
39
35
|
animationIn="slideInUp" animationOut="slideOutDown" onBackButtonPress={() => {
|
|
40
36
|
//按下Android后退按钮时调用
|
|
@@ -42,35 +38,34 @@ exports.default = React.forwardRef((_, ref) => {
|
|
|
42
38
|
}} onBackdropPress={() => {
|
|
43
39
|
//按下背景时调用
|
|
44
40
|
hide();
|
|
45
|
-
}} isVisible={state.visible} deviceHeight={
|
|
46
|
-
<
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
{state.actions?.map((i, idx) => (<
|
|
41
|
+
}} isVisible={state.visible} deviceHeight={Dimensions.get("screen").height} style={{ margin: 0 }}>
|
|
42
|
+
<View style={styles.container}>
|
|
43
|
+
<View style={[styles.wrapper]}>
|
|
44
|
+
<View style={styles.itemContainer}>
|
|
45
|
+
{state.actions?.map((i, idx) => (<TouchableOpacity key={`sg-action-${idx}`} style={[styles.item]} activeOpacity={1} onPress={() => {
|
|
50
46
|
hide();
|
|
51
47
|
i.onClick && i.onClick();
|
|
52
48
|
}}>
|
|
53
|
-
<
|
|
49
|
+
<Text style={[styles.itemText, { color: i.color }]} numberOfLines={2}>
|
|
54
50
|
{i.text}
|
|
55
|
-
</
|
|
56
|
-
</
|
|
57
|
-
</
|
|
51
|
+
</Text>
|
|
52
|
+
</TouchableOpacity>))}
|
|
53
|
+
</View>
|
|
58
54
|
|
|
59
|
-
<
|
|
55
|
+
<TouchableOpacity style={[styles.cancel]} activeOpacity={1} onPress={() => {
|
|
60
56
|
hide();
|
|
61
57
|
}}>
|
|
62
|
-
<
|
|
63
|
-
</
|
|
64
|
-
</
|
|
65
|
-
</
|
|
66
|
-
</
|
|
58
|
+
<Text style={[styles.cancelText]}>取消</Text>
|
|
59
|
+
</TouchableOpacity>
|
|
60
|
+
</View>
|
|
61
|
+
</View>
|
|
62
|
+
</Modal>);
|
|
67
63
|
});
|
|
68
|
-
|
|
69
|
-
const showAlertSheetModal = (props) => {
|
|
70
|
-
|
|
64
|
+
export const alertSheetViewRef = React.createRef();
|
|
65
|
+
export const showAlertSheetModal = (props) => {
|
|
66
|
+
alertSheetViewRef.current?.show(props);
|
|
71
67
|
};
|
|
72
|
-
|
|
73
|
-
const styles = react_native_1.StyleSheet.create({
|
|
68
|
+
const styles = StyleSheet.create({
|
|
74
69
|
container: {
|
|
75
70
|
display: "flex",
|
|
76
71
|
flexGrow: 1,
|
|
@@ -83,40 +78,40 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
83
78
|
width: "100%",
|
|
84
79
|
// backgroundColor: 'pink',
|
|
85
80
|
overflow: "hidden",
|
|
86
|
-
borderTopLeftRadius:
|
|
87
|
-
borderTopRightRadius:
|
|
81
|
+
borderTopLeftRadius: px2dp(10),
|
|
82
|
+
borderTopRightRadius: px2dp(10),
|
|
88
83
|
display: "flex",
|
|
89
|
-
padding:
|
|
84
|
+
padding: px2dp(15),
|
|
90
85
|
},
|
|
91
86
|
cancel: {
|
|
92
|
-
height:
|
|
87
|
+
height: px2dp(50),
|
|
93
88
|
display: "flex",
|
|
94
89
|
justifyContent: "center",
|
|
95
90
|
alignItems: "center",
|
|
96
|
-
borderRadius:
|
|
91
|
+
borderRadius: px2dp(10),
|
|
97
92
|
backgroundColor: "white",
|
|
98
|
-
marginTop:
|
|
93
|
+
marginTop: px2dp(15),
|
|
99
94
|
},
|
|
100
95
|
cancelText: {
|
|
101
|
-
fontSize:
|
|
96
|
+
fontSize: px2sp(15),
|
|
102
97
|
color: "#2763FF",
|
|
103
98
|
},
|
|
104
99
|
itemContainer: {
|
|
105
100
|
display: "flex",
|
|
106
|
-
borderRadius:
|
|
101
|
+
borderRadius: px2dp(10),
|
|
107
102
|
overflow: "hidden",
|
|
108
103
|
backgroundColor: "#f1f1f1",
|
|
109
104
|
},
|
|
110
105
|
item: {
|
|
111
|
-
height:
|
|
106
|
+
height: px2dp(50),
|
|
112
107
|
display: "flex",
|
|
113
108
|
justifyContent: "center",
|
|
114
109
|
alignItems: "center",
|
|
115
110
|
backgroundColor: "white",
|
|
116
|
-
marginTop:
|
|
111
|
+
marginTop: px2dp(0.75),
|
|
117
112
|
},
|
|
118
113
|
itemText: {
|
|
119
|
-
fontSize:
|
|
114
|
+
fontSize: px2sp(12),
|
|
120
115
|
color: "#666666",
|
|
121
116
|
},
|
|
122
117
|
});
|