Refactor and Finalize useMediaPicker Hook for Unified Media Handling #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔄 Pull Request: Refactor and Finalize
useMediaPicker
Hook for Unified Media Handling📌 Summary
This PR finalizes and cleans up the implementation of the
useMediaPicker
custom React hook. It enables streamlined handling of images, videos, and documents from the device's library, camera, or file system, while also managing permissions, thumbnails, and media state.✅ Features & Improvements
✅ Supports picking from:
chooseImageFromLibrary
)pickImageWithCamera
)pickDocument
)✅ Handles permissions (media and camera) automatically
✅ Supports both single and multiple media selections
✅ Generates video thumbnails (with
expo-video-thumbnails
)✅ Unified structure for
MediaAsset
andDocumentAsset
✅ State management:
media
: single selected assetmultipleMedia
: multiple selected assetsthumbnail
: generated preview for videoloading
: boolean indicating async operations in progress✅ Utility function:
resetMedia()
to clear selections🧠 Hook Usage
mediaType
: AcceptsMediaType.Images
,MediaType.Videos
, or bothoptions
: OptionalImagePickerOptions
(e.g., editing, multiple selection)🧪 Example Use Cases
🧹 Cleaned Up