$ show tilltue/TLPhotoPicker
TLPhotoPicker is an iOS library providing a customizable photo and video picker UI similar to Facebook's picker. It wraps the Photos framework (PHAsset, PHAssetCollection) and offers a configurable grid view with support for smart albums, live photos, video playback, iCloud download, and camera capture. The architecture follows a service-oriented pattern with separate classes for photo library access, selection logic, camera handling, and video playback, all coordinated by a central view controller. The library includes a builder pattern for configuration, async/await support for image loading, and comprehensive delegate callbacks. It is distributed via CocoaPods and Swift Package Manager, targeting iOS 13.0+. The codebase is well-structured but shows some technical drift, notably continued use of the deprecated UIImagePickerController for camera capture instead of the modern PHPickerViewController.
The LLM identified 4 files worth highlighting for reuse:
A generic thread-safe dictionary implementation using a concurrent dispatch queue with barrier writes. It provides subscript access, removeAll, removeValue, and forEach methods. This is a clean, reusable utility that can be extracted into any Swift project requiring synchronized access to a dictionary without external dependencies.
A configuration struct with a fluent builder pattern, allowing chained method calls like .numberOfColumns(3).maxSelection(20). It also provides preset configurations (singlePhoto, videoOnly, compactGrid) and supports extending presets. This pattern is reusable for any iOS library that needs a flexible, readable configuration API.
The TLPHAsset struct wraps PHAsset with convenience methods for async image loading (fullResolutionImage() async), iCloud download with progress, file export (tempCopyMediaFile), and file size retrieval. It demonstrates a clean abstraction over Photos framework APIs with modern Swift concurrency. The pattern of wrapping system framework types with domain-specific methods is reusable.
A standalone view controller for previewing photos, live photos, and videos. It handles asset type detection, image fetching, live photo playback, and video playback with AVPlayer. The layout adapts to orientation changes. This component is self-contained and can be extracted for use in other iOS apps needing a media preview screen.