From d87fe40c90e3e321e13c8a533f45a1fb3786b81e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20S=C3=A1nchez?= Date: Wed, 1 Jun 2016 13:43:37 +0100 Subject: [PATCH] Some optimizations for TextBubbleView (#144) --- .../TextMessages/Views/TextBubbleView.swift | 20 +++++++++++++++++++ ...essageCollectionViewCellDefaultStyle.swift | 6 +++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextBubbleView.swift b/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextBubbleView.swift index 4579959..d240740 100644 --- a/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextBubbleView.swift +++ b/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextBubbleView.swift @@ -287,4 +287,24 @@ private final class ChatMessageTextView: UITextView { override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool { return false } + + override var selectedRange: NSRange { + get { + return NSRange(location: 0, length: 0) + } + set { + // Part of the heaviest stack trace when scrolling (when updating text) + // See https://github.com/badoo/Chatto/pull/144 + } + } + + override var contentOffset: CGPoint { + get { + return .zero + } + set { + // Part of the heaviest stack trace when scrolling (when bounds are set) + // See https://github.com/badoo/Chatto/pull/144 + } + } } diff --git a/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextMessageCollectionViewCellDefaultStyle.swift b/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextMessageCollectionViewCellDefaultStyle.swift index d89705d..771c84d 100644 --- a/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextMessageCollectionViewCellDefaultStyle.swift +++ b/ChattoAdditions/Source/Chat Items/TextMessages/Views/TextMessageCollectionViewCellDefaultStyle.swift @@ -146,17 +146,17 @@ public class TextMessageCollectionViewCellDefaultStyle: TextMessageCollectionVie let tailKey = showsTail ? "tail" : "notail" let statusKey = self.statusKey(status) let highlightedKey = isSelected ? "highlighted" : "normal" - let key = "\(directionKey)_\(tailKey)_\(statusKey)_\(highlightedKey)" + let key = directionKey + "_" + tailKey + "_" + statusKey + "_" + highlightedKey return key } private func templateKey(isIncoming isIncoming: Bool, showsTail: Bool) -> String { let directionKey = isIncoming ? "incoming" : "outgoing" let tailKey = showsTail ? "tail" : "notail" - return "\(directionKey)_\(tailKey)" + return directionKey + "_" + tailKey } - private func statusKey(status: MessageViewModelStatus) -> NSString { + private func statusKey(status: MessageViewModelStatus) -> String { switch status { case .Success: return "ok"