@unif/react-native-camera 1.2.6 → 2.0.0
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/LICENSE +1 -1
- package/README.md +92 -22
- package/lib/module/camera/Camera.js +163 -285
- package/lib/module/camera/Camera.js.map +1 -1
- package/lib/module/camera/Container.js +209 -49
- package/lib/module/camera/Container.js.map +1 -1
- package/lib/module/camera/Error.js +23 -18
- package/lib/module/camera/Error.js.map +1 -1
- package/lib/module/camera/FocusIndicator.js +35 -41
- package/lib/module/camera/FocusIndicator.js.map +1 -1
- package/lib/module/camera/ModalView.js +28 -21
- package/lib/module/camera/ModalView.js.map +1 -1
- package/lib/module/camera/NoCamera.js +38 -14
- package/lib/module/camera/NoCamera.js.map +1 -1
- package/lib/module/camera/NoPermission.js +44 -38
- package/lib/module/camera/NoPermission.js.map +1 -1
- package/lib/module/camera/capturePhotoHelper.js +24 -0
- package/lib/module/camera/capturePhotoHelper.js.map +1 -0
- package/lib/module/camera/footer/Footer.js +83 -140
- package/lib/module/camera/footer/Footer.js.map +1 -1
- package/lib/module/camera/footer/index.js +3 -2
- package/lib/module/camera/footer/index.js.map +1 -1
- package/lib/module/camera/index.js +11 -13
- package/lib/module/camera/index.js.map +1 -1
- package/lib/module/camera/preview/PreView.js +36 -93
- package/lib/module/camera/preview/PreView.js.map +1 -1
- package/lib/module/camera/preview/PreViewContainer.js +28 -29
- package/lib/module/camera/preview/PreViewContainer.js.map +1 -1
- package/lib/module/camera/preview/PreviewFooter.js +30 -21
- package/lib/module/camera/preview/PreviewFooter.js.map +1 -1
- package/lib/module/camera/preview/SinglePre.js +28 -60
- package/lib/module/camera/preview/SinglePre.js.map +1 -1
- package/lib/module/camera/preview/index.js +6 -12
- package/lib/module/camera/preview/index.js.map +1 -1
- package/lib/module/camera/setup/SetUp.js +67 -189
- package/lib/module/camera/setup/SetUp.js.map +1 -1
- package/lib/module/camera/setup/index.js +3 -2
- package/lib/module/camera/setup/index.js.map +1 -1
- package/lib/module/components/Carousel/Carousel.js +33 -40
- package/lib/module/components/Carousel/Carousel.js.map +1 -1
- package/lib/module/components/Carousel/SlideItem.js +22 -70
- package/lib/module/components/Carousel/SlideItem.js.map +1 -1
- package/lib/module/components/Carousel/index.js +4 -11
- package/lib/module/components/Carousel/index.js.map +1 -1
- package/lib/module/components/Loading.js +15 -61
- package/lib/module/components/Loading.js.map +1 -1
- package/lib/module/components/PreviewThumbnail.js +36 -33
- package/lib/module/components/PreviewThumbnail.js.map +1 -1
- package/lib/module/components/index.js +5 -8
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/hooks/index.js +5 -11
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useCamera.js +44 -0
- package/lib/module/hooks/useCamera.js.map +1 -0
- package/lib/module/hooks/useConfirm.js +13 -49
- package/lib/module/hooks/useConfirm.js.map +1 -1
- package/lib/module/hooks/useCreation.js +18 -0
- package/lib/module/hooks/useCreation.js.map +1 -0
- package/lib/module/index.js +4 -24
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/utils/depsAreSame.js +7 -4
- package/lib/module/utils/depsAreSame.js.map +1 -1
- package/lib/module/utils/index.js +6 -14
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/interface.js +1 -21
- package/lib/module/utils/interface.js.map +1 -1
- package/lib/module/utils/px-to-dp.js +6 -10
- package/lib/module/utils/px-to-dp.js.map +1 -1
- package/lib/module/utils/util.js +16 -40
- package/lib/module/utils/util.js.map +1 -1
- package/lib/typescript/jest.setup.d.ts +1 -0
- package/lib/typescript/jest.setup.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/camera/Camera.d.ts +18 -10
- package/lib/typescript/src/camera/Camera.d.ts.map +1 -1
- package/lib/typescript/src/camera/Container.d.ts +7 -5
- package/lib/typescript/src/camera/Container.d.ts.map +1 -1
- package/lib/typescript/src/camera/Error.d.ts +3 -7
- package/lib/typescript/src/camera/Error.d.ts.map +1 -1
- package/lib/typescript/src/camera/FocusIndicator.d.ts +7 -7
- package/lib/typescript/src/camera/FocusIndicator.d.ts.map +1 -1
- package/lib/typescript/src/camera/ModalView.d.ts +7 -4
- package/lib/typescript/src/camera/ModalView.d.ts.map +1 -1
- package/lib/typescript/src/camera/NoCamera.d.ts +5 -3
- package/lib/typescript/src/camera/NoCamera.d.ts.map +1 -1
- package/lib/typescript/src/camera/NoPermission.d.ts +6 -3
- package/lib/typescript/src/camera/NoPermission.d.ts.map +1 -1
- package/lib/typescript/src/camera/capturePhotoHelper.d.ts +16 -0
- package/lib/typescript/src/camera/capturePhotoHelper.d.ts.map +1 -0
- package/lib/typescript/src/camera/footer/Footer.d.ts +13 -15
- package/lib/typescript/src/camera/footer/Footer.d.ts.map +1 -1
- package/lib/typescript/src/camera/footer/index.d.ts +1 -2
- package/lib/typescript/src/camera/footer/index.d.ts.map +1 -1
- package/lib/typescript/src/camera/index.d.ts +9 -5
- package/lib/typescript/src/camera/index.d.ts.map +1 -1
- package/lib/typescript/src/camera/preview/PreView.d.ts +6 -9
- package/lib/typescript/src/camera/preview/PreView.d.ts.map +1 -1
- package/lib/typescript/src/camera/preview/PreViewContainer.d.ts +8 -5
- package/lib/typescript/src/camera/preview/PreViewContainer.d.ts.map +1 -1
- package/lib/typescript/src/camera/preview/PreviewFooter.d.ts +6 -6
- package/lib/typescript/src/camera/preview/PreviewFooter.d.ts.map +1 -1
- package/lib/typescript/src/camera/preview/SinglePre.d.ts +5 -28
- package/lib/typescript/src/camera/preview/SinglePre.d.ts.map +1 -1
- package/lib/typescript/src/camera/preview/index.d.ts +4 -4
- package/lib/typescript/src/camera/preview/index.d.ts.map +1 -1
- package/lib/typescript/src/camera/setup/SetUp.d.ts +12 -11
- package/lib/typescript/src/camera/setup/SetUp.d.ts.map +1 -1
- package/lib/typescript/src/camera/setup/index.d.ts +1 -2
- package/lib/typescript/src/camera/setup/index.d.ts.map +1 -1
- package/lib/typescript/src/components/Carousel/Carousel.d.ts +6 -8
- package/lib/typescript/src/components/Carousel/Carousel.d.ts.map +1 -1
- package/lib/typescript/src/components/Carousel/SlideItem.d.ts +4 -12
- package/lib/typescript/src/components/Carousel/SlideItem.d.ts.map +1 -1
- package/lib/typescript/src/components/Carousel/index.d.ts +2 -3
- package/lib/typescript/src/components/Carousel/index.d.ts.map +1 -1
- package/lib/typescript/src/components/Loading.d.ts +1 -3
- package/lib/typescript/src/components/Loading.d.ts.map +1 -1
- package/lib/typescript/src/components/PreviewThumbnail.d.ts +7 -8
- package/lib/typescript/src/components/PreviewThumbnail.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts +2 -7
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/index.d.ts +3 -3
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCamera.d.ts +4 -0
- package/lib/typescript/src/hooks/useCamera.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useConfirm.d.ts +1 -5
- package/lib/typescript/src/hooks/useConfirm.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCreation.d.ts +2 -0
- package/lib/typescript/src/hooks/useCreation.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/depsAreSame.d.ts +1 -2
- package/lib/typescript/src/utils/depsAreSame.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +2 -4
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/interface.d.ts +30 -70
- package/lib/typescript/src/utils/interface.d.ts.map +1 -1
- package/lib/typescript/src/utils/px-to-dp.d.ts +1 -3
- package/lib/typescript/src/utils/px-to-dp.d.ts.map +1 -1
- package/lib/typescript/src/utils/util.d.ts +8 -9
- package/lib/typescript/src/utils/util.d.ts.map +1 -1
- package/package.json +120 -107
- package/src/camera/Camera.tsx +210 -331
- package/src/camera/Container.tsx +224 -50
- package/src/camera/Error.tsx +22 -23
- package/src/camera/FocusIndicator.tsx +36 -46
- package/src/camera/ModalView.tsx +26 -24
- package/src/camera/NoCamera.tsx +37 -14
- package/src/camera/NoPermission.tsx +45 -37
- package/src/camera/capturePhotoHelper.ts +37 -0
- package/src/camera/footer/Footer.tsx +104 -195
- package/src/camera/footer/index.tsx +1 -2
- package/src/camera/index.tsx +12 -13
- package/src/camera/preview/PreView.tsx +22 -103
- package/src/camera/preview/PreViewContainer.tsx +23 -27
- package/src/camera/preview/PreviewFooter.tsx +28 -22
- package/src/camera/preview/SinglePre.tsx +23 -68
- package/src/camera/preview/index.tsx +4 -13
- package/src/camera/setup/SetUp.tsx +80 -217
- package/src/camera/setup/index.tsx +1 -3
- package/src/components/Carousel/Carousel.tsx +22 -42
- package/src/components/Carousel/SlideItem.tsx +12 -87
- package/src/components/Carousel/index.tsx +2 -13
- package/src/components/Loading.tsx +7 -69
- package/src/components/PreviewThumbnail.tsx +38 -33
- package/src/components/index.tsx +2 -7
- package/src/hooks/index.ts +3 -12
- package/src/hooks/useCamera.tsx +42 -0
- package/src/hooks/useConfirm.tsx +10 -57
- package/src/hooks/useCreation.ts +26 -0
- package/src/index.tsx +3 -37
- package/src/utils/depsAreSame.ts +7 -8
- package/src/utils/index.ts +2 -12
- package/src/utils/interface.ts +26 -87
- package/src/utils/px-to-dp.tsx +5 -9
- package/src/utils/util.ts +17 -42
- package/UnifRNCamera.podspec +0 -41
- package/android/CMakeLists.txt +0 -15
- package/android/build.gradle +0 -124
- package/android/cpp-adapter.cpp +0 -8
- package/android/gradle.properties +0 -5
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/android/src/main/java/com/unif/reactnativecamera/ReactNativeCameraModule.java +0 -34
- package/android/src/main/java/com/unif/reactnativecamera/ReactNativeCameraPackage.java +0 -45
- package/android/src/newarch/ReactNativeCameraSpec.java +0 -9
- package/android/src/oldarch/ReactNativeCameraSpec.java +0 -13
- package/cpp/unif-react-native-camera.cpp +0 -7
- package/cpp/unif-react-native-camera.h +0 -8
- package/ios/ReactNativeCamera.h +0 -15
- package/ios/ReactNativeCamera.mm +0 -51
- package/lib/commonjs/NativeReactNativeCamera.js +0 -17
- package/lib/commonjs/NativeReactNativeCamera.js.map +0 -1
- package/lib/commonjs/assets/close.png +0 -0
- package/lib/commonjs/assets/home/record.png +0 -0
- package/lib/commonjs/assets/home/take.png +0 -0
- package/lib/commonjs/assets/preview/back.png +0 -0
- package/lib/commonjs/assets/preview/del.png +0 -0
- package/lib/commonjs/assets/preview/rotate.png +0 -0
- package/lib/commonjs/assets/preview/save.png +0 -0
- package/lib/commonjs/assets/tools/auto.png +0 -0
- package/lib/commonjs/assets/tools/defaultEye.png +0 -0
- package/lib/commonjs/assets/tools/enlarge.png +0 -0
- package/lib/commonjs/assets/tools/fishEye.png +0 -0
- package/lib/commonjs/assets/tools/narrow.png +0 -0
- package/lib/commonjs/assets/tools/off.png +0 -0
- package/lib/commonjs/assets/tools/on.png +0 -0
- package/lib/commonjs/assets/tools/volumeOff.png +0 -0
- package/lib/commonjs/assets/tools/volumeOn.png +0 -0
- package/lib/commonjs/camera/Camera.js +0 -316
- package/lib/commonjs/camera/Camera.js.map +0 -1
- package/lib/commonjs/camera/Container.js +0 -64
- package/lib/commonjs/camera/Container.js.map +0 -1
- package/lib/commonjs/camera/Error.js +0 -30
- package/lib/commonjs/camera/Error.js.map +0 -1
- package/lib/commonjs/camera/FocusIndicator.js +0 -64
- package/lib/commonjs/camera/FocusIndicator.js.map +0 -1
- package/lib/commonjs/camera/ModalView.js +0 -37
- package/lib/commonjs/camera/ModalView.js.map +0 -1
- package/lib/commonjs/camera/NoCamera.js +0 -23
- package/lib/commonjs/camera/NoCamera.js.map +0 -1
- package/lib/commonjs/camera/NoPermission.js +0 -50
- package/lib/commonjs/camera/NoPermission.js.map +0 -1
- package/lib/commonjs/camera/footer/Footer.js +0 -159
- package/lib/commonjs/camera/footer/Footer.js.map +0 -1
- package/lib/commonjs/camera/footer/index.js +0 -14
- package/lib/commonjs/camera/footer/index.js.map +0 -1
- package/lib/commonjs/camera/index.js +0 -35
- package/lib/commonjs/camera/index.js.map +0 -1
- package/lib/commonjs/camera/preview/PreView.js +0 -109
- package/lib/commonjs/camera/preview/PreView.js.map +0 -1
- package/lib/commonjs/camera/preview/PreViewContainer.js +0 -42
- package/lib/commonjs/camera/preview/PreViewContainer.js.map +0 -1
- package/lib/commonjs/camera/preview/PreviewFooter.js +0 -35
- package/lib/commonjs/camera/preview/PreviewFooter.js.map +0 -1
- package/lib/commonjs/camera/preview/SinglePre.js +0 -72
- package/lib/commonjs/camera/preview/SinglePre.js.map +0 -1
- package/lib/commonjs/camera/preview/index.js +0 -28
- package/lib/commonjs/camera/preview/index.js.map +0 -1
- package/lib/commonjs/camera/setup/SetUp.js +0 -205
- package/lib/commonjs/camera/setup/SetUp.js.map +0 -1
- package/lib/commonjs/camera/setup/index.js +0 -14
- package/lib/commonjs/camera/setup/index.js.map +0 -1
- package/lib/commonjs/camera/watermark/Render.js +0 -110
- package/lib/commonjs/camera/watermark/Render.js.map +0 -1
- package/lib/commonjs/camera/watermark/ViewShotWatermark.js +0 -143
- package/lib/commonjs/camera/watermark/ViewShotWatermark.js.map +0 -1
- package/lib/commonjs/camera/watermark/index.js +0 -21
- package/lib/commonjs/camera/watermark/index.js.map +0 -1
- package/lib/commonjs/components/Back.js +0 -48
- package/lib/commonjs/components/Back.js.map +0 -1
- package/lib/commonjs/components/Carousel/Carousel.js +0 -51
- package/lib/commonjs/components/Carousel/Carousel.js.map +0 -1
- package/lib/commonjs/components/Carousel/SlideItem.js +0 -84
- package/lib/commonjs/components/Carousel/SlideItem.js.map +0 -1
- package/lib/commonjs/components/Carousel/index.js +0 -21
- package/lib/commonjs/components/Carousel/index.js.map +0 -1
- package/lib/commonjs/components/Delete.js +0 -36
- package/lib/commonjs/components/Delete.js.map +0 -1
- package/lib/commonjs/components/Loading.js +0 -75
- package/lib/commonjs/components/Loading.js.map +0 -1
- package/lib/commonjs/components/Modal/Confirm.js +0 -121
- package/lib/commonjs/components/Modal/Confirm.js.map +0 -1
- package/lib/commonjs/components/Modal/index.js +0 -14
- package/lib/commonjs/components/Modal/index.js.map +0 -1
- package/lib/commonjs/components/PreviewThumbnail.js +0 -44
- package/lib/commonjs/components/PreviewThumbnail.js.map +0 -1
- package/lib/commonjs/components/Rotate.js +0 -32
- package/lib/commonjs/components/Rotate.js.map +0 -1
- package/lib/commonjs/components/Save.js +0 -48
- package/lib/commonjs/components/Save.js.map +0 -1
- package/lib/commonjs/components/index.js +0 -73
- package/lib/commonjs/components/index.js.map +0 -1
- package/lib/commonjs/hooks/index.js +0 -21
- package/lib/commonjs/hooks/index.js.map +0 -1
- package/lib/commonjs/hooks/useCamera.tsx/index.js +0 -90
- package/lib/commonjs/hooks/useCamera.tsx/index.js.map +0 -1
- package/lib/commonjs/hooks/useConfirm.js +0 -61
- package/lib/commonjs/hooks/useConfirm.js.map +0 -1
- package/lib/commonjs/hooks/useCreation/index.js +0 -34
- package/lib/commonjs/hooks/useCreation/index.js.map +0 -1
- package/lib/commonjs/index.js +0 -39
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/utils/common.js +0 -69
- package/lib/commonjs/utils/common.js.map +0 -1
- package/lib/commonjs/utils/depsAreSame.js +0 -14
- package/lib/commonjs/utils/depsAreSame.js.map +0 -1
- package/lib/commonjs/utils/index.js +0 -72
- package/lib/commonjs/utils/index.js.map +0 -1
- package/lib/commonjs/utils/interface.js +0 -24
- package/lib/commonjs/utils/interface.js.map +0 -1
- package/lib/commonjs/utils/px-to-dp.js +0 -21
- package/lib/commonjs/utils/px-to-dp.js.map +0 -1
- package/lib/commonjs/utils/render-item.js +0 -40
- package/lib/commonjs/utils/render-item.js.map +0 -1
- package/lib/commonjs/utils/util.js +0 -53
- package/lib/commonjs/utils/util.js.map +0 -1
- package/lib/commonjs/utils/watermark.js +0 -49
- package/lib/commonjs/utils/watermark.js.map +0 -1
- package/lib/module/NativeReactNativeCamera.js +0 -12
- package/lib/module/NativeReactNativeCamera.js.map +0 -1
- package/lib/module/assets/close.png +0 -0
- package/lib/module/assets/home/record.png +0 -0
- package/lib/module/assets/home/take.png +0 -0
- package/lib/module/assets/preview/back.png +0 -0
- package/lib/module/assets/preview/del.png +0 -0
- package/lib/module/assets/preview/rotate.png +0 -0
- package/lib/module/assets/preview/save.png +0 -0
- package/lib/module/assets/tools/auto.png +0 -0
- package/lib/module/assets/tools/defaultEye.png +0 -0
- package/lib/module/assets/tools/enlarge.png +0 -0
- package/lib/module/assets/tools/fishEye.png +0 -0
- package/lib/module/assets/tools/narrow.png +0 -0
- package/lib/module/assets/tools/off.png +0 -0
- package/lib/module/assets/tools/on.png +0 -0
- package/lib/module/assets/tools/volumeOff.png +0 -0
- package/lib/module/assets/tools/volumeOn.png +0 -0
- package/lib/module/camera/watermark/Render.js +0 -102
- package/lib/module/camera/watermark/Render.js.map +0 -1
- package/lib/module/camera/watermark/ViewShotWatermark.js +0 -133
- package/lib/module/camera/watermark/ViewShotWatermark.js.map +0 -1
- package/lib/module/camera/watermark/index.js +0 -13
- package/lib/module/camera/watermark/index.js.map +0 -1
- package/lib/module/components/Back.js +0 -40
- package/lib/module/components/Back.js.map +0 -1
- package/lib/module/components/Delete.js +0 -28
- package/lib/module/components/Delete.js.map +0 -1
- package/lib/module/components/Modal/Confirm.js +0 -111
- package/lib/module/components/Modal/Confirm.js.map +0 -1
- package/lib/module/components/Modal/index.js +0 -3
- package/lib/module/components/Modal/index.js.map +0 -1
- package/lib/module/components/Rotate.js +0 -24
- package/lib/module/components/Rotate.js.map +0 -1
- package/lib/module/components/Save.js +0 -40
- package/lib/module/components/Save.js.map +0 -1
- package/lib/module/hooks/useCamera.tsx/index.js +0 -81
- package/lib/module/hooks/useCamera.tsx/index.js.map +0 -1
- package/lib/module/hooks/useCreation/index.js +0 -27
- package/lib/module/hooks/useCreation/index.js.map +0 -1
- package/lib/module/utils/common.js +0 -62
- package/lib/module/utils/common.js.map +0 -1
- package/lib/module/utils/render-item.js +0 -32
- package/lib/module/utils/render-item.js.map +0 -1
- package/lib/module/utils/watermark.js +0 -39
- package/lib/module/utils/watermark.js.map +0 -1
- package/lib/typescript/src/NativeReactNativeCamera.d.ts +0 -6
- package/lib/typescript/src/NativeReactNativeCamera.d.ts.map +0 -1
- package/lib/typescript/src/camera/watermark/Render.d.ts +0 -26
- package/lib/typescript/src/camera/watermark/Render.d.ts.map +0 -1
- package/lib/typescript/src/camera/watermark/ViewShotWatermark.d.ts +0 -41
- package/lib/typescript/src/camera/watermark/ViewShotWatermark.d.ts.map +0 -1
- package/lib/typescript/src/camera/watermark/index.d.ts +0 -4
- package/lib/typescript/src/camera/watermark/index.d.ts.map +0 -1
- package/lib/typescript/src/components/Back.d.ts +0 -20
- package/lib/typescript/src/components/Back.d.ts.map +0 -1
- package/lib/typescript/src/components/Delete.d.ts +0 -7
- package/lib/typescript/src/components/Delete.d.ts.map +0 -1
- package/lib/typescript/src/components/Modal/Confirm.d.ts +0 -9
- package/lib/typescript/src/components/Modal/Confirm.d.ts.map +0 -1
- package/lib/typescript/src/components/Modal/index.d.ts +0 -3
- package/lib/typescript/src/components/Modal/index.d.ts.map +0 -1
- package/lib/typescript/src/components/Rotate.d.ts +0 -9
- package/lib/typescript/src/components/Rotate.d.ts.map +0 -1
- package/lib/typescript/src/components/Save.d.ts +0 -20
- package/lib/typescript/src/components/Save.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useCamera.tsx/index.d.ts +0 -5
- package/lib/typescript/src/hooks/useCamera.tsx/index.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useCreation/index.d.ts +0 -3
- package/lib/typescript/src/hooks/useCreation/index.d.ts.map +0 -1
- package/lib/typescript/src/utils/common.d.ts +0 -14
- package/lib/typescript/src/utils/common.d.ts.map +0 -1
- package/lib/typescript/src/utils/render-item.d.ts +0 -10
- package/lib/typescript/src/utils/render-item.d.ts.map +0 -1
- package/lib/typescript/src/utils/watermark.d.ts +0 -11
- package/lib/typescript/src/utils/watermark.d.ts.map +0 -1
- package/src/NativeReactNativeCamera.ts +0 -15
- package/src/assets/close.png +0 -0
- package/src/assets/home/record.png +0 -0
- package/src/assets/home/take.png +0 -0
- package/src/assets/preview/back.png +0 -0
- package/src/assets/preview/del.png +0 -0
- package/src/assets/preview/rotate.png +0 -0
- package/src/assets/preview/save.png +0 -0
- package/src/assets/tools/auto.png +0 -0
- package/src/assets/tools/defaultEye.png +0 -0
- package/src/assets/tools/enlarge.png +0 -0
- package/src/assets/tools/fishEye.png +0 -0
- package/src/assets/tools/narrow.png +0 -0
- package/src/assets/tools/off.png +0 -0
- package/src/assets/tools/on.png +0 -0
- package/src/assets/tools/volumeOff.png +0 -0
- package/src/assets/tools/volumeOn.png +0 -0
- package/src/camera/watermark/Render.tsx +0 -128
- package/src/camera/watermark/ViewShotWatermark.tsx +0 -134
- package/src/camera/watermark/index.tsx +0 -12
- package/src/components/Back.tsx +0 -37
- package/src/components/Delete.tsx +0 -30
- package/src/components/Modal/Confirm.tsx +0 -116
- package/src/components/Modal/index.tsx +0 -3
- package/src/components/Rotate.tsx +0 -32
- package/src/components/Save.tsx +0 -37
- package/src/hooks/useCamera.tsx/index.tsx +0 -95
- package/src/hooks/useCreation/index.ts +0 -25
- package/src/utils/common.ts +0 -67
- package/src/utils/render-item.tsx +0 -39
- package/src/utils/watermark.ts +0 -55
|
Binary file
|
package/src/assets/tools/off.png
DELETED
|
Binary file
|
package/src/assets/tools/on.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { Dimensions, Image, StyleSheet, View } from 'react-native';
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
getContentMeasure,
|
|
5
|
-
getMeasure,
|
|
6
|
-
lastPx,
|
|
7
|
-
type WatermarkType,
|
|
8
|
-
} from '../../utils';
|
|
9
|
-
import Canvas, { Image as CanvasImage } from 'react-native-canvas';
|
|
10
|
-
|
|
11
|
-
const Render: React.FC<{
|
|
12
|
-
data: WatermarkType;
|
|
13
|
-
zIndex?: number;
|
|
14
|
-
}> = ({ data, zIndex }) => {
|
|
15
|
-
const [waterBase64, setWaterBase64] = useState<string>();
|
|
16
|
-
|
|
17
|
-
const getMarkSize = async (width: number, height: number) => {
|
|
18
|
-
let defaultWidth = lastPx(120);
|
|
19
|
-
let defaultHeight = lastPx(64);
|
|
20
|
-
if (!data?.image) {
|
|
21
|
-
defaultWidth = width;
|
|
22
|
-
defaultHeight = height;
|
|
23
|
-
}
|
|
24
|
-
return [data?.width ?? defaultWidth, data?.height ?? defaultHeight];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const handleImageRect = async (canvas: Canvas) => {
|
|
28
|
-
const ctx = canvas.getContext('2d');
|
|
29
|
-
const {
|
|
30
|
-
image,
|
|
31
|
-
content = [],
|
|
32
|
-
rotate = data.image ? 0 : -22,
|
|
33
|
-
gap = [100, 100],
|
|
34
|
-
} = data;
|
|
35
|
-
|
|
36
|
-
const measure = await getContentMeasure(ctx, content);
|
|
37
|
-
|
|
38
|
-
const [markWidth, markHeight] = await getMarkSize(
|
|
39
|
-
measure.width,
|
|
40
|
-
measure.height
|
|
41
|
-
);
|
|
42
|
-
const x = lastPx(gap[0] as number);
|
|
43
|
-
const y = lastPx(gap[1] as number);
|
|
44
|
-
|
|
45
|
-
const width = lastPx(markWidth as number);
|
|
46
|
-
const height = lastPx(markHeight as number);
|
|
47
|
-
canvas.width = width + x;
|
|
48
|
-
canvas.height = height + y;
|
|
49
|
-
|
|
50
|
-
const angle = (Math.PI * rotate) / 180;
|
|
51
|
-
ctx.translate(canvas.width * 0.5, canvas.height * 0.5);
|
|
52
|
-
const setDataURL = async () => {
|
|
53
|
-
const imgBase64 = await canvas.toDataURL();
|
|
54
|
-
const base = imgBase64.replace(/^"|"$/g, '');
|
|
55
|
-
setWaterBase64(base.split(',')[1]);
|
|
56
|
-
};
|
|
57
|
-
if (image) {
|
|
58
|
-
const canvasImage = new CanvasImage(canvas);
|
|
59
|
-
canvasImage.crossOrigin = 'anonymous';
|
|
60
|
-
canvasImage.src = image;
|
|
61
|
-
canvasImage.width = width;
|
|
62
|
-
canvasImage.height = height;
|
|
63
|
-
|
|
64
|
-
ctx.rotate(angle);
|
|
65
|
-
|
|
66
|
-
canvasImage.addEventListener('load', async () => {
|
|
67
|
-
ctx.drawImage(
|
|
68
|
-
canvasImage,
|
|
69
|
-
-canvas.height / 2,
|
|
70
|
-
-canvas.width / 2,
|
|
71
|
-
width,
|
|
72
|
-
height
|
|
73
|
-
);
|
|
74
|
-
setDataURL();
|
|
75
|
-
});
|
|
76
|
-
} else {
|
|
77
|
-
if (content.length > 0) {
|
|
78
|
-
ctx.font = `${lastPx(22)}px Arial`;
|
|
79
|
-
ctx.textAlign = 'center';
|
|
80
|
-
ctx.rotate(angle);
|
|
81
|
-
for (let index = 0; index < content.length; index++) {
|
|
82
|
-
const element = content[index];
|
|
83
|
-
const metrics = await getMeasure(ctx, element as string);
|
|
84
|
-
ctx.fillText(element as string, 0, metrics.height * (index + 1));
|
|
85
|
-
}
|
|
86
|
-
setDataURL();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
return (
|
|
91
|
-
<View style={[styles.container, { zIndex }]}>
|
|
92
|
-
<View style={styles.watermark}>
|
|
93
|
-
{waterBase64 ? (
|
|
94
|
-
<Image
|
|
95
|
-
resizeMode="repeat"
|
|
96
|
-
source={{ uri: `data:image/png;base64,${waterBase64}` }}
|
|
97
|
-
style={{
|
|
98
|
-
width: Dimensions.get('window').width,
|
|
99
|
-
height: Dimensions.get('window').height,
|
|
100
|
-
}}
|
|
101
|
-
/>
|
|
102
|
-
) : (
|
|
103
|
-
<Canvas
|
|
104
|
-
ref={(canvas: Canvas) => canvas && handleImageRect(canvas)}
|
|
105
|
-
style={styles.canvas}
|
|
106
|
-
/>
|
|
107
|
-
)}
|
|
108
|
-
</View>
|
|
109
|
-
</View>
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export default Render;
|
|
114
|
-
|
|
115
|
-
export const styles = StyleSheet.create({
|
|
116
|
-
container: {
|
|
117
|
-
...StyleSheet.absoluteFillObject,
|
|
118
|
-
},
|
|
119
|
-
watermark: {
|
|
120
|
-
display: 'flex',
|
|
121
|
-
flexWrap: 'wrap',
|
|
122
|
-
flex: 1,
|
|
123
|
-
flexDirection: 'row',
|
|
124
|
-
},
|
|
125
|
-
canvas: {
|
|
126
|
-
display: 'none',
|
|
127
|
-
},
|
|
128
|
-
});
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: 刘利军
|
|
3
|
-
* @Date: 2024-12-25 16:56:42
|
|
4
|
-
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-30 13:07:33
|
|
6
|
-
* @Description:
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
9
|
-
import {
|
|
10
|
-
Image,
|
|
11
|
-
StyleSheet,
|
|
12
|
-
Text,
|
|
13
|
-
Dimensions,
|
|
14
|
-
View,
|
|
15
|
-
type ImageResizeMode,
|
|
16
|
-
} from 'react-native';
|
|
17
|
-
import React, { useRef, useState } from 'react';
|
|
18
|
-
import ViewShot from 'react-native-view-shot';
|
|
19
|
-
import WaterMarkRender from './Render';
|
|
20
|
-
import {
|
|
21
|
-
formatUri,
|
|
22
|
-
MAX_ZINDEX,
|
|
23
|
-
pxToDpWidth,
|
|
24
|
-
type WatermarkType,
|
|
25
|
-
type CustomPhotoFile,
|
|
26
|
-
} from '../../utils';
|
|
27
|
-
const { width: screenWidth, height: screenHeight } = Dimensions.get('window');
|
|
28
|
-
|
|
29
|
-
const ViewShotWatermark: React.FC<{
|
|
30
|
-
data?: CustomPhotoFile;
|
|
31
|
-
resizeMode?: ImageResizeMode;
|
|
32
|
-
watermark?: WatermarkType;
|
|
33
|
-
onChange: (photo: CustomPhotoFile) => void;
|
|
34
|
-
}> = ({ data, resizeMode, watermark, onChange }) => {
|
|
35
|
-
const viewShotRef = useRef<ViewShot>(null);
|
|
36
|
-
const [imageSize, setImageSize] = useState({ width: 0, height: 0 });
|
|
37
|
-
|
|
38
|
-
if (!data || !watermark) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const autoSaveWatermark = async () => {
|
|
43
|
-
const img = await viewShotRef.current?.capture?.();
|
|
44
|
-
onChange({ ...data, path: img || data.path });
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const handleImageLoad = (event: {
|
|
48
|
-
nativeEvent: { source: { width: any; height: any } };
|
|
49
|
-
}) => {
|
|
50
|
-
if (resizeMode === 'cover') {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const { width, height } = event.nativeEvent.source;
|
|
54
|
-
const aspectRatio = width / height;
|
|
55
|
-
const containerWidth = screenWidth;
|
|
56
|
-
const containerHeight = screenHeight;
|
|
57
|
-
let displayWidth = containerWidth;
|
|
58
|
-
let displayHeight = containerWidth / aspectRatio;
|
|
59
|
-
|
|
60
|
-
if (displayHeight > containerHeight) {
|
|
61
|
-
displayHeight = containerHeight;
|
|
62
|
-
displayWidth = containerHeight * aspectRatio;
|
|
63
|
-
}
|
|
64
|
-
setImageSize({ width: displayWidth, height: displayHeight });
|
|
65
|
-
};
|
|
66
|
-
const getWidth = () => {
|
|
67
|
-
if (resizeMode === 'contain') {
|
|
68
|
-
return imageSize.width || screenWidth;
|
|
69
|
-
}
|
|
70
|
-
return '100%';
|
|
71
|
-
};
|
|
72
|
-
const getHeight = () => {
|
|
73
|
-
if (resizeMode === 'contain') {
|
|
74
|
-
return imageSize.height || screenHeight;
|
|
75
|
-
}
|
|
76
|
-
return '100%';
|
|
77
|
-
};
|
|
78
|
-
return (
|
|
79
|
-
<View style={styles.container}>
|
|
80
|
-
<ViewShot
|
|
81
|
-
ref={viewShotRef}
|
|
82
|
-
style={{ width: getWidth(), height: getHeight() }}
|
|
83
|
-
>
|
|
84
|
-
<Image
|
|
85
|
-
source={{ uri: formatUri(data.path) }}
|
|
86
|
-
style={styles.image}
|
|
87
|
-
onLoad={handleImageLoad}
|
|
88
|
-
onLoadEnd={() => {
|
|
89
|
-
setTimeout(() => {
|
|
90
|
-
autoSaveWatermark();
|
|
91
|
-
}, 800);
|
|
92
|
-
}}
|
|
93
|
-
/>
|
|
94
|
-
<WaterMarkRender data={watermark} zIndex={MAX_ZINDEX + 1} />
|
|
95
|
-
</ViewShot>
|
|
96
|
-
<View style={styles.footer}>
|
|
97
|
-
<Text style={styles.text}>生成中...</Text>
|
|
98
|
-
</View>
|
|
99
|
-
</View>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export default ViewShotWatermark;
|
|
104
|
-
|
|
105
|
-
export const styles = StyleSheet.create({
|
|
106
|
-
container: {
|
|
107
|
-
flex: 1,
|
|
108
|
-
position: 'absolute',
|
|
109
|
-
left: 0,
|
|
110
|
-
right: 0,
|
|
111
|
-
top: 0,
|
|
112
|
-
bottom: 0,
|
|
113
|
-
backgroundColor: '#000',
|
|
114
|
-
zIndex: MAX_ZINDEX,
|
|
115
|
-
alignContent: 'center',
|
|
116
|
-
justifyContent: 'center',
|
|
117
|
-
},
|
|
118
|
-
image: {
|
|
119
|
-
width: '100%',
|
|
120
|
-
height: '100%',
|
|
121
|
-
},
|
|
122
|
-
footer: {
|
|
123
|
-
position: 'absolute',
|
|
124
|
-
left: 0,
|
|
125
|
-
right: 0,
|
|
126
|
-
bottom: 24,
|
|
127
|
-
zIndex: MAX_ZINDEX + 2,
|
|
128
|
-
},
|
|
129
|
-
text: {
|
|
130
|
-
color: '#fff',
|
|
131
|
-
textAlign: 'center',
|
|
132
|
-
fontSize: pxToDpWidth(32),
|
|
133
|
-
},
|
|
134
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: 刘利军
|
|
3
|
-
* @Date: 2024-12-25 11:01:20
|
|
4
|
-
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-30 13:08:49
|
|
6
|
-
* @Description:
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import WaterMarkRender from './Render';
|
|
11
|
-
import ViewShotWatermark from './ViewShotWatermark';
|
|
12
|
-
export { WaterMarkRender, ViewShotWatermark };
|
package/src/components/Back.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: 刘利军
|
|
3
|
-
* @Date: 2024-01-16 17:50:24
|
|
4
|
-
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-16 10:21:17
|
|
6
|
-
* @Description:
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
9
|
-
import { Image, StyleSheet, Text, TouchableOpacity } from 'react-native';
|
|
10
|
-
import React from 'react';
|
|
11
|
-
|
|
12
|
-
import { type RotateProps } from './Rotate';
|
|
13
|
-
const Back: React.FC<RotateProps & { text?: string }> = ({
|
|
14
|
-
onPress,
|
|
15
|
-
style,
|
|
16
|
-
text,
|
|
17
|
-
}) => {
|
|
18
|
-
return (
|
|
19
|
-
<TouchableOpacity style={styles.container} onPress={onPress}>
|
|
20
|
-
<Image
|
|
21
|
-
source={require('../assets/preview/back.png')}
|
|
22
|
-
style={[styles.image, style]}
|
|
23
|
-
/>
|
|
24
|
-
{text && <Text style={styles.text}>{text}</Text>}
|
|
25
|
-
</TouchableOpacity>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default Back;
|
|
30
|
-
|
|
31
|
-
export const styles = StyleSheet.create({
|
|
32
|
-
container: {
|
|
33
|
-
alignItems: 'center',
|
|
34
|
-
},
|
|
35
|
-
image: { width: 34, height: 34, marginBottom: 4 },
|
|
36
|
-
text: { color: '#fff' },
|
|
37
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: 刘利军
|
|
3
|
-
* @Date: 2024-01-16 17:50:24
|
|
4
|
-
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-16 10:21:11
|
|
6
|
-
* @Description:
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
9
|
-
import { Image, Text, TouchableOpacity } from 'react-native';
|
|
10
|
-
import React from 'react';
|
|
11
|
-
|
|
12
|
-
import { type RotateProps } from './Rotate';
|
|
13
|
-
import { styles } from './Back';
|
|
14
|
-
const Delete: React.FC<RotateProps & { text?: string }> = ({
|
|
15
|
-
onPress,
|
|
16
|
-
style,
|
|
17
|
-
text,
|
|
18
|
-
}) => {
|
|
19
|
-
return (
|
|
20
|
-
<TouchableOpacity style={styles.container} onPress={onPress}>
|
|
21
|
-
<Image
|
|
22
|
-
source={require('../assets/preview/del.png')}
|
|
23
|
-
style={[styles.image, style]}
|
|
24
|
-
/>
|
|
25
|
-
{text && <Text style={styles.text}>{text}</Text>}
|
|
26
|
-
</TouchableOpacity>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default Delete;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: 刘利军
|
|
3
|
-
* @Date: 2024-12-18 13:55:41
|
|
4
|
-
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2025-01-16 16:42:44
|
|
6
|
-
* @Description:
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
9
|
-
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
10
|
-
import React, { useState } from 'react';
|
|
11
|
-
import { pxToDpWidth } from '../../utils';
|
|
12
|
-
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
13
|
-
import LoadingDots from '../Loading';
|
|
14
|
-
|
|
15
|
-
const Confirm: React.FC<{
|
|
16
|
-
onCancel: () => Promise<void> | void;
|
|
17
|
-
onConfirm: () => Promise<void> | void;
|
|
18
|
-
text?: string;
|
|
19
|
-
title?: string;
|
|
20
|
-
}> = ({ onCancel, onConfirm, text, title }) => {
|
|
21
|
-
const [loading, setLoading] = useState(false);
|
|
22
|
-
const click = async (reset = false) => {
|
|
23
|
-
if (loading) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
setLoading(true);
|
|
27
|
-
if (reset) {
|
|
28
|
-
await onConfirm();
|
|
29
|
-
} else {
|
|
30
|
-
await onCancel();
|
|
31
|
-
}
|
|
32
|
-
setLoading(false);
|
|
33
|
-
};
|
|
34
|
-
return (
|
|
35
|
-
<Animated.View style={styles.modal} entering={FadeIn} exiting={FadeOut}>
|
|
36
|
-
<View style={styles.container}>
|
|
37
|
-
<Text style={[styles.text, styles.title]}>{title || '确认提醒'}</Text>
|
|
38
|
-
<Text style={[styles.text, styles.des]}>{text}</Text>
|
|
39
|
-
<View style={styles.footer}>
|
|
40
|
-
{loading ? (
|
|
41
|
-
<LoadingDots />
|
|
42
|
-
) : (
|
|
43
|
-
<>
|
|
44
|
-
<TouchableOpacity
|
|
45
|
-
style={styles.btn}
|
|
46
|
-
onPress={async () => await click(false)}
|
|
47
|
-
>
|
|
48
|
-
<Text style={styles.btnText}>取消</Text>
|
|
49
|
-
</TouchableOpacity>
|
|
50
|
-
<TouchableOpacity
|
|
51
|
-
style={styles.btn}
|
|
52
|
-
onPress={async () => await click(true)}
|
|
53
|
-
>
|
|
54
|
-
<Text style={[styles.btnText, styles.btnTextConfirm]}>
|
|
55
|
-
确定
|
|
56
|
-
</Text>
|
|
57
|
-
</TouchableOpacity>
|
|
58
|
-
</>
|
|
59
|
-
)}
|
|
60
|
-
</View>
|
|
61
|
-
</View>
|
|
62
|
-
</Animated.View>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export default Confirm;
|
|
67
|
-
|
|
68
|
-
const styles = StyleSheet.create({
|
|
69
|
-
modal: {
|
|
70
|
-
position: 'absolute',
|
|
71
|
-
top: 0,
|
|
72
|
-
left: 0,
|
|
73
|
-
right: 0,
|
|
74
|
-
justifyContent: 'center',
|
|
75
|
-
alignItems: 'center',
|
|
76
|
-
bottom: 0,
|
|
77
|
-
backgroundColor: 'rgba(0,0,0,0.3)',
|
|
78
|
-
zIndex: 99999,
|
|
79
|
-
},
|
|
80
|
-
container: {
|
|
81
|
-
backgroundColor: '#fff',
|
|
82
|
-
width: '80%',
|
|
83
|
-
borderRadius: 10,
|
|
84
|
-
paddingVertical: 12,
|
|
85
|
-
},
|
|
86
|
-
text: {
|
|
87
|
-
textAlign: 'center',
|
|
88
|
-
paddingHorizontal: pxToDpWidth(12),
|
|
89
|
-
color: '#010101',
|
|
90
|
-
},
|
|
91
|
-
title: {
|
|
92
|
-
fontSize: pxToDpWidth(30),
|
|
93
|
-
fontWeight: '500',
|
|
94
|
-
},
|
|
95
|
-
des: {
|
|
96
|
-
fontWeight: '400',
|
|
97
|
-
fontSize: pxToDpWidth(26),
|
|
98
|
-
marginTop: pxToDpWidth(24),
|
|
99
|
-
marginBottom: pxToDpWidth(36),
|
|
100
|
-
},
|
|
101
|
-
footer: {
|
|
102
|
-
paddingTop: pxToDpWidth(24),
|
|
103
|
-
borderTopWidth: 0.5,
|
|
104
|
-
borderTopColor: '#D4D4D4',
|
|
105
|
-
flexDirection: 'row',
|
|
106
|
-
},
|
|
107
|
-
btn: { flex: 1, justifyContent: 'center', alignItems: 'center' },
|
|
108
|
-
btnText: {
|
|
109
|
-
fontSize: pxToDpWidth(30),
|
|
110
|
-
fontWeight: '400',
|
|
111
|
-
color: '#666',
|
|
112
|
-
},
|
|
113
|
-
btnTextConfirm: {
|
|
114
|
-
color: '#FF7600',
|
|
115
|
-
},
|
|
116
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: 刘利军
|
|
3
|
-
* @Date: 2024-01-16 17:51:36
|
|
4
|
-
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-16 09:45:43
|
|
6
|
-
* @Description:
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
9
|
-
import {
|
|
10
|
-
Image,
|
|
11
|
-
TouchableOpacity,
|
|
12
|
-
type ImageStyle,
|
|
13
|
-
type GestureResponderEvent,
|
|
14
|
-
} from 'react-native';
|
|
15
|
-
import React from 'react';
|
|
16
|
-
import { styles } from './Back';
|
|
17
|
-
export type RotateProps = {
|
|
18
|
-
onPress?: (event: GestureResponderEvent) => void;
|
|
19
|
-
style?: ImageStyle;
|
|
20
|
-
};
|
|
21
|
-
const Rotate: React.FC<RotateProps> = ({ onPress, style }) => {
|
|
22
|
-
return (
|
|
23
|
-
<TouchableOpacity onPress={onPress}>
|
|
24
|
-
<Image
|
|
25
|
-
source={require('../assets/preview/rotate.png')}
|
|
26
|
-
style={[styles.image, style]}
|
|
27
|
-
/>
|
|
28
|
-
</TouchableOpacity>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export default Rotate;
|
package/src/components/Save.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: 刘利军
|
|
3
|
-
* @Date: 2024-01-16 17:50:24
|
|
4
|
-
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-16 10:24:18
|
|
6
|
-
* @Description:
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
9
|
-
import { Image, StyleSheet, Text, TouchableOpacity } from 'react-native';
|
|
10
|
-
import React from 'react';
|
|
11
|
-
|
|
12
|
-
import { type RotateProps } from './Rotate';
|
|
13
|
-
const Save: React.FC<RotateProps & { text?: string }> = ({
|
|
14
|
-
onPress,
|
|
15
|
-
style,
|
|
16
|
-
text,
|
|
17
|
-
}) => {
|
|
18
|
-
return (
|
|
19
|
-
<TouchableOpacity style={styles.container} onPress={onPress}>
|
|
20
|
-
<Image
|
|
21
|
-
source={require('../assets/preview/save.png')}
|
|
22
|
-
style={[styles.image, style]}
|
|
23
|
-
/>
|
|
24
|
-
{text && <Text style={styles.text}>{text}</Text>}
|
|
25
|
-
</TouchableOpacity>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default Save;
|
|
30
|
-
|
|
31
|
-
export const styles = StyleSheet.create({
|
|
32
|
-
container: {
|
|
33
|
-
alignItems: 'center',
|
|
34
|
-
},
|
|
35
|
-
image: { width: 34, height: 34, marginBottom: 4 },
|
|
36
|
-
text: { color: '#fff' },
|
|
37
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: 刘利军
|
|
3
|
-
* @Date: 2024-01-17 16:31:19
|
|
4
|
-
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-20 14:58:46
|
|
6
|
-
* @Description:
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import React, { useRef, useState } from 'react';
|
|
11
|
-
import { Camera, NoPermission, NoCamera, ModalView } from '../../camera';
|
|
12
|
-
import type { CameraBack, CameraProps, CameraRef } from '../../utils';
|
|
13
|
-
import {
|
|
14
|
-
useCameraDevice,
|
|
15
|
-
useCameraPermission,
|
|
16
|
-
useMicrophonePermission,
|
|
17
|
-
} from 'react-native-vision-camera';
|
|
18
|
-
import { DefaultData } from '../../utils';
|
|
19
|
-
import Container from '../../camera/Container';
|
|
20
|
-
|
|
21
|
-
const useCamera = (): [CameraRef, React.ReactElement] => {
|
|
22
|
-
const [cameraConfig, setCameraConfig] = useState<CameraProps>(DefaultData);
|
|
23
|
-
const [visible, setVisible] = useState(false);
|
|
24
|
-
|
|
25
|
-
const close = (
|
|
26
|
-
data: CameraBack = { code: 200, data: [], message: '返回' }
|
|
27
|
-
) => {
|
|
28
|
-
setVisible(false);
|
|
29
|
-
ref.current.resolvePromise(data);
|
|
30
|
-
};
|
|
31
|
-
const ref = useRef<{
|
|
32
|
-
resolvePromise: (data: CameraBack) => void;
|
|
33
|
-
}>({
|
|
34
|
-
resolvePromise: () => {},
|
|
35
|
-
});
|
|
36
|
-
const api = React.useMemo<CameraRef>(() => {
|
|
37
|
-
return {
|
|
38
|
-
open: async (config) => {
|
|
39
|
-
setVisible(true);
|
|
40
|
-
setCameraConfig((val) => ({
|
|
41
|
-
...val,
|
|
42
|
-
...config,
|
|
43
|
-
}));
|
|
44
|
-
return new Promise<CameraBack>((resolve) => {
|
|
45
|
-
ref.current.resolvePromise = resolve;
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
close: () => close(),
|
|
49
|
-
};
|
|
50
|
-
}, []);
|
|
51
|
-
|
|
52
|
-
const isVideo = (cameraConfig?.cameraMode || []).some(
|
|
53
|
-
(item) => item.mode === 'video'
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const device = useCameraDevice('front');
|
|
57
|
-
// 相机权限请求
|
|
58
|
-
const { hasPermission, requestPermission } = useCameraPermission();
|
|
59
|
-
// 麦克风权限
|
|
60
|
-
const {
|
|
61
|
-
hasPermission: hasMicroPermission,
|
|
62
|
-
requestPermission: hasRequestMicroPermission,
|
|
63
|
-
} = useMicrophonePermission();
|
|
64
|
-
|
|
65
|
-
let Holder = (
|
|
66
|
-
<Camera
|
|
67
|
-
data={cameraConfig}
|
|
68
|
-
back={() => close()}
|
|
69
|
-
onChange={(val) => close(val)}
|
|
70
|
-
/>
|
|
71
|
-
);
|
|
72
|
-
if (visible) {
|
|
73
|
-
if (!hasPermission) {
|
|
74
|
-
requestPermission();
|
|
75
|
-
Holder = (
|
|
76
|
-
<Container onCancel={() => close()}>
|
|
77
|
-
<NoPermission />
|
|
78
|
-
</Container>
|
|
79
|
-
);
|
|
80
|
-
} else if (isVideo && !hasMicroPermission) {
|
|
81
|
-
hasRequestMicroPermission();
|
|
82
|
-
Holder = (
|
|
83
|
-
<Container onCancel={() => close()}>
|
|
84
|
-
<NoPermission />
|
|
85
|
-
</Container>
|
|
86
|
-
);
|
|
87
|
-
} else if (device == null) {
|
|
88
|
-
Holder = <NoCamera />;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return [api, <ModalView visible={visible}>{Holder}</ModalView>];
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export default useCamera;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: 刘利军
|
|
3
|
-
* @Date: 2024-01-17 16:28:56
|
|
4
|
-
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-01-17 16:29:26
|
|
6
|
-
* @Description:
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
9
|
-
import type { DependencyList } from 'react';
|
|
10
|
-
import { useRef } from 'react';
|
|
11
|
-
import depsAreSame from '../../utils/depsAreSame';
|
|
12
|
-
|
|
13
|
-
export default function useCreation<T>(factory: () => T, deps: DependencyList) {
|
|
14
|
-
const { current } = useRef({
|
|
15
|
-
deps,
|
|
16
|
-
obj: undefined as undefined | T,
|
|
17
|
-
initialized: false,
|
|
18
|
-
});
|
|
19
|
-
if (current.initialized === false || !depsAreSame(current.deps, deps)) {
|
|
20
|
-
current.deps = deps;
|
|
21
|
-
current.obj = factory();
|
|
22
|
-
current.initialized = true;
|
|
23
|
-
}
|
|
24
|
-
return current.obj as T;
|
|
25
|
-
}
|