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
[Feature] Add EmojiPickerUtils for advanced usage #38
[Feature] Add EmojiPickerUtils for advanced usage #38
Conversation
Overall I understand what you want to achieve and it does sounds good to me. Beside my comments above I think it would be great if you could also adjust the readme for this change and explain how it can be used. |
I have modified it, thank you very much for your feedback. |
I added the addEmojiToRecentlyUsedfang method, because it should be useful when expanding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx for addressing the previous comments and your efforts! I took a closer look now and found some other issues, place have a look ! 🙇
…engui/emoji_picker_flutter into feature/emoji_picker_utils # Conflicts: # lib/src/emoji_picker_utils.dart
Your point of view is very correct. I didn’t consider the compatibility issue at the beginning. The method I’m exposing now is to get all the available category emoji and all the available emoji entities and search emoticons. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry more comments :) Let me know if I should support you 👍 Thanks for your hard work
lib/src/emoji_picker_utils.dart
Outdated
static Future<Map<Category, Map<String, String>?>?> | ||
getAvailableCategoryEmoji() async { | ||
if (_availableCategoryEmoji == null) { | ||
// Filter recent category emojis | ||
final categories = | ||
Category.values.where((category) => category != Category.RECENT); | ||
|
||
// Get all available emojis from cached | ||
final futures = categories.map((category) async { | ||
final emojis = await restoreFilteredEmojis(category.name); | ||
return emojis; | ||
}); | ||
|
||
final allAvailableEmojis = await Future.wait(futures); | ||
|
||
_availableCategoryEmoji = | ||
Map.fromIterables(categories, allAvailableEmojis); | ||
} | ||
return _availableCategoryEmoji; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case emoji-picker hasn't been displayed at least once, there are no emojis cached and this method would return an empty Map. Could we maybe extract the logic inside _updateEmojis()
instead into another helper class (non-static, mockable for tests) together with restoreFilteredEmojis
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also considered this problem at first, but what I thought was that since this tool class should be used only when the pop-up window is used, there may be a problem with my idea.😄
lib/src/emoji_picker_utils.dart
Outdated
} | ||
|
||
/// Add an emoji to recently used list or increase its counter | ||
static Future<List<RecentEmoji>> addEmojiToRecentlyUsed( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering what's the use case for this method? How could it be used outside of the Widget?
If it doesn't serve an usage outside of the widget we could also move it to extra helper class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, when searching for expressions, a certain expression is used, and this expression needs to be added to the recent use, so I moved it here
I have already changed it, I believe this is the best version, and I have tested it locally with version 2.0.1 of flutter, and I have not found any problems for the time being. thank you very much for the feedback these days.😃 |
The default value of the recentsLimit parameter of the addEmojiToRecentlyUsed method should be changed to 28. If I don't need to modify the others, please help me change it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome ! we are almost done - just a few little more comments 🙏
It has been revised, although the process is very difficult, but the ending is good.😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested a lot and realized that there were few issues left
- search was case sensitive
addEmojiToRecentlyUsed
didn't update the widget's recent list
Took me 2 days to figure out a good way and ended up making a PR. Hope you don't mind and can take a look to my changes. I thought that's easier than explaining what I mean.
Fix addEmojiToRecentlyUsed zhourengui/emoji_picker_flutter#1
lib/src/emoji_picker_utils.dart
Outdated
} | ||
|
||
return _allAvailableEmojiEntities | ||
.where((emoji) => emoji.name.contains(keyword)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Search seems to be case-sensitive, I think it would be better if not 😅
…ements Fix addEmojiToRecentlyUsed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhourengui Sorry for the delay I was busy. Thank you for your hard work, I think it's good to go now. I will improve the documentation as you mentioned in another PR to make it easier for me. Also I have some other changes related to the emoji's that I want to do first before releasing it as a new version, so please be patient a bit more. You can use the master directly in your app if you need the changes asap.
It's okay, don't worry, I'm currently using a temporary tool class in my project to solve the problem, and when everything is done, I'm going to upgrade. |
close: #37
I encountered a need to search for emojis feature, but I can’t get all emojis, so I think a public method class should be implement for the convenience of expansion.
I think this change should be very useful, for example: