Skip to content

Commit

Permalink
Update Example & reuse identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
SD10 committed Sep 15, 2017
1 parent 468f07b commit 100b8d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Example/Sources/ConversationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,19 @@ extension ConversationViewController: MessagesLayoutDelegate {

extension ConversationViewController: MessageCellDelegate {

func didTapAvatar(in cell: MessageCollectionViewCell) {
func didTapAvatar<T: UIView>(in cell: MessageCollectionViewCell<T>) {
print("Avatar tapped")
}

func didTapMessage(in cell: MessageCollectionViewCell) {
func didTapMessage<T: UIView>(in cell: MessageCollectionViewCell<T>) {
print("Message tapped")
}

func didTapTopLabel(in cell: MessageCollectionViewCell) {
func didTapTopLabel<T: UIView>(in cell: MessageCollectionViewCell<T>) {
print("Top label tapped")
}

func didTapBottomLabel(in cell: MessageCollectionViewCell) {
func didTapBottomLabel<T: UIView>(in cell: MessageCollectionViewCell<T>) {
print("Bottom label tapped")
}

Expand Down
8 changes: 0 additions & 8 deletions Sources/MessageCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@ open class MessageCollectionViewCell<ContentView: UIView>: UICollectionViewCell
cellBottomLabel.attributedText = nil
}

func setAvatar(_ avatar: Avatar) {

}

func setCellLabels(bottomText: NSAttributedString, topText: NSAttributedString) {

}

public func configure(with message: MessageType) {
// Provide in subclass
}
Expand Down
13 changes: 8 additions & 5 deletions Sources/MessagesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ open class MessagesViewController: UIViewController {
}

private func registerReusableViews() {
messagesCollectionView.register(MessageCollectionViewCell.self,
forCellWithReuseIdentifier: "MessageCell")
messagesCollectionView.register(TextMessageCell.self,
forCellWithReuseIdentifier: "TextMessageCell")

messagesCollectionView.register(MessageFooterView.self,
forSupplementaryViewOfKind: UICollectionElementKindSectionFooter,
Expand Down Expand Up @@ -202,9 +202,9 @@ extension MessagesViewController: UICollectionViewDataSource {

let messageColor = displayDelegate.backgroundColor(for: message, at: indexPath, in: messagesCollectionView)
let messageStyle = displayDelegate.messageStyle(for: message, at: indexPath, in: messagesCollectionView)
//let textColor = displayDelegate.textColor(for: message, at: indexPath, in: messagesCollectionView)

//cell.messageLabel.textColor = textColor


cell.messageContainerView.messageColor = messageColor
cell.messageContainerView.style = messageStyle

Expand All @@ -218,7 +218,10 @@ extension MessagesViewController: UICollectionViewDataSource {

switch message.data {
case .text, .attributedText:
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MessageCell", for: indexPath) as? TextMessageCell else { return UICollectionViewCell() }
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TextMessageCell", for: indexPath) as? TextMessageCell else { return UICollectionViewCell() }
let textColor = messagesCollectionView.messagesDisplayDelegate?.textColor(for: message, at: indexPath, in: messagesCollectionView)
cell.messageContentView.textColor = textColor
cell.configure(with: message)
configure(cell)
return cell
}
Expand Down

0 comments on commit 100b8d1

Please sign in to comment.