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

Hashtag auto-complete provided list of suggestions #52

Closed
ravsom opened this issue Dec 9, 2020 · 18 comments
Closed

Hashtag auto-complete provided list of suggestions #52

ravsom opened this issue Dec 9, 2020 · 18 comments

Comments

@ravsom
Copy link

ravsom commented Dec 9, 2020

Hi! Thanks for the wonderful library - is it possible to show auto-complete suggestions just below the HashTagEditableText

I tried adding Overlay but there seems to be some issue with Opacity - was wondering if the feature is in-built

Thanks

@santa112358
Copy link
Owner

@ravsom
Is the auto-complete feature like this? https://pub.dev/packages/autocomplete_textfield

@ravsom
Copy link
Author

ravsom commented Dec 9, 2020

Yes @santa112358, more so like Twitter hashtags autofill, so there can be multiple in a given text.

Thanks for your reponse.

@ravsom
Copy link
Author

ravsom commented Dec 9, 2020

I've not been able to integrate both together, would you have any advice @santa112358, please?

The challenge is both a form field types, not sure how they fit together

@santa112358
Copy link
Owner

related issue: #30

@santa112358
Copy link
Owner

@ravsom
It is clear that you cannot implement this feature with current version's hashtagable.
To implement this, hashtagable needs to have a function called when hashtag is being typed.
Maybe the callback should be called in getComposedTextSpan which controls the textStyle of typing text.
https://github.com/santa112358/hashtagable/blob/master/lib/composer/composer.dart#L8-L71

In the callback, you set the function to show overlay. (Or you can set widget just below the textField and control the visibility of the widget in the callback)

Anyway, I know at least three people are requesting this feature on github, so I am thinking about updating package for this request.

@Abacaxi-Nelson
Copy link

yes overlay or portal.
having some trigger like : open, close, selected
and maybe generate some markup, like [#awesome:133443] (passing some ids)

@santa112358
Copy link
Owner

@ravsom @Abacaxi-Nelson @SchnMar
hashtagable v1.0.6 is published ! 🎉
I haven't written its usage, but now you can use the callback to show auto-complete.
example: https://github.com/santa112358/hashtagable/blob/master/example/lib/main.dart#L41-L44

Feel free to ask If you have any questions about this update.

Thank you.

@ravsom
Copy link
Author

ravsom commented Dec 21, 2020

Thanks a lot @santa112358 Appreciate it.

@SchnMar
Copy link
Contributor

SchnMar commented Dec 21, 2020

Looking good! Thank you so much @santa112358. Do you have a buy me a coffee link? I would love to do so!

@santa112358
Copy link
Owner

santa112358 commented Dec 21, 2020

@SchnMar Thank you so much ! the link is here: https://www.buymeacoffee.com/santatakahashi
It is a great encouragement ☕️

@SchnMar
Copy link
Contributor

SchnMar commented Dec 21, 2020

@SchnMar Thank you so much ! the link is here: https://www.buymeacoffee.com/santatakahashi
It is a great encouragement ☕️

Enjoy the coffee :)

@ravsom
Copy link
Author

ravsom commented Dec 22, 2020

Quick question - the onDetectionTyped gets called continuously when the detectable text is typed. Is there any way to get called only once?

@santa112358
Copy link
Owner

@ravsom

Is there any way to get called only once?

It depends when you want to call, and its purpose. Could you explain with more detail ?

@ravsom
Copy link
Author

ravsom commented Dec 22, 2020

I'd like to make a query to fetch a list of hashtags when # is typed, but as it keeps calling the ValueChanged callback every few seconds, the query is invoked too many times

Also, a callback when the detectabletext has ended so that that suggestions sheet can then be closed?

@santa112358
Copy link
Owner

@ravsom
You mean, if the user types #flutter, the query should run only when #flutter is fully typed?

Also, a callback when the detectabletext has ended so that that suggestions sheet can then be closed?

I agree it is necessary to close the suggestion list.

@santa112358
Copy link
Owner

Also, a callback when the detectabletext has ended so that that suggestions sheet can then be closed?

Opened #60

@ravsom
Copy link
Author

ravsom commented Dec 22, 2020

@ravsom
You mean, if the user types #flutter, the query should run only when #flutter is fully typed?

Apologies, I may have not expressed myself properly.

I mean to say it should call back once #f is typed then once if #fl is typed and so on

Currently, the callback is being triggered multiple times for #f and #fl and so on

@santa112358
Copy link
Owner

@ravsom
Ok. I got it. I know it is called multiple times for same text because it is called when the cursor gets moved.
I recommend you to set variable like previousDetectedText. Then you can use the condition like this.

onDetectionTyped(text){
    if (previousDetectedText != text){
       /// sample
       fetchSuggestions(text);
       ///
      
      previousDetectedText == text;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants