Recommended UIContentConfiguration / UIContentView pattern for table and collection cells
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- ドキュメント
- 明瞭さ
- 説明が足りない
- 活発さ
- 静か
- 技術スタック
- swift
- 領域
- mobile-dev
調査の方向性
Sources/QuickLayout/QuickLayoutBridge/ViewImplementation/HasBody.swift の、リンクされている UITableViewCell と UICollectionViewCell の特殊ケースから始め、その後、この issue にある UIContentConfiguration と CardContentView の例を確認してください。サポートされる ownership、sizing、invalidation の動作、supports(_:) の再利用に関するガイダンス、およびテーブルとコレクションの違いがあれば、それらを両方のセル型の例とともに文書化してください。
索引モデルが issue の本文から書いたものです。
説明
Question
Related to #12, but this question is about UIKit’s configuration-based cell architecture rather than applying @QuickLayout directly to each cell subclass.
QuickLayout currently special-cases UITableViewCell and UICollectionViewCell so that a cell’s QuickLayout body is hosted in cell.contentView. With UIContentConfiguration, UIKit creates and manages a custom UIContentView. I could not find an example of this pattern and am unsure which object should own QuickLayout layout and sizing.
When a generic UITableViewCell or UICollectionViewCell receives a custom UIContentView, is applying @QuickLayout to that content view the supported approach?
Minimal example
struct CardConfiguration: UIContentConfiguration {
let title: String
@MainActor
func makeContentView() -> any UIView & UIContentView {
CardContentView(configuration: self)
}
func updated(for state: any UIConfigurationState) -> Self {
self
}
}
@QuickLayout
final class CardContentView: UIView, UIContentView {
private let titleLabel = UILabel()
private var model: CardConfiguration
var configuration: any UIContentConfiguration {
get { model }
set {
guard let configuration = newValue as? CardConfiguration else { return }
model = configuration
titleLabel.text = configuration.title
setNeedsLayout()
}
}
init(configuration: CardConfiguration) {
model = configuration
super.init(frame: .zero)
self.configuration = configuration
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError()
}
var body: Layout {
HStack {
titleLabel
}
.padding(.horizontal, 16)
.padding(.vertical, 8)
}
}
// The same configuration is assigned to either cell type:
cell.contentConfiguration = CardConfiguration(title: title)
Could you clarify:
- Should
@QuickLayoutlive only on the customUIContentView, leaving the cell generic, or should the cell also adopt@QuickLayout? - For self-sizing table rows and collection items with estimated dimensions, is the generated
sizeThatFits(_:)on the content view sufficient, or is cell-level sizing customization still required as discussed in #12? - When applying a configuration that changes the content size, is
setNeedsLayout()sufficient? ShouldinvalidateIntrinsicContentSize(), a cell-level invalidation call, or a QuickLayout-specific helper be used? - On iOS 16+, should
supports(_:)be implemented so UIKit can reuse the existing content view? - Are there any differences in the recommended pattern for
UITableViewCellandUICollectionViewCell?
An official example covering both cell types would be very helpful. Thanks!
Environment
- QuickLayout:
mainat38020f2 - Swift 6
- iOS 15+
- 主要言語
- Swift
- スター
- 365
- フォーク
- 21
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
facebook/QuickLayout のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
facebook/QuickLayout#21 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
facebook/QuickLayout#6 · コメント 6 件 ·
-
How to run the Test? オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
facebook/QuickLayout#2 · コメント 3 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
facebook/QuickLayout#1 · コメント 1 件 ·
facebook/QuickLayout の issue をすべて見る
似ている issue
-
pending-maintainer-response pending-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
area:build bug good first issue P2
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
uttrflow/uttrflow-swift#1412 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
-
T-Defect
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
element-hq/element-x-ios#6191 ·