-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
Filter games #877
Filter games #877
Conversation
I've implemented a filter for perf: Screencast.from.2024-07-21.14.50.36.webm |
It looks awesome! One samll suggestion tho, is it possible to use chips for filtering like the recommended design in material 3? (https://m3.material.io/components/chips/overview) |
I agree with @ZTL-UwU. Another reason for this is because there will ultimately probably be other filters beyond variant such as result type and piece color |
Thanks! Using chips seems like a great idea, I'll try to make it work. |
I think this is a significant improvement, let me know what you think. Screencast.from.2024-07-25.17.41.35.webm |
Thanks! Can you try to:
|
For a first version this is great but would yall agree formatting the chips more similarly organized to the style laid out in the link shared earlier (screenshotting image) ? That way you can add a few more categories for sub-filters such as win/loss and white/black I think this organization looks a bit more streamlined |
Yeah good idea. We could also separate the "Time control" chips from the variant chips. Using a line separator. |
Now it looks like the picture, big improvement again I think. I also implemented your suggestions veloce. Though I'm not exactly sure what you mean by making it smaller, was shortening the text to just 'variant' enough? Also, I'm not able to test on ios, so I'm not sure whether the app bar will look good on it. Screencast.from.2024-07-26.07.50.33.webm |
I think a filter icon button on the right of the appbar will be more concise. Also, I think putting the chips into a bottom sheet or a separate screen instead of a dialog is better as it gives more space for the chips to spread. |
If I understand correctly, you want a single button in the app bar, that opens all the filters?
I would prefer using a popup, rather than a separate screen. There's less context switching, and you can easily exit by pressing outside the popup. Overall I think it's a better experience. Also, I don't think space is an issue, It easily fits, and this is one of the filters with the most chips. Filters like color and rated will only have 2 chips, so a separate screen seems excessive, and a bottom sheet would be very far down since there would be so little content on it. |
I do think I had similar comments to @ZTL-UwU (even before I read his). Was also thinking:
Just design wise closer to the picture so we can have more sections You can even have little icons in front of the section names to make it slightly prettier (like some pawn or something before variant type) |
Since it's not possible to count games when complex filter in use
So, I created a new branch locally and implemented the design that you both want. I think it looks nice, and I'm willing to go for this design instead of the proposed one. @veloce what do you think? Screencast.from.2024-07-27.14.41.50.webm |
Awesome @Mauritz8 i thinks it's starting to look a lot better. Few more things that I think would get it to finish line
Thanks for trialing out our ideas! It's getting really good! |
Looks good to me. I think on top of the "filter" icon we need a chip indicating the number of selected filters. Same appearance as the "unread messages" chip on the chat icon on game screen. |
Thanks @ijm8710, I've made adjustments now in regards to your feedback:
Not supported in the api yet. This is how it looks: Screencast.from.2024-07-28.11.26.40.webm |
Thanks @Mauritz8 think it looks perfect! You rock Two questions for you:
And two questions for @veloce
|
Games are only fetched a few at a time, so it's unfortunately not possible to count the total when using filters. We could change the title when only a single filter is used, but I'm a bit worried that there might be too little horizontal space in the app bar.
Yes! |
Okay, only reason I thought otherwise is because your other pr if you pull all classical games from the variant card it had the count. No worries then! Thanks again for your work on this |
Yes it's technically possible to get the number of games if the filter is only made up of variants, but it would require an additional api request for each variant selected, which doesn't seem great. I think it could be done in a better way, and in my opinon it's not that useful unless it works no matter how complex the filter is. If it should be implemented, I think the number of results should probably be a part of the api response instead. The advanced search on the website shows the number of results, so it should be possible to implement. |
Yes it is planned to add more filters later. |
@Mauritz8 one other request, not sure if you agree. Before filtering on game type in your pr it says Ivan's games Currently in beta it'll say total # games. I don't think that total count is visible anywhere else in app so can we have it still say total count before filtering? |
lib/src/model/game/game_history.dart
Outdated
MyRecentGamesRef ref, | ||
) async { | ||
MyRecentGamesRef ref, { | ||
GameFilterState filter = const GameFilterState(), |
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.
Recent games should not be filtered (whether it is my recent games or any user recent games) so this parameter should be removed.
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.
The game history provider uses the recent games providers in its implementation. We could create new providers that do the same thing, except they watch the game filter provider instead of passing it as a param. I don't really see the point though.
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'd rather make the request again than have an extra complexity and unnecessary filter in the recent game providers.
So you can just remove the dependency to the recent game provider in UserGameHistory
and perform the request directly with the filters.
lib/src/model/game/game_filter.dart
Outdated
side: filter.side, | ||
); | ||
|
||
int countFiltersInUse() { |
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.
Provider should not define public getters or expose state through public methods.
The count
info is already available in the state. A count
getter can be defined in the GameFilterState
class directly if needed.
); | ||
final filtersInUse = ref |
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.
Cf. other comment. ref.read
should not be used in build()
methods; to count the filters you should get the filter state with ref.watch
.
), | ||
); | ||
|
||
return Container( |
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.
A Container
seems useless here. You could use directly a Padding
.
controller: scrollController, | ||
children: [ | ||
if (userId != null) | ||
ref.watch(userProvider(id: userId)).when( |
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.
It is better to put ref.watch
at the beginning of build()
methods so when we read the code we know immediately what are the watched dependencies of the widget.
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.
The userId
might be null though, so we can't listen to it unconditionally.
I'll add it back in. |
* use ref.watch instead of ref.read inside build method * define count getter directly in class * use padding instead of container
Thanks again for this! |
Partially implement #454