Skip to content

Commit cf4176e

Browse files
committed
add HighlightableItem to WrappedCells
1 parent 8e1cfc8 commit cf4176e

File tree

11 files changed

+56
-11
lines changed

11 files changed

+56
-11
lines changed

Components/Sources/Common/Views/StackView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extension StackView: ConfigurableItem {
4949
}
5050

5151
/// Only for stack. Cannot be included in common macros.
52-
public static func children(@GeneratorsBuilder<ViewGenerator>_ content: @escaping (ViewContext.Type) -> [ViewGenerator]) -> Property {
52+
public static func children(@GeneratorsBuilder<ViewGenerator>_ content: @escaping ViewContext.CellsBuilder) -> Property {
5353
.init(closure: { model in
5454
var model = model
5555
model.set(children: content(ViewContext.self))

Source/Collection/CollectionSection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public extension CollectionSection {
2323

2424
static func create(header: HeaderGeneratorType,
2525
footer: FooterGeneratorType,
26-
@GeneratorsBuilder<GeneratorType> generators: (CollectionContext.Type) -> [GeneratorType]) -> Self {
26+
@GeneratorsBuilder<GeneratorType> generators: CollectionContext.CellsBuilder) -> Self {
2727
Self(generators: generators(CollectionContext.self), header: header, footer: footer)
2828
}
2929

Source/Collection/Generators/CollectionContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
public struct CollectionContext: BuilderContext {
1212

1313
public typealias ViewType = UICollectionViewCell
14-
public typealias GeneratorType = CollectionCellGenerator
14+
public typealias CellsBuilder = (CollectionContext.Type) -> [CollectionCellGenerator]
1515

1616
public static func gen<Item>(_ type: Item.Type, model: Item.Model) -> BaseCellGenerator<CollectionWrappedCell<Item>> where Item: BaseItem {
1717
Item.rddm.collectionGenerator(with: model)

Source/Collection/Wrapper/CollectionWrappedCell.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,25 @@ extension CollectionWrappedCell: CalculatableWidthItem where View: CalculatableW
5757
}
5858

5959
}
60+
61+
// MARK: - HighlightableItem
62+
63+
extension CollectionWrappedCell: HighlightableItem where View: HighlightableItem {
64+
65+
public func applyUnhighlightedStyle() {
66+
nestedView.applyUnhighlightedStyle()
67+
}
68+
69+
public func applyHighlightedStyle() {
70+
nestedView.applyHighlightedStyle()
71+
}
72+
73+
public func applySelectedStyle() {
74+
nestedView.applySelectedStyle()
75+
}
76+
77+
public func applyDeselectedStyle() {
78+
nestedView.applyDeselectedStyle()
79+
}
80+
81+
}

Source/Common/Generators/BaseCellGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public extension BaseCellGenerator where Cell: FoldableStateHolder, Cell: UITabl
146146

147147
/// Creates FoldableCellGenerator with children generated by resultBuilder
148148
/// - Parameter content: resultBuilder based closure that returns array of children
149-
func asFoldable(@GeneratorsBuilder<TableCellGenerator>_ content: @escaping (TableContext.Type) -> [TableCellGenerator]) -> FoldableCellGenerator<Cell> {
149+
func asFoldable(@GeneratorsBuilder<TableCellGenerator>_ content: @escaping TableContext.CellsBuilder) -> FoldableCellGenerator<Cell> {
150150
return .init(with: model,
151151
registerType: registerType)
152152
.children(content)

Source/Common/Generators/FoldableCellGenerator.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public extension FoldableCellGenerator {
9393
self.isExpanded = isExpanded
9494
return self
9595
}
96-
96+
9797
/// - Parameter closure: handler closure for folded/unfolded events
9898
func didFoldEvent(_ closure: @escaping (Bool) -> Void) -> Self {
9999
self.didFoldEvent.addListner(closure)
@@ -117,7 +117,7 @@ public extension FoldableCellGenerator where Cell: UITableViewCell {
117117
}
118118

119119
/// - Parameter content: resultBuilder based closure that returns an array of child generators
120-
func children(@GeneratorsBuilder<TableCellGenerator>_ content: @escaping (TableContext.Type) -> [TableCellGenerator]) -> Self {
120+
func children(@GeneratorsBuilder<TableCellGenerator>_ content: @escaping TableContext.CellsBuilder) -> Self {
121121
self.children = content(TableContext.self)
122122
return self
123123
}
@@ -133,7 +133,7 @@ public extension FoldableCellGenerator where Cell: UICollectionViewCell {
133133
}
134134

135135
/// - Parameter content: resultBuilder based closure that returns an array of child generators
136-
func children(@GeneratorsBuilder<CollectionCellGenerator>_ content: @escaping (CollectionContext.Type) -> [CollectionCellGenerator]) -> Self {
136+
func children(@GeneratorsBuilder<CollectionCellGenerator>_ content: @escaping CollectionContext.CellsBuilder) -> Self {
137137
self.children = content(CollectionContext.self)
138138
return self
139139
}

Source/Stack/Generators/ViewContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
public struct ViewContext: BuilderContext {
1212

1313
public typealias ViewType = UIView
14-
public typealias GeneratorType = ViewGenerator
14+
public typealias CellsBuilder = (ViewContext.Type) -> [ViewGenerator]
1515

1616
public static func gen<Item>(_ type: Item.Type, model: Item.Model) -> BaseViewGenerator<Item> where Item: BaseItem {
1717
Item.rddm.viewGenerator(with: model, and: Item.prefferedRegistration)

Source/Table/Generators/BaseNonReusableCellGenerator.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import UIKit
1313
/// Term *non-reusable* means that we are creating cell manually with constructor type defined in **ConstractableItem**.
1414
/// In other words this generator will not use `tableView.deqeueReusableCell`.
1515
/// - Warning: Do not use this generators in tables with many cells of same type. Because you may catch perfomance issues.
16-
open class BaseNonReusableCellGenerator<Cell: ConfigurableItem & ConstractableItem>: TableCellGenerator & SelectableItem where Cell: UITableViewCell {
16+
open class BaseNonReusableCellGenerator<Cell: ConfigurableItem & ConstractableItem>: TableCellGenerator & SelectableItem
17+
where Cell: UITableViewCell {
1718

1819
// MARK: - Public Properties
1920

Source/Table/Generators/TableContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
public struct TableContext: BuilderContext {
1212

1313
public typealias ViewType = UITableViewCell
14-
public typealias GeneratorType = TableCellGenerator
14+
public typealias CellsBuilder = (TableContext.Type) -> [TableCellGenerator]
1515

1616
public static func gen<Item>(_ type: Item.Type, model: Item.Model) -> BaseCellGenerator<TableWrappedCell<Item>> where Item: BaseItem {
1717
Item.rddm.tableGenerator(with: model)

Source/Table/TableSection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public extension TableSection {
2323

2424
static func create(header: HeaderGeneratorType,
2525
footer: FooterGeneratorType,
26-
@GeneratorsBuilder<GeneratorType> generators: (TableContext.Type) -> [GeneratorType]) -> Self {
26+
@GeneratorsBuilder<GeneratorType> generators: TableContext.CellsBuilder) -> Self {
2727
Self(generators: generators(TableContext.self), header: header, footer: footer)
2828
}
2929

0 commit comments

Comments
 (0)