[Idea] Make `referenceSize(in bounds:)` returns nil by default
ra1028 opened this issue · 0 comments
ra1028 commented
Checklist
- Reviewed the README and documents.
- Searched existing issues for ensure not duplicated.
Description
Make referenceSize(in bounds:)
returns nil by default in Component
.
The table view and collection view are use their own size setting by default.
e.g.
- UITableView uses
UITableView.rowHeight
, default isUITableViewAutomaticDimenstion
. - UICollectionView(flow layout) uses
UICollectionViewFlowLayout.itemSize
, default is CGSize(width: 50, height: 50).
struct Label: Component, Equitable {
var text: String
func renderContent() -> UILabel {
return UILabel()
}
func render(in content: UILabel) {
content.text = text
}
- // Default is nil, it fallback to `UITableView.rowHeight`.
- func referenceSize(in bounds: CGRect) -> CGSize? {
- return CGSize(width: bounds.width, height: 44)
- }
}
Motivation and Context
Wants to simplify the creation of Component like as List in SwiftUI.
Proposed Solution
Make Component.referenceSize
returns nil by default.
Discussion
Agree 👍 or Disagree 👎