Skip to content

Commit

Permalink
disbaled message styling and a new label added in textMessageCell for…
Browse files Browse the repository at this point in the history
… testing
  • Loading branch information
devfsmalik committed Apr 11, 2018
1 parent 74de44e commit cf81c11
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Example/Sources/ConversationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ extension ConversationViewController: MessagesDisplayDelegate {

func messageStyle(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageStyle {
let corner: MessageStyle.TailCorner = isFromCurrentSender(message: message) ? .bottomRight : .bottomLeft
return .bubbleTail(corner, .curved)
return .none//.bubbleTail(corner, .curved)
// let configurationClosure = { (view: MessageContainerView) in}
// return .custom(configurationClosure)
}
Expand Down
6 changes: 3 additions & 3 deletions Example/Sources/SampleData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class SampleData {
private init() {}

let messageTextValues = [
"I think if you do something and it turns out pretty good, then you should go do something else wonderful, not dwell on it for too long. Just figure out what’s next. Price is rarely the most important thing. A cheap product might sell some units. Somebody gets it home and they feel great when they pay the money, but then they get it home and use it and the joy is gone.END"
"I think if you do something and it turns out pretty good, then you should go do something else wonderful, not dwell on it for too long. Just figure out what’s next. Price is rarely the most important thing. A cheap product might sell some units. Somebody gets it home and they feel great when they pay the money, but then they get it home and use it and the joy is gone.1 2 3 4 5 6 7 8 9 0 END"
]

let dan = Sender(id: "123456", displayName: "Dan Leonard")
Expand Down Expand Up @@ -82,8 +82,8 @@ final class SampleData {

switch attributes[randomAttribute] { //here
case "Font1":
mutableAttributedString.addAttribute(NSAttributedStringKey.font, value: UIFont.preferredFont(forTextStyle: .body), range: range)
// mutableAttributedString.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "Colfax-Regular", size: 14)!, range: range)
// mutableAttributedString.addAttribute(NSAttributedStringKey.font, value: UIFont.preferredFont(forTextStyle: .body), range: range)
mutableAttributedString.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "Colfax-Regular", size: 14)!, range: range)
case "Font2":
mutableAttributedString.addAttributes([NSAttributedStringKey.font: UIFont.monospacedDigitSystemFont(ofSize: UIFont.systemFontSize, weight: UIFont.Weight.bold)], range: range)
case "Font3":
Expand Down
14 changes: 13 additions & 1 deletion Sources/Views/Cells/TextMessageCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,31 @@ open class TextMessageCell: MessageCollectionViewCell {
let attributes = displayDelegate.detectorAttributes(for: detector, and: message, at: indexPath)
messageLabel.setAttributes(attributes, detector: detector)
}
let label = UILabel(frame: CGRect(x: 0, y: 0, width: messageContainerView.frame.size.width, height: messageContainerView.frame.size.height))
label.numberOfLines = 0
switch message.data {
case .text(let text), .emoji(let text):
messageLabel.text = text
if let font = messageLabel.messageLabelFont {
messageLabel.font = font
}
case .attributedText(let text):
messageLabel.attributedText = text
// messageLabel.attributedText = text
label.attributedText = text

default:
break
}
// Needs to be set after the attributedText because it takes precedence
messageLabel.textColor = textColor


// label.sizeToFit()

print ("&&&&&&&&&&&&&&&&&&&&")
print(label.frame.height)

messageContainerView.addSubview(label)
}
}

Expand Down

0 comments on commit cf81c11

Please sign in to comment.