@aks-dev/easyui 1.0.163 → 1.1.2
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 +151 -0
- package/dist/components/DottedLine/DottedLine.js +50 -0
- package/{lib/Echarts/EchartsView.tsx → dist/components/EchartsView/EchartsView.js} +74 -113
- package/{lib/Echarts/helper.tsx → dist/components/EchartsView/helper.js} +17 -24
- package/dist/components/Hud/AlertBottomView/AlertBottomView.js +174 -0
- package/dist/components/Hud/AlertSheetView/AlertSheetView.js +117 -0
- package/dist/components/Hud/AlertView/AlertView.js +184 -0
- package/dist/components/Hud/Hud.js +29 -0
- package/dist/components/Hud/Loading/Loading.js +66 -0
- package/dist/components/Hud/PopoverView/PopoverView.js +47 -0
- package/dist/components/Hud/Scanner/Scanner.js +301 -0
- package/dist/components/Hud/Toast/Toast.js +71 -0
- package/dist/components/MenuView/MenuView.js +184 -0
- package/{lib/Modal/Modal.tsx → dist/components/Modal/Modal.js} +1 -4
- package/dist/components/MutiPictureView/MutiPictureView.js +239 -0
- package/dist/components/PictureViewer/PictureViewer.js +54 -0
- package/dist/components/RefreshList/RefreshList.js +155 -0
- package/dist/components/RichText/RichText.js +56 -0
- package/dist/components/StickHeaderView/StickHeaderView.js +37 -0
- package/dist/components/TableCell/TableCell.js +97 -0
- package/dist/components/TextInputArea/TextInputArea.js +65 -0
- package/dist/components/WithLoadingContainer/WithLoadingContainer.js +77 -0
- package/dist/index.js +31 -0
- package/dist/jsbridge/RNEasyui.js +46 -0
- package/{jsbridge/UpgradeModule.ts → dist/jsbridge/UpgradeModule.js} +25 -23
- package/{jsbridge/index.ts → dist/jsbridge/index.js} +2 -2
- package/{screen/index.ts → dist/screen/index.js} +2 -2
- package/dist/screen/px2dp.js +45 -0
- package/{screen/px2sp.ts → dist/screen/px2sp.js} +13 -20
- package/{screen/text-fit.ts → dist/screen/text-fit.js} +10 -20
- package/{utils/index.ts → dist/utils/index.js} +2 -2
- package/{utils/lazy.ts → dist/utils/lazy.js} +164 -165
- package/dist/utils/mode.js +50 -0
- package/package.json +31 -19
- package/readme.md +3 -3
- package/types/components/AnimationModal/AnimationModal.d.ts +27 -0
- package/types/components/AnimationModal/AnimationModal.d.ts.map +1 -0
- package/types/components/DottedLine/DottedLine.d.ts +10 -0
- package/types/components/DottedLine/DottedLine.d.ts.map +1 -0
- package/types/components/EchartsView/EchartsView.d.ts +10 -0
- package/types/components/EchartsView/EchartsView.d.ts.map +1 -0
- package/types/components/EchartsView/helper.d.ts +10 -0
- package/types/components/EchartsView/helper.d.ts.map +1 -0
- package/types/components/Hud/AlertBottomView/AlertBottomView.d.ts +25 -0
- package/types/components/Hud/AlertBottomView/AlertBottomView.d.ts.map +1 -0
- package/types/components/Hud/AlertSheetView/AlertSheetView.d.ts +19 -0
- package/types/components/Hud/AlertSheetView/AlertSheetView.d.ts.map +1 -0
- package/types/components/Hud/AlertView/AlertView.d.ts +25 -0
- package/types/components/Hud/AlertView/AlertView.d.ts.map +1 -0
- package/types/components/Hud/Hud.d.ts +11 -0
- package/types/components/Hud/Hud.d.ts.map +1 -0
- package/types/components/Hud/Loading/Loading.d.ts +11 -0
- package/types/components/Hud/Loading/Loading.d.ts.map +1 -0
- package/types/components/Hud/PopoverView/PopoverView.d.ts +17 -0
- package/types/components/Hud/PopoverView/PopoverView.d.ts.map +1 -0
- package/types/components/Hud/Scanner/Scanner.d.ts +12 -0
- package/types/components/Hud/Scanner/Scanner.d.ts.map +1 -0
- package/types/components/Hud/Toast/Toast.d.ts +9 -0
- package/types/components/Hud/Toast/Toast.d.ts.map +1 -0
- package/types/components/MenuView/MenuView.d.ts +21 -0
- package/types/components/MenuView/MenuView.d.ts.map +1 -0
- package/types/components/Modal/Modal.d.ts +2 -0
- package/types/components/Modal/Modal.d.ts.map +1 -0
- package/{lib/MutiPictureView/index.ts → types/components/MutiPictureView/MutiPictureView.d.ts} +18 -31
- package/types/components/MutiPictureView/MutiPictureView.d.ts.map +1 -0
- package/types/components/PictureViewer/PictureViewer.d.ts +17 -0
- package/types/components/PictureViewer/PictureViewer.d.ts.map +1 -0
- package/types/components/RefreshList/RefreshList.d.ts +45 -0
- package/types/components/RefreshList/RefreshList.d.ts.map +1 -0
- package/types/components/RichText/RichText.d.ts +12 -0
- package/types/components/RichText/RichText.d.ts.map +1 -0
- package/types/components/StickHeaderView/StickHeaderView.d.ts +15 -0
- package/types/components/StickHeaderView/StickHeaderView.d.ts.map +1 -0
- package/{lib/TableCell/index.ts → types/components/TableCell/TableCell.d.ts} +8 -30
- package/types/components/TableCell/TableCell.d.ts.map +1 -0
- package/types/components/TextInputArea/TextInputArea.d.ts +17 -0
- package/types/components/TextInputArea/TextInputArea.d.ts.map +1 -0
- package/types/components/WithLoadingContainer/WithLoadingContainer.d.ts +23 -0
- package/types/components/WithLoadingContainer/WithLoadingContainer.d.ts.map +1 -0
- package/types/index.d.ts +22 -0
- package/types/index.d.ts.map +1 -0
- package/types/jsbridge/RNEasyui.d.ts +23 -0
- package/types/jsbridge/RNEasyui.d.ts.map +1 -0
- package/types/jsbridge/UpgradeModule.d.ts +26 -0
- package/types/jsbridge/UpgradeModule.d.ts.map +1 -0
- package/types/jsbridge/index.d.ts +3 -0
- package/types/jsbridge/index.d.ts.map +1 -0
- package/types/screen/index.d.ts +3 -0
- package/types/screen/index.d.ts.map +1 -0
- package/{screen/index.d.ts → types/screen/px2dp.d.ts} +6 -12
- package/types/screen/px2dp.d.ts.map +1 -0
- package/types/screen/px2sp.d.ts +2 -0
- package/types/screen/px2sp.d.ts.map +1 -0
- package/types/screen/text-fit.d.ts +5 -0
- package/types/screen/text-fit.d.ts.map +1 -0
- package/types/utils/index.d.ts +3 -0
- package/types/utils/index.d.ts.map +1 -0
- package/{utils/index.d.ts → types/utils/lazy.d.ts} +15 -53
- package/types/utils/lazy.d.ts.map +1 -0
- package/types/utils/mode.d.ts +24 -0
- package/types/utils/mode.d.ts.map +1 -0
- package/android/.DS_Store +0 -0
- package/android/src/.DS_Store +0 -0
- package/android/src/main/.DS_Store +0 -0
- package/android/src/main/java/.DS_Store +0 -0
- package/android/src/main/java/com/.DS_Store +0 -0
- package/android/src/main/java/com/easyui/.DS_Store +0 -0
- package/i.sh +0 -23
- package/ios/.DS_Store +0 -0
- package/ios/assets/.DS_Store +0 -0
- package/ios/views/.DS_Store +0 -0
- package/jsbridge/RNEasyui.ts +0 -42
- package/jsbridge/index.d.ts +0 -67
- package/lib/.DS_Store +0 -0
- package/lib/AnimationModal/AnimationModal.tsx +0 -201
- package/lib/AnimationModal/index.d.ts +0 -41
- package/lib/Badge/Badge.tsx +0 -40
- package/lib/Badge/index.ts +0 -21
- package/lib/DottedLine/DottedLine.tsx +0 -66
- package/lib/DottedLine/index.ts +0 -18
- package/lib/Echarts/demo.tsx +0 -235
- package/lib/Echarts/index.ts +0 -29
- package/lib/Hud/.DS_Store +0 -0
- package/lib/Hud/AlertBottomView/AlertBottomView.tsx +0 -228
- package/lib/Hud/AlertBottomView/index.d.ts +0 -42
- package/lib/Hud/AlertSheetView/AlertSheetView.tsx +0 -179
- package/lib/Hud/AlertSheetView/index.d.ts +0 -35
- package/lib/Hud/AlertView/AlertView.tsx +0 -234
- package/lib/Hud/AlertView/index.d.ts +0 -46
- package/lib/Hud/Hud.tsx +0 -67
- package/lib/Hud/Loading/Loading.tsx +0 -87
- package/lib/Hud/Loading/index.d.ts +0 -38
- package/lib/Hud/PopoverView/PopoverView.tsx +0 -66
- package/lib/Hud/PopoverView/index.d.ts +0 -39
- package/lib/Hud/Scanner/Scanner.tsx +0 -250
- package/lib/Hud/Scanner/index.d.ts +0 -42
- package/lib/Hud/Toast/Toast.tsx +0 -86
- package/lib/Hud/Toast/index.d.ts +0 -22
- package/lib/Hud/index.ts +0 -20
- package/lib/MenuView/MenuView.tsx +0 -252
- package/lib/MenuView/index.ts +0 -31
- package/lib/Modal/index.ts +0 -10
- package/lib/MutiPictureView/MutiPictureView.tsx +0 -259
- package/lib/PictureViewer/PictureViewer.tsx +0 -80
- package/lib/PictureViewer/index.ts +0 -26
- package/lib/RefreshList/RefreshList.tsx +0 -235
- package/lib/RefreshList/demo.tsx +0 -30
- package/lib/RefreshList/demo1.tsx +0 -60
- package/lib/RefreshList/demo2.tsx +0 -46
- package/lib/RefreshList/index.ts +0 -84
- package/lib/RichText/RichText.tsx +0 -82
- package/lib/RichText/index.ts +0 -21
- package/lib/StickHeaderView/StickHeaderView.tsx +0 -65
- package/lib/StickHeaderView/demo.tsx +0 -104
- package/lib/StickHeaderView/index.ts +0 -26
- package/lib/TableCell/TableCell.tsx +0 -118
- package/lib/TextInputArea/TextInputArea.tsx +0 -89
- package/lib/TextInputArea/index.d.ts +0 -33
- package/lib/WithLoadingContainer/WithLoadingContainer.tsx +0 -93
- package/lib/WithLoadingContainer/index.ts +0 -36
- package/screen/px2dp.ts +0 -51
- package/src/index.d.ts +0 -42
- package/src/index.ts +0 -54
- package/utils/mode.ts +0 -48
- /package/{lib/Hud/Scanner → dist/components/Hud/Scanner/assets}/flashlight-blue.png +0 -0
- /package/{lib/Hud/Scanner → dist/components/Hud/Scanner/assets}/flashlight-white.png +0 -0
- /package/{lib/Hud/Scanner → dist/components/Hud/Scanner/assets}/icon_back_white.png +0 -0
- /package/{lib/MutiPictureView → dist/components/MutiPictureView/assets}/icon_add_image.png +0 -0
- /package/{lib/MutiPictureView → dist/components/MutiPictureView/assets}/icon_del_image.png +0 -0
- /package/{lib/TableCell → dist/components/TableCell/assets}/back.png +0 -0
- /package/{lib/WithLoadingContainer → dist/components/WithLoadingContainer/assets}/loading.gif +0 -0
- /package/{lib/WithLoadingContainer → dist/components/WithLoadingContainer/assets}/loading3.gif +0 -0
- /package/{lib → dist/components}/index.md +0 -0
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Image, LayoutRectangle, MeasureOnSuccessCallback, ScrollView, StatusBar, Text, TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import type { MenuProps } from '.';
|
|
4
|
-
import { deviceHeight, deviceWidth } from '../../screen/px2dp';
|
|
5
|
-
// import * as utils from '../../utils/lazy';
|
|
6
|
-
import { hidePopoverView, showPopoverView } from '../Hud/Hud';
|
|
7
|
-
|
|
8
|
-
type State = {
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type Reducer = (prevState: State, action: Partial<State>) => State
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export default (props: MenuProps) => {
|
|
17
|
-
|
|
18
|
-
const {
|
|
19
|
-
defaultAlignHorizontal = 'left',
|
|
20
|
-
defaultAlignVertical = 'bottom'
|
|
21
|
-
} = props
|
|
22
|
-
|
|
23
|
-
const [state, dispatch] = React.useReducer<Reducer>((prevState, action) => Object.assign({}, prevState, action), {})
|
|
24
|
-
|
|
25
|
-
// const containerRef = React.useRef<{ measureInWindow: (callback: MeasureInWindowOnSuccessCallback) => void }>()
|
|
26
|
-
const containerRef = React.useRef<{ measure: (callback: MeasureOnSuccessCallback) => void }>()
|
|
27
|
-
const rootView = React.useRef<{
|
|
28
|
-
pageX: number;
|
|
29
|
-
pageY: number;
|
|
30
|
-
height: number;
|
|
31
|
-
width: number;
|
|
32
|
-
}>({ pageX: 0, pageY: 0, width: 0, height: 0 })
|
|
33
|
-
const sc = React.useRef<LayoutRectangle>({ x: 0, y: 0, width: 0, height: 0 })
|
|
34
|
-
|
|
35
|
-
// React.useEffect(() => {
|
|
36
|
-
// ; (async () => {
|
|
37
|
-
// await utils.sleep()
|
|
38
|
-
// containerRef.current?.measure((...args) => {
|
|
39
|
-
// console.log('containerRef', args)
|
|
40
|
-
// if (args.length == 6) {
|
|
41
|
-
// _container.current = {
|
|
42
|
-
// x: args[4],
|
|
43
|
-
// y: args[5],
|
|
44
|
-
// width: args[2],
|
|
45
|
-
// height: args[3],
|
|
46
|
-
// }
|
|
47
|
-
// }
|
|
48
|
-
// })
|
|
49
|
-
// })()
|
|
50
|
-
// })
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const getRootViewlayoutPromise = () => {
|
|
54
|
-
return new Promise((resovle, reject) => {
|
|
55
|
-
containerRef.current?.measure((...args) => {
|
|
56
|
-
if (args.length == 6) {
|
|
57
|
-
rootView.current = {
|
|
58
|
-
width: args[2],
|
|
59
|
-
height: args[3],
|
|
60
|
-
pageX: args[4],
|
|
61
|
-
pageY: args[5],
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// console.log('RootView', rootView.current)
|
|
65
|
-
resovle(args)
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const getLayoutInfos: () => {
|
|
72
|
-
alignVertical: 'bottom' | 'top';
|
|
73
|
-
alignHorizontal: 'left' | 'right';
|
|
74
|
-
width: number;
|
|
75
|
-
height: number;
|
|
76
|
-
x: number;
|
|
77
|
-
y: number;
|
|
78
|
-
target_width: number;
|
|
79
|
-
target_height: number;
|
|
80
|
-
}
|
|
81
|
-
= () => {
|
|
82
|
-
let alignVertical: 'bottom' | 'top' = defaultAlignVertical
|
|
83
|
-
let alignHorizontal: 'left' | 'right' = defaultAlignHorizontal
|
|
84
|
-
let width = rootView.current.width
|
|
85
|
-
let height = rootView.current.height
|
|
86
|
-
let x = rootView.current.pageX
|
|
87
|
-
// let y = (StatusBar.currentHeight || 0) + _container.current.y + height
|
|
88
|
-
let y = rootView.current.pageY + height
|
|
89
|
-
if (x > Math.abs(deviceWidth - width - x)) {
|
|
90
|
-
alignHorizontal = 'right'
|
|
91
|
-
}
|
|
92
|
-
if (y > deviceHeight * .5) {
|
|
93
|
-
alignVertical = 'top'
|
|
94
|
-
}
|
|
95
|
-
/**todo: target_width的获取是延迟的,所以这里又问题 */
|
|
96
|
-
const target_width = sc.current.width
|
|
97
|
-
const target_height = CELL_HEIGHT * (Math.min(props.data?.length || 0, 5) || 0)
|
|
98
|
-
return {
|
|
99
|
-
alignVertical,
|
|
100
|
-
alignHorizontal,
|
|
101
|
-
width,
|
|
102
|
-
height,
|
|
103
|
-
x,
|
|
104
|
-
y,
|
|
105
|
-
target_width,
|
|
106
|
-
target_height,
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const reLayout = (): Partial<{
|
|
112
|
-
left: number;
|
|
113
|
-
right: number;
|
|
114
|
-
top: number;
|
|
115
|
-
botttom: number;
|
|
116
|
-
}> => {
|
|
117
|
-
let {
|
|
118
|
-
alignVertical,
|
|
119
|
-
alignHorizontal,
|
|
120
|
-
width,
|
|
121
|
-
height,
|
|
122
|
-
x,
|
|
123
|
-
y,
|
|
124
|
-
target_width,
|
|
125
|
-
target_height,
|
|
126
|
-
} = getLayoutInfos()
|
|
127
|
-
|
|
128
|
-
// console.log({ getLayoutInfos: getLayoutInfos() })
|
|
129
|
-
const layout = () => {
|
|
130
|
-
if (alignHorizontal == 'left') {
|
|
131
|
-
if (target_width + x > deviceWidth) {
|
|
132
|
-
return {
|
|
133
|
-
left: Math.abs(deviceWidth - target_width) * .7,
|
|
134
|
-
top: y,
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
left: Math.max(x, 15),
|
|
139
|
-
top: y,
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
142
|
-
let _x = deviceWidth - x - width
|
|
143
|
-
if (target_width + _x > deviceWidth) {
|
|
144
|
-
return {
|
|
145
|
-
right: Math.abs(deviceWidth - target_width) * .7,
|
|
146
|
-
top: y
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
right: Math.max(_x, 15),
|
|
151
|
-
top: y
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (alignVertical == 'bottom') {
|
|
156
|
-
y = y + PADDING
|
|
157
|
-
return layout()
|
|
158
|
-
} else {
|
|
159
|
-
y = rootView.current.pageY - target_height - PADDING * 2 - ARROW_HEIGHT
|
|
160
|
-
return layout()
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const PADDING = 10
|
|
166
|
-
const ARROW_HEIGHT = 12
|
|
167
|
-
const CELL_HEIGHT = 36
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const show = async () => {
|
|
171
|
-
props.onContainerClick && props.onContainerClick()
|
|
172
|
-
if (props.data == undefined || props.data?.length == 0) return
|
|
173
|
-
/**重新获取rootview的定位 */
|
|
174
|
-
await getRootViewlayoutPromise()
|
|
175
|
-
/**重新获取rootview的定位 */
|
|
176
|
-
showPopoverView({
|
|
177
|
-
content: (
|
|
178
|
-
<TouchableOpacity
|
|
179
|
-
activeOpacity={1}
|
|
180
|
-
style={{
|
|
181
|
-
|
|
182
|
-
position: 'absolute',
|
|
183
|
-
minWidth: deviceWidth * 0.36,
|
|
184
|
-
maxWidth: deviceWidth * 0.8,
|
|
185
|
-
minHeight: CELL_HEIGHT + PADDING * 2,
|
|
186
|
-
maxHeight: CELL_HEIGHT * 5 + PADDING * 2,
|
|
187
|
-
borderRadius: 6, backgroundColor: '#000000ee',
|
|
188
|
-
// overflow: 'hidden' ,
|
|
189
|
-
padding: PADDING,
|
|
190
|
-
...reLayout()
|
|
191
|
-
}}
|
|
192
|
-
>
|
|
193
|
-
|
|
194
|
-
<View style={{
|
|
195
|
-
width: ARROW_HEIGHT, height: ARROW_HEIGHT,
|
|
196
|
-
backgroundColor: '#000000ee', position: 'absolute', zIndex: 1,
|
|
197
|
-
transform: [{ rotateZ: '45deg' }],
|
|
198
|
-
...(() => {
|
|
199
|
-
const {
|
|
200
|
-
alignVertical,
|
|
201
|
-
alignHorizontal,
|
|
202
|
-
} = getLayoutInfos()
|
|
203
|
-
if (alignVertical == 'bottom' && alignHorizontal == 'left') return { left: '20%', top: -5 }
|
|
204
|
-
if (alignVertical == 'bottom' && alignHorizontal == 'right') return { right: '20%', top: -5 }
|
|
205
|
-
if (alignVertical == 'top' && alignHorizontal == 'left') return { left: '20%', bottom: -5 }
|
|
206
|
-
if (alignVertical == 'top' && alignHorizontal == 'right') return { right: '20%', bottom: -5 }
|
|
207
|
-
return {}
|
|
208
|
-
})()
|
|
209
|
-
}} />
|
|
210
|
-
|
|
211
|
-
<ScrollView onLayout={e => {
|
|
212
|
-
// console.log('target onLayout', e.nativeEvent.layout)
|
|
213
|
-
let _sc: LayoutRectangle = e.nativeEvent.layout
|
|
214
|
-
sc.current = _sc
|
|
215
|
-
}}
|
|
216
|
-
// style={{ backgroundColor: "red" }}
|
|
217
|
-
>
|
|
218
|
-
{props.data?.map((i, idx) => {
|
|
219
|
-
return (
|
|
220
|
-
<TouchableOpacity
|
|
221
|
-
activeOpacity={.7}
|
|
222
|
-
key={`sg-memnu-${idx}`}
|
|
223
|
-
style={{
|
|
224
|
-
height: CELL_HEIGHT, display: 'flex', flexDirection: 'row', alignItems: 'center'
|
|
225
|
-
// ,backgroundColor:utils.randomcolor()
|
|
226
|
-
}}
|
|
227
|
-
onPress={e => {
|
|
228
|
-
props.onItemClick && props.onItemClick(idx, i.extra)
|
|
229
|
-
hidePopoverView()
|
|
230
|
-
}}
|
|
231
|
-
>
|
|
232
|
-
{i.icon &&
|
|
233
|
-
<Image style={{ width: 18, height: 18, marginRight: 4 }} source={i.icon} />
|
|
234
|
-
}
|
|
235
|
-
<Text style={{ flexShrink: 1, fontSize: 14, color: 'white' }}>{i.text}</Text>
|
|
236
|
-
</TouchableOpacity>
|
|
237
|
-
)
|
|
238
|
-
})}
|
|
239
|
-
</ScrollView>
|
|
240
|
-
</TouchableOpacity>
|
|
241
|
-
)
|
|
242
|
-
})
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return (
|
|
246
|
-
<TouchableOpacity
|
|
247
|
-
ref={containerRef as any}
|
|
248
|
-
onPress={e => show()}
|
|
249
|
-
{...props}
|
|
250
|
-
/>
|
|
251
|
-
)
|
|
252
|
-
}
|
package/lib/MenuView/index.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: shiguo
|
|
3
|
-
* @Date: 2022-07-14 18:09:02
|
|
4
|
-
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2023-01-03 17:30:04
|
|
6
|
-
* @FilePath: /@aks-dev/easyui/lib/MenuView/index.ts
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import React from "react";
|
|
10
|
-
import { ImageSourcePropType, StyleProp, ViewStyle, TouchableOpacityProps } from 'react-native';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export type MenuItem = {
|
|
15
|
-
text: string;
|
|
16
|
-
icon?: ImageSourcePropType;
|
|
17
|
-
extra?: any
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type MenuProps = {
|
|
21
|
-
defaultAlignVertical?: 'bottom' | 'top';
|
|
22
|
-
defaultAlignHorizontal?: 'left' | 'right';
|
|
23
|
-
style?: StyleProp<ViewStyle> | undefined;
|
|
24
|
-
data?: MenuItem[];
|
|
25
|
-
onItemClick?: (index: number, extra?: any) => void;
|
|
26
|
-
onContainerClick?:Function;
|
|
27
|
-
activeOpacity?:number;
|
|
28
|
-
} & Readonly<{ children?: React.ReactNode | undefined }> & TouchableOpacityProps
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export declare const MenuView: React.FC<MenuProps>;
|
package/lib/Modal/index.ts
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: OBKoro1
|
|
3
|
-
* @Date: 2022-04-24 17:38:27
|
|
4
|
-
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-11-14 11:33:33
|
|
6
|
-
* @FilePath: /@aks-dev/easyui/lib/MutiPictureView/MutiPictureView.tsx
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import * as React from 'react'
|
|
10
|
-
import { Image, View, StyleSheet, Keyboard, ImageSourcePropType, TouchableOpacity, MeasureOnSuccessCallback, Text } from 'react-native'
|
|
11
|
-
import { px2dp } from '../../screen/px2dp'
|
|
12
|
-
import { px2sp } from '../../screen/px2sp'
|
|
13
|
-
|
|
14
|
-
import SYImagePicker from "@aks-dev/react-native-syan-image-picker";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import type { MutiPictureViewProps } from '.'
|
|
18
|
-
|
|
19
|
-
let icon_add_image = require('./icon_add_image.png')
|
|
20
|
-
let icon_del_image = require('./icon_del_image.png')
|
|
21
|
-
|
|
22
|
-
const MutiPictureView: React.FC<MutiPictureViewProps> = (props) => {
|
|
23
|
-
const {
|
|
24
|
-
bind,
|
|
25
|
-
maxCount = 6,
|
|
26
|
-
type = 'showImagePicker',
|
|
27
|
-
addIcon,
|
|
28
|
-
addIconStyle,
|
|
29
|
-
addIconContainerStyle,//borderWidth: 1, borderStyle: 'dashed', borderColor: assets.color_A3A9CC 虚线框
|
|
30
|
-
itemContainerStyle,
|
|
31
|
-
emptyPlaceHolderStyle,
|
|
32
|
-
delIcon,
|
|
33
|
-
delIconStyle,
|
|
34
|
-
spacingHorizontal = px2dp(15),
|
|
35
|
-
spacingInner = px2dp(8),
|
|
36
|
-
editable = true,
|
|
37
|
-
showEmptyPlaceHolder = false
|
|
38
|
-
} = props
|
|
39
|
-
const { viewModel, setViewModel } = bind
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, [])
|
|
44
|
-
|
|
45
|
-
const [sideLength, setSideLength] = React.useState<number>(0)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const addPhoto = () => {
|
|
50
|
-
let images: any[] = viewModel.photos || []
|
|
51
|
-
if (!images) {
|
|
52
|
-
throw new Error("viewModel没有定义photos字段")
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (type == 'showImagePicker') {
|
|
56
|
-
SYImagePicker.showImagePicker({ imageCount: maxCount - (viewModel.photos?.length || 0), isCrop: false, isRecordSelected: false, quality: 20 }, (err, photos) => {
|
|
57
|
-
if (!err) {
|
|
58
|
-
let imgs = photos.map((it) => { return { uri: it.uri } })
|
|
59
|
-
images = images.concat(imgs)
|
|
60
|
-
setViewModel({ photos: images })
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (type == 'openCamera') {
|
|
66
|
-
SYImagePicker.openCamera({ imageCount: maxCount - (viewModel.photos?.length || 0), isCrop: false, isRecordSelected: false, quality: 20 }, (err, photos) => {
|
|
67
|
-
if (!err) {
|
|
68
|
-
let imgs = photos.map((it) => { return { uri: it.uri } })
|
|
69
|
-
images = images.concat(imgs)
|
|
70
|
-
setViewModel({ photos: images })
|
|
71
|
-
} else {
|
|
72
|
-
console.log('打开相机失败')
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const deletePhoto = (index: number) => {
|
|
82
|
-
Keyboard.dismiss()
|
|
83
|
-
let photos = [...viewModel.photos || []]
|
|
84
|
-
photos.splice(index, 1)
|
|
85
|
-
setViewModel({ photos: photos })
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const showPhoto = (index: number) => {
|
|
89
|
-
Keyboard.dismiss()
|
|
90
|
-
let imgs: any[] = (props.value || viewModel.photos)?.filter((it) => { return (typeof it === 'string' && it.indexOf('http') >= 0) || typeof it == 'object' }) || []
|
|
91
|
-
let images: any[] = []
|
|
92
|
-
// console.log('viewModel', viewModel, imgs)
|
|
93
|
-
imgs.forEach(it => {
|
|
94
|
-
if (typeof it === 'string') {
|
|
95
|
-
images.push({ uri: it })
|
|
96
|
-
} else {
|
|
97
|
-
images.push(it)
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
setViewModel({
|
|
101
|
-
imageViewer: {
|
|
102
|
-
imageUrls: images.map((it) => {
|
|
103
|
-
return it.uri
|
|
104
|
-
}),
|
|
105
|
-
index: index,
|
|
106
|
-
visible: true,
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const ItemView: React.FC<{ source: ImageSourcePropType, index: number }> = ({ source, index }) => {
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<TouchableOpacity style={[styles.item_container, itemContainerStyle, {
|
|
120
|
-
marginTop: index < 3 ? 0 : spacingInner,
|
|
121
|
-
marginLeft: index % 3 == 0 ? spacingHorizontal : spacingInner,
|
|
122
|
-
width: sideLength,
|
|
123
|
-
height: sideLength,
|
|
124
|
-
}]} activeOpacity={0.8} onPress={() => showPhoto(index)}>
|
|
125
|
-
<Image source={source} style={{ width: '100%', height: '100%' }} resizeMode='cover' />
|
|
126
|
-
{
|
|
127
|
-
editable && !props.value &&
|
|
128
|
-
<TouchableOpacity onPress={() => deletePhoto(index)} style={[styles.del_img_container, delIconStyle]}>
|
|
129
|
-
<Image source={delIcon ? delIcon : icon_del_image} resizeMode='contain' style={{ width: '100%', height: '100%' }} />
|
|
130
|
-
</TouchableOpacity>
|
|
131
|
-
}
|
|
132
|
-
</TouchableOpacity>
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const containerRef = React.useRef<{ measure: (callback: MeasureOnSuccessCallback) => void }>()
|
|
141
|
-
|
|
142
|
-
React.useEffect(() => {
|
|
143
|
-
containerRef.current?.measure((...args) => {
|
|
144
|
-
// console.log('measure', args[2])
|
|
145
|
-
if (args.length > 3) {
|
|
146
|
-
let _sideLength = +((args[2] - spacingHorizontal * 2 - spacingInner * 2) / 3).toFixed(1);
|
|
147
|
-
setSideLength(_sideLength - 0.1)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
})
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (props.value && props.value?.length > 0) {
|
|
156
|
-
return (
|
|
157
|
-
<View style={[styles.container, props.style]} ref={containerRef as any}>
|
|
158
|
-
{props.value instanceof Array && props.value?.map((item, index) => {
|
|
159
|
-
return <ItemView key={index} source={typeof item === 'string' ? { uri: item } : item} index={index} />
|
|
160
|
-
})}
|
|
161
|
-
|
|
162
|
-
{
|
|
163
|
-
showEmptyPlaceHolder && maxCount - (props.value?.length || 0) - 1 > 0 &&
|
|
164
|
-
Array.from({ length: maxCount - (props.value?.length || 0) - (editable ? 1 : 0) }, (_, k) =>
|
|
165
|
-
<View key={`sg-showEmptyPlaceHolder-${k}`} style={[styles.empty_place_container, emptyPlaceHolderStyle, itemContainerStyle, {
|
|
166
|
-
marginTop: k + (editable ? 1 : 0) + (props.value?.length || 0) > 2 ? spacingInner : 0,
|
|
167
|
-
marginLeft: (k + (editable ? 1 : 0) + (props.value?.length || 0)) % 3 == 0 ? spacingHorizontal : spacingInner,
|
|
168
|
-
width: sideLength,
|
|
169
|
-
height: sideLength,
|
|
170
|
-
}]} />
|
|
171
|
-
)
|
|
172
|
-
}
|
|
173
|
-
</View >
|
|
174
|
-
)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<View style={[styles.container, props.style]} ref={containerRef as any}>
|
|
179
|
-
{viewModel?.photos instanceof Array && viewModel.photos.map((item, index) => {
|
|
180
|
-
return <ItemView key={index} source={typeof item === 'string' ? { uri: item } : item} index={index} />
|
|
181
|
-
})}
|
|
182
|
-
|
|
183
|
-
{
|
|
184
|
-
!(viewModel?.photos?.length == maxCount) && editable && (
|
|
185
|
-
<TouchableOpacity style={[styles.item_container, itemContainerStyle, {
|
|
186
|
-
marginTop: (viewModel?.photos?.length || 0) >= 3 ? spacingInner : 0,
|
|
187
|
-
marginLeft: (viewModel?.photos?.length || 0) % 3 == 0 ? spacingHorizontal : spacingInner,
|
|
188
|
-
width: sideLength,
|
|
189
|
-
height: sideLength,
|
|
190
|
-
}, addIconContainerStyle]} activeOpacity={0.8} onPress={() => addPhoto()}>
|
|
191
|
-
<Image source={addIcon ? addIcon : icon_add_image} style={[{ width: '25%', height: '25%' }, addIconStyle]} resizeMode='contain' />
|
|
192
|
-
{props.addText && <Text style={[{ fontSize: px2sp(12), color: 'lightgrey', marginTop: px2dp(2) }, props.addTextStyle]}>{props.addText}</Text>}
|
|
193
|
-
</TouchableOpacity>
|
|
194
|
-
|
|
195
|
-
)
|
|
196
|
-
}
|
|
197
|
-
{
|
|
198
|
-
showEmptyPlaceHolder && maxCount - (viewModel.photos?.length || 0) - 1 > 0 &&
|
|
199
|
-
Array.from({ length: maxCount - (viewModel.photos?.length || 0) - (editable ? 1 : 0) }, (_, k) =>
|
|
200
|
-
<View key={`sg-showEmptyPlaceHolder-${k}`} style={[styles.empty_place_container, emptyPlaceHolderStyle, itemContainerStyle, {
|
|
201
|
-
marginTop: k + (editable ? 1 : 0) + (viewModel.photos?.length || 0) > 2 ? spacingInner : 0,
|
|
202
|
-
marginLeft: (k + (editable ? 1 : 0) + (viewModel.photos?.length || 0)) % 3 == 0 ? spacingHorizontal : spacingInner,
|
|
203
|
-
width: sideLength,
|
|
204
|
-
height: sideLength,
|
|
205
|
-
}]} />
|
|
206
|
-
)
|
|
207
|
-
}
|
|
208
|
-
</View >
|
|
209
|
-
|
|
210
|
-
)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const styles = StyleSheet.create({
|
|
221
|
-
container: {
|
|
222
|
-
flex: 1,
|
|
223
|
-
minHeight: 1,
|
|
224
|
-
backgroundColor: 'transparent',
|
|
225
|
-
display: 'flex',
|
|
226
|
-
flexDirection: 'row',
|
|
227
|
-
flexWrap: 'wrap',
|
|
228
|
-
// borderRadius: px2dp(10),
|
|
229
|
-
},
|
|
230
|
-
item_container: {
|
|
231
|
-
overflow: 'hidden',
|
|
232
|
-
borderRadius: px2dp(10),
|
|
233
|
-
display: 'flex',
|
|
234
|
-
position: 'relative',
|
|
235
|
-
justifyContent: 'center',
|
|
236
|
-
alignItems: 'center',
|
|
237
|
-
backgroundColor: '#ededed',
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
del_img_container: {
|
|
241
|
-
position: 'absolute',
|
|
242
|
-
right: 2,
|
|
243
|
-
top: 2,
|
|
244
|
-
width: px2dp(24),
|
|
245
|
-
height: px2dp(24)
|
|
246
|
-
},
|
|
247
|
-
empty_place_container: {
|
|
248
|
-
borderRadius: px2dp(10),
|
|
249
|
-
backgroundColor: '#ededed',
|
|
250
|
-
borderColor: '#cccccc',
|
|
251
|
-
borderWidth: .75,
|
|
252
|
-
}
|
|
253
|
-
})
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
export default React.memo(MutiPictureView, (prevProps, nextProps) => false);
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: shiguo
|
|
3
|
-
* @Date: 2022-04-24 15:58:39
|
|
4
|
-
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-04-26 12:38:13
|
|
6
|
-
* @FilePath: /@aks/easy/lib/PictureViewer/PictureViewer.tsx
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import * as React from 'react'
|
|
10
|
-
import { Modal, StatusBar, Platform } from 'react-native'
|
|
11
|
-
import ImageViewer from "react-native-image-zoom-viewer";
|
|
12
|
-
|
|
13
|
-
import type { BindProps } from './index'
|
|
14
|
-
|
|
15
|
-
export const PictureViewer: React.FC<{ bind: BindProps }> = ({ bind }) => {
|
|
16
|
-
|
|
17
|
-
const { viewModel, setViewModel } = bind
|
|
18
|
-
const visible = viewModel.imageViewer.visible
|
|
19
|
-
const imgs = viewModel.imageViewer.imageUrls?.map(item => ({ url: item }))
|
|
20
|
-
const index = viewModel.imageViewer.index
|
|
21
|
-
|
|
22
|
-
React.useEffect(() => {
|
|
23
|
-
if (Platform.OS == 'android') {
|
|
24
|
-
if (visible) {
|
|
25
|
-
StatusBar.setBackgroundColor('black')
|
|
26
|
-
StatusBar.setBarStyle('light-content')
|
|
27
|
-
} else {
|
|
28
|
-
StatusBar.setBackgroundColor('transparent')
|
|
29
|
-
StatusBar.setBarStyle('dark-content')
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}, [visible])
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<Modal
|
|
38
|
-
presentationStyle='overFullScreen'
|
|
39
|
-
visible={visible}
|
|
40
|
-
transparent={false}
|
|
41
|
-
onRequestClose={() => {
|
|
42
|
-
/**
|
|
43
|
-
* 【官方文档】
|
|
44
|
-
* onRequestClose回调会在用户按下 Android 设备上的后退按键或是 Apple TV 上的菜单键时触发。
|
|
45
|
-
* 请务必注意本属性在 Android 平台上为必填,且会在 modal 处于开启状态时阻止BackHandler事件。
|
|
46
|
-
*/
|
|
47
|
-
setViewModel({
|
|
48
|
-
imageViewer: {
|
|
49
|
-
...viewModel.imageViewer,
|
|
50
|
-
visible: false
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
}}
|
|
54
|
-
style={{ margin: 0, backgroundColor: 'red' }}
|
|
55
|
-
>
|
|
56
|
-
<ImageViewer
|
|
57
|
-
imageUrls={imgs}
|
|
58
|
-
index={index}
|
|
59
|
-
onSwipeDown={() => {
|
|
60
|
-
// console.log('onSwipeDown');
|
|
61
|
-
}}
|
|
62
|
-
saveToLocalByLongPress={false}
|
|
63
|
-
// onMove={data => console.log(data)}
|
|
64
|
-
useNativeDriver={true}
|
|
65
|
-
enableSwipeDown={true}
|
|
66
|
-
onClick={() => {
|
|
67
|
-
setViewModel({
|
|
68
|
-
imageViewer: {
|
|
69
|
-
...viewModel.imageViewer,
|
|
70
|
-
visible: false
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
}}
|
|
74
|
-
/>
|
|
75
|
-
</Modal>
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: shiguo
|
|
3
|
-
* @Date: 2022-04-24 17:10:21
|
|
4
|
-
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-04-26 11:35:20
|
|
6
|
-
* @FilePath: /@aks/easy/lib/PictureViewer/index.ts
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type ViewModelProps = {
|
|
11
|
-
imageViewer: {
|
|
12
|
-
imageUrls: any[],
|
|
13
|
-
index: number,
|
|
14
|
-
visible: boolean
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export type BindProps = {
|
|
20
|
-
viewModel: ViewModelProps,
|
|
21
|
-
setViewModel: (intent: Partial<ViewModelProps>) => void
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export declare const PictureViewer: React.FC<{ bind: BindProps }>;
|