@oxyhq/services 22.10.0 → 22.11.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 (274) hide show
  1. package/lib/commonjs/ui/components/AvatarCameraBadge.js +42 -0
  2. package/lib/commonjs/ui/components/AvatarCameraBadge.js.map +1 -0
  3. package/lib/commonjs/ui/components/OxyAccountDialogScreen.js +41 -19
  4. package/lib/commonjs/ui/components/OxyAccountDialogScreen.js.map +1 -1
  5. package/lib/commonjs/ui/components/OxyAuthChooser.js +640 -168
  6. package/lib/commonjs/ui/components/OxyAuthChooser.js.map +1 -1
  7. package/lib/commonjs/ui/components/ProfileButton.js +14 -0
  8. package/lib/commonjs/ui/components/ProfileButton.js.map +1 -1
  9. package/lib/commonjs/ui/components/ProfileSummaryCard.js +3 -23
  10. package/lib/commonjs/ui/components/ProfileSummaryCard.js.map +1 -1
  11. package/lib/commonjs/ui/components/SurfaceScreen.js +41 -5
  12. package/lib/commonjs/ui/components/SurfaceScreen.js.map +1 -1
  13. package/lib/commonjs/ui/components/oxyAuthChooserStyles.js +78 -26
  14. package/lib/commonjs/ui/components/oxyAuthChooserStyles.js.map +1 -1
  15. package/lib/commonjs/ui/components/photogrid/JustifiedPhotoGrid.js +83 -23
  16. package/lib/commonjs/ui/components/photogrid/JustifiedPhotoGrid.js.map +1 -1
  17. package/lib/commonjs/ui/context/OxyContext.js +73 -37
  18. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  19. package/lib/commonjs/ui/hooks/queries/queryKeys.js +18 -1
  20. package/lib/commonjs/ui/hooks/queries/queryKeys.js.map +1 -1
  21. package/lib/commonjs/ui/hooks/queries/useFileQueries.js +129 -0
  22. package/lib/commonjs/ui/hooks/queries/useFileQueries.js.map +1 -0
  23. package/lib/commonjs/ui/hooks/useAvatarPicker.js +36 -48
  24. package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +1 -1
  25. package/lib/commonjs/ui/hooks/useReduceMotion.js +57 -0
  26. package/lib/commonjs/ui/hooks/useReduceMotion.js.map +1 -0
  27. package/lib/commonjs/ui/hooks/useSurfaceHeader.js +1 -1
  28. package/lib/commonjs/ui/hooks/useSurfaceHeader.js.map +1 -1
  29. package/lib/commonjs/ui/navigation/accountDialogManager.js +22 -0
  30. package/lib/commonjs/ui/navigation/accountDialogManager.js.map +1 -1
  31. package/lib/commonjs/ui/navigation/bottomSheetManager.js +5 -6
  32. package/lib/commonjs/ui/navigation/bottomSheetManager.js.map +1 -1
  33. package/lib/commonjs/ui/navigation/routes.js +1 -0
  34. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  35. package/lib/commonjs/ui/navigation/surfaceNavStack.js +62 -15
  36. package/lib/commonjs/ui/navigation/surfaceNavStack.js.map +1 -1
  37. package/lib/commonjs/ui/navigation/surfaceRegistry.js +38 -17
  38. package/lib/commonjs/ui/navigation/surfaceRegistry.js.map +1 -1
  39. package/lib/commonjs/ui/navigation/surfaces.js +98 -21
  40. package/lib/commonjs/ui/navigation/surfaces.js.map +1 -1
  41. package/lib/commonjs/ui/screens/AvatarCropScreen.js +281 -279
  42. package/lib/commonjs/ui/screens/AvatarCropScreen.js.map +1 -1
  43. package/lib/commonjs/ui/screens/ChangeAvatarScreen.js +301 -0
  44. package/lib/commonjs/ui/screens/ChangeAvatarScreen.js.map +1 -0
  45. package/lib/commonjs/ui/screens/FileManagementScreen.js +194 -431
  46. package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
  47. package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js +16 -48
  48. package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js.map +1 -1
  49. package/lib/commonjs/ui/screens/fileManagement/FileLibraryError.js +63 -0
  50. package/lib/commonjs/ui/screens/fileManagement/FileLibraryError.js.map +1 -0
  51. package/lib/commonjs/ui/screens/fileManagement/PhotoPickerSection.js +54 -41
  52. package/lib/commonjs/ui/screens/fileManagement/PhotoPickerSection.js.map +1 -1
  53. package/lib/commonjs/ui/screens/fileManagement/hooks/useFileUploadState.js +44 -81
  54. package/lib/commonjs/ui/screens/fileManagement/hooks/useFileUploadState.js.map +1 -1
  55. package/lib/commonjs/ui/stores/resetSessionScopedStores.js +8 -3
  56. package/lib/commonjs/ui/stores/resetSessionScopedStores.js.map +1 -1
  57. package/lib/commonjs/ui/utils/avatarUtils.js +11 -2
  58. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  59. package/lib/commonjs/ui/utils/fileManagement.js +0 -79
  60. package/lib/commonjs/ui/utils/fileManagement.js.map +1 -1
  61. package/lib/module/ui/components/AvatarCameraBadge.js +40 -0
  62. package/lib/module/ui/components/AvatarCameraBadge.js.map +1 -0
  63. package/lib/module/ui/components/OxyAccountDialogScreen.js +41 -19
  64. package/lib/module/ui/components/OxyAccountDialogScreen.js.map +1 -1
  65. package/lib/module/ui/components/OxyAuthChooser.js +642 -171
  66. package/lib/module/ui/components/OxyAuthChooser.js.map +1 -1
  67. package/lib/module/ui/components/ProfileButton.js +15 -1
  68. package/lib/module/ui/components/ProfileButton.js.map +1 -1
  69. package/lib/module/ui/components/ProfileSummaryCard.js +2 -23
  70. package/lib/module/ui/components/ProfileSummaryCard.js.map +1 -1
  71. package/lib/module/ui/components/SurfaceScreen.js +43 -7
  72. package/lib/module/ui/components/SurfaceScreen.js.map +1 -1
  73. package/lib/module/ui/components/oxyAuthChooserStyles.js +78 -26
  74. package/lib/module/ui/components/oxyAuthChooserStyles.js.map +1 -1
  75. package/lib/module/ui/components/photogrid/JustifiedPhotoGrid.js +83 -25
  76. package/lib/module/ui/components/photogrid/JustifiedPhotoGrid.js.map +1 -1
  77. package/lib/module/ui/context/OxyContext.js +74 -38
  78. package/lib/module/ui/context/OxyContext.js.map +1 -1
  79. package/lib/module/ui/hooks/queries/queryKeys.js +16 -0
  80. package/lib/module/ui/hooks/queries/queryKeys.js.map +1 -1
  81. package/lib/module/ui/hooks/queries/useFileQueries.js +120 -0
  82. package/lib/module/ui/hooks/queries/useFileQueries.js.map +1 -0
  83. package/lib/module/ui/hooks/useAvatarPicker.js +37 -49
  84. package/lib/module/ui/hooks/useAvatarPicker.js.map +1 -1
  85. package/lib/module/ui/hooks/useReduceMotion.js +53 -0
  86. package/lib/module/ui/hooks/useReduceMotion.js.map +1 -0
  87. package/lib/module/ui/hooks/useSurfaceHeader.js +1 -1
  88. package/lib/module/ui/hooks/useSurfaceHeader.js.map +1 -1
  89. package/lib/module/ui/navigation/accountDialogManager.js +20 -0
  90. package/lib/module/ui/navigation/accountDialogManager.js.map +1 -1
  91. package/lib/module/ui/navigation/bottomSheetManager.js +6 -7
  92. package/lib/module/ui/navigation/bottomSheetManager.js.map +1 -1
  93. package/lib/module/ui/navigation/routes.js +1 -0
  94. package/lib/module/ui/navigation/routes.js.map +1 -1
  95. package/lib/module/ui/navigation/surfaceNavStack.js +62 -15
  96. package/lib/module/ui/navigation/surfaceNavStack.js.map +1 -1
  97. package/lib/module/ui/navigation/surfaceRegistry.js +38 -17
  98. package/lib/module/ui/navigation/surfaceRegistry.js.map +1 -1
  99. package/lib/module/ui/navigation/surfaces.js +97 -22
  100. package/lib/module/ui/navigation/surfaces.js.map +1 -1
  101. package/lib/module/ui/screens/AvatarCropScreen.js +283 -281
  102. package/lib/module/ui/screens/AvatarCropScreen.js.map +1 -1
  103. package/lib/module/ui/screens/ChangeAvatarScreen.js +298 -0
  104. package/lib/module/ui/screens/ChangeAvatarScreen.js.map +1 -0
  105. package/lib/module/ui/screens/FileManagementScreen.js +196 -433
  106. package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
  107. package/lib/module/ui/screens/WelcomeNewUserScreen.js +17 -49
  108. package/lib/module/ui/screens/WelcomeNewUserScreen.js.map +1 -1
  109. package/lib/module/ui/screens/fileManagement/FileLibraryError.js +59 -0
  110. package/lib/module/ui/screens/fileManagement/FileLibraryError.js.map +1 -0
  111. package/lib/module/ui/screens/fileManagement/PhotoPickerSection.js +54 -42
  112. package/lib/module/ui/screens/fileManagement/PhotoPickerSection.js.map +1 -1
  113. package/lib/module/ui/screens/fileManagement/hooks/useFileUploadState.js +45 -81
  114. package/lib/module/ui/screens/fileManagement/hooks/useFileUploadState.js.map +1 -1
  115. package/lib/module/ui/stores/resetSessionScopedStores.js +8 -3
  116. package/lib/module/ui/stores/resetSessionScopedStores.js.map +1 -1
  117. package/lib/module/ui/utils/avatarUtils.js +11 -2
  118. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  119. package/lib/module/ui/utils/fileManagement.js +0 -78
  120. package/lib/module/ui/utils/fileManagement.js.map +1 -1
  121. package/lib/typescript/commonjs/ui/components/AvatarCameraBadge.d.ts +4 -0
  122. package/lib/typescript/commonjs/ui/components/AvatarCameraBadge.d.ts.map +1 -0
  123. package/lib/typescript/commonjs/ui/components/OxyAccountDialogScreen.d.ts +2 -1
  124. package/lib/typescript/commonjs/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts.map +1 -1
  127. package/lib/typescript/commonjs/ui/components/ProfileSummaryCard.d.ts.map +1 -1
  128. package/lib/typescript/commonjs/ui/components/SurfaceScreen.d.ts +1 -4
  129. package/lib/typescript/commonjs/ui/components/SurfaceScreen.d.ts.map +1 -1
  130. package/lib/typescript/commonjs/ui/components/oxyAuthChooserStyles.d.ts +71 -19
  131. package/lib/typescript/commonjs/ui/components/oxyAuthChooserStyles.d.ts.map +1 -1
  132. package/lib/typescript/commonjs/ui/components/photogrid/JustifiedPhotoGrid.d.ts +10 -8
  133. package/lib/typescript/commonjs/ui/components/photogrid/JustifiedPhotoGrid.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  135. package/lib/typescript/commonjs/ui/hooks/queries/queryKeys.d.ts +9 -0
  136. package/lib/typescript/commonjs/ui/hooks/queries/queryKeys.d.ts.map +1 -1
  137. package/lib/typescript/commonjs/ui/hooks/queries/useFileQueries.d.ts +50 -0
  138. package/lib/typescript/commonjs/ui/hooks/queries/useFileQueries.d.ts.map +1 -0
  139. package/lib/typescript/commonjs/ui/hooks/useAvatarPicker.d.ts +15 -10
  140. package/lib/typescript/commonjs/ui/hooks/useAvatarPicker.d.ts.map +1 -1
  141. package/lib/typescript/commonjs/ui/hooks/useReduceMotion.d.ts +14 -0
  142. package/lib/typescript/commonjs/ui/hooks/useReduceMotion.d.ts.map +1 -0
  143. package/lib/typescript/commonjs/ui/hooks/useSurfaceHeader.d.ts +1 -1
  144. package/lib/typescript/commonjs/ui/hooks/useSurfaceHeader.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/ui/navigation/accountDialogManager.d.ts +13 -0
  146. package/lib/typescript/commonjs/ui/navigation/accountDialogManager.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts +4 -5
  148. package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/ui/navigation/routes.d.ts +1 -1
  150. package/lib/typescript/commonjs/ui/navigation/routes.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/ui/navigation/surfaceNavStack.d.ts +21 -0
  152. package/lib/typescript/commonjs/ui/navigation/surfaceNavStack.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/ui/navigation/surfaceRegistry.d.ts +73 -13
  154. package/lib/typescript/commonjs/ui/navigation/surfaceRegistry.d.ts.map +1 -1
  155. package/lib/typescript/commonjs/ui/navigation/surfaces.d.ts +42 -11
  156. package/lib/typescript/commonjs/ui/navigation/surfaces.d.ts.map +1 -1
  157. package/lib/typescript/commonjs/ui/screens/AvatarCropScreen.d.ts +18 -5
  158. package/lib/typescript/commonjs/ui/screens/AvatarCropScreen.d.ts.map +1 -1
  159. package/lib/typescript/commonjs/ui/screens/ChangeAvatarScreen.d.ts +34 -0
  160. package/lib/typescript/commonjs/ui/screens/ChangeAvatarScreen.d.ts.map +1 -0
  161. package/lib/typescript/commonjs/ui/screens/FileManagementScreen.d.ts.map +1 -1
  162. package/lib/typescript/commonjs/ui/screens/WelcomeNewUserScreen.d.ts.map +1 -1
  163. package/lib/typescript/commonjs/ui/screens/fileManagement/FileLibraryError.d.ts +23 -0
  164. package/lib/typescript/commonjs/ui/screens/fileManagement/FileLibraryError.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/ui/screens/fileManagement/PhotoPickerSection.d.ts +4 -0
  166. package/lib/typescript/commonjs/ui/screens/fileManagement/PhotoPickerSection.d.ts.map +1 -1
  167. package/lib/typescript/commonjs/ui/screens/fileManagement/hooks/useFileUploadState.d.ts +10 -2
  168. package/lib/typescript/commonjs/ui/screens/fileManagement/hooks/useFileUploadState.d.ts.map +1 -1
  169. package/lib/typescript/commonjs/ui/stores/resetSessionScopedStores.d.ts +8 -1
  170. package/lib/typescript/commonjs/ui/stores/resetSessionScopedStores.d.ts.map +1 -1
  171. package/lib/typescript/commonjs/ui/types/navigation.d.ts +2 -0
  172. package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
  173. package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts.map +1 -1
  174. package/lib/typescript/commonjs/ui/utils/fileManagement.d.ts +0 -48
  175. package/lib/typescript/commonjs/ui/utils/fileManagement.d.ts.map +1 -1
  176. package/lib/typescript/module/ui/components/AvatarCameraBadge.d.ts +4 -0
  177. package/lib/typescript/module/ui/components/AvatarCameraBadge.d.ts.map +1 -0
  178. package/lib/typescript/module/ui/components/OxyAccountDialogScreen.d.ts +2 -1
  179. package/lib/typescript/module/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
  180. package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts.map +1 -1
  181. package/lib/typescript/module/ui/components/ProfileButton.d.ts.map +1 -1
  182. package/lib/typescript/module/ui/components/ProfileSummaryCard.d.ts.map +1 -1
  183. package/lib/typescript/module/ui/components/SurfaceScreen.d.ts +1 -4
  184. package/lib/typescript/module/ui/components/SurfaceScreen.d.ts.map +1 -1
  185. package/lib/typescript/module/ui/components/oxyAuthChooserStyles.d.ts +71 -19
  186. package/lib/typescript/module/ui/components/oxyAuthChooserStyles.d.ts.map +1 -1
  187. package/lib/typescript/module/ui/components/photogrid/JustifiedPhotoGrid.d.ts +10 -8
  188. package/lib/typescript/module/ui/components/photogrid/JustifiedPhotoGrid.d.ts.map +1 -1
  189. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  190. package/lib/typescript/module/ui/hooks/queries/queryKeys.d.ts +9 -0
  191. package/lib/typescript/module/ui/hooks/queries/queryKeys.d.ts.map +1 -1
  192. package/lib/typescript/module/ui/hooks/queries/useFileQueries.d.ts +50 -0
  193. package/lib/typescript/module/ui/hooks/queries/useFileQueries.d.ts.map +1 -0
  194. package/lib/typescript/module/ui/hooks/useAvatarPicker.d.ts +15 -10
  195. package/lib/typescript/module/ui/hooks/useAvatarPicker.d.ts.map +1 -1
  196. package/lib/typescript/module/ui/hooks/useReduceMotion.d.ts +14 -0
  197. package/lib/typescript/module/ui/hooks/useReduceMotion.d.ts.map +1 -0
  198. package/lib/typescript/module/ui/hooks/useSurfaceHeader.d.ts +1 -1
  199. package/lib/typescript/module/ui/hooks/useSurfaceHeader.d.ts.map +1 -1
  200. package/lib/typescript/module/ui/navigation/accountDialogManager.d.ts +13 -0
  201. package/lib/typescript/module/ui/navigation/accountDialogManager.d.ts.map +1 -1
  202. package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts +4 -5
  203. package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts.map +1 -1
  204. package/lib/typescript/module/ui/navigation/routes.d.ts +1 -1
  205. package/lib/typescript/module/ui/navigation/routes.d.ts.map +1 -1
  206. package/lib/typescript/module/ui/navigation/surfaceNavStack.d.ts +21 -0
  207. package/lib/typescript/module/ui/navigation/surfaceNavStack.d.ts.map +1 -1
  208. package/lib/typescript/module/ui/navigation/surfaceRegistry.d.ts +73 -13
  209. package/lib/typescript/module/ui/navigation/surfaceRegistry.d.ts.map +1 -1
  210. package/lib/typescript/module/ui/navigation/surfaces.d.ts +42 -11
  211. package/lib/typescript/module/ui/navigation/surfaces.d.ts.map +1 -1
  212. package/lib/typescript/module/ui/screens/AvatarCropScreen.d.ts +18 -5
  213. package/lib/typescript/module/ui/screens/AvatarCropScreen.d.ts.map +1 -1
  214. package/lib/typescript/module/ui/screens/ChangeAvatarScreen.d.ts +34 -0
  215. package/lib/typescript/module/ui/screens/ChangeAvatarScreen.d.ts.map +1 -0
  216. package/lib/typescript/module/ui/screens/FileManagementScreen.d.ts.map +1 -1
  217. package/lib/typescript/module/ui/screens/WelcomeNewUserScreen.d.ts.map +1 -1
  218. package/lib/typescript/module/ui/screens/fileManagement/FileLibraryError.d.ts +23 -0
  219. package/lib/typescript/module/ui/screens/fileManagement/FileLibraryError.d.ts.map +1 -0
  220. package/lib/typescript/module/ui/screens/fileManagement/PhotoPickerSection.d.ts +4 -0
  221. package/lib/typescript/module/ui/screens/fileManagement/PhotoPickerSection.d.ts.map +1 -1
  222. package/lib/typescript/module/ui/screens/fileManagement/hooks/useFileUploadState.d.ts +10 -2
  223. package/lib/typescript/module/ui/screens/fileManagement/hooks/useFileUploadState.d.ts.map +1 -1
  224. package/lib/typescript/module/ui/stores/resetSessionScopedStores.d.ts +8 -1
  225. package/lib/typescript/module/ui/stores/resetSessionScopedStores.d.ts.map +1 -1
  226. package/lib/typescript/module/ui/types/navigation.d.ts +2 -0
  227. package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
  228. package/lib/typescript/module/ui/utils/avatarUtils.d.ts.map +1 -1
  229. package/lib/typescript/module/ui/utils/fileManagement.d.ts +0 -48
  230. package/lib/typescript/module/ui/utils/fileManagement.d.ts.map +1 -1
  231. package/package.json +8 -4
  232. package/src/ui/components/AvatarCameraBadge.tsx +35 -0
  233. package/src/ui/components/OxyAccountDialogScreen.tsx +38 -15
  234. package/src/ui/components/OxyAuthChooser.tsx +722 -185
  235. package/src/ui/components/ProfileButton.tsx +16 -1
  236. package/src/ui/components/ProfileSummaryCard.tsx +2 -25
  237. package/src/ui/components/SurfaceScreen.tsx +48 -14
  238. package/src/ui/components/oxyAuthChooserStyles.ts +75 -23
  239. package/src/ui/components/photogrid/JustifiedPhotoGrid.tsx +158 -84
  240. package/src/ui/components/photogrid/__tests__/chunkPhotos.test.ts +51 -0
  241. package/src/ui/context/OxyContext.tsx +74 -34
  242. package/src/ui/hooks/queries/queryKeys.ts +15 -0
  243. package/src/ui/hooks/queries/useFileQueries.ts +162 -0
  244. package/src/ui/hooks/useAvatarPicker.ts +38 -53
  245. package/src/ui/hooks/useReduceMotion.ts +58 -0
  246. package/src/ui/hooks/useSurfaceHeader.ts +2 -1
  247. package/src/ui/navigation/__tests__/getSurfaceConfig.test.ts +55 -7
  248. package/src/ui/navigation/__tests__/surfaceNavStack.test.ts +81 -0
  249. package/src/ui/navigation/accountDialogManager.ts +28 -0
  250. package/src/ui/navigation/bottomSheetManager.ts +6 -7
  251. package/src/ui/navigation/routes.ts +3 -1
  252. package/src/ui/navigation/surfaceNavStack.ts +72 -9
  253. package/src/ui/navigation/surfaceRegistry.ts +91 -17
  254. package/src/ui/navigation/surfaces.ts +108 -29
  255. package/src/ui/screens/AvatarCropScreen.tsx +336 -298
  256. package/src/ui/screens/ChangeAvatarScreen.tsx +359 -0
  257. package/src/ui/screens/FileManagementScreen.tsx +189 -432
  258. package/src/ui/screens/WelcomeNewUserScreen.tsx +18 -48
  259. package/src/ui/screens/fileManagement/FileLibraryError.tsx +56 -0
  260. package/src/ui/screens/fileManagement/PhotoPickerSection.tsx +56 -46
  261. package/src/ui/screens/fileManagement/hooks/useFileUploadState.ts +55 -71
  262. package/src/ui/stores/resetSessionScopedStores.ts +8 -3
  263. package/src/ui/types/navigation.ts +2 -0
  264. package/src/ui/utils/avatarUtils.ts +11 -2
  265. package/src/ui/utils/fileManagement.ts +1 -101
  266. package/lib/commonjs/ui/stores/fileStore.js +0 -153
  267. package/lib/commonjs/ui/stores/fileStore.js.map +0 -1
  268. package/lib/module/ui/stores/fileStore.js +0 -145
  269. package/lib/module/ui/stores/fileStore.js.map +0 -1
  270. package/lib/typescript/commonjs/ui/stores/fileStore.d.ts +0 -31
  271. package/lib/typescript/commonjs/ui/stores/fileStore.d.ts.map +0 -1
  272. package/lib/typescript/module/ui/stores/fileStore.d.ts +0 -31
  273. package/lib/typescript/module/ui/stores/fileStore.d.ts.map +0 -1
  274. package/src/ui/stores/fileStore.ts +0 -118
@@ -7,11 +7,17 @@
7
7
  * but before the avatar is uploaded. Inspired by iOS Photos, Google Photos and
8
8
  * Instagram crop tools.
9
9
  *
10
+ * Reached ONLY by navigating within a `ChangeAvatar` surface, so the panel
11
+ * morphs from the source list into the editor. The surface owns the chrome: this
12
+ * screen declares its title and its "Use photo" action through `useSurfaceHeader`
13
+ * and renders no bar of its own — the nav bar's back arrow is Cancel, and it
14
+ * returns to the source list.
15
+ *
10
16
  * Architecture:
11
- * - Full-bleed black canvas, independent of theme, so photos always read well.
12
- * - Translucent top bar with Cancel / Title / Done (primary CTA).
13
- * - Circular viewport with white ring, outer 50% black mask, and a 3x3
14
- * rule-of-thirds grid that appears during gestures and fades after 800ms.
17
+ * - A dark crop stage, independent of theme, so photos always read well, inset
18
+ * inside the surface's own themed panel.
19
+ * - Circular viewport with white ring and a 3x3 rule-of-thirds grid that
20
+ * appears during gestures and fades after 800ms.
15
21
  * - Floating zoom chip during pinch.
16
22
  * - Pan + pinch via Gesture Handler, transform driven by Reanimated.
17
23
  * - Reduced-motion aware entrance animation.
@@ -22,14 +28,18 @@
22
28
  * error; missing haptics simply degrades silently.
23
29
  */
24
30
 
25
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
26
- import { View, Text, StyleSheet, ActivityIndicator, TouchableOpacity, Image, Platform, AccessibilityInfo, Pressable } from 'react-native';
31
+ import { useCallback, useMemo, useRef, useState } from 'react';
32
+ import { View, Text, StyleSheet, ActivityIndicator, Image, Platform, AccessibilityInfo, Pressable } from 'react-native';
27
33
  import { Gesture, GestureDetector } from 'react-native-gesture-handler';
28
34
  import Animated, { Easing, runOnJS, useAnimatedStyle, useSharedValue, withDelay, withSpring, withTiming } from 'react-native-reanimated';
29
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
35
+ import { useQuery, keepPreviousData } from '@tanstack/react-query';
30
36
  import { useTheme } from '@oxyhq/bloom/theme';
37
+ import { Button } from '@oxyhq/bloom/button';
31
38
  import { logger } from '@oxyhq/core';
39
+ import { useOxy } from "../context/OxyContext.js";
32
40
  import { useI18n } from "../hooks/useI18n.js";
41
+ import { useReduceMotion } from "../hooks/useReduceMotion.js";
42
+ import { useSurfaceHeader } from "../hooks/useSurfaceHeader.js";
33
43
  import { toast } from '@oxyhq/bloom';
34
44
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
35
45
  /** Component name used in `logger` context for filtered diagnostics. */
@@ -42,14 +52,20 @@ const VIEWPORT_SIZE = 320;
42
52
  const OUTPUT_SIZE = 512;
43
53
  const MIN_SCALE = 1;
44
54
  const MAX_SCALE = 4;
55
+ /** Zoom increment per +/- button press (web, where there is no pinch). */
56
+ const ZOOM_STEP = 0.5;
57
+ /** Tween duration for a button-driven zoom (collapses to 0 under reduce-motion). */
58
+ const ZOOM_BUTTON_DURATION_MS = 180;
45
59
  /** Duration (ms) that the rule-of-thirds grid lingers after a gesture ends. */
46
60
  const GRID_FADE_DELAY_MS = 800;
47
61
  const GRID_FADE_DURATION_MS = 220;
48
62
  /** Duration the zoom chip stays visible after a pinch ends. */
49
63
  const ZOOM_CHIP_FADE_DELAY_MS = 600;
50
64
  const ZOOM_CHIP_FADE_DURATION_MS = 200;
51
- /** Backdrop color is fixed independent of theme so the photo always reads well. */
65
+ /** Stage color is fixed independent of theme so the photo always reads well. */
52
66
  const CANVAS_BG = '#000000';
67
+ /** Corner radius of the dark stage block inside the surface's themed panel. */
68
+ const STAGE_RADIUS = 24;
53
69
  const RING_COLOR = '#ffffff';
54
70
  const RING_WIDTH = 2;
55
71
  const REMOTE_HTTP_URI_PATTERN = /^https?:\/\//i;
@@ -71,6 +87,26 @@ function clampTranslation(tx, ty, s, baseW, baseH) {
71
87
  ty: Math.min(Math.max(ty, -maxY), maxY)
72
88
  };
73
89
  }
90
+ /**
91
+ * Measure an image's intrinsic size via `Image.getSize`, wrapped as a Promise so
92
+ * it can be a React Query `queryFn` (no component state / effects). Rejects on a
93
+ * platform failure or degenerate dimensions so the query surfaces `isError`.
94
+ * Mirrors the `measurePhotoDimensions` helper the photo grid uses.
95
+ */
96
+ function measureImageSize(uri) {
97
+ return new Promise((resolve, reject) => {
98
+ Image.getSize(uri, (width, height) => {
99
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
100
+ reject(new Error('Image reported invalid dimensions'));
101
+ return;
102
+ }
103
+ resolve({
104
+ width,
105
+ height
106
+ });
107
+ }, () => reject(new Error('Image measurement failed')));
108
+ });
109
+ }
74
110
 
75
111
  /**
76
112
  * Lazy-loaded reference to the expo-image-manipulator module. The module is an
@@ -192,7 +228,9 @@ async function hapticSelection() {
192
228
  }
193
229
  const AvatarCropScreen = ({
194
230
  dismiss,
231
+ goBack,
195
232
  imageUri,
233
+ imageFileId,
196
234
  sourceWidth,
197
235
  sourceHeight
198
236
  }) => {
@@ -200,19 +238,75 @@ const AvatarCropScreen = ({
200
238
  const {
201
239
  t
202
240
  } = useI18n();
203
- const insets = useSafeAreaInsets();
204
-
205
- // Natural size of the source image. May be known up front (passed in) or
206
- // measured lazily via Image.getSize once the image loads.
207
- const [naturalSize, setNaturalSize] = useState(sourceWidth && sourceHeight ? {
208
- width: sourceWidth,
209
- height: sourceHeight
210
- } : null);
241
+ const {
242
+ oxyServices
243
+ } = useOxy();
244
+ // Reactive OS reduce-motion preference (useSyncExternalStore, no effect). Pins
245
+ // the entrance spring off. Declared before `entrance` so its initial rest value
246
+ // is correct under reduce-motion.
247
+ const reduceMotion = useReduceMotion();
248
+
249
+ // The "My Oxy files" source hands us a file ID instead of a ready URL. Its
250
+ // download URL is usually private, so it must be resolved through the SDK
251
+ // (which throws on failure). Resolving it HERE — not in the source list — is
252
+ // what keeps the list from lingering on screen for the round-trip: this screen
253
+ // shows its own spinner on the dark canvas while the URL resolves. A React
254
+ // Query read (not an effect) so it stays declarative and cached.
255
+ const shouldResolveFile = !imageUri && !!imageFileId;
256
+ const sourceQuery = useQuery({
257
+ queryKey: ['avatarCropSource', imageFileId],
258
+ enabled: shouldResolveFile,
259
+ staleTime: Number.POSITIVE_INFINITY,
260
+ retry: false,
261
+ queryFn: async () => {
262
+ if (!imageFileId) {
263
+ throw new Error('No file id to resolve for cropping');
264
+ }
265
+ const resolved = await oxyServices.assetGetUrl(imageFileId);
266
+ if (!resolved?.url) {
267
+ throw new Error('No download URL returned for the selected image');
268
+ }
269
+ return resolved.url;
270
+ }
271
+ });
272
+
273
+ // The URL the cropper actually loads: the passed `imageUri`, else the URL the
274
+ // file-ID query resolved. While it resolves, `effectiveUri` is undefined and
275
+ // the stage shows its own spinner (never the empty state).
276
+ const effectiveUri = imageUri ?? sourceQuery.data;
277
+ const isResolvingSource = shouldResolveFile && !sourceQuery.data && !sourceQuery.isError;
278
+ const sourceErrorMessage = sourceQuery.isError ? t('changeAvatar.errors.loadImageFailed') || 'Could not load the selected image' : null;
279
+
280
+ // Natural size of the source image. Known up front (device/camera sources pass
281
+ // the dimensions) OR measured lazily from `effectiveUri` via a React Query read
282
+ // (no effect) — the same Image.getSize→useQuery pattern the photo grid uses.
283
+ const hasPassedDimensions = !!(sourceWidth && sourceHeight);
284
+ const measureQuery = useQuery({
285
+ queryKey: ['avatarCropMeasure', effectiveUri],
286
+ enabled: !!effectiveUri && !hasPassedDimensions,
287
+ queryFn: () => {
288
+ if (!effectiveUri) {
289
+ throw new Error('No image to measure');
290
+ }
291
+ return measureImageSize(effectiveUri);
292
+ },
293
+ staleTime: Number.POSITIVE_INFINITY,
294
+ retry: false,
295
+ placeholderData: keepPreviousData
296
+ });
297
+ const naturalSize = useMemo(() => {
298
+ if (sourceWidth && sourceHeight) return {
299
+ width: sourceWidth,
300
+ height: sourceHeight
301
+ };
302
+ return measureQuery.data ?? null;
303
+ }, [sourceWidth, sourceHeight, measureQuery.data]);
304
+ /** Measurement failed (bad dimensions / getSize error) — surfaced via the empty UI. */
305
+ const measureErrorMessage = measureQuery.isError ? t('editProfile.toasts.cropMeasureFailed') || 'Could not measure the image' : null;
211
306
  const [isProcessing, setIsProcessing] = useState(false);
212
307
  const [zoomLabel, setZoomLabel] = useState('1.0');
213
308
  /** True when scale != MIN_SCALE OR translate != 0 — used to reveal the reset link. */
214
309
  const [isModified, setIsModified] = useState(false);
215
- const [reduceMotion, setReduceMotion] = useState(false);
216
310
 
217
311
  // Shared values for the active gesture transform.
218
312
  const scale = useSharedValue(MIN_SCALE);
@@ -262,99 +356,18 @@ const AvatarCropScreen = ({
262
356
  };
263
357
  }, [naturalSize]);
264
358
 
265
- // Track in-flight measurement to avoid duplicate Image.getSize calls when
266
- // the component re-renders before the previous getSize callback fires.
267
- const measuringUriRef = useRef(null);
268
- /** Failure state for measurement, surfaced to the user via the empty UI. */
269
- const [measureError, setMeasureError] = useState(null);
270
- const handleImageMeasured = useCallback(uri => {
271
- if (measuringUriRef.current === uri) return;
272
- measuringUriRef.current = uri;
273
- // `logger.debug` is dev-gated upstream (no-op in production).
274
- // We deliberately don't log the full file URI in any production
275
- // path — only in debug builds — to avoid leaking on-device file
276
- // paths into logcat / Sentry breadcrumbs.
277
- logger.debug('Measuring image', {
278
- component: LOG_COMPONENT
279
- });
280
- Image.getSize(uri, (w, h) => {
281
- logger.debug('Image measured', {
282
- component: LOG_COMPONENT
283
- }, {
284
- width: w,
285
- height: h
286
- });
287
- if (!Number.isFinite(w) || !Number.isFinite(h) || w <= 0 || h <= 0) {
288
- const message = t('editProfile.toasts.cropMeasureFailed') || 'Could not measure the image';
289
- setMeasureError(message);
290
- toast.error(message);
291
- measuringUriRef.current = null;
292
- return;
293
- }
294
- setMeasureError(null);
295
- setNaturalSize({
296
- width: w,
297
- height: h
298
- });
299
- }, () => {
300
- logger.error('Image.getSize failed', new Error('Image measurement failed'), {
301
- component: LOG_COMPONENT
302
- });
303
- const message = t('editProfile.toasts.cropMeasureFailed') || 'Could not measure the image';
304
- setMeasureError(message);
305
- toast.error(message);
306
- measuringUriRef.current = null;
307
- });
308
- }, [t]);
309
-
310
- // Kick off measurement once per imageUri. Using useEffect (not a render-body
311
- // side effect) so the call is scheduled exactly when the URI changes,
312
- // rather than being re-fired on every parent re-render.
313
- useEffect(() => {
314
- if (!imageUri) return;
315
- if (sourceWidth && sourceHeight) return;
316
- if (naturalSize) return;
317
- handleImageMeasured(imageUri);
318
- }, [handleImageMeasured, imageUri, naturalSize, sourceHeight, sourceWidth]);
319
-
320
- // Dev-only one-time mount breadcrumb. `logger.debug` is dev-gated so
321
- // this is a no-op in production releases; we additionally avoid logging
322
- // the full `imageUri` to prevent leaking on-device file paths into any
323
- // breadcrumb sink that picks up debug output.
324
- useEffect(() => {
325
- logger.debug('mount', {
326
- component: LOG_COMPONENT
327
- }, {
328
- hasImageUri: !!imageUri,
329
- hasSourceDimensions: !!(sourceWidth && sourceHeight)
330
- });
331
- }, [imageUri, sourceHeight, sourceWidth]);
332
-
333
- // Detect reduce-motion preference once on mount + subscribe to changes.
334
- useEffect(() => {
335
- let cancelled = false;
336
- AccessibilityInfo.isReduceMotionEnabled().then(enabled => {
337
- if (cancelled) return;
338
- setReduceMotion(enabled);
339
- if (enabled) {
340
- entrance.value = 1;
341
- }
342
- }).catch(() => {
343
- // Best-effort — fall back to motion enabled.
344
- });
345
- const sub = AccessibilityInfo.addEventListener('reduceMotionChanged', enabled => {
346
- setReduceMotion(enabled);
347
- if (enabled) entrance.value = 1;
348
- });
349
- return () => {
350
- cancelled = true;
351
- sub.remove();
352
- };
353
- }, [entrance]);
354
-
355
- // Play the entrance pulse exactly once when motion is allowed.
356
- useEffect(() => {
357
- if (reduceMotion) return;
359
+ // Entrance pulse, driven from the crop frame's ref callback (fires on mount)
360
+ // rather than an effect the media-cleanup `startEntrance` pattern. Reduce
361
+ // motion pins the frame at rest; otherwise it springs in from 0.95→1. The
362
+ // callback depends on `reduceMotion`, so if that preference resolves/flips the
363
+ // callback re-runs with the node and re-pins (snap to 1) — matching the old
364
+ // effect that snapped the entrance to rest when reduce-motion turned on.
365
+ const startEntrance = useCallback(node => {
366
+ if (!node) return; // unmount
367
+ if (reduceMotion) {
368
+ entrance.value = 1;
369
+ return;
370
+ }
358
371
  entrance.value = withSpring(1, {
359
372
  damping: 14,
360
373
  stiffness: 180,
@@ -473,6 +486,11 @@ const AvatarCropScreen = ({
473
486
  runOnJS(hideZoomChip)();
474
487
  }), [baseFit, commitTransform, hideGrid, hideZoomChip, logGestureStart, notifyMaxBoundHit, notifyMinBoundHit, resetPinchBounds, savedScale, scale, showGrid, showZoomChip, translateX, translateY, updateZoomLabel]);
475
488
  const composedGesture = useMemo(() => Gesture.Simultaneous(panGesture, pinchGesture), [panGesture, pinchGesture]);
489
+
490
+ // Deps list every shared value the mapper reads so it re-runs on web (RN-Web
491
+ // has no worklets plugin — a mapper omitting its driver SVs freezes at the
492
+ // first frame, which would leave the button-driven zoom stuck). Native
493
+ // auto-tracks and ignores the extra deps, so this is safe cross-platform.
476
494
  const imageAnimatedStyle = useAnimatedStyle(() => ({
477
495
  transform: [{
478
496
  translateX: translateX.value
@@ -481,12 +499,15 @@ const AvatarCropScreen = ({
481
499
  }, {
482
500
  scale: scale.value
483
501
  }]
484
- }));
502
+ }), [translateX, translateY, scale]);
503
+
504
+ // `[entrance]` in deps so the ref-callback-driven entrance spring ticks on
505
+ // RN-Web (no worklets plugin); native auto-tracks and ignores the extra dep.
485
506
  const cropFrameAnimatedStyle = useAnimatedStyle(() => ({
486
507
  transform: [{
487
508
  scale: entrance.value
488
509
  }]
489
- }));
510
+ }), [entrance]);
490
511
  const gridAnimatedStyle = useAnimatedStyle(() => ({
491
512
  opacity: gridOpacity.value
492
513
  }));
@@ -509,6 +530,43 @@ const AvatarCropScreen = ({
509
530
  AccessibilityInfo.announceForAccessibility(t('editProfile.crop.a11yResetAnnouncement') || 'Crop reset');
510
531
  }, [commitTransform, reduceMotion, scale, t, translateX, translateY]);
511
532
 
533
+ /**
534
+ * Web zoom controls. A desktop pointer has no pinch, so the +/- buttons drive
535
+ * the SAME `scale` shared value the pinch gesture does — clamped to the same
536
+ * bounds, with translation re-clamped through the shared {@link clampTranslation}
537
+ * helper so the image never leaves the viewport. Native keeps pinch (the
538
+ * buttons are hidden there). Reduced motion collapses the tween to an instant
539
+ * set. Reads the committed transform (refs) at press time, never during render.
540
+ */
541
+ const applyZoom = useCallback(direction => {
542
+ if (!baseFit || isProcessing) return;
543
+ const current = committedScale.current;
544
+ const target = Math.min(MAX_SCALE, Math.max(MIN_SCALE, current + direction * ZOOM_STEP));
545
+ if (Math.abs(target - current) < 0.001) {
546
+ // Already at the bound — a soft selection tick, no transform change.
547
+ void hapticSelection();
548
+ return;
549
+ }
550
+ const clamped = clampTranslation(committedTranslateX.current, committedTranslateY.current, target, baseFit.width, baseFit.height);
551
+ const duration = reduceMotion ? 0 : ZOOM_BUTTON_DURATION_MS;
552
+ scale.value = withTiming(target, {
553
+ duration
554
+ });
555
+ translateX.value = withTiming(clamped.tx, {
556
+ duration
557
+ });
558
+ translateY.value = withTiming(clamped.ty, {
559
+ duration
560
+ });
561
+ commitTransform(target, clamped.tx, clamped.ty);
562
+ void hapticImpact('light');
563
+ // Mirror the pinch's transient chrome so the buttons feel identical.
564
+ showGrid();
565
+ hideGrid();
566
+ showZoomChip();
567
+ hideZoomChip();
568
+ }, [baseFit, commitTransform, hideGrid, hideZoomChip, isProcessing, reduceMotion, scale, showGrid, showZoomChip, translateX, translateY]);
569
+
512
570
  /**
513
571
  * Convert the on-screen transform into pixel-space crop coordinates
514
572
  * relative to the source image, then invoke expo-image-manipulator to
@@ -526,7 +584,7 @@ const AvatarCropScreen = ({
526
584
  committedTranslateX: committedTranslateX.current,
527
585
  committedTranslateY: committedTranslateY.current
528
586
  });
529
- if (!imageUri || !baseFit || !naturalSize) {
587
+ if (!effectiveUri || !baseFit || !naturalSize) {
530
588
  toast.error(t('editProfile.toasts.cropNotReady') || 'Image not ready yet');
531
589
  return;
532
590
  }
@@ -569,7 +627,7 @@ const AvatarCropScreen = ({
569
627
  cropSize,
570
628
  outputSize: OUTPUT_SIZE
571
629
  });
572
- const preparedImage = await prepareImageForManipulator(imageUri);
630
+ const preparedImage = await prepareImageForManipulator(effectiveUri);
573
631
  preparedImageCleanup = preparedImage.cleanup;
574
632
  const result = await manipulateAsync(preparedImage.uri, [{
575
633
  crop: {
@@ -617,85 +675,48 @@ const AvatarCropScreen = ({
617
675
  preparedImageCleanup?.();
618
676
  setIsProcessing(false);
619
677
  }
620
- }, [baseFit, imageUri, naturalSize, dismiss, t]);
621
- const handleCancel = useCallback(() => {
622
- dismiss?.();
623
- }, [dismiss]);
624
- const topInset = Platform.OS === 'ios' ? Math.max(insets.top, 12) : Math.max(insets.top, 16);
625
- const bottomInset = Math.max(insets.bottom, 16);
678
+ }, [baseFit, effectiveUri, naturalSize, dismiss, t]);
679
+
680
+ /**
681
+ * The surface's primary action, mounted into the Dialog nav bar's right slot
682
+ * (which is why it must stay referentially stable). While processing it keeps
683
+ * its width and shows a spinner; the a11y label carries the "Saving…" state
684
+ * the visible label can no longer show.
685
+ */
686
+ const doneAction = useMemo(() => /*#__PURE__*/_jsx(Button, {
687
+ variant: "primary",
688
+ size: "small",
689
+ onPress: () => void handleConfirm(),
690
+ disabled: isProcessing || !baseFit,
691
+ loading: isProcessing,
692
+ accessibilityLabel: isProcessing ? t('editProfile.crop.saving') : t('editProfile.crop.confirm'),
693
+ children: t('editProfile.crop.confirm')
694
+ }), [baseFit, handleConfirm, isProcessing, t]);
695
+
696
+ // No bar of our own: the surface owns the chrome. `goBack` pops back to the
697
+ // ChangeAvatar source list (and dismisses the surface if this is somehow the
698
+ // root frame), which is exactly Cancel.
699
+ useSurfaceHeader({
700
+ title: t('editProfile.crop.title'),
701
+ largeTitle: false,
702
+ right: doneAction,
703
+ onBack: goBack
704
+ });
626
705
  const styles = useMemo(() => StyleSheet.create({
627
706
  container: {
628
- flex: 1,
629
- backgroundColor: CANVAS_BG
630
- },
631
- topBar: {
632
- paddingTop: topInset,
633
- paddingHorizontal: 12,
634
- paddingBottom: 10,
635
- flexDirection: 'row',
636
- alignItems: 'center',
637
- justifyContent: 'space-between',
638
- backgroundColor: 'rgba(0,0,0,0.6)',
639
- zIndex: 10
640
- },
641
- topBarTitleWrap: {
642
- flex: 1,
643
- alignItems: 'center',
644
- justifyContent: 'center',
645
- paddingHorizontal: 4
646
- },
647
- topBarTitle: {
648
- color: '#ffffff',
649
- fontSize: 17,
650
- letterSpacing: -0.2,
651
- ...(Platform.OS === 'web' ? {
652
- fontWeight: '600'
653
- } : null)
654
- },
655
- cancelBtn: {
656
- minWidth: 64,
657
- paddingHorizontal: 10,
658
- paddingVertical: 8,
659
- borderRadius: 18,
660
- alignItems: 'flex-start',
661
- justifyContent: 'center'
662
- },
663
- cancelLabel: {
664
- color: '#ffffff',
665
- fontSize: 15,
666
- opacity: 0.85
667
- },
668
- doneBtn: {
669
- minWidth: 76,
670
- paddingHorizontal: 14,
671
- paddingVertical: 8,
672
- borderRadius: 18,
673
- alignItems: 'center',
674
- justifyContent: 'center',
675
- backgroundColor: theme.colors.primary
676
- },
677
- doneBtnDisabled: {
678
- opacity: 0.5
679
- },
680
- doneLabel: {
681
- color: '#ffffff',
682
- fontSize: 15,
683
- letterSpacing: -0.1,
684
- ...(Platform.OS === 'web' ? {
685
- fontWeight: '600'
686
- } : null)
687
- },
688
- doneLabelLoading: {
689
- flexDirection: 'row',
690
- alignItems: 'center',
691
- justifyContent: 'center',
692
- gap: 8
707
+ backgroundColor: theme.colors.background
693
708
  },
694
709
  stage: {
695
- flex: 1,
710
+ backgroundColor: CANVAS_BG,
711
+ borderRadius: STAGE_RADIUS,
712
+ overflow: 'hidden',
713
+ // Top padding clears the zoom chip, which floats 44dp above
714
+ // the crop frame and would otherwise be clipped by `overflow`.
715
+ paddingTop: 60,
716
+ paddingBottom: 28,
717
+ paddingHorizontal: 16,
696
718
  alignItems: 'center',
697
- justifyContent: 'center',
698
- paddingHorizontal: 16
719
+ justifyContent: 'center'
699
720
  },
700
721
  cropFrame: {
701
722
  width: VIEWPORT_SIZE,
@@ -780,17 +801,14 @@ const AvatarCropScreen = ({
780
801
  letterSpacing: 0.2
781
802
  },
782
803
  helperBlock: {
783
- paddingHorizontal: 24,
784
- paddingTop: 24,
785
- paddingBottom: bottomInset,
804
+ paddingTop: 16,
786
805
  alignItems: 'center',
787
- justifyContent: 'flex-end',
788
- gap: 10
806
+ gap: 8
789
807
  },
790
808
  helper: {
791
809
  fontSize: 13,
792
810
  lineHeight: 18,
793
- color: 'rgba(255,255,255,0.6)',
811
+ color: theme.colors.textSecondary,
794
812
  textAlign: 'center',
795
813
  maxWidth: 320
796
814
  },
@@ -800,123 +818,72 @@ const AvatarCropScreen = ({
800
818
  },
801
819
  resetLinkText: {
802
820
  fontSize: 13,
803
- color: '#ffffff',
804
- opacity: 0.85,
821
+ color: theme.colors.primary,
805
822
  textDecorationLine: 'underline'
806
823
  },
807
824
  emptyState: {
808
- flex: 1,
809
825
  alignItems: 'center',
810
826
  justifyContent: 'center',
811
- padding: 24
827
+ paddingVertical: 48
812
828
  },
813
829
  emptyLabel: {
814
830
  fontSize: 14,
815
- color: 'rgba(255,255,255,0.7)',
831
+ color: theme.colors.textSecondary,
816
832
  textAlign: 'center'
817
833
  }
818
- }), [baseFit, bottomInset, theme, topInset]);
834
+ }), [baseFit, theme]);
819
835
 
820
836
  // Reset link reveal — only show when the image is not at the default
821
837
  // transform. Use derived display state to avoid mounting/unmounting jank.
822
838
  const resetLinkOpacity = isModified ? 1 : 0;
823
839
 
824
- // No image supplied OR measurement failed render a minimal empty state.
825
- if (!imageUri || measureError) {
826
- const emptyMessage = !imageUri ? t('editProfile.crop.noImage') || 'No image to crop' : measureError;
827
- return /*#__PURE__*/_jsxs(View, {
840
+ // Zoom-button state is derived from `zoomLabel` (reactive state, set on every
841
+ // commit) rather than the committed-scale ref, so it stays correct across
842
+ // renders without reading mutable state during render. The +/- pair is web-only
843
+ // (native has pinch).
844
+ const currentZoom = Number.parseFloat(zoomLabel) || MIN_SCALE;
845
+ const canZoomOut = currentZoom > MIN_SCALE + 0.001;
846
+ const canZoomIn = currentZoom < MAX_SCALE - 0.001;
847
+ const showZoomControls = Platform.OS === 'web';
848
+ const zoomOutDisabled = !canZoomOut || !baseFit || isProcessing;
849
+ const zoomInDisabled = !canZoomIn || !baseFit || isProcessing;
850
+
851
+ // No source at all (and none resolving), a resolution failure, or a
852
+ // measurement failure — render a minimal empty state. While a file ID is still
853
+ // resolving, fall THROUGH to the stage so its own spinner shows, not this.
854
+ // The surface's nav bar (back = cancel) is the only chrome needed here.
855
+ if (!effectiveUri && !isResolvingSource || sourceErrorMessage || measureErrorMessage) {
856
+ const emptyMessage = sourceErrorMessage ? sourceErrorMessage : measureErrorMessage ? measureErrorMessage : t('editProfile.crop.noImage');
857
+ return /*#__PURE__*/_jsx(View, {
828
858
  style: styles.container,
829
- children: [/*#__PURE__*/_jsxs(View, {
830
- style: styles.topBar,
831
- children: [/*#__PURE__*/_jsx(TouchableOpacity, {
832
- accessibilityLabel: t('editProfile.crop.cancel') || 'Cancel',
833
- accessibilityRole: "button",
834
- style: styles.cancelBtn,
835
- onPress: handleCancel,
836
- activeOpacity: 0.6,
837
- children: /*#__PURE__*/_jsx(Text, {
838
- style: styles.cancelLabel,
839
- children: t('editProfile.crop.cancel') || 'Cancel'
840
- })
841
- }), /*#__PURE__*/_jsx(View, {
842
- style: styles.topBarTitleWrap,
843
- children: /*#__PURE__*/_jsx(Text, {
844
- style: styles.topBarTitle,
845
- children: t('editProfile.crop.title') || 'Crop avatar'
846
- })
847
- }), /*#__PURE__*/_jsx(View, {
848
- style: styles.cancelBtn
849
- })]
850
- }), /*#__PURE__*/_jsx(View, {
859
+ className: "px-screen-margin pb-space-24",
860
+ children: /*#__PURE__*/_jsx(View, {
851
861
  style: styles.emptyState,
852
862
  children: /*#__PURE__*/_jsx(Text, {
853
863
  style: styles.emptyLabel,
854
864
  children: emptyMessage
855
865
  })
856
- })]
866
+ })
857
867
  });
858
868
  }
859
869
  return /*#__PURE__*/_jsxs(View, {
860
870
  style: styles.container,
871
+ className: "px-screen-margin pb-space-24",
861
872
  children: [/*#__PURE__*/_jsxs(View, {
862
- style: styles.topBar,
863
- children: [/*#__PURE__*/_jsx(TouchableOpacity, {
864
- accessibilityLabel: t('editProfile.crop.cancel') || 'Cancel',
865
- accessibilityRole: "button",
866
- style: styles.cancelBtn,
867
- onPress: handleCancel,
868
- disabled: isProcessing,
869
- activeOpacity: 0.6,
870
- children: /*#__PURE__*/_jsx(Text, {
871
- style: styles.cancelLabel,
872
- children: t('editProfile.crop.cancel') || 'Cancel'
873
- })
874
- }), /*#__PURE__*/_jsx(View, {
875
- style: styles.topBarTitleWrap,
876
- children: /*#__PURE__*/_jsx(Text, {
877
- style: styles.topBarTitle,
878
- numberOfLines: 1,
879
- children: t('editProfile.crop.title') || 'Crop avatar'
880
- })
881
- }), /*#__PURE__*/_jsx(TouchableOpacity, {
882
- accessibilityLabel: t('editProfile.crop.confirm') || 'Use photo',
883
- accessibilityRole: "button",
884
- accessibilityState: {
885
- disabled: isProcessing || !baseFit,
886
- busy: isProcessing
887
- },
888
- style: [styles.doneBtn, (isProcessing || !baseFit) && styles.doneBtnDisabled],
889
- onPress: handleConfirm,
890
- disabled: isProcessing || !baseFit,
891
- activeOpacity: 0.85,
892
- children: isProcessing ? /*#__PURE__*/_jsxs(View, {
893
- style: styles.doneLabelLoading,
894
- children: [/*#__PURE__*/_jsx(ActivityIndicator, {
895
- size: "small",
896
- color: "#ffffff"
897
- }), /*#__PURE__*/_jsx(Text, {
898
- style: styles.doneLabel,
899
- children: t('editProfile.crop.saving') || 'Saving…'
900
- })]
901
- }) : /*#__PURE__*/_jsx(Text, {
902
- style: styles.doneLabel,
903
- children: t('editProfile.crop.confirm') || 'Use photo'
904
- })
905
- })]
906
- }), /*#__PURE__*/_jsx(View, {
907
873
  style: styles.stage,
908
- children: /*#__PURE__*/_jsxs(Animated.View, {
874
+ children: [/*#__PURE__*/_jsxs(Animated.View, {
875
+ ref: startEntrance,
909
876
  style: [styles.cropFrame, cropFrameAnimatedStyle],
910
877
  accessible: true,
911
878
  accessibilityRole: "image",
912
- accessibilityLabel: t('editProfile.crop.a11yImage') || 'Crop preview. Pinch to zoom and drag to reposition the image.',
879
+ accessibilityLabel: t('editProfile.crop.a11yImage'),
913
880
  children: [/*#__PURE__*/_jsx(GestureDetector, {
914
881
  gesture: composedGesture,
915
882
  children: /*#__PURE__*/_jsx(View, {
916
883
  style: styles.viewport,
917
- children: baseFit ? /*#__PURE__*/_jsx(Animated.Image, {
884
+ children: baseFit && effectiveUri ? /*#__PURE__*/_jsx(Animated.Image, {
918
885
  source: {
919
- uri: imageUri
886
+ uri: effectiveUri
920
887
  },
921
888
  style: [styles.image, imageAnimatedStyle],
922
889
  resizeMode: "cover"
@@ -954,17 +921,52 @@ const AvatarCropScreen = ({
954
921
  style: styles.zoomChipText,
955
922
  children: t('editProfile.crop.zoom', {
956
923
  value: zoomLabel
957
- }) || `${zoomLabel}×`
924
+ })
958
925
  })
959
926
  })]
960
- })
927
+ }), showZoomControls ? /*#__PURE__*/_jsx(View, {
928
+ className: "absolute bottom-4 left-0 right-0 items-center",
929
+ pointerEvents: "box-none",
930
+ children: /*#__PURE__*/_jsxs(View, {
931
+ className: "flex-row overflow-hidden rounded-full bg-black/70",
932
+ children: [/*#__PURE__*/_jsx(Pressable, {
933
+ accessibilityRole: "button",
934
+ accessibilityLabel: t('editProfile.crop.zoomOut'),
935
+ accessibilityState: {
936
+ disabled: zoomOutDisabled
937
+ },
938
+ disabled: zoomOutDisabled,
939
+ onPress: () => applyZoom(-1),
940
+ className: `h-10 w-[52px] items-center justify-center active:bg-white/10${zoomOutDisabled ? ' opacity-40' : ''}`,
941
+ children: /*#__PURE__*/_jsx(Text, {
942
+ className: "text-white text-[22px] font-medium leading-[24px]",
943
+ children: '−'
944
+ })
945
+ }), /*#__PURE__*/_jsx(View, {
946
+ className: "w-px self-stretch bg-white/25"
947
+ }), /*#__PURE__*/_jsx(Pressable, {
948
+ accessibilityRole: "button",
949
+ accessibilityLabel: t('editProfile.crop.zoomIn'),
950
+ accessibilityState: {
951
+ disabled: zoomInDisabled
952
+ },
953
+ disabled: zoomInDisabled,
954
+ onPress: () => applyZoom(1),
955
+ className: `h-10 w-[52px] items-center justify-center active:bg-white/10${zoomInDisabled ? ' opacity-40' : ''}`,
956
+ children: /*#__PURE__*/_jsx(Text, {
957
+ className: "text-white text-[22px] font-medium leading-[24px]",
958
+ children: '+'
959
+ })
960
+ })]
961
+ })
962
+ }) : null]
961
963
  }), /*#__PURE__*/_jsxs(View, {
962
964
  style: styles.helperBlock,
963
965
  children: [/*#__PURE__*/_jsx(Text, {
964
966
  style: styles.helper,
965
- children: t('editProfile.crop.helper') || 'The cropped circle is what will appear on your profile. Pinch to zoom, drag to position.'
967
+ children: t('editProfile.crop.helper')
966
968
  }), /*#__PURE__*/_jsx(Pressable, {
967
- accessibilityLabel: t('editProfile.crop.a11yReset') || 'Reset crop to default position',
969
+ accessibilityLabel: t('editProfile.crop.a11yReset'),
968
970
  accessibilityRole: "button",
969
971
  accessibilityState: {
970
972
  disabled: !isModified || isProcessing
@@ -976,7 +978,7 @@ const AvatarCropScreen = ({
976
978
  }],
977
979
  children: /*#__PURE__*/_jsx(Text, {
978
980
  style: styles.resetLinkText,
979
- children: t('editProfile.crop.resetToCenter') || 'Reset to center'
981
+ children: t('editProfile.crop.resetToCenter')
980
982
  })
981
983
  })]
982
984
  })]