Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @mention highlighting support to autocomplete #8

Closed
nathantannar4 opened this issue Jan 30, 2018 · 4 comments
Closed

Add @mention highlighting support to autocomplete #8

nathantannar4 opened this issue Jan 30, 2018 · 4 comments
Labels

Comments

@nathantannar4
Copy link
Contributor

Hey!

First off thanks for the GitHawk app, I use it all the time! I liked your implementation of autocomplete, as I to did something similar for an InputAccessoryView that made its way into MessageKit.

I notice that in the GitHawk app @mention is highlighted with colors but not in the UITextView for the MessageViewController. Is this something you are already working towards? If not I would be happy to make a PR to support this feature! 😊

@rnystrom
Copy link
Member

@nathantannar4 love the idea! Practically though, I think it'll be pretty difficult to pull off b/c what would happen if you autocomplete something but then go back and edit it. Imagine:

  • Search for @
  • Tap "rnystrom", inserting "@rnystrom "
  • Then backspace to "@rnyst"
  • Type "abc" to have "@rnystabc"

You'd expect the full string to apply the prefix style, right?

Also needing to track when the prefix isn't inserted.

If you've got ideas on how to tackle this, I'm all ears! I think it'd be really slick 😎

@nathantannar4
Copy link
Contributor Author

I've been playing around off and on with different ideas. With my autocomplete solution I primarily rely on attributed strings, so I can add color and what not. I did initially run into your problem you mentioned but resolved it by always forcing the typingAttributes to be reset to a default before text is changed. But now the problem of [@highlighted][some other stuff] was present.

Looking at Facebook, WhatsApp, etc. it appears that when a user try to delete @mention text the entire autocomplete text is deleted. So that is the same approach I took.

Rather than keeping track of the prefix inserted like you mentioned I overcame this by applying a custom NSAttributedStringKey attribute to autocompleted text. This mean that if a range with that attribute ever is about to be removed, delete the entire substring.

Still a few bugs to work on but its working with this approach. Any problems you foresee with this?

demo

@rnystrom
Copy link
Member

rnystrom commented Jan 31, 2018

Super cool! I’d love this.

Sent with GitHawk

@BasThomas
Copy link
Collaborator

Is this completely done in #15? If so, we can close this :)

@rnystrom rnystrom closed this as completed Feb 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants