{"id":15038395,"url":"https://github.com/rallahaseh/raimagepicker","last_synced_at":"2025-04-10T01:22:03.655Z","repository":{"id":62451765,"uuid":"112441791","full_name":"rallahaseh/RAImagePicker","owner":"rallahaseh","description":" 📸 iMessage-like, Image Picker Controller Provides custom features.","archived":false,"fork":false,"pushed_at":"2017-12-07T07:08:31.000Z","size":186,"stargazers_count":16,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-20T17:52:39.624Z","etag":null,"topics":["assets","imagepicker","images","ios","swift","swift-4","swift4","videos"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rallahaseh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-29T07:27:44.000Z","updated_at":"2023-11-22T11:01:14.000Z","dependencies_parsed_at":"2022-11-01T23:45:35.889Z","dependency_job_id":null,"html_url":"https://github.com/rallahaseh/RAImagePicker","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rallahaseh%2FRAImagePicker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rallahaseh%2FRAImagePicker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rallahaseh%2FRAImagePicker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rallahaseh%2FRAImagePicker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rallahaseh","download_url":"https://codeload.github.com/rallahaseh/RAImagePicker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248138273,"owners_count":21053840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assets","imagepicker","images","ios","swift","swift-4","swift4","videos"],"created_at":"2024-09-24T20:38:17.401Z","updated_at":"2025-04-10T01:22:03.625Z","avatar_url":"https://github.com/rallahaseh.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RAImagePicker\n\n[![CI Status](http://img.shields.io/travis/rallahaseh/RAImagePicker.svg?style=flat)](https://travis-ci.org/rallahaseh/RAImagePicker)\n[![Version](https://img.shields.io/cocoapods/v/RAImagePicker.svg?style=flat)](http://cocoapods.org/pods/RAImagePicker)\n[![License](https://img.shields.io/cocoapods/l/RAImagePicker.svg?style=flat)](http://cocoapods.org/pods/RAImagePicker)\n[![Platform](https://img.shields.io/cocoapods/p/RAImagePicker.svg?style=flat)](http://cocoapods.org/pods/RAImagePicker)\n\n## Description\n\nRAImagePicker is a protocol-oriented framework that provides custom features from the built-in Image Picker Edit.\n\n\u003cbr\u003e\n\u003cimg src=\"https://media.giphy.com/media/3ohs7QgfzREzPpDsk0/giphy.gif\"/\u003e\n\u003cbr\u003e\n\n## Overview\n\nObject `RAImagePickerController` manages user interactions and delivers the results of those interactions to a delegate object.\n\n**RAImagePickerController** depend on the configuration you set up before presenting it.\n\nFunctional Parts:\n1. **Action Items(Default Asset.)** - Supports two actions, this section is optional and by default contains action item for camera and photos.\n2. **Camera** - Camera's output(Capture Videos/Photos), this section is optinal and by default it's turned on.\n3. **Asset.** - Thumbnails of assets found in gallery, this section is mandatory and and can not be turned off.\n\n**Protocol**\nProvide a delegate that conforms to `RAImagePickerControllerDelegate` protocol. Use delegate to get informed when user takes a picture or selects an asset from library and configure custom action and asset collection view cells.\n\n## Usage\n\nFollow the following steps to get started:\n1. Add permissions to your `info.plist` file.\n2. Create new instance of RAImagePickerController.\n3. Present the controller\n**Note:** You can configure the controller by set **Custom Cells**, change **Appearance and Layout** and the **Capture Mode**\n\n## Features\n\n- [x] Presentation Design Handeled for `.horizontal`(like iMessage) and `.vertical` Modes\n- [x] Portrait and Landscape Supported\n- [x] Support iPhone X\n- [x] Support Live Photos\n- [x] Flip Camera (Rear/Front)\n- [x] Highly and Easly Customisable Layout\n\n## Plist Privacy Permissions\n\nIn order to get access to the user Camera and Photos/Videos Gallery, you will need to add permissions to the `plist` file :\n- Privacy - Camera Usage Description (Photos/Videos)\n- Privacy - Photo Library Usage Description (Gallery)\n- Privacy - Microphone Usage Description (Videos)\n\n```xml\n\u003ckey\u003eNSCameraUsageDescription\u003c/key\u003e\n\u003cstring\u003eAccess Description\u003c/string\u003e\n\u003ckey\u003eNSPhotoLibraryUsageDescription\u003c/key\u003e\n\u003cstring\u003eAccess Description\u003c/string\u003e\n\u003ckey\u003eNSMicrophoneUsageDescription\u003c/key\u003e\n\u003cstring\u003eAccess Description\u003c/string\u003e\n```\n\n## Capture Modes\n\nCurrently it supports capturing **Photos**, **Live Photos** and **Videos**.\n\nTo configure RAImagePicker to support desired media type use `captureSettings` struct. Use property `cameraMode` to specify what kind of output you are interested in.\n- [x] photo [Support Photos Only (Default)]\n- [x] video [Support Videos Only]\n- [x] photoAndLivePhoto [Support Photos \u0026 Live Photos]\n- [x] photoAndVideo [Support Videos \u0026 Photos]\n\n\u003cbr\u003e\n\n**Example:**\n```swift\nlet imagePicker = RAImagePickerController()\nimagePicker.captureSettings.cameraMode = .photoAndLivePhoto\n```\n\nTo save the captured photos to the gallery. Set the flag `savesCapturedPhotosToPhotoLibrary` to true.\n\n\u003cbr\u003e\n\n**Example:**\n```swift\nlet imagePicker = RAImagePickerController()\nimagePicker.captureSettings.savesCapturedPhotosToPhotoLibrary = true\n```\n\n## Fetching\n\nDefault Image Picker fetches from Photo Library 1000 photos and videos from smart album `smartAlbumUserLibrary` that should represent **Camera Roll** album. If you wish to provide your own fetch result please implement image picker controller's `assetsFetchResultBlock` block.\n\nFor example the following code snippet can fetch only live photos:\n```swift\nlet imagePicker = RAImagePickerController()\nimagePicker.assetsFetchResultBlock = {\n    guard let livePhotosCollection = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumLivePhotos, options: nil).firstObject else {\n        return nil //you can return nil if you did not find desired fetch result, default fetch result will be used.\n    }\n    return PHAsset.fetchAssets(in: livePhotosCollection, options: nil)\n}\n```\nReference [Photos Framework](https://developer.apple.com/documentation/photos).\n\n## Customization\n\n\u003cbr\u003e\n\u003cimg src=\"https://media.giphy.com/media/3oxHQoBwQwoETbaxZS/giphy.gif\"/\u003e\n\u003cbr\u003e\n\n**Action Cells**\n1. Set Layout Configuration\n```swift\nlet imagePicker = RAImagePickerController()\nimagePicker.layoutConfiguration.showsDefaultCameraItem  = true\nimagePicker.layoutConfiguration.showsDefaultGalleryItem = true\n```\n\n2. Register Action Cells\nNow there's multiple ways to register your custom cells\n- [x] Using nib \n```swift \nimagePicker.registerNibForActionItems(CustomNib) \n```\n- [x] Using class \n```swift \nimagePicker.registerCellClassForActionItems(CustomCell) \n```\n- [x] For specific item(nib) \n```swift \nimagePicker.cellRegistrator.register(nib: CustomNib, forActionItemAt: 0) \n```\n- [x] For specific item(class) \n```swift \nimagePicker.cellRegistrator.register(nib: CustomCell, forActionItemAt: 0) \n```\n\n3. Configure Delegate\n```swift\nfunc imagePicker(controller: RAImagePickerController, willDisplayActionItem cell: UICollectionViewCell, at index: Int) {\n    switch cell {\n    case let customCell as CustomCell:\n        switch index {\n        case 0:\n            customCell.title.text = \"Title\"\n            customCell.icon.image = UIImage(named: \"icon_name\")\n        case 1:\n            customCell.title.text = \"Title\"\n            customCell.icon.image = UIImage(named: \"icon_name\")\n        default: break\n        }\n    default:\n        break\n    }\n}\n```\n\n4. Handle Selected Assets\n```swift\nfunc imagePicker(controller: RAImagePickerController, didSelectActionItemAt index: Int) {\n    print(\"Selected Asset. Index: \\(index)\")\n}\n```\n\n**Appearance Cells**\n\n1. Register Cell Classes\n```swift\nlet imagePicker = RAImagePickerController()\nimagePicker.register(cellClass: CustomImageCell.self, forAssetItemOf: .image)\nimagePicker.register(cellClass: CustomVideoCell.self, forAssetItemOf: .video)\n```\n\u003e Please note, that `RACellRegistrator` provides a method to register one cell or nib for any asset media type.\n\n2. Configure Delegate\n```swift\nfunc imagePicker(controller: RAImagePickerController, willDisplayAssetItem cell: RAImagePickerAssetCell, asset: PHAsset) {\n    switch cell {\n    case let imageCell as CustomImageCell:\n        if asset.mediaSubtypes.contains(.photoLive) {\n            imageCell.subtypeImageView.image = UIImage(named: \"icon_name\")\n        }\n        else if asset.mediaSubtypes.contains(.photoPanorama) {\n            imageCell.subtypeImageView.image = UIImage(named: \"icon_name\")\n        }\n        else if #available(iOS 10.2, *), asset.mediaSubtypes.contains(.photoDepthEffect) {\n            imageCell.subtypeImageView.image = UIImage(named: \"icon_name\")\n        }\n        // etc ...\n    case let videoCell as CustomVideoCell:\n        videoCell.label.text = asset.duration\n    default:\n        break\n    }\n}\n```\n\n## Presentation\n\n```swift\nlet imagePicker = RAImagePickerController()\nnavigationController.present(imagePicker, animated: true, completion: nil)\n```\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## References\n\n- [Photos Framework](https://developer.apple.com/documentation/photos)\n- [devxoul - UIImage Category](https://github.com/devxoul/ImageEffects)\n\n## Requirements\n\n- Xcode +9.0\n- iOS 10.0+\n- Swift 4\n\n## Installation\n\nRAImagePicker is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'RAImagePicker'\n```\n\n## Author\n\nrallahaseh, rallahaseh@gmail.com\n\n## License\n\nRAImagePicker is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frallahaseh%2Fraimagepicker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frallahaseh%2Fraimagepicker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frallahaseh%2Fraimagepicker/lists"}