Skip to content

Commit

Permalink
Fix not working cellAction in CollectionViewBase.
Browse files Browse the repository at this point in the history
  • Loading branch information
matoushybl committed Nov 9, 2017
1 parent ed77404 commit 663a365
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Source/CollectionView/CollectionViewBase.swift
Expand Up @@ -138,6 +138,7 @@ open class CollectionViewBase<MODEL, ACTION>: ViewBase<CollectionViewState<MODEL

open func configure<T: Component>(cell: CollectionViewCellWrapper<T>, factory: @escaping () -> T, model: T.StateType,
mapAction: @escaping (T.ActionType) -> ACTION) -> Void {
cell.configureDisposeBag = DisposeBag()
if configurationChangeTime != cell.configurationChangeTime {
cell.configuration = configuration
cell.configurationChangeTime = configurationChangeTime
Expand All @@ -146,7 +147,7 @@ open class CollectionViewBase<MODEL, ACTION>: ViewBase<CollectionViewState<MODEL
component.componentState = model
component.action.map(mapAction)
.subscribe(onNext: perform)
.disposed(by: stateDisposeBag)
.disposed(by: cell.configureDisposeBag)
}

open func dequeueAndConfigure<T: Component>(identifier: CollectionViewCellIdentifier<T>, forRow row: Int, factory: @escaping () -> T,
Expand All @@ -158,6 +159,7 @@ open class CollectionViewBase<MODEL, ACTION>: ViewBase<CollectionViewState<MODEL

open func configure<T: Component>(view: CollectionReusableViewWrapper<T>, factory: @escaping () -> T, model: T.StateType,
mapAction: @escaping (T.ActionType) -> ACTION) -> Void {
view.configureDisposeBag = DisposeBag()
if configurationChangeTime != view.configurationChangeTime {
view.configuration = configuration
view.configurationChangeTime = configurationChangeTime
Expand All @@ -166,7 +168,7 @@ open class CollectionViewBase<MODEL, ACTION>: ViewBase<CollectionViewState<MODEL
component.componentState = model
component.action.map(mapAction)
.subscribe(onNext: perform)
.disposed(by: stateDisposeBag)
.disposed(by: view.configureDisposeBag)
}

open func dequeueAndConfigure<T: Component>(identifier: CollectionSupplementaryViewIdentifier<T>, forRow row: Int, factory: @escaping () -> T,
Expand Down
Expand Up @@ -7,6 +7,7 @@
//

import UIKit
import RxSwift

public final class CollectionReusableViewWrapper<VIEW: UIView>: UICollectionReusableView, Configurable {

Expand All @@ -20,6 +21,8 @@ public final class CollectionReusableViewWrapper<VIEW: UIView>: UICollectionReus
configuration.get(valueFor: Properties.Style.CollectionView.reusableViewWrapper)(self)
}
}

public var configureDisposeBag = DisposeBag()

public override class var requiresConstraintBasedLayout: Bool {
return true
Expand Down
Expand Up @@ -7,6 +7,7 @@
//

import UIKit
import RxSwift

public final class CollectionViewCellWrapper<CELL: UIView>: UICollectionViewCell, Configurable {

Expand Down Expand Up @@ -42,6 +43,8 @@ public final class CollectionViewCellWrapper<CELL: UIView>: UICollectionViewCell
collectionViewCell?.setSelected(isSelected)
}
}

public var configureDisposeBag = DisposeBag()

public override var isHighlighted: Bool {
didSet {
Expand Down
3 changes: 3 additions & 0 deletions Source/TableView/Internal/TableViewCellWrapper.swift
Expand Up @@ -7,6 +7,7 @@
//

import UIKit
import RxSwift

public final class TableViewCellWrapper<CELL: UIView>: UITableViewCell, Configurable {

Expand All @@ -20,6 +21,8 @@ public final class TableViewCellWrapper<CELL: UIView>: UITableViewCell, Configur
configuration.get(valueFor: Properties.Style.TableView.cellWrapper)(self)
}
}

public var configureDisposeBag = DisposeBag()

public override class var requiresConstraintBasedLayout: Bool {
return true
Expand Down
3 changes: 3 additions & 0 deletions Source/TableView/Internal/TableViewHeaderFooterWrapper.swift
Expand Up @@ -7,6 +7,7 @@
//

import UIKit
import RxSwift

public final class TableViewHeaderFooterWrapper<VIEW: UIView>: UITableViewHeaderFooterView, Configurable {

Expand All @@ -20,6 +21,8 @@ public final class TableViewHeaderFooterWrapper<VIEW: UIView>: UITableViewHeader
configuration.get(valueFor: Properties.Style.TableView.headerFooterWrapper)(self)
}
}

public var configureDisposeBag = DisposeBag()

public override class var requiresConstraintBasedLayout: Bool {
return true
Expand Down
6 changes: 4 additions & 2 deletions Source/TableView/TableViewBase.swift
Expand Up @@ -150,6 +150,7 @@ open class TableViewBase<MODEL, ACTION>: ViewBase<TableViewState<MODEL>, ACTION>

open func configure<T: Component>(cell: TableViewCellWrapper<T>, factory: @escaping () -> T, model: T.StateType,
mapAction: @escaping (T.ActionType) -> ACTION) -> Void {
cell.configureDisposeBag = DisposeBag()
if configurationChangeTime != cell.configurationChangeTime {
cell.configuration = configuration
cell.configurationChangeTime = configurationChangeTime
Expand All @@ -159,7 +160,7 @@ open class TableViewBase<MODEL, ACTION>: ViewBase<TableViewState<MODEL>, ACTION>
(component as? Configurable)?.configuration = configuration
component.action.map(mapAction)
.subscribe(onNext: perform)
.disposed(by: component.stateDisposeBag)
.disposed(by: cell.configureDisposeBag)
}

open func dequeueAndConfigure<T: Component>(identifier: TableViewCellIdentifier<T>, factory: @escaping () -> T,
Expand All @@ -171,6 +172,7 @@ open class TableViewBase<MODEL, ACTION>: ViewBase<TableViewState<MODEL>, ACTION>

open func configure<T: Component>(view: TableViewHeaderFooterWrapper<T>, factory: @escaping () -> T, model: T.StateType,
mapAction: @escaping (T.ActionType) -> ACTION) -> Void {
view.configureDisposeBag = DisposeBag()
if configurationChangeTime != view.configurationChangeTime {
view.configuration = configuration
view.configurationChangeTime = configurationChangeTime
Expand All @@ -180,7 +182,7 @@ open class TableViewBase<MODEL, ACTION>: ViewBase<TableViewState<MODEL>, ACTION>
(component as? Configurable)?.configuration = configuration
component.action.map(mapAction)
.subscribe(onNext: perform)
.disposed(by: component.stateDisposeBag)
.disposed(by: view.configureDisposeBag)
}

open func dequeueAndConfigure<T: Component>(identifier: TableViewHeaderFooterIdentifier<T>, factory: @escaping () -> T,
Expand Down

0 comments on commit 663a365

Please sign in to comment.