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 1.4.3
Photo/Video Selector-Supports LivePhoto, GIF selection, online download of resources on iCloud, and editing of photos/videos
⭐️ 258
πŸ•“ 1 week ago
iOS
.package(url: "https://github.com/SilenceLove/HXPHPicker.git", from: "1.4.3")

HXPHPicker is a 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
    • β˜‘ English (en)
    • β˜‘ Chinese, Simplified (zh-Hans)
    • β˜‘ Chinese, traditional (zh-Hant)
    • β˜‘ Japanese (ja)
    • β˜‘ Korean (ko)
    • β˜‘ Thai (th)
    • β˜‘ Indonesian (id)
    • β˜‘ Vietnamese (vi)
    • β˜‘ 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: "1.4.3"))
]

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`

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 = PhotoTools.getWXPickerConfig()
        
        // 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) {
        
    }
}

Release Notes

Version Release Date Xcode Swift iOS
v1.4.3 2022-09-15 14.0.0 5.7.0 12.0+
v1.4.2 2022-09-13 13.1.0 5.4.2 12.0+
v1.4.1 2022-05-24 13.1.0 5.4.2 12.0+
v1.4.0 2022-04-13 13.1.0 5.4.2 12.0+
v1.3.9 2022-03-24 13.1.0 5.4.2 12.0+
v1.3.7 2022-02-19 13.1.0 5.4.2 12.0+
v1.3.5 2022-02-09 13.1.0 5.4.2 12.0+
v1.3.4 2022-01-26 13.1.0 5.4.2 12.0+
v1.3.3 2022-01-19 13.1.0 5.4.2 12.0+
v1.3.2 2022-01-14 13.1.0 5.4.2 12.0+
v1.3.1 2022-01-05 13.1.0 5.4.2 12.0+
v1.3.0 2021-12-16 13.1.0 5.4.2 12.0+
v1.2.9 2021-12-02 13.1.0 5.4.2 12.0+
v1.2.8 2021-11-26 12.5.1 5.4.2 12.0+

License

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

πŸ”

GitHub

link
Stars: 258
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

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