$ show zekunyan/TTGTagCollectionView
TTGTagCollectionView is a production-ready iOS UI library that renders collections of tags/chips in a flowing, wrap-aware layout. The two principal entry points are `TextTagCollectionView`, which displays styled text tags driven by a datasource of `TextTag` model objects, and `TagCollectionView`, a generic container for arbitrary `UIView` tags using a delegate/datasource pattern. Tags are plain in-memory model objects — there is no persistence, networking, or data pipeline. The library is Swift-first with an intentional `@objc` compatibility surface preserving the pre-3.0 Objective-C API, and it ships with CocoaPods and Swift Package Manager support plus a `TagCloudView` SwiftUI wrapper.
The LLM identified 4 files worth highlighting for reuse:
A side-effect-free flow layout calculator that computes tag frames, wrapping, line limits, and all six alignment modes without touching the view hierarchy. It is unit-tested and uses an internal layout cache. This is the strongest reusable asset in the repo: it can be extracted into any project needing deterministic chip/tag layout or precomputed content sizes (e.g., UITableView row heights) detached from UIKit rendering.
Defines the `TextTagContent` protocol with `TextTagStringContent` and `TextTagAttributedStringContent` implementations, abstracting a tag's payload so the same tag model can carry plain strings, localized strings, or attributed strings. A clean, self-contained protocol-oriented modeling pattern that generalizes to any chip/collection component needing multiple content representations.
A value-type style object encapsulating tag appearance — background color/image, gradient, border, shadow, corner radius, and size — separate from both the tag model and the rendering view. Demonstrates a reusable decoupled-styling pattern: styles can be composed, shared across tags, and swapped without touching layout or display code.
A compact `UIViewRepresentable` wrapper exposing `TextTagCollectionView` to SwiftUI as `TagCloudView`, with binding-backed configuration and delegate forwarding. A clean reference implementation of the UIKit-to-SwiftUI bridging pattern that can be copied into any project wrapping an existing UIKit component.