ra1028 / Carbon

🚴 A declarative library for building component-based user interfaces in UITableView and UICollectionView.

Home Page:https://ra1028.github.io/Carbon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Idea] Make `referenceSize(in bounds:)` returns nil by default

ra1028 opened this issue · comments

Checklist

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 is UITableViewAutomaticDimenstion.
  • 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 👎