@@ -24,8 +24,7 @@ import CONST from '@src/CONST';
2424import type { TranslationPaths } from '@src/languages/types' ;
2525import type { FileObject , ImagePickerResponse as FileResponse } from '@src/types/utils/Attachment' ;
2626import type IconAsset from '@src/types/utils/IconAsset' ;
27- import AttachmentCamera from './AttachmentCamera' ;
28- import type { CapturedPhoto } from './AttachmentCamera' ;
27+ import launchCamera from './launchCamera/launchCamera' ;
2928import type AttachmentPickerProps from './types' ;
3029
3130type LocalCopy = {
@@ -137,10 +136,6 @@ function AttachmentPicker({
137136 const onClosed = useRef < ( ) => void > ( ( ) => { } ) ;
138137 const popoverRef = useRef ( null ) ;
139138
140- // In-app camera state — uses VisionCamera to keep the app in the foreground during photo capture
141- const [ showAttachmentCamera , setShowAttachmentCamera ] = useState ( false ) ;
142- const cameraResolveRef = useRef < ( ( photos ?: CapturedPhoto [ ] ) => void ) | null > ( null ) ;
143-
144139 const { translate} = useLocalize ( ) ;
145140 const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
146141
@@ -154,43 +149,6 @@ function AttachmentPicker({
154149 [ translate ] ,
155150 ) ;
156151
157- /**
158- * Launch the in-app camera using VisionCamera.
159- * Returns a Promise that resolves with the captured photo as an Asset-compatible object,
160- * or resolves with void if the user closes the camera without capturing.
161- */
162- const launchInAppCamera = useCallback ( ( ) : Promise < Asset [ ] | void > => {
163- return new Promise ( ( resolve ) => {
164- cameraResolveRef . current = ( photos ?: CapturedPhoto [ ] ) => {
165- if ( ! photos || photos . length === 0 ) {
166- resolve ( ) ;
167- return ;
168- }
169- const assets : Asset [ ] = photos . map ( ( photo ) => ( {
170- uri : photo . uri ,
171- fileName : photo . fileName ,
172- type : photo . type ,
173- width : photo . width ,
174- height : photo . height ,
175- } ) ) ;
176- resolve ( assets ) ;
177- } ;
178- setShowAttachmentCamera ( true ) ;
179- } ) ;
180- } , [ ] ) ;
181-
182- const handleCameraCapture = ( photos : CapturedPhoto [ ] ) => {
183- setShowAttachmentCamera ( false ) ;
184- cameraResolveRef . current ?.( photos ) ;
185- cameraResolveRef . current = null ;
186- } ;
187-
188- const handleCameraClose = ( ) => {
189- setShowAttachmentCamera ( false ) ;
190- cameraResolveRef . current ?.( ) ;
191- cameraResolveRef . current = null ;
192- } ;
193-
194152 /**
195153 * Common image picker handling
196154 *
@@ -343,12 +301,12 @@ function AttachmentPicker({
343301 data . unshift ( {
344302 icon : icons . Camera ,
345303 textTranslationKey : 'attachmentPicker.takePhoto' ,
346- pickAttachment : launchInAppCamera ,
304+ pickAttachment : ( ) => showImagePicker ( launchCamera ) ,
347305 } ) ;
348306 }
349307
350308 return data ;
351- } , [ icons . Camera , icons . Paperclip , icons . Gallery , showDocumentPicker , shouldHideGalleryOption , shouldHideCameraOption , showImagePicker , launchInAppCamera ] ) ;
309+ } , [ icons . Camera , icons . Paperclip , icons . Gallery , showDocumentPicker , shouldHideGalleryOption , shouldHideCameraOption , showImagePicker ] ) ;
352310
353311 const [ focusedIndex , setFocusedIndex ] = useArrowKeyFocusManager ( { initialFocusedIndex : - 1 , maxIndex : menuItemData . length - 1 , isActive : isVisible } ) ;
354312
@@ -570,13 +528,6 @@ function AttachmentPicker({
570528 ) ) }
571529 </ View >
572530 </ Popover >
573- { showAttachmentCamera && (
574- < AttachmentCamera
575- isVisible = { showAttachmentCamera }
576- onCapture = { handleCameraCapture }
577- onClose = { handleCameraClose }
578- />
579- ) }
580531 { renderChildren ( ) }
581532 </ >
582533 ) ;
0 commit comments