@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
package/src/camera/Container.tsx
CHANGED
|
@@ -1,59 +1,233 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @Date: 2024-12-02 11:24:47
|
|
4
|
-
* @LastEditors: 刘利军
|
|
5
|
-
* @LastEditTime: 2024-12-16 09:33:14
|
|
6
|
-
* @Description:
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Linking, StyleSheet, View } from 'react-native';
|
|
9
3
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from '
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
</View>
|
|
29
|
-
<View style={styles.children}>{children}</View>
|
|
30
|
-
</SafeAreaView>
|
|
31
|
-
);
|
|
4
|
+
useCameraDevice,
|
|
5
|
+
useCameraPermission,
|
|
6
|
+
} from 'react-native-vision-camera';
|
|
7
|
+
import { useSharedValue } from 'react-native-reanimated';
|
|
8
|
+
import type { CameraResult, CustomPhotoFile, OpenConfig } from '../utils';
|
|
9
|
+
import { NoCamera } from './NoCamera';
|
|
10
|
+
import { NoPermission } from './NoPermission';
|
|
11
|
+
import { Loading } from '../components/Loading';
|
|
12
|
+
import { Camera, type CameraHandle } from './Camera';
|
|
13
|
+
import { PreViewContainer } from './preview';
|
|
14
|
+
import { Footer } from './footer';
|
|
15
|
+
import { SetUp, type AspectRatio, type FlashMode } from './setup';
|
|
16
|
+
|
|
17
|
+
const NEUTRAL_ZOOM = 1;
|
|
18
|
+
|
|
19
|
+
type Props = {
|
|
20
|
+
config: OpenConfig;
|
|
21
|
+
onSettle: (r: CameraResult) => void;
|
|
32
22
|
};
|
|
33
23
|
|
|
34
|
-
|
|
24
|
+
type PermissionState = 'pending' | 'granted' | 'denied';
|
|
25
|
+
|
|
26
|
+
export function Container({ config, onSettle }: Props) {
|
|
27
|
+
const settledRef = useRef(false);
|
|
28
|
+
|
|
29
|
+
const settle = useCallback(
|
|
30
|
+
(r: CameraResult) => {
|
|
31
|
+
if (settledRef.current) return;
|
|
32
|
+
settledRef.current = true;
|
|
33
|
+
onSettle(r);
|
|
34
|
+
},
|
|
35
|
+
[onSettle]
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
useEffect(
|
|
39
|
+
() => () => {
|
|
40
|
+
if (!settledRef.current) {
|
|
41
|
+
onSettle({ code: 0, data: [], message: 'cancelled' });
|
|
42
|
+
settledRef.current = true;
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
[onSettle]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const { hasPermission, requestPermission } = useCameraPermission();
|
|
49
|
+
const [state, setState] = useState<PermissionState>(
|
|
50
|
+
hasPermission ? 'granted' : 'pending'
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (hasPermission) {
|
|
55
|
+
setState('granted');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let cancelled = false;
|
|
59
|
+
// 5.x:Android 并行 requestPermission 调用会 leak coroutine(issue #3834),
|
|
60
|
+
// 必须 .catch(() => {}) 兜底;依赖 hasPermission 作为 source of truth
|
|
61
|
+
requestPermission()
|
|
62
|
+
.then((ok) => {
|
|
63
|
+
if (cancelled) return;
|
|
64
|
+
setState(ok ? 'granted' : 'denied');
|
|
65
|
+
})
|
|
66
|
+
.catch(() => {
|
|
67
|
+
if (cancelled) return;
|
|
68
|
+
setState('denied');
|
|
69
|
+
});
|
|
70
|
+
return () => {
|
|
71
|
+
cancelled = true;
|
|
72
|
+
};
|
|
73
|
+
}, [hasPermission, requestPermission]);
|
|
74
|
+
|
|
75
|
+
// 5.x:physicalDevices 字符串不带 -camera;单 'wide-angle' 规避 iOS #3773
|
|
76
|
+
const device = useCameraDevice('back', {
|
|
77
|
+
physicalDevices: ['wide-angle'],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const cameraRef = useRef<CameraHandle>(null);
|
|
81
|
+
const [photos, setPhotos] = useState<CustomPhotoFile[]>([]);
|
|
82
|
+
const [previewing, setPreviewing] = useState(false);
|
|
83
|
+
const [recording, setRecording] = useState(false);
|
|
84
|
+
const [modeIndex, setModeIndex] = useState(0);
|
|
85
|
+
const currentMode = config.cameraMode[modeIndex];
|
|
86
|
+
|
|
87
|
+
const [flash, setFlash] = useState<FlashMode>('off');
|
|
88
|
+
const [aspectRatio, setAspectRatio] = useState<AspectRatio>('4:3');
|
|
89
|
+
const zoomShared = useSharedValue(NEUTRAL_ZOOM);
|
|
90
|
+
const [lensLabel, setLensLabel] = useState(`${NEUTRAL_ZOOM.toFixed(1)}x`);
|
|
91
|
+
|
|
92
|
+
const onShutter = async () => {
|
|
93
|
+
if (currentMode?.mode === 'video') {
|
|
94
|
+
if (!recording) {
|
|
95
|
+
await cameraRef.current?.startVideo();
|
|
96
|
+
setRecording(true);
|
|
97
|
+
} else {
|
|
98
|
+
const f = await cameraRef.current?.stopVideo();
|
|
99
|
+
setRecording(false);
|
|
100
|
+
if (f) {
|
|
101
|
+
setPhotos([f]);
|
|
102
|
+
setPreviewing(true);
|
|
103
|
+
} else {
|
|
104
|
+
settle({ code: 503, data: [], message: 'video_failed' });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const f = await cameraRef.current?.capture();
|
|
110
|
+
if (!f) {
|
|
111
|
+
settle({ code: 500, data: photos, message: 'capture_failed' });
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
setPhotos((prev) => [...prev, f]);
|
|
115
|
+
if (currentMode?.mode !== 'continuous') {
|
|
116
|
+
setPreviewing(true);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
if (state === 'denied') {
|
|
121
|
+
return (
|
|
122
|
+
<NoPermission
|
|
123
|
+
onCancel={() =>
|
|
124
|
+
settle({ code: 403, data: [], message: 'permission_denied' })
|
|
125
|
+
}
|
|
126
|
+
onOpenSettings={() => Linking.openSettings()}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (state === 'pending') {
|
|
132
|
+
return (
|
|
133
|
+
<View style={styles.root} testID="permission-pending">
|
|
134
|
+
<Loading />
|
|
135
|
+
</View>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (previewing) {
|
|
140
|
+
return (
|
|
141
|
+
<PreViewContainer
|
|
142
|
+
files={photos}
|
|
143
|
+
onRetake={() => {
|
|
144
|
+
setPhotos([]);
|
|
145
|
+
setPreviewing(false);
|
|
146
|
+
}}
|
|
147
|
+
onConfirm={() => settle({ code: 200, data: photos, message: 'ok' })}
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (device == null) {
|
|
153
|
+
return (
|
|
154
|
+
<NoCamera
|
|
155
|
+
onCancel={() => settle({ code: 404, data: [], message: 'no_device' })}
|
|
156
|
+
/>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (currentMode == null) {
|
|
161
|
+
return (
|
|
162
|
+
<NoCamera
|
|
163
|
+
onCancel={() =>
|
|
164
|
+
settle({ code: 500, data: [], message: 'invalid_config' })
|
|
165
|
+
}
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const onToggleLens = () => {
|
|
171
|
+
if (lensLabel.startsWith(device.minZoom.toFixed(1))) {
|
|
172
|
+
zoomShared.value = NEUTRAL_ZOOM;
|
|
173
|
+
setLensLabel(`${NEUTRAL_ZOOM.toFixed(1)}x`);
|
|
174
|
+
} else {
|
|
175
|
+
zoomShared.value = device.minZoom;
|
|
176
|
+
setLensLabel(`${device.minZoom.toFixed(1)}x`);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<View style={styles.root} testID="device-ready">
|
|
182
|
+
<Camera
|
|
183
|
+
ref={cameraRef}
|
|
184
|
+
device={device}
|
|
185
|
+
currentMode={currentMode}
|
|
186
|
+
flash={flash}
|
|
187
|
+
aspectRatio={aspectRatio}
|
|
188
|
+
zoomShared={zoomShared}
|
|
189
|
+
/>
|
|
190
|
+
{!previewing && (
|
|
191
|
+
<SetUp
|
|
192
|
+
flash={flash}
|
|
193
|
+
aspectRatio={aspectRatio}
|
|
194
|
+
onChangeFlash={setFlash}
|
|
195
|
+
onChangeAspectRatio={setAspectRatio}
|
|
196
|
+
onToggleLens={onToggleLens}
|
|
197
|
+
lensLabel={lensLabel}
|
|
198
|
+
/>
|
|
199
|
+
)}
|
|
200
|
+
<Footer
|
|
201
|
+
modes={config.cameraMode}
|
|
202
|
+
currentIndex={modeIndex}
|
|
203
|
+
recording={recording}
|
|
204
|
+
onShutter={onShutter}
|
|
205
|
+
onSelectMode={(i) => {
|
|
206
|
+
if (config.dataRetainedMode === 'clear' && i !== modeIndex) {
|
|
207
|
+
setPhotos([]);
|
|
208
|
+
}
|
|
209
|
+
setModeIndex(i);
|
|
210
|
+
}}
|
|
211
|
+
onCancel={() => settle({ code: 0, data: [], message: 'cancelled' })}
|
|
212
|
+
onFinishBurst={
|
|
213
|
+
currentMode?.mode === 'continuous'
|
|
214
|
+
? () => setPreviewing(true)
|
|
215
|
+
: undefined
|
|
216
|
+
}
|
|
217
|
+
burstCount={
|
|
218
|
+
currentMode?.mode === 'continuous' ? photos.length : undefined
|
|
219
|
+
}
|
|
220
|
+
/>
|
|
221
|
+
</View>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
35
224
|
|
|
36
225
|
const styles = StyleSheet.create({
|
|
37
|
-
|
|
38
|
-
flex: 1,
|
|
39
|
-
margin: 0,
|
|
40
|
-
backgroundColor: '#fff',
|
|
41
|
-
},
|
|
42
|
-
container: { flex: 1 },
|
|
43
|
-
headerContainer: {
|
|
44
|
-
marginHorizontal: 12,
|
|
45
|
-
marginBottom: 12,
|
|
46
|
-
height: 25,
|
|
47
|
-
display: 'flex',
|
|
48
|
-
alignItems: 'flex-end',
|
|
49
|
-
},
|
|
50
|
-
img: {
|
|
51
|
-
width: 25,
|
|
52
|
-
height: 25,
|
|
53
|
-
},
|
|
54
|
-
children: {
|
|
55
|
-
display: 'flex',
|
|
226
|
+
root: {
|
|
56
227
|
flex: 1,
|
|
228
|
+
// 相机主容器固定黑底:相机 UX 惯例(预览 / 拍照取景需要黑底凸显),
|
|
229
|
+
// 不走 c.background token.
|
|
230
|
+
backgroundColor: '#000',
|
|
57
231
|
justifyContent: 'center',
|
|
58
232
|
alignItems: 'center',
|
|
59
233
|
},
|
package/src/camera/Error.tsx
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { StyleSheet, View } from 'react-native';
|
|
2
|
+
import {
|
|
3
|
+
Empty,
|
|
4
|
+
r,
|
|
5
|
+
useThemedStyles,
|
|
6
|
+
type ColorTokens,
|
|
7
|
+
} from '@unif/react-native-design';
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
onPress,
|
|
8
|
-
}) => {
|
|
9
|
+
export function ErrorView({ message }: { message: string }) {
|
|
10
|
+
const styles = useThemedStyles(makeStyles);
|
|
9
11
|
return (
|
|
10
|
-
<View style={styles.
|
|
11
|
-
<
|
|
12
|
-
<Text>code:{data?.code}||''错误</Text>
|
|
13
|
-
<Text>message:{data?.message}||错误</Text>
|
|
14
|
-
<Text>cause:{JSON.stringify(data?.cause)}</Text>
|
|
12
|
+
<View style={styles.root} testID="error-view">
|
|
13
|
+
<Empty icon="error-alert" title={message} />
|
|
15
14
|
</View>
|
|
16
15
|
);
|
|
17
|
-
}
|
|
16
|
+
}
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
18
|
+
const makeStyles = (c: ColorTokens) =>
|
|
19
|
+
StyleSheet.create({
|
|
20
|
+
root: {
|
|
21
|
+
flex: 1,
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
padding: r(24),
|
|
25
|
+
backgroundColor: c.background,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -1,70 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* @LastEditTime: 2025-01-17 08:44:43
|
|
6
|
-
* @Description: 聚焦指示器组件
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated, StyleSheet } from 'react-native';
|
|
3
|
+
import { r } from '@unif/react-native-design';
|
|
4
|
+
import type { Point } from '../utils';
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
import React, { useRef, useEffect } from 'react';
|
|
6
|
+
type Props = { point: Point; onAnimationEnd: () => void };
|
|
12
7
|
|
|
13
|
-
|
|
14
|
-
x: number;
|
|
15
|
-
y: number;
|
|
16
|
-
}
|
|
8
|
+
const SIZE = r(80);
|
|
17
9
|
|
|
18
|
-
|
|
19
|
-
const scale = useRef(new Animated.Value(1.
|
|
20
|
-
const opacity = useRef(new Animated.Value(1));
|
|
10
|
+
export function FocusIndicator({ point, onAnimationEnd }: Props) {
|
|
11
|
+
const scale = useRef(new Animated.Value(1.6)).current;
|
|
12
|
+
const opacity = useRef(new Animated.Value(1)).current;
|
|
21
13
|
|
|
22
14
|
useEffect(() => {
|
|
23
|
-
scale.current.setValue(1.2);
|
|
24
|
-
opacity.current.setValue(1);
|
|
25
|
-
|
|
26
15
|
Animated.parallel([
|
|
27
|
-
Animated.timing(scale
|
|
16
|
+
Animated.timing(scale, {
|
|
28
17
|
toValue: 1,
|
|
29
18
|
duration: 200,
|
|
30
19
|
useNativeDriver: true,
|
|
31
20
|
}),
|
|
32
|
-
Animated.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
21
|
+
Animated.sequence([
|
|
22
|
+
Animated.delay(600),
|
|
23
|
+
Animated.timing(opacity, {
|
|
24
|
+
toValue: 0,
|
|
25
|
+
duration: 200,
|
|
26
|
+
useNativeDriver: true,
|
|
27
|
+
}),
|
|
28
|
+
]),
|
|
29
|
+
]).start(() => onAnimationEnd());
|
|
30
|
+
}, [scale, opacity, onAnimationEnd]);
|
|
42
31
|
|
|
43
32
|
return (
|
|
44
33
|
<Animated.View
|
|
45
34
|
style={[
|
|
46
|
-
styles.
|
|
35
|
+
styles.box,
|
|
47
36
|
{
|
|
48
|
-
left: x -
|
|
49
|
-
top: y -
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
transform: [{ scale: scale.current }],
|
|
53
|
-
opacity: opacity.current,
|
|
37
|
+
left: point.x - SIZE / 2,
|
|
38
|
+
top: point.y - SIZE / 2,
|
|
39
|
+
transform: [{ scale }],
|
|
40
|
+
opacity,
|
|
54
41
|
},
|
|
55
42
|
]}
|
|
43
|
+
pointerEvents="none"
|
|
44
|
+
testID="focus-indicator"
|
|
56
45
|
/>
|
|
57
46
|
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export default FocusIndicator;
|
|
47
|
+
}
|
|
61
48
|
|
|
62
49
|
const styles = StyleSheet.create({
|
|
63
|
-
|
|
50
|
+
box: {
|
|
64
51
|
position: 'absolute',
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
width: SIZE,
|
|
53
|
+
height: SIZE,
|
|
54
|
+
borderWidth: 1.5,
|
|
55
|
+
// 对焦黄框:相机 UX 惯例(iOS / Android 系统相机统一用饱和黄高对比度),
|
|
56
|
+
// 不走主题 token —— 任何主题下都需要在镜头预览(黑底为主)上一眼可见.
|
|
57
|
+
borderColor: 'yellow',
|
|
58
|
+
borderRadius: r(6),
|
|
69
59
|
},
|
|
70
60
|
});
|
package/src/camera/ModalView.tsx
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* @LastEditTime: 2024-12-20 16:02:36
|
|
6
|
-
* @Description:
|
|
7
|
-
* @PageName:
|
|
8
|
-
*/
|
|
9
|
-
import { Modal, StyleSheet } from 'react-native';
|
|
10
|
-
import React, { type PropsWithChildren } from 'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
4
|
+
import { ThemeProvider } from '@unif/react-native-design';
|
|
11
5
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
type Props = {
|
|
7
|
+
visible: boolean;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function ModalView({ visible, onClose, children }: Props) {
|
|
16
13
|
return (
|
|
17
|
-
<Modal
|
|
18
|
-
{
|
|
14
|
+
<Modal
|
|
15
|
+
visible={visible}
|
|
16
|
+
animationType="slide"
|
|
17
|
+
statusBarTranslucent
|
|
18
|
+
onRequestClose={onClose}
|
|
19
|
+
testID="camera-modal"
|
|
20
|
+
>
|
|
21
|
+
<SafeAreaProvider>
|
|
22
|
+
<ThemeProvider>
|
|
23
|
+
<View style={styles.root}>{children}</View>
|
|
24
|
+
</ThemeProvider>
|
|
25
|
+
</SafeAreaProvider>
|
|
19
26
|
</Modal>
|
|
20
27
|
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default ModalView;
|
|
28
|
+
}
|
|
24
29
|
|
|
25
30
|
const styles = StyleSheet.create({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
margin: 0,
|
|
29
|
-
backgroundColor: '#000',
|
|
30
|
-
},
|
|
31
|
+
// 相机 Modal 根视图固定黑底:相机 UX 惯例,与 Container / 预览系列一致.
|
|
32
|
+
root: { flex: 1, backgroundColor: '#000' },
|
|
31
33
|
});
|
package/src/camera/NoCamera.tsx
CHANGED
|
@@ -1,16 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { Text } from 'react-native';
|
|
10
|
-
import React from 'react';
|
|
1
|
+
import { StyleSheet, View } from 'react-native';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Empty,
|
|
5
|
+
r,
|
|
6
|
+
useThemedStyles,
|
|
7
|
+
type ColorTokens,
|
|
8
|
+
} from '@unif/react-native-design';
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
return <Text>未检测到摄像头,请重试!</Text>;
|
|
14
|
-
};
|
|
10
|
+
type Props = { onCancel: () => void };
|
|
15
11
|
|
|
16
|
-
export
|
|
12
|
+
export function NoCamera({ onCancel }: Props) {
|
|
13
|
+
const styles = useThemedStyles(makeStyles);
|
|
14
|
+
return (
|
|
15
|
+
<View style={styles.root} testID="no-camera">
|
|
16
|
+
<Empty icon="camera-off" title="未检测到可用相机" />
|
|
17
|
+
<View style={styles.row}>
|
|
18
|
+
<Button
|
|
19
|
+
variant="primary"
|
|
20
|
+
label="关闭"
|
|
21
|
+
onPress={onCancel}
|
|
22
|
+
testID="close-btn"
|
|
23
|
+
/>
|
|
24
|
+
</View>
|
|
25
|
+
</View>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const makeStyles = (c: ColorTokens) =>
|
|
30
|
+
StyleSheet.create({
|
|
31
|
+
root: {
|
|
32
|
+
flex: 1,
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
padding: r(24),
|
|
36
|
+
backgroundColor: c.background,
|
|
37
|
+
},
|
|
38
|
+
row: { marginTop: r(16) },
|
|
39
|
+
});
|
|
@@ -1,43 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { Linking, View, Text, StyleSheet } from 'react-native';
|
|
10
|
-
import React from 'react';
|
|
1
|
+
import { StyleSheet, View } from 'react-native';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Empty,
|
|
5
|
+
r,
|
|
6
|
+
useThemedStyles,
|
|
7
|
+
type ColorTokens,
|
|
8
|
+
} from '@unif/react-native-design';
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
type Props = { onCancel: () => void; onOpenSettings?: () => void };
|
|
11
|
+
|
|
12
|
+
export function NoPermission({ onCancel, onOpenSettings }: Props) {
|
|
13
|
+
const styles = useThemedStyles(makeStyles);
|
|
13
14
|
return (
|
|
14
|
-
<View>
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
<View style={styles.root} testID="no-permission">
|
|
16
|
+
<Empty
|
|
17
|
+
icon="permission-denied"
|
|
18
|
+
title="相机权限被拒"
|
|
19
|
+
desc="请前往系统设置开启权限"
|
|
20
|
+
/>
|
|
21
|
+
<View style={styles.row}>
|
|
22
|
+
<Button
|
|
23
|
+
variant="ghost"
|
|
24
|
+
label="取消"
|
|
25
|
+
onPress={onCancel}
|
|
26
|
+
testID="cancel-btn"
|
|
27
|
+
/>
|
|
28
|
+
{onOpenSettings && (
|
|
29
|
+
<Button
|
|
30
|
+
variant="primary"
|
|
31
|
+
label="去设置"
|
|
32
|
+
onPress={onOpenSettings}
|
|
33
|
+
testID="open-settings-btn"
|
|
34
|
+
/>
|
|
35
|
+
)}
|
|
31
36
|
</View>
|
|
32
37
|
</View>
|
|
33
38
|
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default NoPermission;
|
|
39
|
+
}
|
|
37
40
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const makeStyles = (c: ColorTokens) =>
|
|
42
|
+
StyleSheet.create({
|
|
43
|
+
root: {
|
|
44
|
+
flex: 1,
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
padding: r(24),
|
|
48
|
+
backgroundColor: c.background,
|
|
49
|
+
},
|
|
50
|
+
row: { flexDirection: 'row', gap: r(16), marginTop: r(16) },
|
|
51
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CameraPhotoOutput,
|
|
3
|
+
CapturePhotoSettings,
|
|
4
|
+
CameraOrientation,
|
|
5
|
+
} from 'react-native-vision-camera';
|
|
6
|
+
|
|
7
|
+
export type CapturedPhotoRaw = {
|
|
8
|
+
path: string;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
orientation: CameraOrientation;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 5.x 拍照标准序列:
|
|
16
|
+
* 1. await photoOutput.capturePhoto(settings, {})
|
|
17
|
+
* 2. await photo.saveToTemporaryFileAsync()
|
|
18
|
+
* 3. 读 photo.width / photo.height / photo.orientation
|
|
19
|
+
* 4. photo.dispose() (try/finally 保护)
|
|
20
|
+
*/
|
|
21
|
+
export async function capturePhotoToFile(
|
|
22
|
+
photoOutput: CameraPhotoOutput,
|
|
23
|
+
settings: CapturePhotoSettings
|
|
24
|
+
): Promise<CapturedPhotoRaw> {
|
|
25
|
+
const photo = await photoOutput.capturePhoto(settings, {});
|
|
26
|
+
try {
|
|
27
|
+
const path = await photo.saveToTemporaryFileAsync();
|
|
28
|
+
return {
|
|
29
|
+
path,
|
|
30
|
+
width: photo.width,
|
|
31
|
+
height: photo.height,
|
|
32
|
+
orientation: photo.orientation,
|
|
33
|
+
};
|
|
34
|
+
} finally {
|
|
35
|
+
photo.dispose();
|
|
36
|
+
}
|
|
37
|
+
}
|