[DetectorType][MessageLabel] Add custom, mention and hashtag detector type 👻#913
Conversation
nathantannar4
left a comment
There was a problem hiding this comment.
We need some ample test cases to ensure the regex matches all cases for hashtag and mention
|
Please make sure your branch, |
|
This looks promising ❤️ Thanks for working on this @JulienKode 🥇 💯 |
2096ee1 to
c71e599
Compare
|
@nathantannar4 Thanks it's now sync with the @SD10 I've change it into a var There now the testing to do I've see that there are already test for If I uncomment theses tests they do not pass but they are right. |
talanov
left a comment
There was a problem hiding this comment.
Could you, please, squash commits into 1?
701ba59 to
fe11a31
Compare
|
@talanov for sure |
fe11a31 to
39bdde9
Compare
cc14069 to
1ae82ed
Compare
|
Very close! I'd like to see the Example updated so people can see these detectors in action 😊 |
…n 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]
c66ee49 to
77e9ccd
Compare
|
@nathantannar4 I’ve added examples Sent with GitHawk |
|
Hey guys, in MessageLabel.swift, it's calling MessageKit/Sources/Views/MessageLabel.swift Line 493 in 77e9ccd |
|
@strujillojr Thanks, It's fixed now |
nathantannar4
left a comment
There was a problem hiding this comment.
@JulienKode can you please add the delegate methods in the Example so users know they exist?
func didSelectHashtag(_ hashtag: String) {
print("Hashtag selected: \(hashtag)")
}
func didSelectMention(_ mention: String) {
print("Mention selected: \(mention)")
}
func didSelectCustom(_ pattern: String, match: String?) {
print("Custom data detector patter selected")
}
|
After example changes it LGTM 💯 @SD10 Should we include this in 2.0.0? |
…into CustomDetectorType
… into CustomDetectorType
|
@nathantannar4 I've update the branch to the latest |
|
This can't be in 2.0 because we already did a beta. You can't have anything other than bugfixes in a beta or it defeats the purpose of the beta lol. This is an API breaking change so I changed it to be part of the 3.0 milestone. |
|
|
||
| case Hashtag = 8 | ||
| case Mention = 9 | ||
| case Custom = 10 |
There was a problem hiding this comment.
Let's make all these cases lowercased, it is not very Swifty 😆 If you could take care of all of them 💯
There was a problem hiding this comment.
That’s true, It’s not really swift, may I changes all of them in this PR or create another one ? To change others
| let detector = try? NSDataDetector(types: checkingTypes) | ||
| let range = NSRange(location: 0, length: text.length) | ||
| let matches = detector?.matches(in: text.string, options: [], range: range) ?? [] | ||
| var matches = [NSTextCheckingResult]() |
There was a problem hiding this comment.
I've did it, thanks
|
What are the graphs showing? FPS? CPU %? Sent with GitHawk |
|
@nathantannar4 FPS in purple |
|
@JulienKode It does look like adding those code has some major spikes in the CPU 😞 |
|
It is optional, personally in my apps I wouldn't use this, I would use attributed strings. But this is a nice to have feature for ease of use Sent with GitHawk |
|
Ok, I understand, but It’s only in the worst case, if you just handle hashtag the perf is the same I know it's a sensitive part of the library If you have any idea of change to improve the performance. I want to know it Sent with GitHawk |
|
Going to merge this into the 3.0.0-beta branch. While it does come at a performance hit I am going to leave it to the end user to decide if they want this since without using the new detectors there is no difference. |
|
@nathantannar4 ok it makes sense, if someone have an idea to improve the speed, we also can improve it |


Adding other
DetectorTypessuch as:.mention.hashtag.custom(regex: NSRegularExpression)Others elements of the enum are made with
NSDataDetectorwhich inherit fromNSRegularExpressionTheses three new element use only
NSRegularExpressionWe can discuss of the API or changes to make here