File tree Expand file tree Collapse file tree 6 files changed +27
-12
lines changed Expand file tree Collapse file tree 6 files changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,13 @@ import UIKit
99import ReactiveDataDisplayManager
1010
1111/// Empty collection cell with `View`. Configuration is implemented within `ViewWrapper`.
12- public final class CollectionWrappedCell < View: ConfigurableItem > : UICollectionViewCell , ViewWrapper {
12+ public final class CollectionWrappedCell < View: ConfigurableItem & RegistrationTypeProvider > : UICollectionViewCell , ViewWrapper {
1313
1414 public typealias Model = View . Model
1515
1616 // MARK: - Properties
1717
18- // TODO: - Add way to construct nested view from nib (like in BaseViewGenerator)
19- public let nestedView : View = . init( frame: . zero)
18+ public let nestedView : View = EmptyViewGenerator ( ) . generate ( )
2019
2120 public var cachedInsets : UIEdgeInsets ?
2221
Original file line number Diff line number Diff line change 88import ReactiveDataDisplayManager
99import UIKit
1010
11- public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem {
11+ public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem & RegistrationTypeProvider {
1212
1313 func collectionGenerator( with model: Base . Model ,
1414 and registerType: RegistrationType = . nib) -> BaseCollectionCellGenerator < CollectionWrappedCell < Base > > {
@@ -20,7 +20,7 @@ public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem
2020
2121// MARK: - CalculatableHeightItem
2222
23- public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem & CalculatableHeightItem {
23+ public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem & CalculatableHeightItem & RegistrationTypeProvider {
2424
2525 func tableCalculatableHightGenerator(
2626 with model: Base . Model ,
@@ -37,7 +37,7 @@ public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem
3737
3838// MARK: - CalculatableWidthItem
3939
40- public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem & CalculatableWidthItem {
40+ public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem & CalculatableWidthItem & RegistrationTypeProvider {
4141
4242 func tableCalculatableWidthGenerator(
4343 with model: Base . Model ,
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import UIKit
99import ReactiveDataDisplayManager
1010
1111public extension ConfigurableItem where Self: RegistrationTypeProvider {
12-
12+
1313 static func build< Context: BuilderContext > ( in ctx: Context . Type , with model: Model ) -> Context . GeneratorType {
1414 ctx. gen ( Self . self, model: model)
1515 }
Original file line number Diff line number Diff line change 88import ReactiveDataDisplayManager
99import UIKit
1010
11- public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem {
11+ public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem & RegistrationTypeProvider {
1212
1313 func tableGenerator( with model: Base . Model ,
1414 and registerType: RegistrationType = . nib) -> BaseCellGenerator < TableWrappedCell < Base > > {
@@ -20,7 +20,7 @@ public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem
2020
2121// MARK: - CalculatableHeightItem
2222
23- public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem & CalculatableHeightItem {
23+ public extension StaticDataDisplayWrapper where Base: UIView & ConfigurableItem & CalculatableHeightItem & RegistrationTypeProvider {
2424
2525 func tableCalculatableHightGenerator(
2626 with model: Base . Model ,
Original file line number Diff line number Diff line change @@ -9,14 +9,13 @@ import UIKit
99import ReactiveDataDisplayManager
1010
1111/// Empty table cell with `View`. Configuration is implemented within `ViewWrapper`.
12- public final class TableWrappedCell < View: ConfigurableItem > : UITableViewCell , ViewWrapper {
12+ public final class TableWrappedCell < View: ConfigurableItem & RegistrationTypeProvider > : UITableViewCell , ViewWrapper {
1313
1414 public typealias Model = View . Model
1515
1616 // MARK: - Properties
1717
18- // TODO: - Add way to construct nested view from nib (like in BaseViewGenerator)
19- public let nestedView : View = . init( frame: . zero)
18+ public let nestedView : View = EmptyViewGenerator ( ) . generate ( )
2019
2120 public var cachedInsets : UIEdgeInsets ?
2221
Original file line number Diff line number Diff line change 77
88import UIKit
99
10+ final public class EmptyViewGenerator < View: ConfigurableItem & RegistrationTypeProvider > : AccessoryViewGenerator {
11+
12+ public typealias ViewType = View
13+
14+ public init ( ) { }
15+
16+ public func generate( ) -> View {
17+ switch View . prefferedRegistration {
18+ case . nib:
19+ return View . loadFromNib ( bundle: ViewType . bundle ( ) ?? . main)
20+ case . class:
21+ return View ( )
22+ }
23+ }
24+
25+ }
26+
1027open class BaseViewGenerator < View: ConfigurableItem > : ViewGenerator , ViewBuilder {
1128
1229 public let model : View . Model
You can’t perform that action at this time.
0 commit comments