Swiftpack.co - SilenceLove/HXPHPicker as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by SilenceLove.
SilenceLove/HXPHPicker 2.0.0
Photo/Video Selector-Supports LivePhoto, GIF selection, online download of resources on iCloud, and editing of photos/videos
โญ๏ธ 360
๐Ÿ•“ 46 weeks ago
iOS
.package(url: "https://github.com/SilenceLove/HXPHPicker.git", from: "2.0.0")

ไธญๆ–‡ | English

Please move to HXPhotoPicker for the latest version

Buy Me A Coffee
photo/video selector-supports LivePhoto, GIF selection, iCloud resource online download, photo/video editing

Features

  • โ˜‘ UI Appearance supports light/dark/auto/custom
  • โ˜‘ Support multiple selection/mixed content selection
  • โ˜‘ Supported media types๏ผš
    • โ˜‘ Photo
    • โ˜‘ GIF
    • โ˜‘ Live Photo
    • โ˜‘ Video
  • โ˜‘ Supported local media types๏ผš
    • โ˜‘ Photo
    • โ˜‘ Video
    • โ˜‘ GIF
    • โ˜‘ Live Photo
  • โ˜‘ Supported network media types๏ผš
    • โ˜‘ Photo
    • โ˜‘ Video
  • โ˜‘ Support downloading assets on iCloud
  • โ˜‘ Support gesture back
  • โ˜‘ Support sliding selection
  • โ˜‘ Edit pictures (support animated pictures, network pictures)
    • โ˜‘ Graffiti
    • โ˜‘ Sticker
    • โ˜‘ Text
    • โ˜‘ Crop
    • โ˜‘ Mosaic
    • โ˜‘ Filter
  • โ˜‘ Edit video (support network video)
    • โ˜‘ Graffiti
    • โ˜‘ Stickers (support GIF)
    • โ˜‘ Text
    • โ˜‘ Soundtrack (support lyrics and subtitles)
    • โ˜‘ Crop duration
    • โ˜‘ Crop Size
    • โ˜‘ Filter
  • โ˜‘ Album display mode
    • โ˜‘ Separate list
    • โ˜‘ Pop-ups
  • โ˜‘ Multi-platform support
    • โ˜‘ iOS
    • โ˜‘ iPadOS
  • โ˜‘ Internationalization support
    • โ˜‘ ๐Ÿ‡จ๐Ÿ‡ณ Chinese, Simplified (zh-Hans)
    • โ˜‘ ๐Ÿ‡ฌ๐Ÿ‡ง English (en)
    • โ˜‘ ๐Ÿ‡จ๐Ÿ‡ณ Chinese, traditional (zh-Hant)
    • โ˜‘ ๐Ÿ‡ฏ๐Ÿ‡ต Japanese (ja)
    • โ˜‘ ๐Ÿ‡ฐ๐Ÿ‡ท Korean (ko)
    • โ˜‘ ๐Ÿ‡น๐Ÿ‡ญ Thai (th)
    • โ˜‘ ๐Ÿ‡ฎ๐Ÿ‡ณ Indonesian (id)
    • โ˜‘ ๐Ÿ‡ป๐Ÿ‡ณ Vietnamese (vi)
    • โ˜‘ ๐Ÿ‡ท๐Ÿ‡บ russian (ru)
    • โ˜‘ ๐Ÿ‡ฉ๐Ÿ‡ช german (de)
    • โ˜‘ ๐Ÿ‡ซ๐Ÿ‡ท french (fr)
    • โ˜‘ ๐Ÿ‡ธ๐Ÿ‡ฆ arabic (ar)
    • โ˜‘ โœ๏ธ Custom language (custom)
    • โ˜ ๐Ÿค More support... (Pull requests welcome)

Requirements

  • iOS 12.0+
  • Xcode 12.5+
  • Swift 5.4+

Installation

Swift Package Manager

โš ๏ธ Needs Xcode 12.0+ to support resources and localization files

dependencies: [
    .package(url: "https://github.com/SilenceLove/HXPHPicker.git", .upToNextMajor(from: "2.0.0"))
]

CocoaPods

Add this to Podfile, and then update dependency:


iOS 12.0+
pod 'HXPHPicker'

/// No Kingfisher
pod `HXPHPicker/Lite`

/// Only Picker
pod `HXPHPicker/Picker`
pod `HXPHPicker/Picker/Lite`

/// Only Editor
pod `HXPHPicker/Editor`
pod `HXPHPicker/Editor/Lite`

/// Only Camera
pod `HXPHPicker/Camera`
/// Does not include location functionality
pod `HXPHPicker/Camera/Lite`

iOS 10.0+
pod 'HXPHPicker-Lite'
pod 'HXPHPicker-Lite/Picker'
pod 'HXPHPicker-Lite/Editor'
pod 'HXPHPicker-Lite/Camera'

Carthage

Add the following content to Cartfile and perform dependency update.

github "SilenceLove/HXPHPicker"

Usage

Wiki

Prepare

Add these keys to your Info.plist when needed:

Key Module Info
NSPhotoLibraryUsageDescription Picker Allow access to album
NSPhotoLibraryAddUsageDescription Picker Allow to save pictures to album
PHPhotoLibraryPreventAutomaticLimitedAccessAlert Picker Set YES to prevent automatic limited access alert in iOS 14+ (Picker has been adapted with Limited features that can be triggered by the user to enhance the user experience)
NSCameraUsageDescription Camera Allow camera
NSMicrophoneUsageDescription Camera Allow microphone

Quick Start

import HXPHPicker

class ViewController: UIViewController {

    func presentPickerController() {
        // Set the configuration consistent with the WeChat theme
        let config = PickerConfiguration.default
        
        // Method 1๏ผš
        let pickerController = PhotoPickerController(picker: config)
        pickerController.pickerDelegate = self
        // The array of PhotoAsset objects corresponding to the currently selected asset
        pickerController.selectedAssetArray = selectedAssets 
        // Whether to select the original image
        pickerController.isOriginal = isOriginal
        present(pickerController, animated: true, completion: nil)
        
        // Method 2๏ผš
        Photo.picker(
            config
        ) { result, pickerController in
            // Select completion callback
            // result Select result
            //  .photoAssets Currently selected data
            //  .isOriginal Whether the original image is selected
            // photoPickerController Corresponding photo selection controller
        } cancel: { pickerController in
            // Cancelled callback
            // photoPickerController Corresponding photo selection controller
        }
    }
}

extension ViewController: PhotoPickerControllerDelegate {
    
    /// Called after the selection is complete
    /// - Parameters:
    ///   - pickerController: corresponding PhotoPickerController
    ///   - result: Selected result
    ///     result.photoAssets  Selected asset array
    ///     result.isOriginal   Whether to select the original image
    func pickerController(_ pickerController: PhotoPickerController, 
                            didFinishSelection result: PickerResult) {
        result.getImage { (image, photoAsset, index) in
            if let image = image {
                print("success", image)
            }else {
                print("failed")
            }
        } completionHandler: { (images) in
            print(images)
        }
    }
    
    /// Called when cancel is clicked
    /// - Parameter pickerController: Corresponding PhotoPickerController
    func pickerController(didCancel pickerController: PhotoPickerController) {
        
    }
}

Get Content

Get UIImage

/// If it is a video, get the cover of the video
/// compressionQuality: Compress parameters, if not passed, no compression
photoAsset.getImage(compressionQuality: compressionQuality) { image in
    print(image)
}

Get URL

/// compression: Compress parameters, if not passed, no compression
photoAsset.getURL(compression: compression) { result in
    switch result {
    case .success(let urlResult): 
        
        switch urlResult.mediaType {
        case .photo:
        
        case .video:
        
        }
        
        switch urlResult.urlType {
        case .local:
        
        case .network:
        
        }
        
        print(urlResult.url)
        
        // Image and video urls contained in LivePhoto
        print(urlResult.livePhoto) 
        
    case .failure(let error):
        print(error)
    }
}

Release Notes

Version Release Date Xcode Swift iOS
v2.0.0 2023-06-14 14.3.0 5.7.0 12.0+
v1.4.6 2022-11-20 14.0.0 5.7.0 12.0+

License

HXPHPicker is released under the MIT license. See LICENSE for details.

Support

Buy Me A Coffee

or

Stargazers over time

Stargazers over time

๐Ÿ”

GitHub

link
Stars: 360
Last commit: 45 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics