@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.
Files changed (407) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +92 -22
  3. package/lib/module/camera/Camera.js +163 -285
  4. package/lib/module/camera/Camera.js.map +1 -1
  5. package/lib/module/camera/Container.js +209 -49
  6. package/lib/module/camera/Container.js.map +1 -1
  7. package/lib/module/camera/Error.js +23 -18
  8. package/lib/module/camera/Error.js.map +1 -1
  9. package/lib/module/camera/FocusIndicator.js +35 -41
  10. package/lib/module/camera/FocusIndicator.js.map +1 -1
  11. package/lib/module/camera/ModalView.js +28 -21
  12. package/lib/module/camera/ModalView.js.map +1 -1
  13. package/lib/module/camera/NoCamera.js +38 -14
  14. package/lib/module/camera/NoCamera.js.map +1 -1
  15. package/lib/module/camera/NoPermission.js +44 -38
  16. package/lib/module/camera/NoPermission.js.map +1 -1
  17. package/lib/module/camera/capturePhotoHelper.js +24 -0
  18. package/lib/module/camera/capturePhotoHelper.js.map +1 -0
  19. package/lib/module/camera/footer/Footer.js +83 -140
  20. package/lib/module/camera/footer/Footer.js.map +1 -1
  21. package/lib/module/camera/footer/index.js +3 -2
  22. package/lib/module/camera/footer/index.js.map +1 -1
  23. package/lib/module/camera/index.js +11 -13
  24. package/lib/module/camera/index.js.map +1 -1
  25. package/lib/module/camera/preview/PreView.js +36 -93
  26. package/lib/module/camera/preview/PreView.js.map +1 -1
  27. package/lib/module/camera/preview/PreViewContainer.js +28 -29
  28. package/lib/module/camera/preview/PreViewContainer.js.map +1 -1
  29. package/lib/module/camera/preview/PreviewFooter.js +30 -21
  30. package/lib/module/camera/preview/PreviewFooter.js.map +1 -1
  31. package/lib/module/camera/preview/SinglePre.js +28 -60
  32. package/lib/module/camera/preview/SinglePre.js.map +1 -1
  33. package/lib/module/camera/preview/index.js +6 -12
  34. package/lib/module/camera/preview/index.js.map +1 -1
  35. package/lib/module/camera/setup/SetUp.js +67 -189
  36. package/lib/module/camera/setup/SetUp.js.map +1 -1
  37. package/lib/module/camera/setup/index.js +3 -2
  38. package/lib/module/camera/setup/index.js.map +1 -1
  39. package/lib/module/components/Carousel/Carousel.js +33 -40
  40. package/lib/module/components/Carousel/Carousel.js.map +1 -1
  41. package/lib/module/components/Carousel/SlideItem.js +22 -70
  42. package/lib/module/components/Carousel/SlideItem.js.map +1 -1
  43. package/lib/module/components/Carousel/index.js +4 -11
  44. package/lib/module/components/Carousel/index.js.map +1 -1
  45. package/lib/module/components/Loading.js +15 -61
  46. package/lib/module/components/Loading.js.map +1 -1
  47. package/lib/module/components/PreviewThumbnail.js +36 -33
  48. package/lib/module/components/PreviewThumbnail.js.map +1 -1
  49. package/lib/module/components/index.js +5 -8
  50. package/lib/module/components/index.js.map +1 -1
  51. package/lib/module/hooks/index.js +5 -11
  52. package/lib/module/hooks/index.js.map +1 -1
  53. package/lib/module/hooks/useCamera.js +44 -0
  54. package/lib/module/hooks/useCamera.js.map +1 -0
  55. package/lib/module/hooks/useConfirm.js +13 -49
  56. package/lib/module/hooks/useConfirm.js.map +1 -1
  57. package/lib/module/hooks/useCreation.js +18 -0
  58. package/lib/module/hooks/useCreation.js.map +1 -0
  59. package/lib/module/index.js +4 -24
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/module/package.json +1 -0
  62. package/lib/module/utils/depsAreSame.js +7 -4
  63. package/lib/module/utils/depsAreSame.js.map +1 -1
  64. package/lib/module/utils/index.js +6 -14
  65. package/lib/module/utils/index.js.map +1 -1
  66. package/lib/module/utils/interface.js +1 -21
  67. package/lib/module/utils/interface.js.map +1 -1
  68. package/lib/module/utils/px-to-dp.js +6 -10
  69. package/lib/module/utils/px-to-dp.js.map +1 -1
  70. package/lib/module/utils/util.js +16 -40
  71. package/lib/module/utils/util.js.map +1 -1
  72. package/lib/typescript/jest.setup.d.ts +1 -0
  73. package/lib/typescript/jest.setup.d.ts.map +1 -0
  74. package/lib/typescript/package.json +1 -0
  75. package/lib/typescript/src/camera/Camera.d.ts +18 -10
  76. package/lib/typescript/src/camera/Camera.d.ts.map +1 -1
  77. package/lib/typescript/src/camera/Container.d.ts +7 -5
  78. package/lib/typescript/src/camera/Container.d.ts.map +1 -1
  79. package/lib/typescript/src/camera/Error.d.ts +3 -7
  80. package/lib/typescript/src/camera/Error.d.ts.map +1 -1
  81. package/lib/typescript/src/camera/FocusIndicator.d.ts +7 -7
  82. package/lib/typescript/src/camera/FocusIndicator.d.ts.map +1 -1
  83. package/lib/typescript/src/camera/ModalView.d.ts +7 -4
  84. package/lib/typescript/src/camera/ModalView.d.ts.map +1 -1
  85. package/lib/typescript/src/camera/NoCamera.d.ts +5 -3
  86. package/lib/typescript/src/camera/NoCamera.d.ts.map +1 -1
  87. package/lib/typescript/src/camera/NoPermission.d.ts +6 -3
  88. package/lib/typescript/src/camera/NoPermission.d.ts.map +1 -1
  89. package/lib/typescript/src/camera/capturePhotoHelper.d.ts +16 -0
  90. package/lib/typescript/src/camera/capturePhotoHelper.d.ts.map +1 -0
  91. package/lib/typescript/src/camera/footer/Footer.d.ts +13 -15
  92. package/lib/typescript/src/camera/footer/Footer.d.ts.map +1 -1
  93. package/lib/typescript/src/camera/footer/index.d.ts +1 -2
  94. package/lib/typescript/src/camera/footer/index.d.ts.map +1 -1
  95. package/lib/typescript/src/camera/index.d.ts +9 -5
  96. package/lib/typescript/src/camera/index.d.ts.map +1 -1
  97. package/lib/typescript/src/camera/preview/PreView.d.ts +6 -9
  98. package/lib/typescript/src/camera/preview/PreView.d.ts.map +1 -1
  99. package/lib/typescript/src/camera/preview/PreViewContainer.d.ts +8 -5
  100. package/lib/typescript/src/camera/preview/PreViewContainer.d.ts.map +1 -1
  101. package/lib/typescript/src/camera/preview/PreviewFooter.d.ts +6 -6
  102. package/lib/typescript/src/camera/preview/PreviewFooter.d.ts.map +1 -1
  103. package/lib/typescript/src/camera/preview/SinglePre.d.ts +5 -28
  104. package/lib/typescript/src/camera/preview/SinglePre.d.ts.map +1 -1
  105. package/lib/typescript/src/camera/preview/index.d.ts +4 -4
  106. package/lib/typescript/src/camera/preview/index.d.ts.map +1 -1
  107. package/lib/typescript/src/camera/setup/SetUp.d.ts +12 -11
  108. package/lib/typescript/src/camera/setup/SetUp.d.ts.map +1 -1
  109. package/lib/typescript/src/camera/setup/index.d.ts +1 -2
  110. package/lib/typescript/src/camera/setup/index.d.ts.map +1 -1
  111. package/lib/typescript/src/components/Carousel/Carousel.d.ts +6 -8
  112. package/lib/typescript/src/components/Carousel/Carousel.d.ts.map +1 -1
  113. package/lib/typescript/src/components/Carousel/SlideItem.d.ts +4 -12
  114. package/lib/typescript/src/components/Carousel/SlideItem.d.ts.map +1 -1
  115. package/lib/typescript/src/components/Carousel/index.d.ts +2 -3
  116. package/lib/typescript/src/components/Carousel/index.d.ts.map +1 -1
  117. package/lib/typescript/src/components/Loading.d.ts +1 -3
  118. package/lib/typescript/src/components/Loading.d.ts.map +1 -1
  119. package/lib/typescript/src/components/PreviewThumbnail.d.ts +7 -8
  120. package/lib/typescript/src/components/PreviewThumbnail.d.ts.map +1 -1
  121. package/lib/typescript/src/components/index.d.ts +2 -7
  122. package/lib/typescript/src/components/index.d.ts.map +1 -1
  123. package/lib/typescript/src/hooks/index.d.ts +3 -3
  124. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  125. package/lib/typescript/src/hooks/useCamera.d.ts +4 -0
  126. package/lib/typescript/src/hooks/useCamera.d.ts.map +1 -0
  127. package/lib/typescript/src/hooks/useConfirm.d.ts +1 -5
  128. package/lib/typescript/src/hooks/useConfirm.d.ts.map +1 -1
  129. package/lib/typescript/src/hooks/useCreation.d.ts +2 -0
  130. package/lib/typescript/src/hooks/useCreation.d.ts.map +1 -0
  131. package/lib/typescript/src/index.d.ts +3 -4
  132. package/lib/typescript/src/index.d.ts.map +1 -1
  133. package/lib/typescript/src/utils/depsAreSame.d.ts +1 -2
  134. package/lib/typescript/src/utils/depsAreSame.d.ts.map +1 -1
  135. package/lib/typescript/src/utils/index.d.ts +2 -4
  136. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  137. package/lib/typescript/src/utils/interface.d.ts +30 -70
  138. package/lib/typescript/src/utils/interface.d.ts.map +1 -1
  139. package/lib/typescript/src/utils/px-to-dp.d.ts +1 -3
  140. package/lib/typescript/src/utils/px-to-dp.d.ts.map +1 -1
  141. package/lib/typescript/src/utils/util.d.ts +8 -9
  142. package/lib/typescript/src/utils/util.d.ts.map +1 -1
  143. package/package.json +120 -107
  144. package/src/camera/Camera.tsx +210 -331
  145. package/src/camera/Container.tsx +224 -50
  146. package/src/camera/Error.tsx +22 -23
  147. package/src/camera/FocusIndicator.tsx +36 -46
  148. package/src/camera/ModalView.tsx +26 -24
  149. package/src/camera/NoCamera.tsx +37 -14
  150. package/src/camera/NoPermission.tsx +45 -37
  151. package/src/camera/capturePhotoHelper.ts +37 -0
  152. package/src/camera/footer/Footer.tsx +104 -195
  153. package/src/camera/footer/index.tsx +1 -2
  154. package/src/camera/index.tsx +12 -13
  155. package/src/camera/preview/PreView.tsx +22 -103
  156. package/src/camera/preview/PreViewContainer.tsx +23 -27
  157. package/src/camera/preview/PreviewFooter.tsx +28 -22
  158. package/src/camera/preview/SinglePre.tsx +23 -68
  159. package/src/camera/preview/index.tsx +4 -13
  160. package/src/camera/setup/SetUp.tsx +80 -217
  161. package/src/camera/setup/index.tsx +1 -3
  162. package/src/components/Carousel/Carousel.tsx +22 -42
  163. package/src/components/Carousel/SlideItem.tsx +12 -87
  164. package/src/components/Carousel/index.tsx +2 -13
  165. package/src/components/Loading.tsx +7 -69
  166. package/src/components/PreviewThumbnail.tsx +38 -33
  167. package/src/components/index.tsx +2 -7
  168. package/src/hooks/index.ts +3 -12
  169. package/src/hooks/useCamera.tsx +42 -0
  170. package/src/hooks/useConfirm.tsx +10 -57
  171. package/src/hooks/useCreation.ts +26 -0
  172. package/src/index.tsx +3 -37
  173. package/src/utils/depsAreSame.ts +7 -8
  174. package/src/utils/index.ts +2 -12
  175. package/src/utils/interface.ts +26 -87
  176. package/src/utils/px-to-dp.tsx +5 -9
  177. package/src/utils/util.ts +17 -42
  178. package/UnifRNCamera.podspec +0 -41
  179. package/android/CMakeLists.txt +0 -15
  180. package/android/build.gradle +0 -124
  181. package/android/cpp-adapter.cpp +0 -8
  182. package/android/gradle.properties +0 -5
  183. package/android/src/main/AndroidManifest.xml +0 -3
  184. package/android/src/main/AndroidManifestNew.xml +0 -2
  185. package/android/src/main/java/com/unif/reactnativecamera/ReactNativeCameraModule.java +0 -34
  186. package/android/src/main/java/com/unif/reactnativecamera/ReactNativeCameraPackage.java +0 -45
  187. package/android/src/newarch/ReactNativeCameraSpec.java +0 -9
  188. package/android/src/oldarch/ReactNativeCameraSpec.java +0 -13
  189. package/cpp/unif-react-native-camera.cpp +0 -7
  190. package/cpp/unif-react-native-camera.h +0 -8
  191. package/ios/ReactNativeCamera.h +0 -15
  192. package/ios/ReactNativeCamera.mm +0 -51
  193. package/lib/commonjs/NativeReactNativeCamera.js +0 -17
  194. package/lib/commonjs/NativeReactNativeCamera.js.map +0 -1
  195. package/lib/commonjs/assets/close.png +0 -0
  196. package/lib/commonjs/assets/home/record.png +0 -0
  197. package/lib/commonjs/assets/home/take.png +0 -0
  198. package/lib/commonjs/assets/preview/back.png +0 -0
  199. package/lib/commonjs/assets/preview/del.png +0 -0
  200. package/lib/commonjs/assets/preview/rotate.png +0 -0
  201. package/lib/commonjs/assets/preview/save.png +0 -0
  202. package/lib/commonjs/assets/tools/auto.png +0 -0
  203. package/lib/commonjs/assets/tools/defaultEye.png +0 -0
  204. package/lib/commonjs/assets/tools/enlarge.png +0 -0
  205. package/lib/commonjs/assets/tools/fishEye.png +0 -0
  206. package/lib/commonjs/assets/tools/narrow.png +0 -0
  207. package/lib/commonjs/assets/tools/off.png +0 -0
  208. package/lib/commonjs/assets/tools/on.png +0 -0
  209. package/lib/commonjs/assets/tools/volumeOff.png +0 -0
  210. package/lib/commonjs/assets/tools/volumeOn.png +0 -0
  211. package/lib/commonjs/camera/Camera.js +0 -316
  212. package/lib/commonjs/camera/Camera.js.map +0 -1
  213. package/lib/commonjs/camera/Container.js +0 -64
  214. package/lib/commonjs/camera/Container.js.map +0 -1
  215. package/lib/commonjs/camera/Error.js +0 -30
  216. package/lib/commonjs/camera/Error.js.map +0 -1
  217. package/lib/commonjs/camera/FocusIndicator.js +0 -64
  218. package/lib/commonjs/camera/FocusIndicator.js.map +0 -1
  219. package/lib/commonjs/camera/ModalView.js +0 -37
  220. package/lib/commonjs/camera/ModalView.js.map +0 -1
  221. package/lib/commonjs/camera/NoCamera.js +0 -23
  222. package/lib/commonjs/camera/NoCamera.js.map +0 -1
  223. package/lib/commonjs/camera/NoPermission.js +0 -50
  224. package/lib/commonjs/camera/NoPermission.js.map +0 -1
  225. package/lib/commonjs/camera/footer/Footer.js +0 -159
  226. package/lib/commonjs/camera/footer/Footer.js.map +0 -1
  227. package/lib/commonjs/camera/footer/index.js +0 -14
  228. package/lib/commonjs/camera/footer/index.js.map +0 -1
  229. package/lib/commonjs/camera/index.js +0 -35
  230. package/lib/commonjs/camera/index.js.map +0 -1
  231. package/lib/commonjs/camera/preview/PreView.js +0 -109
  232. package/lib/commonjs/camera/preview/PreView.js.map +0 -1
  233. package/lib/commonjs/camera/preview/PreViewContainer.js +0 -42
  234. package/lib/commonjs/camera/preview/PreViewContainer.js.map +0 -1
  235. package/lib/commonjs/camera/preview/PreviewFooter.js +0 -35
  236. package/lib/commonjs/camera/preview/PreviewFooter.js.map +0 -1
  237. package/lib/commonjs/camera/preview/SinglePre.js +0 -72
  238. package/lib/commonjs/camera/preview/SinglePre.js.map +0 -1
  239. package/lib/commonjs/camera/preview/index.js +0 -28
  240. package/lib/commonjs/camera/preview/index.js.map +0 -1
  241. package/lib/commonjs/camera/setup/SetUp.js +0 -205
  242. package/lib/commonjs/camera/setup/SetUp.js.map +0 -1
  243. package/lib/commonjs/camera/setup/index.js +0 -14
  244. package/lib/commonjs/camera/setup/index.js.map +0 -1
  245. package/lib/commonjs/camera/watermark/Render.js +0 -110
  246. package/lib/commonjs/camera/watermark/Render.js.map +0 -1
  247. package/lib/commonjs/camera/watermark/ViewShotWatermark.js +0 -143
  248. package/lib/commonjs/camera/watermark/ViewShotWatermark.js.map +0 -1
  249. package/lib/commonjs/camera/watermark/index.js +0 -21
  250. package/lib/commonjs/camera/watermark/index.js.map +0 -1
  251. package/lib/commonjs/components/Back.js +0 -48
  252. package/lib/commonjs/components/Back.js.map +0 -1
  253. package/lib/commonjs/components/Carousel/Carousel.js +0 -51
  254. package/lib/commonjs/components/Carousel/Carousel.js.map +0 -1
  255. package/lib/commonjs/components/Carousel/SlideItem.js +0 -84
  256. package/lib/commonjs/components/Carousel/SlideItem.js.map +0 -1
  257. package/lib/commonjs/components/Carousel/index.js +0 -21
  258. package/lib/commonjs/components/Carousel/index.js.map +0 -1
  259. package/lib/commonjs/components/Delete.js +0 -36
  260. package/lib/commonjs/components/Delete.js.map +0 -1
  261. package/lib/commonjs/components/Loading.js +0 -75
  262. package/lib/commonjs/components/Loading.js.map +0 -1
  263. package/lib/commonjs/components/Modal/Confirm.js +0 -121
  264. package/lib/commonjs/components/Modal/Confirm.js.map +0 -1
  265. package/lib/commonjs/components/Modal/index.js +0 -14
  266. package/lib/commonjs/components/Modal/index.js.map +0 -1
  267. package/lib/commonjs/components/PreviewThumbnail.js +0 -44
  268. package/lib/commonjs/components/PreviewThumbnail.js.map +0 -1
  269. package/lib/commonjs/components/Rotate.js +0 -32
  270. package/lib/commonjs/components/Rotate.js.map +0 -1
  271. package/lib/commonjs/components/Save.js +0 -48
  272. package/lib/commonjs/components/Save.js.map +0 -1
  273. package/lib/commonjs/components/index.js +0 -73
  274. package/lib/commonjs/components/index.js.map +0 -1
  275. package/lib/commonjs/hooks/index.js +0 -21
  276. package/lib/commonjs/hooks/index.js.map +0 -1
  277. package/lib/commonjs/hooks/useCamera.tsx/index.js +0 -90
  278. package/lib/commonjs/hooks/useCamera.tsx/index.js.map +0 -1
  279. package/lib/commonjs/hooks/useConfirm.js +0 -61
  280. package/lib/commonjs/hooks/useConfirm.js.map +0 -1
  281. package/lib/commonjs/hooks/useCreation/index.js +0 -34
  282. package/lib/commonjs/hooks/useCreation/index.js.map +0 -1
  283. package/lib/commonjs/index.js +0 -39
  284. package/lib/commonjs/index.js.map +0 -1
  285. package/lib/commonjs/utils/common.js +0 -69
  286. package/lib/commonjs/utils/common.js.map +0 -1
  287. package/lib/commonjs/utils/depsAreSame.js +0 -14
  288. package/lib/commonjs/utils/depsAreSame.js.map +0 -1
  289. package/lib/commonjs/utils/index.js +0 -72
  290. package/lib/commonjs/utils/index.js.map +0 -1
  291. package/lib/commonjs/utils/interface.js +0 -24
  292. package/lib/commonjs/utils/interface.js.map +0 -1
  293. package/lib/commonjs/utils/px-to-dp.js +0 -21
  294. package/lib/commonjs/utils/px-to-dp.js.map +0 -1
  295. package/lib/commonjs/utils/render-item.js +0 -40
  296. package/lib/commonjs/utils/render-item.js.map +0 -1
  297. package/lib/commonjs/utils/util.js +0 -53
  298. package/lib/commonjs/utils/util.js.map +0 -1
  299. package/lib/commonjs/utils/watermark.js +0 -49
  300. package/lib/commonjs/utils/watermark.js.map +0 -1
  301. package/lib/module/NativeReactNativeCamera.js +0 -12
  302. package/lib/module/NativeReactNativeCamera.js.map +0 -1
  303. package/lib/module/assets/close.png +0 -0
  304. package/lib/module/assets/home/record.png +0 -0
  305. package/lib/module/assets/home/take.png +0 -0
  306. package/lib/module/assets/preview/back.png +0 -0
  307. package/lib/module/assets/preview/del.png +0 -0
  308. package/lib/module/assets/preview/rotate.png +0 -0
  309. package/lib/module/assets/preview/save.png +0 -0
  310. package/lib/module/assets/tools/auto.png +0 -0
  311. package/lib/module/assets/tools/defaultEye.png +0 -0
  312. package/lib/module/assets/tools/enlarge.png +0 -0
  313. package/lib/module/assets/tools/fishEye.png +0 -0
  314. package/lib/module/assets/tools/narrow.png +0 -0
  315. package/lib/module/assets/tools/off.png +0 -0
  316. package/lib/module/assets/tools/on.png +0 -0
  317. package/lib/module/assets/tools/volumeOff.png +0 -0
  318. package/lib/module/assets/tools/volumeOn.png +0 -0
  319. package/lib/module/camera/watermark/Render.js +0 -102
  320. package/lib/module/camera/watermark/Render.js.map +0 -1
  321. package/lib/module/camera/watermark/ViewShotWatermark.js +0 -133
  322. package/lib/module/camera/watermark/ViewShotWatermark.js.map +0 -1
  323. package/lib/module/camera/watermark/index.js +0 -13
  324. package/lib/module/camera/watermark/index.js.map +0 -1
  325. package/lib/module/components/Back.js +0 -40
  326. package/lib/module/components/Back.js.map +0 -1
  327. package/lib/module/components/Delete.js +0 -28
  328. package/lib/module/components/Delete.js.map +0 -1
  329. package/lib/module/components/Modal/Confirm.js +0 -111
  330. package/lib/module/components/Modal/Confirm.js.map +0 -1
  331. package/lib/module/components/Modal/index.js +0 -3
  332. package/lib/module/components/Modal/index.js.map +0 -1
  333. package/lib/module/components/Rotate.js +0 -24
  334. package/lib/module/components/Rotate.js.map +0 -1
  335. package/lib/module/components/Save.js +0 -40
  336. package/lib/module/components/Save.js.map +0 -1
  337. package/lib/module/hooks/useCamera.tsx/index.js +0 -81
  338. package/lib/module/hooks/useCamera.tsx/index.js.map +0 -1
  339. package/lib/module/hooks/useCreation/index.js +0 -27
  340. package/lib/module/hooks/useCreation/index.js.map +0 -1
  341. package/lib/module/utils/common.js +0 -62
  342. package/lib/module/utils/common.js.map +0 -1
  343. package/lib/module/utils/render-item.js +0 -32
  344. package/lib/module/utils/render-item.js.map +0 -1
  345. package/lib/module/utils/watermark.js +0 -39
  346. package/lib/module/utils/watermark.js.map +0 -1
  347. package/lib/typescript/src/NativeReactNativeCamera.d.ts +0 -6
  348. package/lib/typescript/src/NativeReactNativeCamera.d.ts.map +0 -1
  349. package/lib/typescript/src/camera/watermark/Render.d.ts +0 -26
  350. package/lib/typescript/src/camera/watermark/Render.d.ts.map +0 -1
  351. package/lib/typescript/src/camera/watermark/ViewShotWatermark.d.ts +0 -41
  352. package/lib/typescript/src/camera/watermark/ViewShotWatermark.d.ts.map +0 -1
  353. package/lib/typescript/src/camera/watermark/index.d.ts +0 -4
  354. package/lib/typescript/src/camera/watermark/index.d.ts.map +0 -1
  355. package/lib/typescript/src/components/Back.d.ts +0 -20
  356. package/lib/typescript/src/components/Back.d.ts.map +0 -1
  357. package/lib/typescript/src/components/Delete.d.ts +0 -7
  358. package/lib/typescript/src/components/Delete.d.ts.map +0 -1
  359. package/lib/typescript/src/components/Modal/Confirm.d.ts +0 -9
  360. package/lib/typescript/src/components/Modal/Confirm.d.ts.map +0 -1
  361. package/lib/typescript/src/components/Modal/index.d.ts +0 -3
  362. package/lib/typescript/src/components/Modal/index.d.ts.map +0 -1
  363. package/lib/typescript/src/components/Rotate.d.ts +0 -9
  364. package/lib/typescript/src/components/Rotate.d.ts.map +0 -1
  365. package/lib/typescript/src/components/Save.d.ts +0 -20
  366. package/lib/typescript/src/components/Save.d.ts.map +0 -1
  367. package/lib/typescript/src/hooks/useCamera.tsx/index.d.ts +0 -5
  368. package/lib/typescript/src/hooks/useCamera.tsx/index.d.ts.map +0 -1
  369. package/lib/typescript/src/hooks/useCreation/index.d.ts +0 -3
  370. package/lib/typescript/src/hooks/useCreation/index.d.ts.map +0 -1
  371. package/lib/typescript/src/utils/common.d.ts +0 -14
  372. package/lib/typescript/src/utils/common.d.ts.map +0 -1
  373. package/lib/typescript/src/utils/render-item.d.ts +0 -10
  374. package/lib/typescript/src/utils/render-item.d.ts.map +0 -1
  375. package/lib/typescript/src/utils/watermark.d.ts +0 -11
  376. package/lib/typescript/src/utils/watermark.d.ts.map +0 -1
  377. package/src/NativeReactNativeCamera.ts +0 -15
  378. package/src/assets/close.png +0 -0
  379. package/src/assets/home/record.png +0 -0
  380. package/src/assets/home/take.png +0 -0
  381. package/src/assets/preview/back.png +0 -0
  382. package/src/assets/preview/del.png +0 -0
  383. package/src/assets/preview/rotate.png +0 -0
  384. package/src/assets/preview/save.png +0 -0
  385. package/src/assets/tools/auto.png +0 -0
  386. package/src/assets/tools/defaultEye.png +0 -0
  387. package/src/assets/tools/enlarge.png +0 -0
  388. package/src/assets/tools/fishEye.png +0 -0
  389. package/src/assets/tools/narrow.png +0 -0
  390. package/src/assets/tools/off.png +0 -0
  391. package/src/assets/tools/on.png +0 -0
  392. package/src/assets/tools/volumeOff.png +0 -0
  393. package/src/assets/tools/volumeOn.png +0 -0
  394. package/src/camera/watermark/Render.tsx +0 -128
  395. package/src/camera/watermark/ViewShotWatermark.tsx +0 -134
  396. package/src/camera/watermark/index.tsx +0 -12
  397. package/src/components/Back.tsx +0 -37
  398. package/src/components/Delete.tsx +0 -30
  399. package/src/components/Modal/Confirm.tsx +0 -116
  400. package/src/components/Modal/index.tsx +0 -3
  401. package/src/components/Rotate.tsx +0 -32
  402. package/src/components/Save.tsx +0 -37
  403. package/src/hooks/useCamera.tsx/index.tsx +0 -95
  404. package/src/hooks/useCreation/index.ts +0 -25
  405. package/src/utils/common.ts +0 -67
  406. package/src/utils/render-item.tsx +0 -39
  407. package/src/utils/watermark.ts +0 -55
Binary file
Binary file
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 };
@@ -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,3 +0,0 @@
1
- import Confirm from './Confirm';
2
-
3
- export { Confirm };
@@ -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;
@@ -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
- }