@aks-dev/easyui 1.1.5 → 1.1.7

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.
@@ -16,12 +16,11 @@ export type AnimationModalProps = {
16
16
  backgroundColor?: ColorValue | undefined;
17
17
  };
18
18
  };
19
- type RefAttributes = {
20
- show: () => RefAttributes;
21
- hide: () => RefAttributes;
22
- setData: (data?: any) => RefAttributes;
19
+ export type AnimationModalRefAttributes = {
20
+ show: () => AnimationModalRefAttributes;
21
+ hide: () => AnimationModalRefAttributes;
22
+ setData: (data?: any) => AnimationModalRefAttributes;
23
23
  getData: () => any;
24
24
  };
25
- export declare const AnimationModal: React.ForwardRefExoticComponent<React.PropsWithoutRef<AnimationModalProps> & React.RefAttributes<RefAttributes>>;
26
- export {};
25
+ export declare const AnimationModal: React.ForwardRefExoticComponent<React.PropsWithoutRef<AnimationModalProps> & React.RefAttributes<AnimationModalRefAttributes>>;
27
26
  //# sourceMappingURL=AnimationModal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnimationModal.d.ts","sourceRoot":"","sources":["../../../src/components/AnimationModal/AnimationModal.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAUL,UAAU,EACX,MAAM,cAAc,CAAC;AAItB,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,GAAG,WAAW,CAAC;IAC5C;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,KAAK,CAAC,EAAE;QACN,eAAe,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;KAC1C,CAAC;CACH,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,aAAa,CAAC;IAC1B,IAAI,EAAE,MAAM,aAAa,CAAC;IAC1B,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,aAAa,CAAC;IACvC,OAAO,EAAE,MAAM,GAAG,CAAC;CACpB,CAAC;AAMF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,yBAAyB,CAC1D,KAAK,CAAC,eAAe,CAAC,mBAAmB,CAAC,GACxC,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CAkIpC,CAAC"}
1
+ {"version":3,"file":"AnimationModal.d.ts","sourceRoot":"","sources":["../../../src/components/AnimationModal/AnimationModal.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAUL,UAAU,EACX,MAAM,cAAc,CAAC;AAItB,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,GAAG,WAAW,CAAC;IAC5C;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,KAAK,CAAC,EAAE;QACN,eAAe,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;KAC1C,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,MAAM,2BAA2B,CAAC;IACxC,IAAI,EAAE,MAAM,2BAA2B,CAAC;IACxC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,2BAA2B,CAAC;IACrD,OAAO,EAAE,MAAM,GAAG,CAAC;CACpB,CAAC;AAMF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,yBAAyB,CAC1D,KAAK,CAAC,eAAe,CAAC,mBAAmB,CAAC,GACxC,KAAK,CAAC,aAAa,CAAC,2BAA2B,CAAC,CAsIlD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AlertBottomView.d.ts","sourceRoot":"","sources":["../../../../src/components/Hud/AlertBottomView/AlertBottomView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK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,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC;IACrC,qBAAqB,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC3C,eAAe,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5C,gBAAgB,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACvC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IACrD,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;;AAKF,wBAsGG;AAEH,eAAO,MAAM,kBAAkB,uCAAmC,CAAC;AAEnE,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,CAAC,kBAAkB,CAAC,SAEtE,CAAC"}
@@ -1,6 +1,6 @@
1
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";
2
+ import { View, Text, StyleSheet, Platform, StatusBar, TouchableOpacity, } from "react-native";
3
+ import { AnimationModal, } from "../../AnimationModal/AnimationModal";
4
4
  import { px2dp, deviceWidth } from "../../../screen/px2dp";
5
5
  import { px2sp } from "../../../screen/px2sp";
6
6
  export default React.forwardRef((_, ref) => {
@@ -12,9 +12,11 @@ export default React.forwardRef((_, ref) => {
12
12
  const [state, setState] = React.useState(defaultState);
13
13
  const cancelCallbackRef = React.useRef(undefined);
14
14
  const confirmCallbackRef = React.useRef(undefined);
15
+ const animationModalRef = React.useRef(null);
15
16
  React.useImperativeHandle(ref, () => ({
16
17
  show: async (options) => {
17
18
  setState(Object.assign({}, defaultState, { visible: true }, options));
19
+ animationModalRef.current?.show();
18
20
  cancelCallbackRef.current = options.cancel;
19
21
  confirmCallbackRef.current = options.confirm;
20
22
  },
@@ -22,6 +24,7 @@ export default React.forwardRef((_, ref) => {
22
24
  }), []);
23
25
  const hide = async () => {
24
26
  setState(defaultState);
27
+ animationModalRef.current?.hide();
25
28
  };
26
29
  React.useEffect(() => {
27
30
  if (Platform.OS == "android") {
@@ -35,15 +38,7 @@ export default React.forwardRef((_, ref) => {
35
38
  }
36
39
  }
37
40
  }, [state.visible]);
38
- return (<Modal hideModalContentWhileAnimating={true} //通过隐藏模态内容直到动画完成来增强性能
39
- useNativeDriver={true} //定义动画是否应使用本机驱动程序
40
- animationIn="slideInUp" animationOut="slideOutDown" onBackButtonPress={() => {
41
- //按下Android后退按钮时调用
42
- hide();
43
- }} onBackdropPress={() => {
44
- //按下背景时调用
45
- hide();
46
- }} isVisible={state.visible} style={{ margin: 0 }} deviceHeight={Dimensions.get("screen").height}>
41
+ return (<AnimationModal ref={animationModalRef}>
47
42
  <View style={styles.container}>
48
43
  <View style={[styles.wrapper, state.wrapperStyle]}>
49
44
  {state.title && <Text style={styles.titleText}>{state.title}</Text>}
@@ -87,7 +82,7 @@ export default React.forwardRef((_, ref) => {
87
82
  </View>)}
88
83
  </View>
89
84
  </View>
90
- </Modal>);
85
+ </AnimationModal>);
91
86
  });
92
87
  export const alertBottomViewRef = React.createRef();
93
88
  export const showAlertBottomModal = (props) => {
@@ -0,0 +1,245 @@
1
+ import * as React from "react";
2
+ import {
3
+ View,
4
+ Text,
5
+ StyleSheet,
6
+ Platform,
7
+ StatusBar,
8
+ TouchableOpacity,
9
+ Dimensions,
10
+ StyleProp,
11
+ ViewStyle,
12
+ TextStyle,
13
+ } from "react-native";
14
+ import Modal from "react-native-modal";
15
+
16
+ import { px2dp, deviceWidth } from "../../../screen/px2dp";
17
+ import { px2sp } from "../../../screen/px2sp";
18
+
19
+ export type AlertBottomOptions = {
20
+ title: string;
21
+ wrapperStyle: StyleProp<ViewStyle>;
22
+ content: string | React.ReactElement;
23
+ contentContainerStyle: StyleProp<ViewStyle>;
24
+ cancelText: string;
25
+ cancelContainerStyle: StyleProp<ViewStyle>;
26
+ cancelTextStyle: StyleProp<TextStyle>;
27
+ cancel: () => void;
28
+ confirmText: string;
29
+ confirmContainerStyle: StyleProp<ViewStyle>;
30
+ confirmTextStyle: StyleProp<TextStyle>;
31
+ confirm: () => void;
32
+ };
33
+
34
+ type RefAttributes = {
35
+ show: (options: Partial<AlertBottomOptions>) => void;
36
+ hide: () => void;
37
+ };
38
+ type State = {
39
+ visible: boolean;
40
+ } & Omit<AlertBottomOptions, "cancel" | "confirm">;
41
+
42
+ export default React.forwardRef<RefAttributes, {}>((_, ref) => {
43
+ const defaultState: Partial<State> = {
44
+ visible: false,
45
+ cancelText: "取消",
46
+ confirmText: "确定",
47
+ };
48
+ const [state, setState] = React.useState<Partial<State>>(defaultState);
49
+ const cancelCallbackRef = React.useRef<Function>(undefined);
50
+ const confirmCallbackRef = React.useRef<Function>(undefined);
51
+
52
+ React.useImperativeHandle<unknown, RefAttributes>(
53
+ ref,
54
+ () => ({
55
+ show: async (options: Partial<AlertBottomOptions>) => {
56
+ setState(Object.assign({}, defaultState, { visible: true }, options));
57
+ cancelCallbackRef.current = options.cancel;
58
+ confirmCallbackRef.current = options.confirm;
59
+ },
60
+ hide,
61
+ }),
62
+ [],
63
+ );
64
+
65
+ const hide = async () => {
66
+ setState(defaultState);
67
+ };
68
+
69
+ React.useEffect(() => {
70
+ if (Platform.OS == "android") {
71
+ if (state.visible) {
72
+ StatusBar.setBackgroundColor("black");
73
+ StatusBar.setBarStyle("light-content");
74
+ } else {
75
+ StatusBar.setBackgroundColor("transparent");
76
+ StatusBar.setBarStyle("dark-content");
77
+ }
78
+ }
79
+ }, [state.visible]);
80
+ return (
81
+ <Modal
82
+ hideModalContentWhileAnimating={true} //通过隐藏模态内容直到动画完成来增强性能
83
+ useNativeDriver={true} //定义动画是否应使用本机驱动程序
84
+ animationIn="slideInUp"
85
+ animationOut="slideOutDown"
86
+ onBackButtonPress={() => {
87
+ //按下Android后退按钮时调用
88
+ hide();
89
+ }}
90
+ onBackdropPress={() => {
91
+ //按下背景时调用
92
+ hide();
93
+ }}
94
+ isVisible={state.visible}
95
+ style={{ margin: 0 }}
96
+ deviceHeight={Dimensions.get("screen").height}
97
+ >
98
+ <View style={styles.container}>
99
+ <View style={[styles.wrapper, state.wrapperStyle]}>
100
+ {state.title && <Text style={styles.titleText}>{state.title}</Text>}
101
+ <View style={[state.contentContainerStyle]}>
102
+ {(() => {
103
+ if (typeof state.content == "string")
104
+ return <Text style={styles.contentText}>{state.content}</Text>;
105
+ if (React.isValidElement(state.content)) return state.content;
106
+ return <View />;
107
+ })()}
108
+ </View>
109
+ {(state.cancelText || state.confirmText) && (
110
+ <View style={styles.action}>
111
+ {state.cancelText && (
112
+ <TouchableOpacity
113
+ style={[
114
+ styles.cancel,
115
+ { marginRight: state.confirmText ? px2dp(15) : 0 },
116
+ state.cancelContainerStyle,
117
+ ]}
118
+ activeOpacity={0.8}
119
+ onPress={() => {
120
+ hide();
121
+ cancelCallbackRef.current && cancelCallbackRef.current();
122
+ cancelCallbackRef.current = undefined;
123
+ }}
124
+ >
125
+ <Text style={[styles.cancelText, state.cancelTextStyle]}>
126
+ {state.cancelText}
127
+ </Text>
128
+ </TouchableOpacity>
129
+ )}
130
+
131
+ {state.confirmText && (
132
+ <TouchableOpacity
133
+ style={[
134
+ styles.confirm,
135
+ { marginLeft: state.cancelText ? px2dp(15) : 0 },
136
+ state.confirmContainerStyle,
137
+ ]}
138
+ activeOpacity={0.8}
139
+ onPress={() => {
140
+ hide();
141
+ confirmCallbackRef.current && confirmCallbackRef.current();
142
+ confirmCallbackRef.current = undefined;
143
+ }}
144
+ >
145
+ <Text style={[styles.confirmText, state.confirmTextStyle]}>
146
+ {state.confirmText}
147
+ </Text>
148
+ </TouchableOpacity>
149
+ )}
150
+ </View>
151
+ )}
152
+ </View>
153
+ </View>
154
+ </Modal>
155
+ );
156
+ });
157
+
158
+ export const alertBottomViewRef = React.createRef<RefAttributes>();
159
+
160
+ export const showAlertBottomModal = (props: Partial<AlertBottomOptions>) => {
161
+ alertBottomViewRef.current?.show(props);
162
+ };
163
+
164
+ // const sleep = (msec?: number) => {
165
+ // return new Promise(resolve => {
166
+ // setTimeout(resolve, msec || 350);
167
+ // });
168
+ // }
169
+
170
+ const styles = StyleSheet.create({
171
+ container: {
172
+ display: "flex",
173
+ flexGrow: 1,
174
+ justifyContent: "flex-end",
175
+ alignItems: "center",
176
+ },
177
+
178
+ wrapper: {
179
+ flexGrow: 0,
180
+ flexShrink: 0,
181
+ width: "100%",
182
+ backgroundColor: "white",
183
+ overflow: "hidden",
184
+ borderTopLeftRadius: px2dp(10),
185
+ borderTopRightRadius: px2dp(10),
186
+ display: "flex",
187
+ padding: px2dp(15),
188
+ },
189
+ titleText: {
190
+ maxWidth: deviceWidth - px2dp(30),
191
+ fontSize: px2sp(18),
192
+ marginBottom: px2dp(20),
193
+ // backgroundColor: 'red',
194
+ textAlign: "center",
195
+ fontWeight: "bold",
196
+ color: "#1A1A1A",
197
+ },
198
+ contentText: {
199
+ maxWidth: deviceWidth - px2dp(30),
200
+ marginBottom: px2dp(20),
201
+ minHeight: px2dp(40),
202
+ flexGrow: 0,
203
+ flexShrink: 1,
204
+ width: undefined,
205
+ fontSize: px2sp(15),
206
+ // backgroundColor: 'red',
207
+ color: "#1A1A1A",
208
+ textAlign: "center",
209
+ },
210
+ action: {
211
+ display: "flex",
212
+ flexDirection: "row",
213
+ justifyContent: "space-between",
214
+ alignItems: "center",
215
+ // backgroundColor:"red"
216
+ },
217
+ cancel: {
218
+ width: "40%",
219
+ height: px2dp(44),
220
+ display: "flex",
221
+ justifyContent: "center",
222
+ alignItems: "center",
223
+ borderRadius: px2dp(10),
224
+ borderWidth: px2dp(1),
225
+ borderColor: "#A3A9CC",
226
+ },
227
+
228
+ confirm: {
229
+ width: "40%",
230
+ height: px2dp(44),
231
+ display: "flex",
232
+ justifyContent: "center",
233
+ alignItems: "center",
234
+ backgroundColor: "#2763FF",
235
+ borderRadius: px2dp(10),
236
+ },
237
+ cancelText: {
238
+ fontSize: px2sp(15),
239
+ color: "#A3A9CC",
240
+ },
241
+ confirmText: {
242
+ fontSize: px2sp(15),
243
+ color: "white",
244
+ },
245
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"AlertSheetView.d.ts","sourceRoot":"","sources":["../../../../src/components/Hud/AlertSheetView/AlertSheetView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAQL,UAAU,EACX,MAAM,cAAc,CAAC;AAKtB,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,qBAAqB,CAAC,KAAK,IAAI,CAAC;IACxD,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AACF,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;;AAKF,wBAuFG;AAEH,eAAO,MAAM,iBAAiB,uCAAmC,CAAC;AAElE,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,CAAC,qBAAqB,CAAC,SAExE,CAAC"}
1
+ {"version":3,"file":"AlertSheetView.d.ts","sourceRoot":"","sources":["../../../../src/components/Hud/AlertSheetView/AlertSheetView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAQL,UAAU,EACX,MAAM,cAAc,CAAC;AAQtB,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,qBAAqB,CAAC,KAAK,IAAI,CAAC;IACxD,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AACF,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;;AAKF,wBA0EG;AAEH,eAAO,MAAM,iBAAiB,uCAAmC,CAAC;AAElE,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,CAAC,qBAAqB,CAAC,SAExE,CAAC"}
@@ -1,6 +1,6 @@
1
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";
2
+ import { Platform, StatusBar, StyleSheet, Text, TouchableOpacity, View, } from "react-native";
3
+ import { AnimationModal, } from "../../AnimationModal/AnimationModal";
4
4
  import { px2dp } from "../../../screen/px2dp";
5
5
  import { px2sp } from "../../../screen/px2sp";
6
6
  export default React.forwardRef((_, ref) => {
@@ -9,14 +9,17 @@ export default React.forwardRef((_, ref) => {
9
9
  actions: [],
10
10
  };
11
11
  const [state, setState] = React.useState(defaultState);
12
+ const animationModalRef = React.useRef(null);
12
13
  React.useImperativeHandle(ref, () => ({
13
14
  show: async (options) => {
14
15
  setState(Object.assign({}, defaultState, { visible: true }, options));
16
+ animationModalRef.current?.show();
15
17
  },
16
18
  hide,
17
19
  }), []);
18
20
  const hide = async () => {
19
21
  setState(defaultState);
22
+ animationModalRef.current?.hide();
20
23
  };
21
24
  React.useEffect(() => {
22
25
  if (Platform.OS == "android") {
@@ -30,15 +33,7 @@ export default React.forwardRef((_, ref) => {
30
33
  }
31
34
  }
32
35
  }, [state.visible]);
33
- return (<Modal hideModalContentWhileAnimating={true} //通过隐藏模态内容直到动画完成来增强性能
34
- useNativeDriver={true} //定义动画是否应使用本机驱动程序
35
- animationIn="slideInUp" animationOut="slideOutDown" onBackButtonPress={() => {
36
- //按下Android后退按钮时调用
37
- hide();
38
- }} onBackdropPress={() => {
39
- //按下背景时调用
40
- hide();
41
- }} isVisible={state.visible} deviceHeight={Dimensions.get("screen").height} style={{ margin: 0 }}>
36
+ return (<AnimationModal ref={animationModalRef}>
42
37
  <View style={styles.container}>
43
38
  <View style={[styles.wrapper]}>
44
39
  <View style={styles.itemContainer}>
@@ -59,7 +54,7 @@ export default React.forwardRef((_, ref) => {
59
54
  </TouchableOpacity>
60
55
  </View>
61
56
  </View>
62
- </Modal>);
57
+ </AnimationModal>);
63
58
  });
64
59
  export const alertSheetViewRef = React.createRef();
65
60
  export const showAlertSheetModal = (props) => {
@@ -0,0 +1,180 @@
1
+ import * as React from "react";
2
+ import {
3
+ Dimensions,
4
+ Platform,
5
+ StatusBar,
6
+ StyleSheet,
7
+ Text,
8
+ TouchableOpacity,
9
+ View,
10
+ ColorValue,
11
+ } from "react-native";
12
+ import Modal from "react-native-modal";
13
+
14
+ import { px2dp } from "../../../screen/px2dp";
15
+ import { px2sp } from "../../../screen/px2sp";
16
+ type RefAttributes = {
17
+ show: (options: Partial<AlertSheetViewOptions>) => void;
18
+ hide: () => void;
19
+ };
20
+ type ActionSheet = {
21
+ text: string;
22
+ color?: ColorValue | undefined;
23
+ onClick?: () => void;
24
+ };
25
+ export type AlertSheetViewOptions = {
26
+ actions: ActionSheet[];
27
+ };
28
+ type State = {
29
+ visible: boolean;
30
+ } & AlertSheetViewOptions;
31
+
32
+ export default React.forwardRef<RefAttributes, {}>((_, ref) => {
33
+ const defaultState: Partial<State> = {
34
+ visible: false,
35
+ actions: [],
36
+ };
37
+ const [state, setState] = React.useState<Partial<State>>(defaultState);
38
+
39
+ React.useImperativeHandle<unknown, RefAttributes>(
40
+ ref,
41
+ () => ({
42
+ show: async (options: Partial<AlertSheetViewOptions>) => {
43
+ setState(Object.assign({}, defaultState, { visible: true }, options));
44
+ },
45
+ hide,
46
+ }),
47
+ [],
48
+ );
49
+
50
+ const hide = async () => {
51
+ setState(defaultState);
52
+ };
53
+
54
+ React.useEffect(() => {
55
+ if (Platform.OS == "android") {
56
+ if (state.visible) {
57
+ StatusBar.setBackgroundColor("black");
58
+ StatusBar.setBarStyle("light-content");
59
+ } else {
60
+ StatusBar.setBackgroundColor("transparent");
61
+ StatusBar.setBarStyle("dark-content");
62
+ }
63
+ }
64
+ }, [state.visible]);
65
+ return (
66
+ <Modal
67
+ hideModalContentWhileAnimating={true} //通过隐藏模态内容直到动画完成来增强性能
68
+ useNativeDriver={true} //定义动画是否应使用本机驱动程序
69
+ animationIn="slideInUp"
70
+ animationOut="slideOutDown"
71
+ onBackButtonPress={() => {
72
+ //按下Android后退按钮时调用
73
+ hide();
74
+ }}
75
+ onBackdropPress={() => {
76
+ //按下背景时调用
77
+ hide();
78
+ }}
79
+ isVisible={state.visible}
80
+ deviceHeight={Dimensions.get("screen").height}
81
+ style={{ margin: 0 }}
82
+ >
83
+ <View style={styles.container}>
84
+ <View style={[styles.wrapper]}>
85
+ <View style={styles.itemContainer}>
86
+ {state.actions?.map((i, idx) => (
87
+ <TouchableOpacity
88
+ key={`sg-action-${idx}`}
89
+ style={[styles.item]}
90
+ activeOpacity={1}
91
+ onPress={() => {
92
+ hide();
93
+ i.onClick && i.onClick();
94
+ }}
95
+ >
96
+ <Text
97
+ style={[styles.itemText, { color: i.color }]}
98
+ numberOfLines={2}
99
+ >
100
+ {i.text}
101
+ </Text>
102
+ </TouchableOpacity>
103
+ ))}
104
+ </View>
105
+
106
+ <TouchableOpacity
107
+ style={[styles.cancel]}
108
+ activeOpacity={1}
109
+ onPress={() => {
110
+ hide();
111
+ }}
112
+ >
113
+ <Text style={[styles.cancelText]}>取消</Text>
114
+ </TouchableOpacity>
115
+ </View>
116
+ </View>
117
+ </Modal>
118
+ );
119
+ });
120
+
121
+ export const alertSheetViewRef = React.createRef<RefAttributes>();
122
+
123
+ export const showAlertSheetModal = (props: Partial<AlertSheetViewOptions>) => {
124
+ alertSheetViewRef.current?.show(props);
125
+ };
126
+
127
+ const styles = StyleSheet.create({
128
+ container: {
129
+ display: "flex",
130
+ flexGrow: 1,
131
+ justifyContent: "flex-end",
132
+ alignItems: "center",
133
+ },
134
+
135
+ wrapper: {
136
+ flexGrow: 0,
137
+ flexShrink: 0,
138
+ width: "100%",
139
+ // backgroundColor: 'pink',
140
+ overflow: "hidden",
141
+ borderTopLeftRadius: px2dp(10),
142
+ borderTopRightRadius: px2dp(10),
143
+ display: "flex",
144
+ padding: px2dp(15),
145
+ },
146
+
147
+ cancel: {
148
+ height: px2dp(50),
149
+ display: "flex",
150
+ justifyContent: "center",
151
+ alignItems: "center",
152
+ borderRadius: px2dp(10),
153
+ backgroundColor: "white",
154
+ marginTop: px2dp(15),
155
+ },
156
+ cancelText: {
157
+ fontSize: px2sp(15),
158
+ color: "#2763FF",
159
+ },
160
+
161
+ itemContainer: {
162
+ display: "flex",
163
+ borderRadius: px2dp(10),
164
+ overflow: "hidden",
165
+ backgroundColor: "#f1f1f1",
166
+ },
167
+ item: {
168
+ height: px2dp(50),
169
+ display: "flex",
170
+ justifyContent: "center",
171
+ alignItems: "center",
172
+
173
+ backgroundColor: "white",
174
+ marginTop: px2dp(0.75),
175
+ },
176
+ itemText: {
177
+ fontSize: px2sp(12),
178
+ color: "#666666",
179
+ },
180
+ });
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export { Hud, showLoading, hideLoading, showToast, showAlertModal, showAlertBottomModal, showAlertSheetModal, showPopoverView, hidePopoverView, showScanner, hideScanner, } from "./components/Hud/Hud";
2
- export { Modal, ModalProps } from "./components/Modal/Modal";
3
2
  export { default as MutiPictureView } from "./components/MutiPictureView/MutiPictureView";
4
3
  export { PictureViewer } from "./components/PictureViewer/PictureViewer";
5
4
  export { default as RefreshList, RefreshState, RefreshText, } from "./components/RefreshList/RefreshList";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,GAAG,EACH,WAAW,EACX,WAAW,EACX,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EACL,OAAO,IAAI,WAAW,EACtB,YAAY,EACZ,WAAW,GACZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EACL,OAAO,IAAI,oBAAoB,EAC/B,MAAM,GACP,MAAM,wDAAwD,CAAC;AAEhE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,UAAU;AACV,cAAc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jD,UAAU;AACV,cAAc,UAAU,CAAC;AACzB,QAAQ;AACR,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,QAAQ;AACR,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@
9
9
  // export { Badge } from "./components/Badge/Badge";
10
10
  // export type { BadgeProps } from "./components/Badge/Badge";
11
11
  export { Hud, showLoading, hideLoading, showToast, showAlertModal, showAlertBottomModal, showAlertSheetModal, showPopoverView, hidePopoverView, showScanner, hideScanner, } from "./components/Hud/Hud";
12
- export { Modal } from "./components/Modal/Modal";
12
+ // export { Modal, ModalProps } from "./components/Modal/Modal";
13
13
  export { default as MutiPictureView } from "./components/MutiPictureView/MutiPictureView";
14
14
  export { PictureViewer } from "./components/PictureViewer/PictureViewer";
15
15
  export { default as RefreshList, RefreshState, RefreshText, } from "./components/RefreshList/RefreshList";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aks-dev/easyui",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "工具箱",
5
5
  "exports": {
6
6
  ".": {
@@ -55,7 +55,6 @@
55
55
  "dependencies": {
56
56
  "echarts": "^6.0.0",
57
57
  "react-native-image-zoom-viewer": "^3.0.1",
58
- "react-native-modal": "^14.0.0-rc.1",
59
58
  "react-native-smart-refresh": "^1.1.6",
60
59
  "react-native-swipe-list-view": "^3.2.9"
61
60
  },