@wavemaker/app-rn-runtime 11.4.0-next.1417013 → 11.4.0-next.1417014
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.
- app-rn-runtime/actions/notification-action.js +5 -4
- app-rn-runtime/actions/notification-action.js.map +1 -1
- app-rn-runtime/components/advanced/carousel/carousel-content/carousel-content.component.js +1 -1
- app-rn-runtime/components/advanced/carousel/carousel-content/carousel-content.component.js.map +1 -1
- app-rn-runtime/components/advanced/carousel/carousel-template/carousel-template.component.js +1 -1
- app-rn-runtime/components/advanced/carousel/carousel-template/carousel-template.component.js.map +1 -1
- app-rn-runtime/components/advanced/carousel/carousel.component.js +1 -1
- app-rn-runtime/components/advanced/carousel/carousel.component.js.map +1 -1
- app-rn-runtime/components/advanced/login/login.component.js +1 -1
- app-rn-runtime/components/advanced/login/login.component.js.map +1 -1
- app-rn-runtime/components/advanced/network-info-toaster/network-info-toaster.component.js +5 -5
- app-rn-runtime/components/advanced/network-info-toaster/network-info-toaster.component.js.map +1 -1
- app-rn-runtime/components/advanced/webview/webview.component.js +1 -1
- app-rn-runtime/components/advanced/webview/webview.component.js.map +1 -1
- app-rn-runtime/components/basic/anchor/anchor.component.js +1 -1
- app-rn-runtime/components/basic/anchor/anchor.component.js.map +1 -1
- app-rn-runtime/components/basic/button/button.component.js +1 -1
- app-rn-runtime/components/basic/button/button.component.js.map +1 -1
- app-rn-runtime/components/basic/buttongroup/buttongroup.component.js +1 -1
- app-rn-runtime/components/basic/buttongroup/buttongroup.component.js.map +1 -1
- app-rn-runtime/components/basic/icon/icon.component.js +1 -1
- app-rn-runtime/components/basic/icon/icon.component.js.map +1 -1
- app-rn-runtime/components/basic/label/label.component.js +1 -1
- app-rn-runtime/components/basic/label/label.component.js.map +1 -1
- app-rn-runtime/components/basic/message/message.component.js +1 -1
- app-rn-runtime/components/basic/message/message.component.js.map +1 -1
- app-rn-runtime/components/basic/picture/picture.component.js +37 -26
- app-rn-runtime/components/basic/picture/picture.component.js.map +1 -1
- app-rn-runtime/components/basic/progress-bar/progress-bar.component.js +3 -2
- app-rn-runtime/components/basic/progress-bar/progress-bar.component.js.map +1 -1
- app-rn-runtime/components/basic/progress-circle/progress-circle.component.js +1 -1
- app-rn-runtime/components/basic/progress-circle/progress-circle.component.js.map +1 -1
- app-rn-runtime/components/basic/search/search.component.js +4 -1
- app-rn-runtime/components/basic/search/search.component.js.map +1 -1
- app-rn-runtime/components/basic/spinner/spinner.component.js +1 -1
- app-rn-runtime/components/basic/spinner/spinner.component.js.map +1 -1
- app-rn-runtime/components/basic/video/video.component.js +56 -0
- app-rn-runtime/components/basic/video/video.component.js.map +1 -0
- app-rn-runtime/components/basic/video/video.props.js +22 -0
- app-rn-runtime/components/basic/video/video.props.js.map +1 -0
- app-rn-runtime/components/basic/video/video.styles.js +11 -0
- app-rn-runtime/components/basic/video/video.styles.js.map +1 -0
- app-rn-runtime/components/container/accordion/accordion.component.js +1 -1
- app-rn-runtime/components/container/accordion/accordion.component.js.map +1 -1
- app-rn-runtime/components/container/accordion/accordionpane/accordionpane.component.js +1 -1
- app-rn-runtime/components/container/accordion/accordionpane/accordionpane.component.js.map +1 -1
- app-rn-runtime/components/container/container.component.js +1 -1
- app-rn-runtime/components/container/container.component.js.map +1 -1
- app-rn-runtime/components/container/layoutgrid/gridcolumn/gridcolumn.component.js +1 -1
- app-rn-runtime/components/container/layoutgrid/gridcolumn/gridcolumn.component.js.map +1 -1
- app-rn-runtime/components/container/layoutgrid/gridrow/gridrow.component.js +1 -1
- app-rn-runtime/components/container/layoutgrid/gridrow/gridrow.component.js.map +1 -1
- app-rn-runtime/components/container/layoutgrid/layoutgrid.component.js +1 -1
- app-rn-runtime/components/container/layoutgrid/layoutgrid.component.js.map +1 -1
- app-rn-runtime/components/container/linearlayout/linearlayout.component.js +1 -1
- app-rn-runtime/components/container/linearlayout/linearlayout.component.js.map +1 -1
- app-rn-runtime/components/container/linearlayout/linearlayoutitem/linearlayoutitem.component.js +1 -1
- app-rn-runtime/components/container/linearlayout/linearlayoutitem/linearlayoutitem.component.js.map +1 -1
- app-rn-runtime/components/container/panel/panel-content/panel-content.component.js +1 -1
- app-rn-runtime/components/container/panel/panel-content/panel-content.component.js.map +1 -1
- app-rn-runtime/components/container/panel/panel-footer/panel-footer.component.js +1 -1
- app-rn-runtime/components/container/panel/panel-footer/panel-footer.component.js.map +1 -1
- app-rn-runtime/components/container/panel/panel.component.js +1 -1
- app-rn-runtime/components/container/panel/panel.component.js.map +1 -1
- app-rn-runtime/components/container/tabs/tabheader/tabheader.component.js +12 -4
- app-rn-runtime/components/container/tabs/tabheader/tabheader.component.js.map +1 -1
- app-rn-runtime/components/container/tabs/tabheader/tabheader.styles.js +2 -1
- app-rn-runtime/components/container/tabs/tabheader/tabheader.styles.js.map +1 -1
- app-rn-runtime/components/container/tabs/tabpane/tabpane.component.js +5 -2
- app-rn-runtime/components/container/tabs/tabpane/tabpane.component.js.map +1 -1
- app-rn-runtime/components/container/tabs/tabs.component.js +80 -64
- app-rn-runtime/components/container/tabs/tabs.component.js.map +1 -1
- app-rn-runtime/components/container/tabs/tabs.props.js +1 -0
- app-rn-runtime/components/container/tabs/tabs.props.js.map +1 -1
- app-rn-runtime/components/container/tabs/tabs.styles.js +1 -1
- app-rn-runtime/components/container/tabs/tabs.styles.js.map +1 -1
- app-rn-runtime/components/container/tile/tile.component.js +1 -1
- app-rn-runtime/components/container/tile/tile.component.js.map +1 -1
- app-rn-runtime/components/container/wizard/wizard.component.js +1 -1
- app-rn-runtime/components/container/wizard/wizard.component.js.map +1 -1
- app-rn-runtime/components/container/wizard/wizardstep/wizardstep.component.js +1 -1
- app-rn-runtime/components/container/wizard/wizardstep/wizardstep.component.js.map +1 -1
- app-rn-runtime/components/data/card/card-content/card-content.component.js +1 -1
- app-rn-runtime/components/data/card/card-content/card-content.component.js.map +1 -1
- app-rn-runtime/components/data/card/card-footer/card-footer.component.js +1 -1
- app-rn-runtime/components/data/card/card-footer/card-footer.component.js.map +1 -1
- app-rn-runtime/components/data/card/card.component.js +1 -1
- app-rn-runtime/components/data/card/card.component.js.map +1 -1
- app-rn-runtime/components/data/form/form-action/form-action.component.js +0 -6
- app-rn-runtime/components/data/form/form-action/form-action.component.js.map +1 -1
- app-rn-runtime/components/data/form/form-body/form-body.component.js +1 -1
- app-rn-runtime/components/data/form/form-body/form-body.component.js.map +1 -1
- app-rn-runtime/components/data/form/form-field/form-field.component.js +1 -1
- app-rn-runtime/components/data/form/form-field/form-field.component.js.map +1 -1
- app-rn-runtime/components/data/form/form-footer/form-footer.component.js +1 -1
- app-rn-runtime/components/data/form/form-footer/form-footer.component.js.map +1 -1
- app-rn-runtime/components/data/form/form.component.js +2 -31
- app-rn-runtime/components/data/form/form.component.js.map +1 -1
- app-rn-runtime/components/data/list/list-template/list-template.component.js +1 -1
- app-rn-runtime/components/data/list/list-template/list-template.component.js.map +1 -1
- app-rn-runtime/components/data/list/list.component.js +17 -8
- app-rn-runtime/components/data/list/list.component.js.map +1 -1
- app-rn-runtime/components/device/barcodescanner/barcodescanner.component.js +3 -2
- app-rn-runtime/components/device/barcodescanner/barcodescanner.component.js.map +1 -1
- app-rn-runtime/components/device/camera/camera.component.js +9 -4
- app-rn-runtime/components/device/camera/camera.component.js.map +1 -1
- app-rn-runtime/components/device/camera/camera.props.js +0 -1
- app-rn-runtime/components/device/camera/camera.props.js.map +1 -1
- app-rn-runtime/components/dialogs/dialog/dialog.component.js +1 -1
- app-rn-runtime/components/dialogs/dialog/dialog.component.js.map +1 -1
- app-rn-runtime/components/dialogs/dialogactions/dialogactions.component.js +1 -1
- app-rn-runtime/components/dialogs/dialogactions/dialogactions.component.js.map +1 -1
- app-rn-runtime/components/dialogs/dialogcontent/dialogcontent.component.js +1 -1
- app-rn-runtime/components/dialogs/dialogcontent/dialogcontent.component.js.map +1 -1
- app-rn-runtime/components/input/baseinput/baseinput.component.js +7 -0
- app-rn-runtime/components/input/baseinput/baseinput.component.js.map +1 -1
- app-rn-runtime/components/input/calendar/calendar.component.js +1 -1
- app-rn-runtime/components/input/calendar/calendar.component.js.map +1 -1
- app-rn-runtime/components/input/checkbox/checkbox.component.js +1 -16
- app-rn-runtime/components/input/checkbox/checkbox.component.js.map +1 -1
- app-rn-runtime/components/input/checkboxset/checkboxset.component.js +0 -38
- app-rn-runtime/components/input/checkboxset/checkboxset.component.js.map +1 -1
- app-rn-runtime/components/input/composite/composite.component.js +1 -1
- app-rn-runtime/components/input/composite/composite.component.js.map +1 -1
- app-rn-runtime/components/input/epoch/base-datetime.component.js +1 -1
- app-rn-runtime/components/input/epoch/base-datetime.component.js.map +1 -1
- app-rn-runtime/components/input/fileupload/fileupload.component.js +1 -1
- app-rn-runtime/components/input/fileupload/fileupload.component.js.map +1 -1
- app-rn-runtime/components/input/number/number.component.js +0 -9
- app-rn-runtime/components/input/number/number.component.js.map +1 -1
- app-rn-runtime/components/input/radioset/radioset.component.js +0 -40
- app-rn-runtime/components/input/radioset/radioset.component.js.map +1 -1
- app-rn-runtime/components/input/rating/rating.component.js +1 -1
- app-rn-runtime/components/input/rating/rating.component.js.map +1 -1
- app-rn-runtime/components/input/slider/slider.component.js +1 -1
- app-rn-runtime/components/input/slider/slider.component.js.map +1 -1
- app-rn-runtime/components/input/switch/switch.component.js +19 -22
- app-rn-runtime/components/input/switch/switch.component.js.map +1 -1
- app-rn-runtime/components/input/switch/switch.styles.js +7 -7
- app-rn-runtime/components/input/switch/switch.styles.js.map +1 -1
- app-rn-runtime/components/input/text/text.component.js +1 -10
- app-rn-runtime/components/input/text/text.component.js.map +1 -1
- app-rn-runtime/components/input/textarea/textarea.component.js +0 -10
- app-rn-runtime/components/input/textarea/textarea.component.js.map +1 -1
- app-rn-runtime/components/input/toggle/toggle.component.js +1 -1
- app-rn-runtime/components/input/toggle/toggle.component.js.map +1 -1
- app-rn-runtime/components/navigation/appnavbar/appnavbar.component.js +1 -1
- app-rn-runtime/components/navigation/appnavbar/appnavbar.component.js.map +1 -1
- app-rn-runtime/components/navigation/basenav/basenav.props.js +1 -0
- app-rn-runtime/components/navigation/basenav/basenav.props.js.map +1 -1
- app-rn-runtime/components/navigation/menu/menu.component.js +2 -1
- app-rn-runtime/components/navigation/menu/menu.component.js.map +1 -1
- app-rn-runtime/components/navigation/navbar/navbar.component.js +2 -0
- app-rn-runtime/components/navigation/navbar/navbar.component.js.map +1 -1
- app-rn-runtime/components/navigation/navitem/navitem.component.js +4 -3
- app-rn-runtime/components/navigation/navitem/navitem.component.js.map +1 -1
- app-rn-runtime/components/navigation/navitem/navitem.props.js +1 -0
- app-rn-runtime/components/navigation/navitem/navitem.props.js.map +1 -1
- app-rn-runtime/components/navigation/popover/popover.component.js +1 -1
- app-rn-runtime/components/navigation/popover/popover.component.js.map +1 -1
- app-rn-runtime/components/page/content/content.component.js +1 -1
- app-rn-runtime/components/page/content/content.component.js.map +1 -1
- app-rn-runtime/components/page/left-panel/left-panel.component.js +1 -1
- app-rn-runtime/components/page/left-panel/left-panel.component.js.map +1 -1
- app-rn-runtime/components/page/page-content/page-content.component.js +2 -2
- app-rn-runtime/components/page/page-content/page-content.component.js.map +1 -1
- app-rn-runtime/components/page/page.component.js +1 -1
- app-rn-runtime/components/page/page.component.js.map +1 -1
- app-rn-runtime/components/page/partial/partial.component.js +1 -1
- app-rn-runtime/components/page/partial/partial.component.js.map +1 -1
- app-rn-runtime/components/page/partial-container/partial-container.component.js +1 -1
- app-rn-runtime/components/page/partial-container/partial-container.component.js.map +1 -1
- app-rn-runtime/components/page/partial-container/partial-container.styles.js +2 -1
- app-rn-runtime/components/page/partial-container/partial-container.styles.js.map +1 -1
- app-rn-runtime/components/page/tabbar/tabbar.component.js +2 -1
- app-rn-runtime/components/page/tabbar/tabbar.component.js.map +1 -1
- app-rn-runtime/components/prefab/prefab-container.component.js +1 -1
- app-rn-runtime/components/prefab/prefab-container.component.js.map +1 -1
- app-rn-runtime/core/asset.provider.js +5 -0
- app-rn-runtime/core/asset.provider.js.map +1 -0
- app-rn-runtime/core/base.component.js +113 -41
- app-rn-runtime/core/base.component.js.map +1 -1
- app-rn-runtime/core/imageSizeEstimator.js +1 -0
- app-rn-runtime/core/imageSizeEstimator.js.map +1 -1
- app-rn-runtime/core/injector.js +15 -1
- app-rn-runtime/core/injector.js.map +1 -1
- app-rn-runtime/core/tappable.component.js +9 -2
- app-rn-runtime/core/tappable.component.js.map +1 -1
- app-rn-runtime/core/utils.js +6 -0
- app-rn-runtime/core/utils.js.map +1 -1
- app-rn-runtime/gestures/swipe.animation.js +105 -0
- app-rn-runtime/gestures/swipe.animation.js.map +1 -0
- app-rn-runtime/package.json +5 -5
- app-rn-runtime/runtime/App.js +20 -15
- app-rn-runtime/runtime/App.js.map +1 -1
- app-rn-runtime/runtime/App.navigator.js +2 -12
- app-rn-runtime/runtime/App.navigator.js.map +1 -1
- app-rn-runtime/runtime/base-fragment.component.js +6 -4
- app-rn-runtime/runtime/base-fragment.component.js.map +1 -1
- app-rn-runtime/runtime/navigator/drawer.navigator.js +4 -0
- app-rn-runtime/runtime/navigator/drawer.navigator.js.map +1 -1
- app-rn-runtime/runtime/navigator/stack.navigator.js +5 -1
- app-rn-runtime/runtime/navigator/stack.navigator.js.map +1 -1
- app-rn-runtime/runtime/services/device/camera-service.js +28 -6
- app-rn-runtime/runtime/services/device/camera-service.js.map +1 -1
- app-rn-runtime/runtime/services/device/scan-service.js +15 -14
- app-rn-runtime/runtime/services/device/scan-service.js.map +1 -1
- app-rn-runtime/styles/background.component.js +259 -0
- app-rn-runtime/styles/background.component.js.map +1 -0
- app-rn-runtime/styles/style-prop.validator.js +11 -6
- app-rn-runtime/styles/style-prop.validator.js.map +1 -1
- app-rn-runtime/styles/style-props.js +93 -0
- app-rn-runtime/styles/style-props.js.map +1 -0
- app-rn-runtime/styles/theme.js +5 -36
- app-rn-runtime/styles/theme.js.map +1 -1
- app-rn-runtime/variables/device/camera/capture-image.operation.js.map +1 -1
- app-rn-runtime/variables/device/camera/capture-video.operation.js.map +1 -1
- app-rn-runtime/variables/device/file/upload-file.operation.js +43 -21
- app-rn-runtime/variables/device/file/upload-file.operation.js.map +1 -1
- app-rn-runtime/variables/http.service.js +3 -12
- app-rn-runtime/variables/http.service.js.map +1 -1
- app-rn-runtime/variables/service-variable.js +19 -8
- app-rn-runtime/variables/service-variable.js.map +1 -1
|
@@ -6,6 +6,7 @@ import { ImageBackground, TouchableOpacity, View } from "react-native";
|
|
|
6
6
|
import { Ionicons } from "@expo/vector-icons";
|
|
7
7
|
import { ResizeMode, Video } from "expo-av";
|
|
8
8
|
import { Camera, CameraType } from "expo-camera";
|
|
9
|
+
import * as FileSystem from "expo-file-system";
|
|
9
10
|
import permissionManager from '@wavemaker/app-rn-runtime/runtime/services/device/permissions';
|
|
10
11
|
import appDisplayManagerService from "@wavemaker/app-rn-runtime/runtime/services/app-display-manager.service";
|
|
11
12
|
const styles = {
|
|
@@ -36,14 +37,17 @@ const styles = {
|
|
|
36
37
|
},
|
|
37
38
|
leftWrapper: {
|
|
38
39
|
flex: 1,
|
|
40
|
+
justifyContent: 'center',
|
|
39
41
|
alignItems: 'flex-start'
|
|
40
42
|
},
|
|
41
43
|
midWrapper: {
|
|
42
44
|
flex: 1,
|
|
45
|
+
justifyContent: 'center',
|
|
43
46
|
alignItems: 'center'
|
|
44
47
|
},
|
|
45
48
|
rightWrapper: {
|
|
46
49
|
flex: 1,
|
|
50
|
+
justifyContent: 'center',
|
|
47
51
|
alignItems: 'flex-end'
|
|
48
52
|
},
|
|
49
53
|
circle: {
|
|
@@ -79,8 +83,12 @@ export class CameraService {
|
|
|
79
83
|
captureType: 'video',
|
|
80
84
|
onSuccess: o => {
|
|
81
85
|
destroy.call(this.displayManager);
|
|
86
|
+
/*o.content().catch(() => {}).then(base64 => {
|
|
87
|
+
resolve({videoPath: o.uri, content: base64 || ''});
|
|
88
|
+
});*/
|
|
82
89
|
resolve({
|
|
83
|
-
videoPath: o.uri
|
|
90
|
+
videoPath: o.uri,
|
|
91
|
+
content: ''
|
|
84
92
|
});
|
|
85
93
|
},
|
|
86
94
|
onCancel: () => {
|
|
@@ -100,8 +108,11 @@ export class CameraService {
|
|
|
100
108
|
captureType: 'image',
|
|
101
109
|
onSuccess: o => {
|
|
102
110
|
destroy.call(this.displayManager);
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
o.content().catch(() => {}).then(base64 => {
|
|
112
|
+
resolve({
|
|
113
|
+
imagePath: o.uri,
|
|
114
|
+
content: base64 || ''
|
|
115
|
+
});
|
|
105
116
|
});
|
|
106
117
|
},
|
|
107
118
|
onCancel: () => {
|
|
@@ -137,6 +148,11 @@ export class CameraView extends React.Component {
|
|
|
137
148
|
_defineProperty(this, "camera", {});
|
|
138
149
|
_defineProperty(this, "startRecord", async () => {
|
|
139
150
|
this.camera.recordAsync().then(response => {
|
|
151
|
+
response.content = async () => {
|
|
152
|
+
return await FileSystem.readAsStringAsync(response.uri, {
|
|
153
|
+
encoding: 'base64'
|
|
154
|
+
});
|
|
155
|
+
};
|
|
140
156
|
this.setState({
|
|
141
157
|
cameraContent: response,
|
|
142
158
|
isCaptured: true
|
|
@@ -182,9 +198,15 @@ export class CameraView extends React.Component {
|
|
|
182
198
|
base64: false,
|
|
183
199
|
skipProcessing: true,
|
|
184
200
|
onPictureSaved: response => {
|
|
201
|
+
response.content = async () => {
|
|
202
|
+
return await FileSystem.readAsStringAsync(response.uri, {
|
|
203
|
+
encoding: 'base64'
|
|
204
|
+
});
|
|
205
|
+
};
|
|
185
206
|
this.setState({
|
|
186
207
|
cameraContent: response,
|
|
187
|
-
isCaptured: true
|
|
208
|
+
isCaptured: true,
|
|
209
|
+
showActionBtns: true
|
|
188
210
|
});
|
|
189
211
|
}
|
|
190
212
|
};
|
|
@@ -270,7 +292,7 @@ export class CameraView extends React.Component {
|
|
|
270
292
|
source: {
|
|
271
293
|
uri: this.state.cameraContent.uri
|
|
272
294
|
},
|
|
273
|
-
resizeMode: ResizeMode.
|
|
295
|
+
resizeMode: ResizeMode.CONTAIN,
|
|
274
296
|
style: {
|
|
275
297
|
flex: 1
|
|
276
298
|
}
|
|
@@ -284,7 +306,7 @@ export class CameraView extends React.Component {
|
|
|
284
306
|
shouldPlay: true,
|
|
285
307
|
useNativeControls: true,
|
|
286
308
|
isLooping: true,
|
|
287
|
-
resizeMode: ResizeMode.
|
|
309
|
+
resizeMode: ResizeMode.CONTAIN
|
|
288
310
|
});
|
|
289
311
|
}
|
|
290
312
|
render() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","ImageBackground","TouchableOpacity","View","Ionicons","ResizeMode","Video","Camera","CameraType","permissionManager","appDisplayManagerService","styles","preview","top","left","right","flexGrow","backgroundColor","actionBtn","flex","padding","paddingHorizontal","alignSelf","margin","actionBar","flexDirection","justifyContent","position","bottom","leftWrapper","alignItems","midWrapper","rightWrapper","circle","display","outerCircle","borderWidth","height","width","borderRadius","borderColor","innerCircle","CameraService","constructor","displayManager","back","captureVideo","options","Promise","resolve","reject","requestPermissions","then","destroy","show","content","type","o","call","videoPath","uri","captureImage","params","imagePath","CameraViewProps","CameraViewState","CameraView","Component","props","camera","recordAsync","response","setState","cameraContent","isCaptured","state","showActionBtns","recording","stopRecording","toggleCapture","captureType","takePicture","startRecord","stopRecord","quality","base64","skipProcessing","onPictureSaved","takePictureAsync","getActionsTemplate","closeView","onCancel","bind","onSuccess","cameraType","getPreviewTemplate","actions","COVER","render","ref","cameraService"],"sources":["camera-service.tsx"],"sourcesContent":["import React from \"react\";\nimport { ImageBackground, TouchableOpacity, View, ViewStyle } from \"react-native\";\nimport { Ionicons } from \"@expo/vector-icons\";\nimport { ResizeMode, Video } from \"expo-av\";\nimport { Camera, CameraType } from \"expo-camera\";\n\nimport { DisplayManager } from \"@wavemaker/app-rn-runtime/core/display.manager\";\nimport { CaptureVideoOutput } from \"@wavemaker/app-rn-runtime/variables/device/camera/capture-video.operation\";\nimport { CaptureImageOutput } from \"@wavemaker/app-rn-runtime/variables/device/camera/capture-image.operation\";\nimport permissionManager from '@wavemaker/app-rn-runtime/runtime/services/device/permissions';\nimport { CameraInput } from \"@wavemaker/app-rn-runtime/core/device/camera-service\";\nimport { Input } from \"@wavemaker/app-rn-runtime/variables/device/operation.provider\";\nimport appDisplayManagerService from \"@wavemaker/app-rn-runtime/runtime/services/app-display-manager.service\";\nconst styles = {\n preview: {\n top: 0,\n left: 0,\n right: 0,\n flexGrow: 1,\n backgroundColor: 'black'\n },\n actionBtn: {\n flex: 0,\n padding: 15,\n paddingHorizontal: 20,\n alignSelf: 'center',\n margin: 20,\n } as ViewStyle,\n actionBar: {\n flex: 0,\n flexDirection: 'row',\n justifyContent: 'center',\n backgroundColor: 'rgba(0,0,0,0.6)',\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n padding: 20\n } as ViewStyle,\n leftWrapper: {\n flex: 1,\n alignItems: 'flex-start',\n } as ViewStyle,\n midWrapper: {\n flex: 1,\n alignItems: 'center',\n } as ViewStyle,\n rightWrapper: {\n flex: 1,\n alignItems: 'flex-end',\n } as ViewStyle,\n circle: {\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n } as ViewStyle,\n outerCircle: {\n borderWidth: 3,\n height: 50,\n width: 50,\n borderRadius: 25,\n borderColor: 'white'\n },\n innerCircle: {\n borderRadius:2,\n height: 20,\n width:20,\n backgroundColor: 'red'\n }\n};\n\nexport interface CameraVideoInput extends Input {}\n\nexport class CameraService {\n private type= CameraType.back;\n\n constructor(private displayManager: DisplayManager) {\n }\n\n public captureVideo(options?: CameraVideoInput): Promise<CaptureVideoOutput> {\n return new Promise((resolve, reject) => {\n permissionManager.requestPermissions('video').then(() => {\n const destroy = this.displayManager.show({\n content: (<CameraView type={this.type} captureType={'video'} onSuccess={(o) => {\n destroy.call(this.displayManager);\n resolve({videoPath: o.uri});\n }}\n onCancel={() => {\n destroy.call(this.displayManager);\n }}\n ></CameraView>)\n });\n }, reject);\n });\n }\n\n public captureImage(params: CameraInput): Promise<CaptureImageOutput> {\n return new Promise((resolve, reject) => {\n permissionManager.requestPermissions('image').then(() => {\n const destroy = this.displayManager.show({\n content: (<CameraView type={this.type} captureType={'image'} onSuccess={(o) => {\n destroy.call(this.displayManager);\n resolve({imagePath: o.uri});\n }} onCancel={() => {destroy.call(this.displayManager);}}\n ></CameraView>)\n });\n }, reject);\n });\n }\n}\n\ninterface CameraOutput {\n uri: string;\n}\n\nclass CameraViewProps {\n type: 'front' | 'back' = 'back' as CameraType;\n captureType: 'image' | 'video' = 'image';\n onSuccess: (o: CameraOutput) => any = () => {};\n onCancel: () => any = () => {};\n}\n\nclass CameraViewState {\n recording: boolean = false;\n showActionBtns: boolean = false;\n cameraType: CameraType = CameraType.back;\n isCaptured: boolean = false;\n closeView: boolean = false;\n cameraContent: CameraOutput = {} as CameraOutput;\n}\n\nexport class CameraView extends React.Component<CameraViewProps, CameraViewState> {\n private camera: Camera = {} as Camera;\n\n constructor(props: CameraViewProps) {\n super(props);\n this.state = new CameraViewState();\n }\n\n toggleCapture() {\n if (this.props.captureType === 'image') {\n this.takePicture();\n } else {\n if (!this.state.recording) {\n this.startRecord();\n } else {\n this.stopRecord();\n this.setState({showActionBtns: true} as CameraViewState);\n }\n }\n }\n\n async takePicture() {\n const options = {\n quality: 0.5,\n base64: false,\n skipProcessing: true,\n onPictureSaved: (response: any) => {\n this.setState({ cameraContent: response, isCaptured: true } as CameraViewState);\n }\n }\n await this.camera.takePictureAsync(options);\n\n if (this.state.showActionBtns) {\n this.setState({showActionBtns: false} as CameraViewState);\n }\n this.setState({showActionBtns: true} as CameraViewState);\n }\n\n // start recording\n startRecord = async () => {\n this.camera.recordAsync().then((response: any) => {\n this.setState({ cameraContent: response, isCaptured: true } as CameraViewState);\n });\n if (this.state.showActionBtns) {\n this.setState({showActionBtns: false} as CameraViewState);\n }\n\n this.setState({recording: true} as CameraViewState);\n };\n\n // stop recording\n stopRecord = async () => {\n this.camera.stopRecording();\n this.setState({recording: false} as CameraViewState);\n this.setState({showActionBtns: true} as CameraViewState);\n };\n\n getActionsTemplate() {\n return <View style={styles.actionBar}>\n <View style={styles.leftWrapper}>\n <TouchableOpacity\n onPress={() => {\n this.setState({ cameraContent: {uri: ''}, isCaptured: false, closeView: true } as CameraViewState);\n this.props.onCancel();\n }}>\n <Ionicons name='close-circle' size={32} color='white' />\n </TouchableOpacity>\n </View>\n <View style={styles.midWrapper}>\n {!this.state.isCaptured ? <TouchableOpacity style={[styles.circle, styles.outerCircle, this.props.captureType === 'video' && !this.state.recording ? { backgroundColor: \"red\" } : {},\n this.props.captureType === 'image' ? { backgroundColor: \"white\" } : {}]}\n onPress={this.toggleCapture.bind(this)}>\n <View style={[styles.circle as ViewStyle, this.props.captureType === 'image' ? {} : styles.innerCircle, this.props.captureType === 'image' ? { backgroundColor: \"white\" } : {}]}></View>\n </TouchableOpacity> : null}\n </View>\n <View style={styles.rightWrapper}>\n {this.state.showActionBtns ? (<TouchableOpacity\n onPress={() => {\n this.setState({ isCaptured: false, closeView: true } as CameraViewState);\n this.props.onSuccess(this.state.cameraContent);\n this.setState({ cameraContent: {uri: ''} } as CameraViewState);\n }}>\n <Ionicons name='checkmark-circle' size={32} color='white'/>\n </TouchableOpacity>) : (<TouchableOpacity\n onPress={() => {\n this.setState({cameraType: this.state.cameraType === 'back' ? 'front' : 'back'} as CameraViewState);\n }}>\n <Ionicons name='camera-reverse' size={32} color='white' />\n </TouchableOpacity>)}\n </View>\n </View>\n }\n\n getPreviewTemplate(actions: any) {\n return this.props.captureType === 'image' ?\n <ImageBackground source={{uri : this.state.cameraContent.uri}} resizeMode={ResizeMode.COVER} style={{flex: 1}} />\n : <Video\n style={{ flex: 1 }}\n source={{\n uri: this.state.cameraContent.uri,\n }}\n shouldPlay={true}\n useNativeControls\n isLooping\n resizeMode={ResizeMode.COVER}\n ></Video>\n }\n\n render() {\n if (this.state.closeView) {\n return null;\n }\n const actions = this.getActionsTemplate();\n return (\n <View style={styles.preview}>\n {this.state.isCaptured ? (\n this.getPreviewTemplate(actions)\n ) : (\n <Camera type={CameraType[this.state.cameraType]} ref={(ref: Camera) => { this.camera = ref; }}\n style={{flex: 1}}\n onCameraReady={() => {}}>\n\n </Camera>)}\n {actions}\n </View>)\n }\n}\nconst cameraService = new CameraService(appDisplayManagerService);\nexport default cameraService;\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,EAAEC,gBAAgB,EAAEC,IAAI,QAAmB,cAAc;AACjF,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,UAAU,EAAEC,KAAK,QAAQ,SAAS;AAC3C,SAASC,MAAM,EAAEC,UAAU,QAAQ,aAAa;AAKhD,OAAOC,iBAAiB,MAAM,+DAA+D;AAG7F,OAAOC,wBAAwB,MAAM,wEAAwE;AAC7G,MAAMC,MAAM,GAAG;EACbC,OAAO,EAAE;IACPC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,QAAQ,EAAE,CAAC;IACXC,eAAe,EAAE;EACnB,CAAC;EACDC,SAAS,EAAE;IACTC,IAAI,EAAE,CAAC;IACPC,OAAO,EAAE,EAAE;IACXC,iBAAiB,EAAE,EAAE;IACrBC,SAAS,EAAE,QAAQ;IACnBC,MAAM,EAAE;EACV,CAAc;EACdC,SAAS,EAAE;IACTL,IAAI,EAAE,CAAC;IACPM,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,QAAQ;IACxBT,eAAe,EAAE,iBAAiB;IAClCU,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTd,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRK,OAAO,EAAE;EACX,CAAc;EACdS,WAAW,EAAE;IACXV,IAAI,EAAE,CAAC;IACPW,UAAU,EAAE;EACd,CAAc;EACdC,UAAU,EAAE;IACVZ,IAAI,EAAE,CAAC;IACPW,UAAU,EAAE;EACd,CAAc;EACdE,YAAY,EAAE;IACZb,IAAI,EAAE,CAAC;IACPW,UAAU,E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AC5B,KAAK,CAACY,WAAW,KAAK,OAAO,gBACvC,oBAAC,eAAe;MAAC,MAAM,EAAE;QAACpB,GAAG,EAAG,IAAI,CAACe,KAAK,CAACF,aAAa,CAACb;MAAG,CAAE;MAAC,UAAU,EAAEvD,UAAU,CAAC4F,KAAM;MAAC,KAAK,EAAE;QAAC9E,IAAI,EAAE;MAAC;IAAE,EAAG,gBAC/G,oBAAC,KAAK;MACJ,KAAK,EAAE;QAAEA,IAAI,EAAE;MAAE,CAAE;MACnB,MAAM,EAAE;QACNyC,GAAG,EAAE,IAAI,CAACe,KAAK,CAACF,aAAa,CAACb;MAChC,CAAE;MACF,UAAU,EAAE,IAAK;MACjB,iBAAiB;MACjB,SAAS;MACT,UAAU,EAAEvD,UAAU,CAAC4F;IAAM,EACtB;EACf;EAEAC,MAAM,GAAG;IACP,IAAI,IAAI,CAACvB,KAAK,CAACe,SAAS,EAAE;MACxB,OAAO,IAAI;IACb;IACA,MAAMM,OAAO,GAAG,IAAI,CAACP,kBAAkB,EAAE;IACzC,oBACE,oBAAC,IAAI;MAAC,KAAK,EAAE9E,MAAM,CAACC;IAAQ,GACzB,IAAI,CAAC+D,KAAK,CAACD,UAAU,GACpB,IAAI,CAACqB,kBAAkB,CAACC,OAAO,CAAC,gBAEhC,oBAAC,MAAM;MAAC,IAAI,EAAExF,UAAU,CAAC,IAAI,CAACmE,KAAK,CAACmB,UAAU,CAAE;MAAC,GAAG,EAAGK,GAAW,IAAK;QAAE,IAAI,CAAC9B,MAAM,GAAG8B,GAAG;MAAE,CAAE;MAC1F,KAAK,EAAE;QAAChF,IAAI,EAAE;MAAC,CAAE;MACjB,aAAa,EAAE,MAAM,CAAC;IAAE,EAElB,EACX6E,OAAO,CACH;EACX;AACF;AACA,MAAMI,aAAa,GAAG,IAAI1D,aAAa,CAAChC,wBAAwB,CAAC;AACjE,eAAe0F,aAAa"}
|
|
1
|
+
{"version":3,"names":["React","ImageBackground","TouchableOpacity","View","Ionicons","ResizeMode","Video","Camera","CameraType","FileSystem","permissionManager","appDisplayManagerService","styles","preview","top","left","right","flexGrow","backgroundColor","actionBtn","flex","padding","paddingHorizontal","alignSelf","margin","actionBar","flexDirection","justifyContent","position","bottom","leftWrapper","alignItems","midWrapper","rightWrapper","circle","display","outerCircle","borderWidth","height","width","borderRadius","borderColor","innerCircle","CameraService","constructor","displayManager","back","captureVideo","options","Promise","resolve","reject","requestPermissions","then","destroy","show","content","type","o","call","videoPath","uri","captureImage","params","catch","base64","imagePath","CameraViewProps","CameraViewState","CameraView","Component","props","camera","recordAsync","response","readAsStringAsync","encoding","setState","cameraContent","isCaptured","state","showActionBtns","recording","stopRecording","toggleCapture","captureType","takePicture","startRecord","stopRecord","quality","skipProcessing","onPictureSaved","takePictureAsync","getActionsTemplate","closeView","onCancel","bind","onSuccess","cameraType","getPreviewTemplate","actions","CONTAIN","render","ref","cameraService"],"sources":["camera-service.tsx"],"sourcesContent":["import React from \"react\";\nimport { ImageBackground, TouchableOpacity, View, ViewStyle } from \"react-native\";\nimport { Ionicons } from \"@expo/vector-icons\";\nimport { ResizeMode, Video } from \"expo-av\";\nimport { Camera, CameraType } from \"expo-camera\";\nimport * as FileSystem from \"expo-file-system\";\n\nimport { DisplayManager } from \"@wavemaker/app-rn-runtime/core/display.manager\";\nimport { CaptureVideoOutput } from \"@wavemaker/app-rn-runtime/variables/device/camera/capture-video.operation\";\nimport { CaptureImageOutput } from \"@wavemaker/app-rn-runtime/variables/device/camera/capture-image.operation\";\nimport permissionManager from '@wavemaker/app-rn-runtime/runtime/services/device/permissions';\nimport { CameraInput } from \"@wavemaker/app-rn-runtime/core/device/camera-service\";\nimport { Input } from \"@wavemaker/app-rn-runtime/variables/device/operation.provider\";\nimport appDisplayManagerService from \"@wavemaker/app-rn-runtime/runtime/services/app-display-manager.service\";\nconst styles = {\n preview: {\n top: 0,\n left: 0,\n right: 0,\n flexGrow: 1,\n backgroundColor: 'black'\n },\n actionBtn: {\n flex: 0,\n padding: 15,\n paddingHorizontal: 20,\n alignSelf: 'center',\n margin: 20,\n } as ViewStyle,\n actionBar: {\n flex: 0,\n flexDirection: 'row',\n justifyContent: 'center',\n backgroundColor: 'rgba(0,0,0,0.6)',\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n padding: 20\n } as ViewStyle,\n leftWrapper: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'flex-start',\n } as ViewStyle,\n midWrapper: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n } as ViewStyle,\n rightWrapper: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'flex-end',\n } as ViewStyle,\n circle: {\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n } as ViewStyle,\n outerCircle: {\n borderWidth: 3,\n height: 50,\n width: 50,\n borderRadius: 25,\n borderColor: 'white'\n },\n innerCircle: {\n borderRadius:2,\n height: 20,\n width:20,\n backgroundColor: 'red'\n }\n};\n\nexport interface CameraVideoInput extends Input {}\n\nexport class CameraService {\n private type= CameraType.back;\n\n constructor(private displayManager: DisplayManager) {\n }\n\n public captureVideo(options?: CameraVideoInput): Promise<CaptureVideoOutput> {\n return new Promise((resolve, reject) => {\n permissionManager.requestPermissions('video').then(() => {\n const destroy = this.displayManager.show({\n content: (<CameraView type={this.type} captureType={'video'} onSuccess={(o) => {\n destroy.call(this.displayManager);\n /*o.content().catch(() => {}).then(base64 => {\n resolve({videoPath: o.uri, content: base64 || ''});\n });*/\n resolve({videoPath: o.uri, content: ''});\n }}\n onCancel={() => {\n destroy.call(this.displayManager);\n }}\n ></CameraView>)\n });\n }, reject);\n });\n }\n\n public captureImage(params: CameraInput): Promise<CaptureImageOutput> {\n return new Promise((resolve, reject) => {\n permissionManager.requestPermissions('image').then(() => {\n const destroy = this.displayManager.show({\n content: (<CameraView type={this.type} captureType={'image'} onSuccess={(o) => {\n destroy.call(this.displayManager);\n o.content().catch(() => {}).then(base64 => {\n resolve({imagePath: o.uri, content: base64 || ''});\n });\n }} onCancel={() => {destroy.call(this.displayManager);}}\n ></CameraView>)\n });\n }, reject);\n });\n }\n}\n\ninterface CameraOutput {\n uri: string;\n content: () => Promise<string>;\n}\n\nclass CameraViewProps {\n type: 'front' | 'back' = 'back' as CameraType;\n captureType: 'image' | 'video' = 'image';\n onSuccess: (o: CameraOutput) => any = () => {};\n onCancel: () => any = () => {};\n}\n\nclass CameraViewState {\n recording: boolean = false;\n showActionBtns: boolean = false;\n cameraType: CameraType = CameraType.back;\n isCaptured: boolean = false;\n closeView: boolean = false;\n cameraContent: CameraOutput = {} as CameraOutput;\n}\n\nexport class CameraView extends React.Component<CameraViewProps, CameraViewState> {\n private camera: Camera = {} as Camera;\n\n constructor(props: CameraViewProps) {\n super(props);\n this.state = new CameraViewState();\n }\n\n toggleCapture() {\n if (this.props.captureType === 'image') {\n this.takePicture();\n } else {\n if (!this.state.recording) {\n this.startRecord();\n } else {\n this.stopRecord();\n this.setState({showActionBtns: true} as CameraViewState);\n }\n }\n }\n\n async takePicture() {\n const options = {\n quality: 0.5,\n base64: false,\n skipProcessing: true,\n onPictureSaved: (response: any) => {\n response.content = async () => {\n return await FileSystem.readAsStringAsync(response.uri, { encoding: 'base64' });\n };\n this.setState({ \n cameraContent: response,\n isCaptured: true,\n showActionBtns: true } as CameraViewState);\n }\n }\n await this.camera.takePictureAsync(options);\n\n if (this.state.showActionBtns) {\n this.setState({showActionBtns: false} as CameraViewState);\n }\n this.setState({showActionBtns: true} as CameraViewState);\n }\n\n // start recording\n startRecord = async () => {\n this.camera.recordAsync().then((response: any) => {\n response.content = async () => {\n return await FileSystem.readAsStringAsync(response.uri, { encoding: 'base64' });\n };\n this.setState({ cameraContent: response, isCaptured: true } as CameraViewState);\n });\n if (this.state.showActionBtns) {\n this.setState({showActionBtns: false} as CameraViewState);\n }\n\n this.setState({recording: true} as CameraViewState);\n };\n\n // stop recording\n stopRecord = async () => {\n this.camera.stopRecording();\n this.setState({recording: false} as CameraViewState);\n this.setState({showActionBtns: true} as CameraViewState);\n };\n\n getActionsTemplate() {\n return <View style={styles.actionBar}>\n <View style={styles.leftWrapper}>\n <TouchableOpacity\n onPress={() => {\n this.setState({ cameraContent: {uri: ''}, isCaptured: false, closeView: true } as CameraViewState);\n this.props.onCancel();\n }}>\n <Ionicons name='close-circle' size={32} color='white' />\n </TouchableOpacity>\n </View>\n <View style={styles.midWrapper}>\n {!this.state.isCaptured ? <TouchableOpacity style={[styles.circle, styles.outerCircle, this.props.captureType === 'video' && !this.state.recording ? { backgroundColor: \"red\" } : {},\n this.props.captureType === 'image' ? { backgroundColor: \"white\" } : {}]}\n onPress={this.toggleCapture.bind(this)}>\n <View style={[styles.circle as ViewStyle, this.props.captureType === 'image' ? {} : styles.innerCircle, this.props.captureType === 'image' ? { backgroundColor: \"white\" } : {}]}></View>\n </TouchableOpacity> : null}\n </View>\n <View style={styles.rightWrapper}>\n {this.state.showActionBtns ? (<TouchableOpacity\n onPress={() => {\n this.setState({ isCaptured: false, closeView: true } as CameraViewState);\n this.props.onSuccess(this.state.cameraContent);\n this.setState({ cameraContent: {uri: ''} } as CameraViewState);\n }}>\n <Ionicons name='checkmark-circle' size={32} color='white'/>\n </TouchableOpacity>) : (<TouchableOpacity\n onPress={() => {\n this.setState({cameraType: this.state.cameraType === 'back' ? 'front' : 'back'} as CameraViewState);\n }}>\n <Ionicons name='camera-reverse' size={32} color='white' />\n </TouchableOpacity>)}\n </View>\n </View>\n }\n\n getPreviewTemplate(actions: any) {\n return this.props.captureType === 'image' ?\n <ImageBackground source={{uri : this.state.cameraContent.uri}} resizeMode={ResizeMode.CONTAIN} style={{flex: 1}} />\n : <Video\n style={{ flex: 1 }}\n source={{\n uri: this.state.cameraContent.uri,\n }}\n shouldPlay={true}\n useNativeControls\n isLooping\n resizeMode={ResizeMode.CONTAIN}\n ></Video>\n }\n\n render() {\n if (this.state.closeView) {\n return null;\n }\n const actions = this.getActionsTemplate();\n return (\n <View style={styles.preview}>\n {this.state.isCaptured ? (\n this.getPreviewTemplate(actions)\n ) : (\n <Camera type={CameraType[this.state.cameraType]} ref={(ref: Camera) => { this.camera = ref; }}\n style={{flex: 1}}\n onCameraReady={() => {}}>\n\n </Camera>)}\n {actions}\n </View>)\n }\n}\nconst cameraService = new CameraService(appDisplayManagerService);\nexport default cameraService;\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,EAAEC,gBAAgB,EAAEC,IAAI,QAAmB,cAAc;AACjF,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,UAAU,EAAEC,KAAK,QAAQ,SAAS;AAC3C,SAASC,MAAM,EAAEC,UAAU,QAAQ,aAAa;AAChD,OAAO,KAAKC,UAAU,MAAM,kBAAkB;AAK9C,OAAOC,iBAAiB,MAAM,+DAA+D;AAG7F,OAAOC,wBAAwB,MAAM,wEAAwE;AAC7G,MAAMC,MAAM,GAAG;EACbC,OAAO,EAAE;IACPC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,QAAQ,EAAE,CAAC;IACXC,eAAe,EAAE;EACnB,CAAC;EACDC,SAAS,EAAE;IACTC,IAAI,EAAE,CAAC;IACPC,OAAO,EAAE,EAAE;IACXC,iBAAiB,EAAE,EAAE;IACrBC,SAAS,EAAE,QAAQ;IACnBC,MAAM,EAAE;EACV,CAAc;EACdC,SAAS,EAAE;IACTL,IAAI,EAAE,CAAC;IACPM,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,QAAQ;IACxBT,eAAe,EAAE,iBAAiB;IAClCU,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTd,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRK,OAAO,EAAE;EACX,CAAc;EACdS,WAAW,EAAE;IACXV,IAAI,EAAE,CAAC;IACPO,cAAc,EAAE,QAAQ;IACxBI,UAAU,EAAE;EACd,CAAc;EACdC,UAAU,EAAE;IACVZ,IAAI,EAAE,CAAC;IACPO,cA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tB,KAAK,CAACc,SAAS,EAAE;MACxB,OAAO,IAAI;IACb;IACA,MAAMM,OAAO,GAAG,IAAI,CAACP,kBAAkB,EAAE;IACzC,oBACE,oBAAC,IAAI;MAAC,KAAK,EAAEjF,MAAM,CAACC;IAAQ,GACzB,IAAI,CAACmE,KAAK,CAACD,UAAU,GACpB,IAAI,CAACoB,kBAAkB,CAACC,OAAO,CAAC,gBAEhC,oBAAC,MAAM;MAAC,IAAI,EAAE5F,UAAU,CAAC,IAAI,CAACwE,KAAK,CAACkB,UAAU,CAAE;MAAC,GAAG,EAAGK,GAAW,IAAK;QAAE,IAAI,CAAC/B,MAAM,GAAG+B,GAAG;MAAE,CAAE;MAC1F,KAAK,EAAE;QAACnF,IAAI,EAAE;MAAC,CAAE;MACjB,aAAa,EAAE,MAAM,CAAC;IAAE,EAElB,EACXgF,OAAO,CACH;EACX;AACF;AACA,MAAMI,aAAa,GAAG,IAAI7D,aAAa,CAAChC,wBAAwB,CAAC;AACjE,eAAe6F,aAAa"}
|
|
@@ -30,8 +30,9 @@ const styles = StyleSheet.create({
|
|
|
30
30
|
},
|
|
31
31
|
closeWrapper: {
|
|
32
32
|
flex: 1,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
justifyContent: 'flex-end',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
paddingBottom: 32
|
|
35
36
|
},
|
|
36
37
|
topWrapper: {
|
|
37
38
|
flex: 2,
|
|
@@ -78,17 +79,7 @@ export class ScanService {
|
|
|
78
79
|
style: StyleSheet.absoluteFillObject
|
|
79
80
|
}, /*#__PURE__*/React.createElement(View, {
|
|
80
81
|
style: styles.topWrapper
|
|
81
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
82
|
-
style: styles.closeWrapper
|
|
83
|
-
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
84
|
-
onPress: () => {
|
|
85
|
-
destroy.call(this.displayManager);
|
|
86
|
-
}
|
|
87
|
-
}, /*#__PURE__*/React.createElement(Ionicons, {
|
|
88
|
-
name: "close-circle",
|
|
89
|
-
size: 32,
|
|
90
|
-
color: "white"
|
|
91
|
-
})))), /*#__PURE__*/React.createElement(View, {
|
|
82
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
92
83
|
style: styles.centerWrapper
|
|
93
84
|
}, /*#__PURE__*/React.createElement(View, {
|
|
94
85
|
style: styles.leftWrapper
|
|
@@ -98,7 +89,17 @@ export class ScanService {
|
|
|
98
89
|
style: styles.rightWrapper
|
|
99
90
|
})), /*#__PURE__*/React.createElement(View, {
|
|
100
91
|
style: styles.bottomWrapper
|
|
101
|
-
}
|
|
92
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
93
|
+
style: styles.closeWrapper
|
|
94
|
+
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
95
|
+
onPress: () => {
|
|
96
|
+
destroy.call(this.displayManager);
|
|
97
|
+
}
|
|
98
|
+
}, /*#__PURE__*/React.createElement(Ionicons, {
|
|
99
|
+
name: "close-circle",
|
|
100
|
+
size: 48,
|
|
101
|
+
color: "white"
|
|
102
|
+
})))))
|
|
102
103
|
});
|
|
103
104
|
}, reject);
|
|
104
105
|
}).then(response => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Camera","Ionicons","BarCodeScanner","Platform","StyleSheet","TouchableOpacity","View","React","permissionManager","appDisplayManagerService","barcodeFormatOptions","opacity","styles","create","container","flex","flexDirection","closeWrapper","alignItems","
|
|
1
|
+
{"version":3,"names":["Camera","Ionicons","BarCodeScanner","Platform","StyleSheet","TouchableOpacity","View","React","permissionManager","appDisplayManagerService","barcodeFormatOptions","opacity","styles","create","container","flex","flexDirection","closeWrapper","justifyContent","alignItems","paddingBottom","topWrapper","backgroundColor","centerWrapper","leftWrapper","focused","rightWrapper","bottomWrapper","ScanService","constructor","displayManager","scanBarcode","params","format","barcodeFormat","OS","undefined","Promise","resolve","reject","requestPermissions","then","destroy","show","content","barCodeTypes","Constants","BarCodeType","result","call","absoluteFillObject","response","type","values","Object","index","indexOf","keys","text","data","cancelled","scanService"],"sources":["scan-service.tsx"],"sourcesContent":["import { Camera } from 'expo-camera';\nimport { Ionicons } from '@expo/vector-icons';\nimport { BarCodeScanner } from 'expo-barcode-scanner';\nimport { Platform, StyleSheet, TouchableOpacity, View } from 'react-native';\nimport React from 'react';\nimport { ScanInput, ScanOutput } from '@wavemaker/app-rn-runtime/variables/device/scan/scan.operation';\nimport { DisplayManager } from '@wavemaker/app-rn-runtime/core/display.manager';\nimport permissionManager from '@wavemaker/app-rn-runtime/runtime/services/device/permissions';\nimport appDisplayManagerService from '@wavemaker/app-rn-runtime/runtime/services/app-display-manager.service';\n\ninterface objectMap {\n [key: string]: string\n}\n\nconst barcodeFormatOptions: objectMap = {\n 'ALL': 'ALL',\n 'CODABAR': 'codabar',\n 'CODE_39': 'code39',\n 'CODE_93': 'code93',\n 'CODE_128': 'code128',\n 'DATA_MATRIX': 'datamatrix',\n 'EAN_8': 'ean8',\n 'EAN_13': 'ean13',\n 'ITF': 'itf14',\n 'PDF_417': 'pdf417',\n 'QR_CODE': 'qr',\n 'RSS14': 'rss14',\n 'RSS_EXPANDED': 'rssexpanded',\n 'UPC_E': 'upc_e',\n 'UPC_A': 'upc_a'\n};\nconst opacity = 'rgba(0, 0, 0, 0.6)';\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n flexDirection: 'column'\n },\n closeWrapper: {\n flex: 1,\n justifyContent: 'flex-end',\n alignItems: 'center',\n paddingBottom: 32\n },\n topWrapper: {\n flex: 2,\n backgroundColor: opacity\n },\n centerWrapper: {\n flex: 2,\n flexDirection: 'row'\n },\n leftWrapper: {\n flex: 2,\n backgroundColor: opacity\n },\n focused: {\n flex: 10\n },\n rightWrapper: {\n flex: 2,\n backgroundColor: opacity\n },\n bottomWrapper: {\n flex: 2,\n backgroundColor: opacity\n },\n});\n\nexport class ScanService {\n\n constructor(private displayManager: DisplayManager) {}\n\n public scanBarcode(params: ScanInput): Promise<ScanOutput> {\n const format = params?.barcodeFormat || 'ALL';\n const barcodeFormat: string | undefined = Platform.OS === 'ios' ? undefined : barcodeFormatOptions[format];\n return new Promise((resolve, reject) => {\n permissionManager.requestPermissions('camera').then(() => {\n const destroy = this.displayManager.show({\n content: (<Camera\n barCodeScannerSettings={barcodeFormat ? {\n barCodeTypes: [BarCodeScanner.Constants.BarCodeType[barcodeFormat]],\n }: undefined}\n onBarCodeScanned={(result) => {\n destroy.call(this.displayManager);\n resolve(result);\n }}\n style={StyleSheet.absoluteFillObject}\n >\n <View style={styles.topWrapper}>\n </View>\n <View style={styles.centerWrapper}>\n <View style={styles.leftWrapper}/>\n <View style={styles.focused}/>\n <View style={styles.rightWrapper}/>\n </View>\n <View style={styles.bottomWrapper}>\n \n <View style={styles.closeWrapper}>\n <TouchableOpacity\n onPress={() => {\n destroy.call(this.displayManager);\n }}>\n <Ionicons name='close-circle' size={48} color='white' />\n </TouchableOpacity>\n </View>\n </View>\n </Camera>)\n });\n }, reject)\n }).then((response: any) => {\n let format;\n if (response.type) {\n const values = Object.values(BarCodeScanner.Constants.BarCodeType);\n const index = values.indexOf(response.type);\n format = index > -1 ? Object.keys(BarCodeScanner.Constants.BarCodeType)[index] : '';\n }\n return Promise.resolve({\n text: response.data,\n format : format || response.type,\n cancelled : false\n });\n });\n }\n}\nconst scanService = new ScanService(appDisplayManagerService);\nexport default scanService;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,aAAa;AACpC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SAASC,QAAQ,EAAEC,UAAU,EAAEC,gBAAgB,EAAEC,IAAI,QAAQ,cAAc;AAC3E,OAAOC,KAAK,MAAM,OAAO;AAGzB,OAAOC,iBAAiB,MAAM,+DAA+D;AAC7F,OAAOC,wBAAwB,MAAM,wEAAwE;AAM7G,MAAMC,oBAA+B,GAAG;EACtC,KAAK,EAAE,KAAK;EACZ,SAAS,EAAE,SAAS;EACp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E,gBACF,oBAAC,QAAQ;YAAC,IAAI,EAAC,cAAc;YAAC,IAAI,EAAE,EAAG;YAAC,KAAK,EAAC;UAAO,EAAG,CACzC,CAChB,CACF;QAEX,CAAC,CAAC;MACJ,CAAC,EAAES,MAAM,CAAC;IACZ,CAAC,CAAC,CAACE,IAAI,CAAEU,QAAa,IAAK;MACzB,IAAIlB,MAAM;MACV,IAAIkB,QAAQ,CAACC,IAAI,EAAE;QACjB,MAAMC,MAAM,GAAGC,MAAM,CAACD,MAAM,CAACnD,cAAc,CAAC4C,SAAS,CAACC,WAAW,CAAC;QAClE,MAAMQ,KAAK,GAAGF,MAAM,CAACG,OAAO,CAACL,QAAQ,CAACC,IAAI,CAAC;QAC3CnB,MAAM,GAAGsB,KAAK,GAAG,CAAC,CAAC,GAAGD,MAAM,CAACG,IAAI,CAACvD,cAAc,CAAC4C,SAAS,CAACC,WAAW,CAAC,CAACQ,KAAK,CAAC,GAAG,EAAE;MACrF;MACA,OAAOlB,OAAO,CAACC,OAAO,CAAC;QACrBoB,IAAI,EAAEP,QAAQ,CAACQ,IAAI;QACnB1B,MAAM,EAAGA,MAAM,IAAIkB,QAAQ,CAACC,IAAI;QAChCQ,SAAS,EAAG;MACd,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF;AACA,MAAMC,WAAW,GAAG,IAAIjC,WAAW,CAACnB,wBAAwB,CAAC;AAC7D,eAAeoD,WAAW"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { LinearGradient as ExpoLinearGradient } from 'expo-linear-gradient';
|
|
6
|
+
import { Image, StyleSheet, View } from 'react-native';
|
|
7
|
+
import { isEmpty, isNil, isNumber, isString } from 'lodash-es';
|
|
8
|
+
import imageSizeEstimator from '@wavemaker/app-rn-runtime/core/imageSizeEstimator';
|
|
9
|
+
import { AssetConsumer } from '@wavemaker/app-rn-runtime/core/asset.provider';
|
|
10
|
+
const IMAGE_URL_REGEX = /url\(['|"]?(.+)['|"]?\)$/gi;
|
|
11
|
+
const LINEAT_GRADIENT_REGEX = /linear-gradient\((.+)\)$/gi;
|
|
12
|
+
const BACKGROUND_POSITION_REGEX = /([0-9%]+)[a-z]*\s*([0-9%]+)[a-z]*/g;
|
|
13
|
+
const BACKGROUND_SIZE_REGEX = /([0-9%]+)[a-z]*\s*([0-9%]+)[a-z]*/g;
|
|
14
|
+
export class LinearGradient extends React.Component {
|
|
15
|
+
constructor(props) {
|
|
16
|
+
super(props);
|
|
17
|
+
this.state = this.parse();
|
|
18
|
+
}
|
|
19
|
+
parse() {
|
|
20
|
+
let val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.value;
|
|
21
|
+
let state = {};
|
|
22
|
+
const splits = val.split(',').map(v => v.trim());
|
|
23
|
+
let angle = 0;
|
|
24
|
+
const locations = [];
|
|
25
|
+
if (splits[0].endsWith('deg')) {
|
|
26
|
+
angle = parseInt(splits[0].split('deg')[0]) % 360;
|
|
27
|
+
angle = angle < 0 ? 360 + angle : angle;
|
|
28
|
+
splits.shift();
|
|
29
|
+
}
|
|
30
|
+
angle += 90;
|
|
31
|
+
const delta = Math.round(Math.tan(angle * Math.PI / 180) * 100) / 100;
|
|
32
|
+
if (Math.abs(delta) > 1) {
|
|
33
|
+
state = {
|
|
34
|
+
end: {
|
|
35
|
+
x: -0.5 / delta + 0.5,
|
|
36
|
+
y: 0
|
|
37
|
+
},
|
|
38
|
+
start: {
|
|
39
|
+
x: 0.5 / delta + 0.5,
|
|
40
|
+
y: 1
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
} else {
|
|
44
|
+
state = {
|
|
45
|
+
start: {
|
|
46
|
+
x: 0,
|
|
47
|
+
y: -0.5 * delta + 0.5
|
|
48
|
+
},
|
|
49
|
+
end: {
|
|
50
|
+
x: 1,
|
|
51
|
+
y: 0.5 * delta + 0.5
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (angle >= 270 && angle <= 450) {
|
|
56
|
+
state = {
|
|
57
|
+
start: state.end,
|
|
58
|
+
end: state.start
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
state.colors = [];
|
|
62
|
+
state.locations = [];
|
|
63
|
+
splits.map(s => {
|
|
64
|
+
var _s$matchAll$next;
|
|
65
|
+
const p = (_s$matchAll$next = s.matchAll(/\s*([0-9]+)%/g).next()) === null || _s$matchAll$next === void 0 ? void 0 : _s$matchAll$next.value;
|
|
66
|
+
if (p) {
|
|
67
|
+
state.locations.push(parseInt(p[1]) / 100);
|
|
68
|
+
state.colors.push(s.replace(p[0], ''));
|
|
69
|
+
} else {
|
|
70
|
+
state.locations.push(null);
|
|
71
|
+
state.colors.push(s);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return state;
|
|
75
|
+
}
|
|
76
|
+
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
77
|
+
if (prevProps.value !== this.props.value) {
|
|
78
|
+
this.setState(this.parse());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
render() {
|
|
82
|
+
var _this$props$size, _this$props$style;
|
|
83
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
84
|
+
style: [{
|
|
85
|
+
borderWidth: 0,
|
|
86
|
+
overflow: 'hidden'
|
|
87
|
+
}, StyleSheet.absoluteFill, this.props.style]
|
|
88
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
89
|
+
style: [StyleSheet.absoluteFill, this.props.middle ? {
|
|
90
|
+
flexDirection: 'row',
|
|
91
|
+
justifyContent: 'center',
|
|
92
|
+
alignItems: 'center'
|
|
93
|
+
} : null]
|
|
94
|
+
}, /*#__PURE__*/React.createElement(ExpoLinearGradient, {
|
|
95
|
+
colors: this.state.colors,
|
|
96
|
+
locations: this.state.locations,
|
|
97
|
+
start: this.state.start,
|
|
98
|
+
end: this.state.end,
|
|
99
|
+
style: [(_this$props$size = this.props.size) !== null && _this$props$size !== void 0 && _this$props$size.width ? this.props.size : StyleSheet.absoluteFill, this.props.position, {
|
|
100
|
+
position: 'absolute',
|
|
101
|
+
borderRadius: (_this$props$style = this.props.style) === null || _this$props$style === void 0 ? void 0 : _this$props$style.borderRadius
|
|
102
|
+
}]
|
|
103
|
+
})), this.props.children);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export class BackgroundComponent extends React.Component {
|
|
107
|
+
constructor(props) {
|
|
108
|
+
super(props);
|
|
109
|
+
_defineProperty(this, "loadAsset", null);
|
|
110
|
+
this.state = {};
|
|
111
|
+
}
|
|
112
|
+
caluculateSize(imageSrc) {
|
|
113
|
+
if (isNumber(imageSrc)) {
|
|
114
|
+
const {
|
|
115
|
+
width,
|
|
116
|
+
height
|
|
117
|
+
} = Image.resolveAssetSource(imageSrc);
|
|
118
|
+
this.setState({
|
|
119
|
+
naturalImageWidth: width,
|
|
120
|
+
naturalImageHeight: height
|
|
121
|
+
});
|
|
122
|
+
} else if (!isNil(imageSrc)) {
|
|
123
|
+
imageSizeEstimator.getSize(imageSrc.uri, (width, height) => {
|
|
124
|
+
this.setState({
|
|
125
|
+
naturalImageWidth: width,
|
|
126
|
+
naturalImageHeight: height
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
getPositionAndSize() {
|
|
132
|
+
var _this$props$size2, _this$getGradient, _this$getGradient$val;
|
|
133
|
+
const result = {};
|
|
134
|
+
if (this.props.resizeMode) {
|
|
135
|
+
result.resizeMode = this.props.resizeMode;
|
|
136
|
+
return result;
|
|
137
|
+
} else if (this.props.position === 'center') {
|
|
138
|
+
result.resizeMode = 'center';
|
|
139
|
+
} else if (this.props.size === 'contain' || this.props.size === 'cover') {
|
|
140
|
+
result.resizeMode = this.props.size;
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
const size = (_this$props$size2 = this.props.size) === null || _this$props$size2 === void 0 ? void 0 : _this$props$size2.matchAll(BACKGROUND_SIZE_REGEX).next().value;
|
|
144
|
+
result.size = {};
|
|
145
|
+
if (size) {
|
|
146
|
+
result.size.width = size[1].endsWith('%') ? size[1] : parseInt(size[1]);
|
|
147
|
+
result.size.height = size[2].endsWith('%') ? size[2] : parseInt(size[2]);
|
|
148
|
+
}
|
|
149
|
+
if (!result.resizeMode && this.props.position) {
|
|
150
|
+
result.position = {};
|
|
151
|
+
const position = this.props.position.matchAll(BACKGROUND_POSITION_REGEX).next().value;
|
|
152
|
+
result.position.top = position[1].endsWith('%') ? position[1] : parseInt(position[1]);
|
|
153
|
+
result.position.left = position[2].endsWith('%') ? position[2] : parseInt(position[2]);
|
|
154
|
+
}
|
|
155
|
+
if (!((_this$getGradient = this.getGradient()) !== null && _this$getGradient !== void 0 && (_this$getGradient$val = _this$getGradient.value) !== null && _this$getGradient$val !== void 0 && _this$getGradient$val.length)) {
|
|
156
|
+
if (this.props.repeat === 'no-repeat') {
|
|
157
|
+
result.size.width = result.size.width || this.state.naturalImageWidth;
|
|
158
|
+
result.size.height = result.size.height || this.state.naturalImageHeight;
|
|
159
|
+
} else if (this.props.repeat === 'repeat-x') {
|
|
160
|
+
result.resizeMode = 'repeat';
|
|
161
|
+
result.size.width = result.size.width || '100%';
|
|
162
|
+
result.size.height = result.size.height || this.state.naturalImageHeight;
|
|
163
|
+
} else if (this.props.repeat === 'repeat-y') {
|
|
164
|
+
result.resizeMode = 'repeat';
|
|
165
|
+
result.size.width = result.size.width || this.state.naturalImageWidth;
|
|
166
|
+
result.size.height = result.size.height || '100%';
|
|
167
|
+
} else {
|
|
168
|
+
result.resizeMode = 'repeat';
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
renderLinearGradient(data) {
|
|
174
|
+
const psresult = this.getPositionAndSize();
|
|
175
|
+
return /*#__PURE__*/React.createElement(LinearGradient, {
|
|
176
|
+
value: data || '',
|
|
177
|
+
style: this.props.style,
|
|
178
|
+
size: psresult.size,
|
|
179
|
+
position: psresult.position,
|
|
180
|
+
middle: psresult.resizeMode === 'center'
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
184
|
+
if (prevProps.image !== this.props.image) {
|
|
185
|
+
this.setImage();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
componentDidMount() {
|
|
189
|
+
setTimeout(() => this.setImage(), 100);
|
|
190
|
+
}
|
|
191
|
+
setImage() {
|
|
192
|
+
var _this$props$image, _source;
|
|
193
|
+
let source = (_this$props$image = this.props.image) === null || _this$props$image === void 0 ? void 0 : _this$props$image.trim();
|
|
194
|
+
if ((_source = source) !== null && _source !== void 0 && _source.startsWith('url')) {
|
|
195
|
+
var _this$props$image2;
|
|
196
|
+
source = (_this$props$image2 = this.props.image) === null || _this$props$image2 === void 0 ? void 0 : _this$props$image2.matchAll(IMAGE_URL_REGEX).next().value[1];
|
|
197
|
+
}
|
|
198
|
+
if (this.loadAsset) {
|
|
199
|
+
source = this.loadAsset(source);
|
|
200
|
+
}
|
|
201
|
+
if (isString(source) && (source.startsWith('data:') || source.startsWith('http') || source.startsWith('file:'))) {
|
|
202
|
+
source = {
|
|
203
|
+
uri: source
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
this.caluculateSize(source);
|
|
207
|
+
this.setState({
|
|
208
|
+
imageSrc: source
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
getGradient() {
|
|
212
|
+
var _this$props$image3;
|
|
213
|
+
return (_this$props$image3 = this.props.image) === null || _this$props$image3 === void 0 ? void 0 : _this$props$image3.trim().matchAll(LINEAT_GRADIENT_REGEX).next();
|
|
214
|
+
}
|
|
215
|
+
renderImage() {
|
|
216
|
+
const psresult = this.getPositionAndSize();
|
|
217
|
+
return /*#__PURE__*/React.createElement(AssetConsumer, null, loadAsset => {
|
|
218
|
+
this.loadAsset = loadAsset;
|
|
219
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
220
|
+
style: [{
|
|
221
|
+
borderWidth: 0,
|
|
222
|
+
overflow: 'hidden'
|
|
223
|
+
}, StyleSheet.absoluteFill, this.props.style]
|
|
224
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
225
|
+
style: [StyleSheet.absoluteFill, this.props.position === 'center' ? {
|
|
226
|
+
flexDirection: 'row',
|
|
227
|
+
justifyContent: 'center',
|
|
228
|
+
alignItems: 'center'
|
|
229
|
+
} : null]
|
|
230
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
231
|
+
style: [{
|
|
232
|
+
position: 'absolute',
|
|
233
|
+
overflow: 'hidden'
|
|
234
|
+
}, psresult.position, isEmpty(psresult.size) ? StyleSheet.absoluteFill : psresult.size]
|
|
235
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
236
|
+
source: this.state.imageSrc,
|
|
237
|
+
resizeMode: psresult.resizeMode || 'cover',
|
|
238
|
+
style: [{
|
|
239
|
+
width: '100%',
|
|
240
|
+
height: '100%'
|
|
241
|
+
}, isEmpty(psresult.size) ? {
|
|
242
|
+
minWidth: this.state.naturalImageWidth,
|
|
243
|
+
minHeight: this.state.naturalImageHeight
|
|
244
|
+
} : null]
|
|
245
|
+
}))));
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
render() {
|
|
249
|
+
var _gradientData$value;
|
|
250
|
+
const gradientData = this.getGradient();
|
|
251
|
+
if (gradientData !== null && gradientData !== void 0 && (_gradientData$value = gradientData.value) !== null && _gradientData$value !== void 0 && _gradientData$value.length) {
|
|
252
|
+
return this.renderLinearGradient(gradientData.value[1]);
|
|
253
|
+
} else if (this.props.image) {
|
|
254
|
+
return this.renderImage();
|
|
255
|
+
}
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=background.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","LinearGradient","ExpoLinearGradient","Image","StyleSheet","View","isEmpty","isNil","isNumber","isString","imageSizeEstimator","AssetConsumer","IMAGE_URL_REGEX","LINEAT_GRADIENT_REGEX","BACKGROUND_POSITION_REGEX","BACKGROUND_SIZE_REGEX","Component","constructor","props","state","parse","val","value","splits","split","map","v","trim","angle","locations","endsWith","parseInt","shift","delta","Math","round","tan","PI","abs","end","x","y","start","colors","s","p","matchAll","next","push","replace","componentDidUpdate","prevProps","prevState","snapshot","setState","render","borderWidth","overflow","absoluteFill","style","middle","flexDirection","justifyContent","alignItems","size","width","position","borderRadius","children","BackgroundComponent","caluculateSize","imageSrc","height","resolveAssetSource","naturalImageWidth","naturalImageHeight","getSize","uri","getPositionAndSize","result","resizeMode","top","left","getGradient","length","repeat","renderLinearGradient","data","psresult","image","setImage","componentDidMount","setTimeout","source","startsWith","loadAsset","renderImage","minWidth","minHeight","gradientData"],"sources":["background.component.tsx"],"sourcesContent":["import * as React from 'react';\nimport { LinearGradient as ExpoLinearGradient, LinearGradientPoint } from 'expo-linear-gradient';\nimport { Image, StyleSheet, View, ViewStyle } from 'react-native';\nimport { isEmpty, isNil, isNumber, isString } from 'lodash-es';\nimport imageSizeEstimator from '@wavemaker/app-rn-runtime/core/imageSizeEstimator';\nimport { AssetConsumer } from '@wavemaker/app-rn-runtime/core/asset.provider';\n\nexport interface LinearGradientProps {\n value: string;\n children: any;\n style?: ViewStyle;\n size?: ViewStyle;\n position?: ViewStyle;\n middle?: boolean;\n}\n\nexport interface LinearGradientState {\n colors: string[];\n locations: number[];\n start: LinearGradientPoint;\n end: LinearGradientPoint;\n}\n\nconst IMAGE_URL_REGEX = /url\\(['|\"]?(.+)['|\"]?\\)$/gi;\nconst LINEAT_GRADIENT_REGEX = /linear-gradient\\((.+)\\)$/gi;\nconst BACKGROUND_POSITION_REGEX = /([0-9%]+)[a-z]*\\s*([0-9%]+)[a-z]*/g;\nconst BACKGROUND_SIZE_REGEX = /([0-9%]+)[a-z]*\\s*([0-9%]+)[a-z]*/g;\n\nexport class LinearGradient extends React.Component<LinearGradientProps, LinearGradientState> {\n\n constructor(props: LinearGradientProps) {\n super(props);\n this.state = this.parse();\n }\n\n parse(val = this.props.value) {\n let state = {} as LinearGradientState;\n const splits = val.split(',').map(v => v.trim());\n let angle = 0;\n const locations: LinearGradientPoint[] = [];\n if (splits[0].endsWith('deg')) {\n angle = (parseInt(splits[0].split('deg')[0]))%360;\n angle = angle < 0 ? (360 + angle) : angle;\n splits.shift();\n }\n angle += 90;\n const delta = Math.round(Math.tan((angle * Math.PI) / 180) * 100)/100;\n if (Math.abs(delta) > 1) {\n state = {\n end: {\n x: -0.5 / delta + 0.5,\n y: 0\n },\n start: {\n x: 0.5 / delta + 0.5,\n y: 1\n }\n } as LinearGradientState;\n } else {\n state = {\n start: {\n x: 0,\n y: -0.5 * delta + 0.5\n },\n end: {\n x: 1,\n y: 0.5 * delta + 0.5\n }\n } as LinearGradientState;\n }\n if (angle >= 270 && angle <= 450) {\n state = {\n start : state.end,\n end: state.start\n } as LinearGradientState;\n }\n state.colors = [];\n state.locations = [];\n splits.map(s => {\n const p = s.matchAll(/\\s*([0-9]+)%/g).next()?.value;\n if (p) {\n state.locations.push(parseInt(p[1]) / 100);\n state.colors.push(s.replace(p[0], ''));\n } else {\n state.locations.push(null as any);\n state.colors.push(s);\n }\n });\n return state;\n }\n\n componentDidUpdate(prevProps: Readonly<LinearGradientProps>, prevState: Readonly<{}>, snapshot?: any): void {\n if (prevProps.value !== this.props.value) {\n this.setState(this.parse());\n }\n }\n \n\n public render() {\n return (\n <View style={[{borderWidth: 0, overflow: 'hidden'}, StyleSheet.absoluteFill, this.props.style]}>\n <View style={[\n StyleSheet.absoluteFill, this.props.middle ? {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center'\n } : null]}>\n <ExpoLinearGradient\n colors={this.state.colors}\n locations={this.state.locations}\n start={this.state.start}\n end={this.state.end}\n style={[\n this.props.size?.width ? this.props.size : StyleSheet.absoluteFill,\n this.props.position,\n {position: 'absolute', borderRadius: this.props.style?.borderRadius}\n ]}\n />\n </View>\n {this.props.children}\n </View>\n );\n }\n}\n\nexport interface BackgroundProps {\n image?: string;\n position?: string;\n children?: any;\n resizeMode?: string;\n repeat?: string;\n style?: ViewStyle;\n size: string;\n}\n\nexport interface BackgroundState {\n imageSrc: any;\n naturalImageWidth: number,\n naturalImageHeight: number\n}\n\nexport class BackgroundComponent extends React.Component<BackgroundProps, BackgroundState> {\n\n private loadAsset: (path: string) => number | string = null as any;\n\n constructor(props: BackgroundProps) {\n super(props);\n this.state = {} as BackgroundState;\n }\n\n public caluculateSize(imageSrc: any) {\n if (isNumber(imageSrc)) {\n const {width, height} = Image.resolveAssetSource(imageSrc);\n this.setState({\n naturalImageWidth: width,\n naturalImageHeight: height\n } as BackgroundState);\n } else if (!isNil(imageSrc)) {\n imageSizeEstimator.getSize(imageSrc.uri, (width: number, height: number) => {\n this.setState({\n naturalImageWidth: width,\n naturalImageHeight: height\n } as BackgroundState);\n });\n }\n }\n\n public getPositionAndSize() {\n const result: {\n resizeMode? : string,\n position?: {\n top?: string | number,\n left?: string | number,\n },\n size?: {\n width?: string | number,\n height? : string | number\n }\n } = {} as any;\n if (this.props.resizeMode) {\n result.resizeMode = this.props.resizeMode;\n return result;\n } else if (this.props.position === 'center') {\n result.resizeMode = 'center';\n } else if (this.props.size === 'contain' || this.props.size === 'cover') {\n result.resizeMode = this.props.size;\n return result;\n }\n const size = this.props.size?.matchAll(BACKGROUND_SIZE_REGEX).next().value;\n result.size = {};\n if (size) {\n result.size.width = size[1].endsWith('%') ? size[1] : parseInt(size[1]);\n result.size.height = size[2].endsWith('%') ? size[2] : parseInt(size[2]);\n }\n if (!result.resizeMode && this.props.position) {\n result.position = {};\n const position = this.props.position.matchAll(BACKGROUND_POSITION_REGEX).next().value;\n result.position.top = position[1].endsWith('%') ? position[1] : parseInt(position[1]);\n result.position.left = position[2].endsWith('%') ? position[2] : parseInt(position[2]);\n }\n if (!this.getGradient()?.value?.length) {\n if (this.props.repeat === 'no-repeat') {\n result.size.width = result.size.width || this.state.naturalImageWidth; \n result.size.height = result.size.height || this.state.naturalImageHeight; \n } else if (this.props.repeat === 'repeat-x') {\n result.resizeMode = 'repeat';\n result.size.width = result.size.width || '100%'; \n result.size.height = result.size.height || this.state.naturalImageHeight; \n } else if (this.props.repeat === 'repeat-y') {\n result.resizeMode = 'repeat';\n result.size.width = result.size.width || this.state.naturalImageWidth; \n result.size.height = result.size.height || '100%'; \n } else {\n result.resizeMode = 'repeat';\n }\n }\n return result;\n }\n\n public renderLinearGradient(data: string) {\n const psresult = this.getPositionAndSize();\n return (\n <LinearGradient\n value={data || ''}\n style={this.props.style}\n size={psresult.size}\n position={psresult.position}\n middle={psresult.resizeMode === 'center'}>\n </LinearGradient>\n );\n }\n\n componentDidUpdate(prevProps: Readonly<BackgroundProps>, prevState: Readonly<{}>, snapshot?: any): void {\n if (prevProps.image !== this.props.image) {\n this.setImage();\n }\n }\n\n componentDidMount(): void {\n setTimeout(() => this.setImage(), 100);\n }\n\n setImage() {\n let source = this.props.image?.trim() as any;\n if (source?.startsWith('url')) {\n source = this.props.image?.matchAll(IMAGE_URL_REGEX).next().value[1];\n }\n if (this.loadAsset) {\n source = this.loadAsset(source);\n }\n if (isString(source) && (\n source.startsWith('data:') ||\n source.startsWith('http') || \n source.startsWith('file:'))) {\n source = {\n uri: source\n };\n }\n this.caluculateSize(source);\n this.setState({\n imageSrc: source\n } as BackgroundState);\n }\n\n public getGradient() {\n return this.props.image?.trim().matchAll(LINEAT_GRADIENT_REGEX).next();\n }\n\n public renderImage() {\n const psresult = this.getPositionAndSize();\n return (\n <AssetConsumer>\n {(loadAsset) => {\n this.loadAsset = loadAsset;\n return (<View style={[{borderWidth: 0, overflow: 'hidden'}, StyleSheet.absoluteFill, this.props.style]}>\n <View style={[\n StyleSheet.absoluteFill, this.props.position === 'center' ? {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center'\n } : null]}>\n <View style={[\n { position: 'absolute', overflow: 'hidden' },\n psresult.position,\n isEmpty(psresult.size) ? StyleSheet.absoluteFill : psresult.size\n ]}>\n <Image\n source={this.state.imageSrc}\n resizeMode={psresult.resizeMode as any || 'cover'}\n style={[\n { \n width: '100%',\n height: '100%'\n }, \n isEmpty(psresult.size) ? {\n minWidth: this.state.naturalImageWidth,\n minHeight: this.state.naturalImageHeight\n } : null\n ]}/>\n </View>\n </View>\n </View>);\n }}\n </AssetConsumer>\n );\n }\n\n public render() {\n const gradientData = this.getGradient();\n if (gradientData?.value?.length) {\n return this.renderLinearGradient(gradientData.value[1]);\n } else if (this.props.image) {\n return this.renderImage();\n }\n return null;\n }\n}\n\n"],"mappings":";;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,cAAc,IAAIC,kBAAkB,QAA6B,sBAAsB;AAChG,SAASC,KAAK,EAAEC,UAAU,EAAEC,IAAI,QAAmB,cAAc;AACjE,SAASC,OAAO,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,WAAW;AAC9D,OAAOC,kBAAkB,MAAM,mDAAmD;AAClF,SAASC,aAAa,QAAQ,+CAA+C;AAkB7E,MAAMC,eAAe,GAAG,4BAA4B;AACpD,MAAMC,qBAAqB,GAAG,4BAA4B;AAC1D,MAAMC,yBAAyB,GAAG,oCAAoC;AACtE,MAAMC,qBAAqB,GAAG,oCAAoC;AAElE,OAAO,MAAMd,cAAc,SAASD,KAAK,CAACgB,SAAS,CAA2C;EAE1FC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E,OAAO,CAACkF,QAAQ,CAACxB,IAAI,CAAC,GAAG;UACrBiC,QAAQ,EAAE,IAAI,CAAC9E,KAAK,CAACuD,iBAAiB;UACtCwB,SAAS,EAAE,IAAI,CAAC/E,KAAK,CAACwD;QAC1B,CAAC,GAAG,IAAI;MACV,EAAE,CACL,CACJ,CACJ;IACP,CAAC,CACW;EAEpB;EAEOpB,MAAM,GAAG;IAAA;IACZ,MAAM4C,YAAY,GAAG,IAAI,CAAChB,WAAW,EAAE;IACvC,IAAIgB,YAAY,aAAZA,YAAY,sCAAZA,YAAY,CAAE7E,KAAK,gDAAnB,oBAAqB8D,MAAM,EAAE;MAC7B,OAAO,IAAI,CAACE,oBAAoB,CAACa,YAAY,CAAC7E,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC,MAAM,IAAI,IAAI,CAACJ,KAAK,CAACuE,KAAK,EAAE;MACzB,OAAO,IAAI,CAACO,WAAW,EAAE;IAC7B;IACA,OAAO,IAAI;EACf;AACJ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isNumber, isString } from 'lodash-es';
|
|
2
|
+
import * as Font from 'expo-font';
|
|
2
3
|
const isColor = c => true;
|
|
3
4
|
const isStringOrNumber = v => isNumber(v) || isString(v);
|
|
4
5
|
const isIn = function () {
|
|
@@ -108,12 +109,8 @@ const STYLE_PROP_TYPE_INFO = {
|
|
|
108
109
|
isValid: isIn('solid', 'dotted', 'dashed'),
|
|
109
110
|
ref: 'https://reactnative.dev/docs/view-style-props#borderstyle'
|
|
110
111
|
},
|
|
111
|
-
borderTopColor: {
|
|
112
|
-
isValid: isNumber,
|
|
113
|
-
ref: 'https://reactnative.dev/docs/view-style-props#bordertopcolor'
|
|
114
|
-
},
|
|
115
112
|
borderTopEndRadius: {
|
|
116
|
-
isValid:
|
|
113
|
+
isValid: isColor,
|
|
117
114
|
ref: 'https://reactnative.dev/docs/view-style-props#bordertopendradius'
|
|
118
115
|
},
|
|
119
116
|
borderTopLeftRadius: {
|
|
@@ -189,7 +186,8 @@ const STYLE_PROP_TYPE_INFO = {
|
|
|
189
186
|
ref: 'https://reactnative.dev/docs/layout-props#flexwrap'
|
|
190
187
|
},
|
|
191
188
|
fontFamily: {
|
|
192
|
-
isValid:
|
|
189
|
+
isValid: v => Font.isLoaded(v),
|
|
190
|
+
errorMsg: v => `Font '${v}' is not loaded. Font family names are case-sensitive. Please add font either in theme or app.`,
|
|
193
191
|
ref: 'https://reactnative.dev/docs/text-style-props#fontfamily'
|
|
194
192
|
},
|
|
195
193
|
fontSize: {
|
|
@@ -433,4 +431,11 @@ export const isValidStyleProp = (name, value) => {
|
|
|
433
431
|
const info = STYLE_PROP_TYPE_INFO[name];
|
|
434
432
|
return !info || info.isValid(value);
|
|
435
433
|
};
|
|
434
|
+
export const getErrorMessage = (name, value) => {
|
|
435
|
+
const info = STYLE_PROP_TYPE_INFO[name];
|
|
436
|
+
if (info && info.errorMsg) {
|
|
437
|
+
return info.errorMsg(value);
|
|
438
|
+
}
|
|
439
|
+
return `'${value}' is not a valid value to '${name}'.`;
|
|
440
|
+
};
|
|
436
441
|
//# sourceMappingURL=style-prop.validator.js.map
|