@unif/react-native-camera 1.0.10 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/camera/Camera.js +40 -7
- package/lib/commonjs/camera/Camera.js.map +1 -1
- package/lib/commonjs/camera/footer/Footer.js +3 -2
- package/lib/commonjs/camera/footer/Footer.js.map +1 -1
- package/lib/commonjs/camera/preview/PreView.js +6 -2
- package/lib/commonjs/camera/preview/PreView.js.map +1 -1
- package/lib/commonjs/camera/preview/PreViewContainer.js +3 -2
- package/lib/commonjs/camera/preview/PreViewContainer.js.map +1 -1
- package/lib/commonjs/camera/preview/PreviewFooter.js +1 -1
- package/lib/commonjs/camera/preview/SinglePre.js +7 -7
- package/lib/commonjs/camera/preview/SinglePre.js.map +1 -1
- package/lib/commonjs/camera/setup/SetUp.js +6 -10
- package/lib/commonjs/camera/setup/SetUp.js.map +1 -1
- package/lib/commonjs/camera/watermark/Render.js +110 -0
- package/lib/commonjs/camera/watermark/Render.js.map +1 -0
- package/lib/commonjs/camera/watermark/ViewShotWatermark.js +88 -0
- package/lib/commonjs/camera/watermark/ViewShotWatermark.js.map +1 -0
- package/lib/commonjs/camera/watermark/index.js +21 -0
- package/lib/commonjs/camera/watermark/index.js.map +1 -0
- package/lib/commonjs/utils/common.js +3 -2
- package/lib/commonjs/utils/common.js.map +1 -1
- package/lib/commonjs/utils/index.js +22 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/interface.js +1 -1
- package/lib/commonjs/utils/render-item.js +3 -2
- package/lib/commonjs/utils/render-item.js.map +1 -1
- package/lib/commonjs/utils/util.js +23 -0
- package/lib/commonjs/utils/util.js.map +1 -0
- package/lib/commonjs/utils/watermark.js +43 -0
- package/lib/commonjs/utils/watermark.js.map +1 -0
- package/lib/module/camera/Camera.js +41 -7
- package/lib/module/camera/Camera.js.map +1 -1
- package/lib/module/camera/footer/Footer.js +4 -3
- package/lib/module/camera/footer/Footer.js.map +1 -1
- package/lib/module/camera/index.js +1 -1
- package/lib/module/camera/preview/PreView.js +6 -2
- package/lib/module/camera/preview/PreView.js.map +1 -1
- package/lib/module/camera/preview/PreViewContainer.js +3 -2
- package/lib/module/camera/preview/PreViewContainer.js.map +1 -1
- package/lib/module/camera/preview/PreviewFooter.js +1 -1
- package/lib/module/camera/preview/SinglePre.js +7 -7
- package/lib/module/camera/preview/SinglePre.js.map +1 -1
- package/lib/module/camera/setup/SetUp.js +6 -10
- package/lib/module/camera/setup/SetUp.js.map +1 -1
- package/lib/module/camera/watermark/Render.js +102 -0
- package/lib/module/camera/watermark/Render.js.map +1 -0
- package/lib/module/camera/watermark/ViewShotWatermark.js +78 -0
- package/lib/module/camera/watermark/ViewShotWatermark.js.map +1 -0
- package/lib/module/camera/watermark/index.js +13 -0
- package/lib/module/camera/watermark/index.js.map +1 -0
- package/lib/module/utils/common.js +2 -1
- package/lib/module/utils/common.js.map +1 -1
- package/lib/module/utils/index.js +3 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/interface.js +1 -1
- package/lib/module/utils/render-item.js +3 -2
- package/lib/module/utils/render-item.js.map +1 -1
- package/lib/module/utils/util.js +16 -0
- package/lib/module/utils/util.js.map +1 -0
- package/lib/module/utils/watermark.js +33 -0
- package/lib/module/utils/watermark.js.map +1 -0
- package/lib/typescript/src/camera/Camera.d.ts.map +1 -1
- package/lib/typescript/src/camera/footer/Footer.d.ts.map +1 -1
- package/lib/typescript/src/camera/preview/PreView.d.ts.map +1 -1
- package/lib/typescript/src/camera/preview/SinglePre.d.ts +2 -0
- package/lib/typescript/src/camera/preview/SinglePre.d.ts.map +1 -1
- package/lib/typescript/src/camera/watermark/Render.d.ts +26 -0
- package/lib/typescript/src/camera/watermark/Render.d.ts.map +1 -0
- package/lib/typescript/src/camera/watermark/ViewShotWatermark.d.ts +33 -0
- package/lib/typescript/src/camera/watermark/ViewShotWatermark.d.ts.map +1 -0
- package/lib/typescript/src/camera/watermark/index.d.ts +4 -0
- package/lib/typescript/src/camera/watermark/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/common.d.ts +1 -0
- package/lib/typescript/src/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +2 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/interface.d.ts +10 -0
- package/lib/typescript/src/utils/interface.d.ts.map +1 -1
- package/lib/typescript/src/utils/render-item.d.ts.map +1 -1
- package/lib/typescript/src/utils/util.d.ts +2 -0
- package/lib/typescript/src/utils/util.d.ts.map +1 -0
- package/lib/typescript/src/utils/watermark.d.ts +11 -0
- package/lib/typescript/src/utils/watermark.d.ts.map +1 -0
- package/package.json +12 -5
- package/src/camera/Camera.tsx +144 -104
- package/src/camera/footer/Footer.tsx +3 -1
- package/src/camera/index.tsx +1 -1
- package/src/camera/preview/PreView.tsx +4 -2
- package/src/camera/preview/PreViewContainer.tsx +2 -1
- package/src/camera/preview/PreviewFooter.tsx +1 -1
- package/src/camera/preview/SinglePre.tsx +5 -10
- package/src/camera/setup/SetUp.tsx +4 -3
- package/src/camera/watermark/Render.tsx +128 -0
- package/src/camera/watermark/ViewShotWatermark.tsx +81 -0
- package/src/camera/watermark/index.tsx +12 -0
- package/src/utils/common.ts +3 -1
- package/src/utils/index.ts +3 -1
- package/src/utils/interface.ts +12 -1
- package/src/utils/render-item.tsx +3 -2
- package/src/utils/util.ts +15 -0
- package/src/utils/watermark.ts +45 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type CustomPhotoFile, type WatermarkType } from '../../utils';
|
|
3
|
+
declare const ViewShotWatermark: React.FC<{
|
|
4
|
+
data?: CustomPhotoFile;
|
|
5
|
+
watermark?: WatermarkType;
|
|
6
|
+
onChange: (photo: CustomPhotoFile) => void;
|
|
7
|
+
}>;
|
|
8
|
+
export default ViewShotWatermark;
|
|
9
|
+
export declare const styles: {
|
|
10
|
+
container: {
|
|
11
|
+
flex: number;
|
|
12
|
+
position: "absolute";
|
|
13
|
+
left: number;
|
|
14
|
+
right: number;
|
|
15
|
+
top: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
backgroundColor: string;
|
|
18
|
+
zIndex: number;
|
|
19
|
+
};
|
|
20
|
+
footer: {
|
|
21
|
+
position: "absolute";
|
|
22
|
+
left: number;
|
|
23
|
+
right: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
zIndex: number;
|
|
26
|
+
};
|
|
27
|
+
text: {
|
|
28
|
+
color: string;
|
|
29
|
+
textAlign: "center";
|
|
30
|
+
fontSize: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=ViewShotWatermark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewShotWatermark.d.ts","sourceRoot":"","sources":["../../../../../src/camera/watermark/ViewShotWatermark.tsx"],"names":[],"mappings":"AASA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAGtC,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IAChC,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;CAC5C,CA6BA,CAAC;AAEF,eAAe,iBAAiB,CAAC;AAEjC,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;CAuBjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/camera/watermark/index.tsx"],"names":[],"mappings":"AASA,OAAO,eAAe,MAAM,UAAU,CAAC;AACvC,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -4,6 +4,7 @@ export declare const SCREEN_WIDTH: number;
|
|
|
4
4
|
export declare const CAPTURE_BUTTON_SIZE = 78;
|
|
5
5
|
export declare const MAX_ZOOM_FACTOR = 10;
|
|
6
6
|
export declare const CONTROL_BUTTON_SIZE = 44;
|
|
7
|
+
export declare const MAX_ZINDEX = 99999;
|
|
7
8
|
export declare const CameraModeList: CameraModeListItem[];
|
|
8
9
|
export declare const CameraModeCommonData: CameraModeCommonType;
|
|
9
10
|
export declare const SingleData: CameraModeCommonType & CameraModeImageType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/utils/common.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACZ,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,eAAO,MAAM,YAAY,QAAiC,CAAC;AAG3D,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,eAAe,KAAK,CAAC;AAGlC,eAAO,MAAM,mBAAmB,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/utils/common.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACZ,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,eAAO,MAAM,YAAY,QAAiC,CAAC;AAG3D,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,eAAe,KAAK,CAAC;AAGlC,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,eAAO,MAAM,UAAU,QAAQ,CAAC;AAGhC,eAAO,MAAM,cAAc,EAAE,kBAAkB,EAI9C,CAAC;AAGF,eAAO,MAAM,oBAAoB,EAAE,oBAIlC,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,oBAAoB,GAAG,mBAG/C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,oBAAoB,GAAG,mBAGnD,CAAC;AAGF,eAAO,MAAM,SAAS,EAAE,oBAAoB,GAAG,kBAK9C,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,WAGzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAQA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAQA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
|
|
@@ -29,6 +29,7 @@ export type DataRetainedModeType = 'retain' | 'clear';
|
|
|
29
29
|
export type CameraProps = {
|
|
30
30
|
cameraMode: CameraModeType[];
|
|
31
31
|
dataRetainedMode: DataRetainedModeType;
|
|
32
|
+
watermark?: WatermarkType;
|
|
32
33
|
};
|
|
33
34
|
export type CameraModeListItem = {
|
|
34
35
|
label: string;
|
|
@@ -52,6 +53,7 @@ export interface CameraRef {
|
|
|
52
53
|
import type { PhotoFile } from 'react-native-vision-camera';
|
|
53
54
|
export interface CustomPhotoFile extends PhotoFile {
|
|
54
55
|
mode: CameraMode;
|
|
56
|
+
frontTime: number;
|
|
55
57
|
}
|
|
56
58
|
export interface ConfirmConfigProps {
|
|
57
59
|
text?: string;
|
|
@@ -61,4 +63,12 @@ export interface ConfirmRef {
|
|
|
61
63
|
open: (config?: ConfirmConfigProps) => Promise<boolean>;
|
|
62
64
|
close: () => void;
|
|
63
65
|
}
|
|
66
|
+
export type WatermarkType = {
|
|
67
|
+
content?: string[];
|
|
68
|
+
image?: string;
|
|
69
|
+
gap?: number[];
|
|
70
|
+
rotate?: number;
|
|
71
|
+
width?: number;
|
|
72
|
+
height?: number;
|
|
73
|
+
};
|
|
64
74
|
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/utils/interface.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAC1C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC;AAE9C,oBAAY,cAAc;IACxB,YAAY,iBAAO;IACnB,QAAQ,iBAAO;IACf,OAAO,iBAAO;CACf;AACD,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,cAAc,CAAC;AAErD,SAAS;AACT,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,SAAS;AACT,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,SAAS;AACT,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AACnD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,SAAS;AACT,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAC/C,mBAAmB,GACnB,kBAAkB,CAAC;AAErB,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,OAA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CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-item.d.ts","sourceRoot":"","sources":["../../../../src/utils/render-item.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"render-item.d.ts","sourceRoot":"","sources":["../../../../src/utils/render-item.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAM3E,UAAU,OAAO;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,UAAU,qCAKlB,OAAO,KAAQ,kBAAkB,CAAC,GAAG,CAYvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/utils/util.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,SAAS,QAAS,MAAM,WAMpC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CanvasRenderingContext2D } from 'react-native-canvas';
|
|
2
|
+
export declare const lastPx: (v: number) => number;
|
|
3
|
+
export declare const getMeasure: (ctx: CanvasRenderingContext2D, content: string) => Promise<{
|
|
4
|
+
width: any;
|
|
5
|
+
height: any;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const getContentMeasure: (ctx: CanvasRenderingContext2D, content: string[]) => Promise<{
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=watermark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watermark.d.ts","sourceRoot":"","sources":["../../../../src/utils/watermark.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,eAAO,MAAM,MAAM,MAAO,MAAM,WACiC,CAAC;AAElE,eAAO,MAAM,UAAU,QAChB,wBAAwB,WACpB,MAAM;;;EAOhB,CAAC;AAEF,eAAO,MAAM,iBAAiB,QACvB,wBAAwB,WACpB,MAAM,EAAE;;;EAgBlB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unif/react-native-camera",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "camera",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"@types/jest": "^28.1.2",
|
|
61
61
|
"@types/react": "~17.0.21",
|
|
62
62
|
"@types/react-native": "0.70.0",
|
|
63
|
+
"@types/react-native-canvas": "^0.1.14",
|
|
63
64
|
"commitlint": "^17.0.2",
|
|
64
65
|
"del-cli": "^5.0.0",
|
|
65
66
|
"eslint": "^8.4.1",
|
|
@@ -71,11 +72,14 @@
|
|
|
71
72
|
"react": "18.2.0",
|
|
72
73
|
"react-native": "0.74.6",
|
|
73
74
|
"react-native-builder-bob": "^0.20.0",
|
|
75
|
+
"react-native-canvas": "0.1.40",
|
|
74
76
|
"react-native-gesture-handler": "^2.21.2",
|
|
75
77
|
"react-native-reanimated": "^3.16.5",
|
|
76
78
|
"react-native-reanimated-carousel": "^4.0.0-canary.22",
|
|
77
79
|
"react-native-safe-area-context": "5.0.0",
|
|
80
|
+
"react-native-view-shot": "^4.0.3",
|
|
78
81
|
"react-native-vision-camera": "^4.6.3",
|
|
82
|
+
"react-native-webview": "^13.0.0",
|
|
79
83
|
"release-it": "^15.0.0",
|
|
80
84
|
"turbo": "^1.10.7",
|
|
81
85
|
"typescript": "^5.0.2"
|
|
@@ -84,13 +88,16 @@
|
|
|
84
88
|
"@types/react": "17.0.21"
|
|
85
89
|
},
|
|
86
90
|
"peerDependencies": {
|
|
87
|
-
"react": "
|
|
88
|
-
"react-native": "
|
|
91
|
+
"react": ">=18.2.0",
|
|
92
|
+
"react-native": ">=0.74.0",
|
|
93
|
+
"react-native-canvas": "*",
|
|
89
94
|
"react-native-gesture-handler": ">=2.21.0",
|
|
90
95
|
"react-native-reanimated": ">=3.9.0",
|
|
91
96
|
"react-native-reanimated-carousel": ">=4.0.0",
|
|
92
|
-
"react-native-safe-area-context": "
|
|
93
|
-
"react-native-
|
|
97
|
+
"react-native-safe-area-context": "*",
|
|
98
|
+
"react-native-view-shot": "^4.0.3",
|
|
99
|
+
"react-native-vision-camera": ">=4.0.0",
|
|
100
|
+
"react-native-webview": "*"
|
|
94
101
|
},
|
|
95
102
|
"workspaces": [
|
|
96
103
|
"example"
|
package/src/camera/Camera.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: 刘利军
|
|
3
|
-
* @Date: 2024-
|
|
3
|
+
* @Date: 2024-12-02 13:48:40
|
|
4
4
|
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-
|
|
5
|
+
* @LastEditTime: 2024-12-30 13:09:30
|
|
6
6
|
* @Description:
|
|
7
7
|
* @PageName:
|
|
8
8
|
*/
|
|
9
|
+
|
|
9
10
|
import { StyleSheet } from 'react-native';
|
|
10
11
|
import React, { useEffect, useRef, useState } from 'react';
|
|
11
12
|
import {
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
useCameraDevice,
|
|
14
15
|
useCameraFormat,
|
|
15
16
|
} from 'react-native-vision-camera';
|
|
17
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
16
18
|
import NoCamera from './NoCamera';
|
|
17
19
|
|
|
18
20
|
import {
|
|
@@ -28,6 +30,7 @@ import { SetUp } from './setup';
|
|
|
28
30
|
import { PreView, PreViewContainer, SinglePre } from './preview';
|
|
29
31
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
30
32
|
import { useConfirm } from '../hooks';
|
|
33
|
+
import { ViewShotWatermark, WaterMarkRender } from './watermark';
|
|
31
34
|
|
|
32
35
|
export const PhotoAspectRatio: { [key: number]: number } = {
|
|
33
36
|
4: 4 / 3,
|
|
@@ -48,6 +51,7 @@ const Camera: React.FC<{
|
|
|
48
51
|
const [isActive, setIsActive] = useState(false);
|
|
49
52
|
const [preVis, setPreVis] = useState(false);
|
|
50
53
|
|
|
54
|
+
const [watermarkUriVis, setWatermarkUriVis] = useState(false);
|
|
51
55
|
const device = useCameraDevice(position, {
|
|
52
56
|
physicalDevices: [
|
|
53
57
|
'ultra-wide-angle-camera',
|
|
@@ -109,117 +113,153 @@ const Camera: React.FC<{
|
|
|
109
113
|
message: '保存成功',
|
|
110
114
|
});
|
|
111
115
|
};
|
|
116
|
+
const openViewShotWatermark = () => {
|
|
117
|
+
setIsActive((val) => !val);
|
|
118
|
+
setWatermarkUriVis((val) => !val);
|
|
119
|
+
};
|
|
112
120
|
return (
|
|
113
121
|
<GestureHandlerRootView>
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (val === 'default') {
|
|
142
|
-
setZoom(device.neutralZoom);
|
|
143
|
-
}
|
|
144
|
-
}}
|
|
145
|
-
/>
|
|
146
|
-
<Footer
|
|
147
|
-
cameraMode={cameraMode}
|
|
148
|
-
photos={photos}
|
|
149
|
-
backPress={async () => {
|
|
150
|
-
if (photos.length > 0) {
|
|
151
|
-
const isBack = await confirmApi.open({
|
|
152
|
-
text: '返回会清空已拍摄数据,请确认!',
|
|
153
|
-
});
|
|
154
|
-
if (isBack) {
|
|
155
|
-
back();
|
|
122
|
+
<SafeAreaProvider>
|
|
123
|
+
<VisionCamera
|
|
124
|
+
zoom={zoom}
|
|
125
|
+
format={format}
|
|
126
|
+
ref={camera}
|
|
127
|
+
style={styles.camera}
|
|
128
|
+
device={device}
|
|
129
|
+
isActive={isActive}
|
|
130
|
+
enableZoomGesture={true}
|
|
131
|
+
photoQualityBalance="balanced"
|
|
132
|
+
photo={cameraMode.some(
|
|
133
|
+
(item) => item.mode === 'single' || item.mode === 'continuous'
|
|
134
|
+
)}
|
|
135
|
+
video={showVideo()}
|
|
136
|
+
audio={showVideo()}
|
|
137
|
+
resizeMode={resizeMode}
|
|
138
|
+
/>
|
|
139
|
+
|
|
140
|
+
<SetUp
|
|
141
|
+
isMultiCam={device?.isMultiCam}
|
|
142
|
+
onChange={(val) => (flash = val)}
|
|
143
|
+
onAspectRationChange={setAspectRatio}
|
|
144
|
+
onScreenChange={setResizeMode}
|
|
145
|
+
onVolumeChange={(val) => (enableShutterSound = val)}
|
|
146
|
+
onFishEyeOpen={(val) => {
|
|
147
|
+
if (val === 'fishEye') {
|
|
148
|
+
setZoom(device.minZoom);
|
|
156
149
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
}}
|
|
161
|
-
thumbnailPress={showPreview}
|
|
162
|
-
onChange={(val) => {
|
|
163
|
-
if (dataRetainedMode === 'clear') {
|
|
164
|
-
setPhotos([]);
|
|
165
|
-
}
|
|
166
|
-
setMode(val);
|
|
167
|
-
}}
|
|
168
|
-
takePress={async () => {
|
|
169
|
-
const photo = await camera.current?.takePhoto({
|
|
170
|
-
flash,
|
|
171
|
-
enableShutterSound: enableShutterSound,
|
|
172
|
-
});
|
|
173
|
-
if (photo) {
|
|
174
|
-
setPhotos((p) => [...p, { ...photo, mode }]);
|
|
175
|
-
}
|
|
176
|
-
if (isSingle()) {
|
|
177
|
-
showPreview();
|
|
178
|
-
}
|
|
179
|
-
}}
|
|
180
|
-
savePress={() => {
|
|
181
|
-
confirm();
|
|
182
|
-
}}
|
|
183
|
-
rotatePress={() => {
|
|
184
|
-
setPosition((val) => {
|
|
185
|
-
if (val === 'back') {
|
|
186
|
-
return 'front';
|
|
150
|
+
if (val === 'default') {
|
|
151
|
+
setZoom(device.neutralZoom);
|
|
187
152
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
onBack={() => signleBack()}
|
|
198
|
-
onSave={() => confirm()}
|
|
199
|
-
/>
|
|
200
|
-
) : (
|
|
201
|
-
<PreView
|
|
202
|
-
cameraMode={cameraMode}
|
|
203
|
-
data={photos}
|
|
204
|
-
onBack={() => commonBack()}
|
|
205
|
-
onDel={async (snapItem) => {
|
|
206
|
-
const isConfirm = await confirmApi.open({
|
|
207
|
-
text: '图片删除后无法恢复,请确认!',
|
|
153
|
+
}}
|
|
154
|
+
/>
|
|
155
|
+
<Footer
|
|
156
|
+
cameraMode={cameraMode}
|
|
157
|
+
photos={photos}
|
|
158
|
+
backPress={async () => {
|
|
159
|
+
if (photos.length > 0) {
|
|
160
|
+
const isBack = await confirmApi.open({
|
|
161
|
+
text: '返回会清空已拍摄数据,请确认!',
|
|
208
162
|
});
|
|
209
|
-
if (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
163
|
+
if (isBack) {
|
|
164
|
+
back();
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
back();
|
|
168
|
+
}
|
|
169
|
+
}}
|
|
170
|
+
thumbnailPress={showPreview}
|
|
171
|
+
onChange={(val) => {
|
|
172
|
+
if (dataRetainedMode === 'clear') {
|
|
173
|
+
setPhotos([]);
|
|
174
|
+
}
|
|
175
|
+
setMode(val);
|
|
176
|
+
}}
|
|
177
|
+
takePress={async () => {
|
|
178
|
+
const photo = await camera.current?.takePhoto({
|
|
179
|
+
flash,
|
|
180
|
+
enableShutterSound: enableShutterSound,
|
|
181
|
+
});
|
|
182
|
+
if (photo) {
|
|
183
|
+
setPhotos((p) => [
|
|
184
|
+
...p,
|
|
185
|
+
{ ...photo, frontTime: new Date().getTime(), mode },
|
|
186
|
+
]);
|
|
187
|
+
}
|
|
188
|
+
// 拍照后进行水印
|
|
189
|
+
if (data.watermark) {
|
|
190
|
+
openViewShotWatermark();
|
|
191
|
+
} else {
|
|
192
|
+
if (isSingle()) {
|
|
193
|
+
showPreview();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}}
|
|
197
|
+
savePress={() => {
|
|
198
|
+
confirm();
|
|
199
|
+
}}
|
|
200
|
+
rotatePress={() => {
|
|
201
|
+
setPosition((val) => {
|
|
202
|
+
if (val === 'back') {
|
|
203
|
+
return 'front';
|
|
204
|
+
}
|
|
205
|
+
return 'back';
|
|
206
|
+
});
|
|
207
|
+
}}
|
|
208
|
+
/>
|
|
209
|
+
|
|
210
|
+
{watermarkUriVis && (
|
|
211
|
+
<ViewShotWatermark
|
|
212
|
+
data={photos.at(-1)}
|
|
213
|
+
watermark={data.watermark}
|
|
214
|
+
onChange={(value) => {
|
|
215
|
+
setPhotos((photosList) => {
|
|
216
|
+
return photosList.map((item) => {
|
|
217
|
+
if (item.frontTime === value.frontTime) {
|
|
218
|
+
return value;
|
|
219
|
+
}
|
|
220
|
+
return item;
|
|
214
221
|
});
|
|
215
|
-
|
|
222
|
+
});
|
|
223
|
+
openViewShotWatermark();
|
|
224
|
+
if (isSingle()) {
|
|
225
|
+
showPreview();
|
|
216
226
|
}
|
|
217
|
-
return isConfirm;
|
|
218
227
|
}}
|
|
219
228
|
/>
|
|
220
229
|
)}
|
|
221
|
-
|
|
222
|
-
|
|
230
|
+
|
|
231
|
+
<PreViewContainer visible={preVis}>
|
|
232
|
+
{isSingle() ? (
|
|
233
|
+
<SinglePre
|
|
234
|
+
uri={photos[0]?.path as string}
|
|
235
|
+
onBack={() => signleBack()}
|
|
236
|
+
onSave={() => confirm()}
|
|
237
|
+
/>
|
|
238
|
+
) : (
|
|
239
|
+
<PreView
|
|
240
|
+
cameraMode={cameraMode}
|
|
241
|
+
data={photos}
|
|
242
|
+
onBack={() => commonBack()}
|
|
243
|
+
onDel={async (snapItem) => {
|
|
244
|
+
const isConfirm = await confirmApi.open({
|
|
245
|
+
text: '图片删除后无法恢复,请确认!',
|
|
246
|
+
});
|
|
247
|
+
if (isConfirm) {
|
|
248
|
+
setPhotos((photoList) => {
|
|
249
|
+
return photoList.filter(
|
|
250
|
+
(photo) => photo.path !== snapItem?.path
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
return isConfirm;
|
|
254
|
+
}
|
|
255
|
+
return isConfirm;
|
|
256
|
+
}}
|
|
257
|
+
/>
|
|
258
|
+
)}
|
|
259
|
+
</PreViewContainer>
|
|
260
|
+
{data.watermark && <WaterMarkRender data={data.watermark} />}
|
|
261
|
+
{contextHolder}
|
|
262
|
+
</SafeAreaProvider>
|
|
223
263
|
</GestureHandlerRootView>
|
|
224
264
|
);
|
|
225
265
|
};
|
|
@@ -227,5 +267,5 @@ const Camera: React.FC<{
|
|
|
227
267
|
export default Camera;
|
|
228
268
|
|
|
229
269
|
const styles = StyleSheet.create({
|
|
230
|
-
camera: { flex: 1 },
|
|
270
|
+
camera: { flex: 1, backgroundColor: '#000' },
|
|
231
271
|
});
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import React, { useState } from 'react';
|
|
10
10
|
import {
|
|
11
11
|
CameraModeEnum,
|
|
12
|
+
formatUri,
|
|
12
13
|
type CameraMode,
|
|
13
14
|
type CameraModeType,
|
|
14
15
|
} from '../../utils';
|
|
@@ -90,7 +91,7 @@ const Footer: React.FC<{
|
|
|
90
91
|
<View style={styles.footerHorizontal}>
|
|
91
92
|
{isPhotos() ? (
|
|
92
93
|
<PreviewThumbnail
|
|
93
|
-
uri={
|
|
94
|
+
uri={formatUri(photos[photos.length - 1]?.path || '')}
|
|
94
95
|
onPress={thumbnailPress}
|
|
95
96
|
/>
|
|
96
97
|
) : (
|
|
@@ -145,6 +146,7 @@ const styles = StyleSheet.create({
|
|
|
145
146
|
borderTopLeftRadius: 10,
|
|
146
147
|
borderTopRightRadius: 10,
|
|
147
148
|
paddingHorizontal: 16,
|
|
149
|
+
zIndex: 9,
|
|
148
150
|
},
|
|
149
151
|
footerBottom: {
|
|
150
152
|
flexDirection: 'row',
|
package/src/camera/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: 刘利军
|
|
3
3
|
* @Date: 2024-12-02 13:37:36
|
|
4
4
|
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-
|
|
5
|
+
* @LastEditTime: 2024-12-25 17:10:52
|
|
6
6
|
* @Description:
|
|
7
7
|
* @PageName:
|
|
8
8
|
*/
|
|
@@ -15,12 +15,14 @@ import { pxToDpWidth, type CustomPhotoFile } from '../../utils';
|
|
|
15
15
|
import PreviewFooter from './PreviewFooter';
|
|
16
16
|
|
|
17
17
|
import { styles as singleStyles, type CommonProps } from './SinglePre';
|
|
18
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
18
19
|
const PreView: React.FC<
|
|
19
20
|
{
|
|
20
21
|
cameraMode: CameraModeType[];
|
|
21
22
|
data: CustomPhotoFile[];
|
|
22
23
|
} & CommonProps
|
|
23
24
|
> = ({ cameraMode, data, onBack, onDel }) => {
|
|
25
|
+
const inset = useSafeAreaInsets();
|
|
24
26
|
const [mode, setMode] = useState(data[0]?.mode);
|
|
25
27
|
const showData = data.filter((item) => item.mode === mode);
|
|
26
28
|
const [snapToIndex, setSnapToIndex] = useState<number>(0);
|
|
@@ -55,7 +57,7 @@ const PreView: React.FC<
|
|
|
55
57
|
<View style={{ paddingHorizontal: pxToDpWidth(34) }}>
|
|
56
58
|
<MyCarousel data={showData} onSnapToItem={setSnapToIndex} />
|
|
57
59
|
</View>
|
|
58
|
-
<View style={singleStyles.footer}>
|
|
60
|
+
<View style={[singleStyles.footer, { bottom: inset.bottom + 16 }]}>
|
|
59
61
|
<PreviewFooter
|
|
60
62
|
actions={[
|
|
61
63
|
<Back
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: 刘利军
|
|
3
3
|
* @Date: 2024-12-02 13:37:36
|
|
4
4
|
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-
|
|
5
|
+
* @LastEditTime: 2024-12-27 13:29:19
|
|
6
6
|
* @Description:
|
|
7
7
|
* @PageName:
|
|
8
8
|
*/
|
|
@@ -29,5 +29,6 @@ const styles = StyleSheet.create({
|
|
|
29
29
|
right: 0,
|
|
30
30
|
left: 0,
|
|
31
31
|
backgroundColor: '#fff',
|
|
32
|
+
zIndex: 19,
|
|
32
33
|
},
|
|
33
34
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: 刘利军
|
|
3
3
|
* @Date: 2024-12-16 09:54:00
|
|
4
4
|
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-
|
|
5
|
+
* @LastEditTime: 2024-12-27 10:55:55
|
|
6
6
|
* @Description:
|
|
7
7
|
* @PageName:
|
|
8
8
|
*/
|
|
@@ -10,7 +10,7 @@ import { Image, StyleSheet, View } from 'react-native';
|
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import PreviewFooter from './PreviewFooter';
|
|
12
12
|
import { Back, Save } from '../../components';
|
|
13
|
-
import { type CustomPhotoFile } from '../../utils';
|
|
13
|
+
import { formatUri, type CustomPhotoFile } from '../../utils';
|
|
14
14
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
15
15
|
|
|
16
16
|
export interface SingleProps extends CommonProps {
|
|
@@ -25,13 +25,7 @@ const SinglePre: React.FC<SingleProps> = ({ uri, onBack, onSave }) => {
|
|
|
25
25
|
const inset = useSafeAreaInsets();
|
|
26
26
|
return (
|
|
27
27
|
<View style={styles.container}>
|
|
28
|
-
<Image
|
|
29
|
-
style={styles.container}
|
|
30
|
-
source={{ uri: `file://${uri}` }}
|
|
31
|
-
onLoadEnd={() => {
|
|
32
|
-
// 预留水印逻辑
|
|
33
|
-
}}
|
|
34
|
-
/>
|
|
28
|
+
<Image style={styles.container} source={{ uri: formatUri(uri) }} />
|
|
35
29
|
<View style={[styles.footer, { bottom: inset.bottom + 16 }]}>
|
|
36
30
|
<PreviewFooter
|
|
37
31
|
actions={[
|
|
@@ -57,11 +51,12 @@ const SinglePre: React.FC<SingleProps> = ({ uri, onBack, onSave }) => {
|
|
|
57
51
|
export default SinglePre;
|
|
58
52
|
|
|
59
53
|
export const styles = StyleSheet.create({
|
|
60
|
-
container: { flex: 1 },
|
|
54
|
+
container: { flex: 1, backgroundColor: '#fff' },
|
|
61
55
|
footer: {
|
|
62
56
|
position: 'absolute',
|
|
63
57
|
left: 0,
|
|
64
58
|
right: 0,
|
|
59
|
+
bottom: 0,
|
|
65
60
|
},
|
|
66
61
|
image: { width: 60, height: 60 },
|
|
67
62
|
});
|