$ show longitachi/ZLPhotoBrowser
ZLPhotoBrowser is a mature, feature-rich iOS library for selecting, previewing, and editing photos and videos, inspired by the WeChat photo picker. It provides a full-screen image/video preview with pinch-to-zoom, a custom camera with photo and video recording, and an extensive image editor supporting drawing, mosaic, text/image stickers, filters, brightness/contrast/saturation adjustments, and clipping with various aspect ratios. The library also handles GIFs, Live Photos, and video trimming/merging. It is built entirely in Swift and targets iOS 10+. The architecture is UIKit-based, centered around a navigation controller flow (`ZLImageNavController`) that manages album list (`ZLAlbumListController`), thumbnail grid (`ZLThumbnailViewController`), and preview (`ZLPhotoPreviewController`). Configuration is handled via singleton classes (`ZLPhotoConfiguration`, `ZLPhotoUIConfiguration`, `ZLEditImageConfiguration`) with a builder-pattern chaining API. The library uses `PHPhotoLibrary` for asset fetching, `AVFoundation` for camera and video processing, and `Core Image` for filters. It includes custom interactive transitions for dismiss and pop animations, and a gesture coordinator for sticker manipulation. Key entry points are `ZLPhotoPicker` (SwiftUI wrapper) and `ZLPhotoPreviewSheet` (UIKit) for presenting the picker. The library has no external dependencies for its core functionality; the example app bundles Kingfisher and SnapKit for demonstration purposes. It supports CocoaPods, Carthage, and Swift Package Manager, and includes localization for 17 languages. The codebase is well-structured with clear separation of concerns, though some view controllers are large and there is minor duplication in transition logic.
The LLM identified 4 files worth highlighting for reuse:
Manages simultaneous pan, pinch, rotation, and tap gestures on sticker views. It tracks the anchor point for multi-finger operations and dispatches events to the correct sticker, enabling precise manipulation even on very small stickers. The pattern is reusable for any interactive overlay system requiring coordinated gesture handling.
Base class for text and image stickers that draws a vector-based border using CAShapeLayer. It re-rasterizes the border at the current view scale to avoid aliasing, a non-obvious technique for maintaining crisp edges during zoom. The class also handles selection state and gesture delegation, making it a solid foundation for custom sticker implementations.
Renders text with background, stroke, and shadow effects using a UITextView and CAShapeLayer for the background. It supports dynamic font sizing and alignment, and uses a private API (_UITextContainerView) for stroke view placement. This component demonstrates advanced Core Animation and text rendering techniques that could be extracted for custom text overlay needs.
A lightweight weak proxy object that forwards messages to a target, commonly used to break retain cycles in timers and delegates. It is implemented as a pure Swift class (with an Objective-C counterpart for compatibility) and is a textbook example of the proxy pattern for safe callback management.