Skip to content

Commit

Permalink
Merge pull request #62 from AntonPalich/Presenters_can_responds_on_ce…
Browse files Browse the repository at this point in the history
…ll_events_directly

Presenters can responds on cell events directly and implement additional behaviour in addition to interaction handlers
  • Loading branch information
diegosanchezr committed Mar 14, 2016
2 parents 73e751d + 1ef01a7 commit 65d15bb
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,21 @@ public class BaseMessagePresenter<BubbleViewT, ViewModelBuilderT, InteractionHan
cell.messageViewModel = self.messageViewModel
cell.onBubbleTapped = { [weak self] (cell) in
guard let sSelf = self else { return }
sSelf.interactionHandler?.userDidTapOnBubble(viewModel: sSelf.messageViewModel)
sSelf.onCellBubbleTapped()
}
cell.onBubbleLongPressed = { [weak self] (cell) in
guard let sSelf = self else { return }
sSelf.interactionHandler?.userDidLongPressOnBubble(viewModel: sSelf.messageViewModel)
sSelf.onCellBubbleLongPressed()
}
cell.onFailedButtonTapped = { [weak self] (cell) in
guard let sSelf = self else { return }
sSelf.interactionHandler?.userDidTapOnFailIcon(viewModel: sSelf.messageViewModel)
sSelf.onCellFailedButtonTapped()
}
additionalConfiguration?()
}, animated: animated, completion: nil)
}

public override func heightForCell(maximumWidth width: CGFloat, decorationAttributes: ChatItemDecorationAttributesProtocol?) -> CGFloat {
public override func heightForCell(maximumWidth width: CGFloat, decorationAttributes: ChatItemDecorationAttributesProtocol?) -> CGFloat {
guard let decorationAttributes = decorationAttributes as? ChatItemDecorationAttributes else {
assert(false, "Expecting decoration attributes")
return 0
Expand Down Expand Up @@ -155,4 +155,16 @@ public class BaseMessagePresenter<BubbleViewT, ViewModelBuilderT, InteractionHan
// Override in subclass
return false
}

public func onCellBubbleTapped() {
self.interactionHandler?.userDidTapOnBubble(viewModel: self.messageViewModel)
}

public func onCellBubbleLongPressed() {
self.interactionHandler?.userDidLongPressOnBubble(viewModel: self.messageViewModel)
}

public func onCellFailedButtonTapped() {
self.interactionHandler?.userDidTapOnFailIcon(viewModel: self.messageViewModel)
}
}

0 comments on commit 65d15bb

Please sign in to comment.