[DetectorType] add .mention, .hashtag and .custon() to detect your own pattern

[DetectorType] Put mention and hashtag as var

[CHANGELOG] Update

[DetectorType] Update to have at least 4 characters and more

[CHANGELOG] Update

[DetectorType]

[MessageLabel] run NSDataDetector once

[MessageLabel] Run NSDataDetector once

[Testing] Add testing and pass rangesOfDetectors as internal

[Refactoring]

[Filter] only .custom

[Examples]
This commit is contained in:
Julien K
2018-10-16 16:26:57 +02:00
parent 095abe0223
commit 77e9ccda46
8 changed files with 284 additions and 20 deletions
@@ -49,11 +49,14 @@ extension BasicExampleViewController: MessagesDisplayDelegate {
}
func detectorAttributes(for detector: DetectorType, and message: MessageType, at indexPath: IndexPath) -> [NSAttributedString.Key: Any] {
return MessageLabel.defaultAttributes
switch detector {
case .hashtag, .mention: return [.foregroundColor: UIColor.blue]
default: return MessageLabel.defaultAttributes
}
}
func enabledDetectors(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> [DetectorType] {
return [.url, .address, .phoneNumber, .date, .transitInformation]
return [.url, .address, .phoneNumber, .date, .transitInformation, .mention, .hashtag]
}
// MARK: - All Messages