Element
-
A component represents a small reusable piece of code of element to be rendered. This behaves as all elements of UIKit’s UITableView and UICollectionView, and can be easily support SwiftUI by used in conjunction with the
View
protocol.Example for the simple component:
struct Label: Component { var text: String init(_ text: String) { self.text = text } func renderContent() -> UILabel { return UILabel() } func render(in content: UILabel) { content.text = text } }
Example for use with SwiftUI:
See moreextension Label: View {} struct ContentView: View { var body: some View { VStack { Text("This is SwiftUI view") Label("This is Carbon component") } } }
Declaration
Swift
public protocol Component
-
Represents a component that can be uniquely identify.
Example for the simple identified component:
See morestruct UserLabel: IdentifiableComponent { var id: Int64 var name: String func renderContent() -> UILabel { return UILabel() } func render(in content: UILabel) { content.text = name } }
Declaration
Swift
public protocol IdentifiableComponent : CellsBuildable, Component
-
Represents a section of list UI, containing header node, footer node and collection of cell nodes. This works as an intermediary for
DifferenceKit
.Example for simple section.
See moreSection( id: 0, header: Label("Header"), footer: Label("Footer"), cells: { Label("Cell 0") .identified(by: \.text) Label("Cell 1") .identified(by: \.text) Label("Cell 2") .identified(by: \.text) } )
Declaration
Swift
public struct Section