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

Filter games #877

Merged
merged 40 commits into from
Aug 5, 2024
Merged

Filter games #877

merged 40 commits into from
Aug 5, 2024

Conversation

Mauritz8
Copy link
Contributor

Partially implement #454

@Mauritz8
Copy link
Contributor Author

I've implemented a filter for perf:

Screencast.from.2024-07-21.14.50.36.webm

@Mauritz8 Mauritz8 marked this pull request as ready for review July 21, 2024 13:05
@ZTL-UwU
Copy link
Contributor

ZTL-UwU commented Jul 21, 2024

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)

@ijm8710
Copy link

ijm8710 commented Jul 21, 2024

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

@Mauritz8
Copy link
Contributor Author

Thanks! Using chips seems like a great idea, I'll try to make it work.

@Mauritz8
Copy link
Contributor Author

I think this is a significant improvement, let me know what you think.

Screencast.from.2024-07-25.17.41.35.webm

@veloce
Copy link
Contributor

veloce commented Jul 25, 2024

Thanks!

Can you try to:

  • make the chip smaller
  • call it only "variant" instead of "Time control / variant": it will be shorter;
  • put the chip in the app bar, or make it look like it is in the app bar; (I guess it is not that hard to do, but I'm not sure)

@ijm8710
Copy link

ijm8710 commented Jul 25, 2024

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

image

@veloce
Copy link
Contributor

veloce commented Jul 25, 2024

Yeah good idea. We could also separate the "Time control" chips from the variant chips. Using a line separator.

@Mauritz8
Copy link
Contributor Author

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

@ZTL-UwU
Copy link
Contributor

ZTL-UwU commented Jul 26, 2024

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.

@Mauritz8
Copy link
Contributor Author

If I understand correctly, you want a single button in the app bar, that opens all the filters?
That would be a different design than what's detailed in #454. To quote:

On top of the list, an horizontal list of filters should be displayed (like in the notifications screen of GitHub app). Filters would include: "rated", "perf type", "bookmarks", etc. (list non exhaustive).

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.

@ijm8710
Copy link

ijm8710 commented Jul 26, 2024

I do think I had similar comments to @ZTL-UwU (even before I read his).

Was also thinking:

  • separate screen or bottom sheet may work better for this
  • a filter button rather than a chip to launch the screen with all the choices
  • Smaller chips with headers by section

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)

@Mauritz8
Copy link
Contributor Author

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

@ijm8710
Copy link

ijm8710 commented Jul 27, 2024

Awesome @Mauritz8 i thinks it's starting to look a lot better.

Few more things that I think would get it to finish line

  • I feel order of variants should be either based on the same order of your perf cards (which I believe is based on total games played) or based on just most popular variant sitewide.
  • I like that we have the starting filter now! is it still possible to have the filter but still have the designation you had before to show what the filter is currently selecting? Perhaps can change the title of the header screen to say like bullet or something especially if it's just one filter selected
  • would you be able to add a section for result: won/loss/draw
  • I think icons before the section names would be the final polish to make them easy to discern quickly? Like perhaps the rabbit, bullet or turtle before the variant section. A black or white pawn before the side section. And the green plus icon for the result section? I'm not to picky with which icon you choose, I just personally feel icons before section names really work well.
  • posing one question: if you have zero activity for a variant should it show? Personally I lean no so, for example, if you've only played bullet and rapid, you would only see 2 chips. I'm not stubborn on this one, but just my personal take (if it doesn't tax the server to gather that info).

Thanks for trialing out our ideas! It's getting really good!

@veloce
Copy link
Contributor

veloce commented Jul 27, 2024

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?

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.

@Mauritz8
Copy link
Contributor Author

Mauritz8 commented Jul 28, 2024

Thanks @ijm8710, I've made adjustments now in regards to your feedback:

  • Variants now work the same as the perf cards on the home screen. That is, they are ordered based on total games played, and ones with no games played are not shown.
  • Chip indicating how many filters are in use, like veloce suggested.
  • Icon before filter name

would you be able to add a section for result: won/loss/draw

Not supported in the api yet.

This is how it looks:

Screencast.from.2024-07-28.11.26.40.webm

@ijm8710
Copy link

ijm8710 commented Jul 28, 2024

Thanks @Mauritz8 think it looks perfect! You rock

Two questions for you:

  • if only one filter is chosen, any chance to have the title reflect filter chosen as well as the result count "83 classical games"...."83 games" if multi filters chosen (this would then match the format used when opening specific games from the variant screens)
  • these same filters can be run from another user profile too, correct?

And two questions for @veloce

  • mauritz mentioned game result is not supported in api. Would this be something worth adding to api if possible? I feel being able to query a win vs loss will have use-case here and possibly elsewhere
  • on web, there are many more filters. Do you think it may make sense to have a link on the filter screen "advanced filters" for even more advanced filter access?
    Dream scenario is a user would be able to open an overlay web screen of the filters, choose what they want and they generate in a native screen within the app. But perhaps this is overboard.

@Mauritz8
Copy link
Contributor Author

if only one filter is chosen, any chance to have the title reflect filter chosen as well as the result count "83 classical games"...."83 games" if multi filters chosen (this would then match the format used when opening specific games from the variant screens)

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.

these same filters can be run from another user profile too, correct?

Yes!

@ijm8710
Copy link

ijm8710 commented Jul 28, 2024

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

@Mauritz8
Copy link
Contributor Author

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.

@veloce
Copy link
Contributor

veloce commented Jul 30, 2024

mauritz mentioned game result is not supported in api. Would this be something worth adding to api if possible? I feel being able to query a win vs loss will have use-case here and possibly elsewhere

Yes it is planned to add more filters later.

@ijm8710
Copy link

ijm8710 commented Jul 31, 2024

@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?

MyRecentGamesRef ref,
) async {
MyRecentGamesRef ref, {
GameFilterState filter = const GameFilterState(),
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

side: filter.side,
);

int countFiltersInUse() {
Copy link
Contributor

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
Copy link
Contributor

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(
Copy link
Contributor

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(
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@Mauritz8
Copy link
Contributor Author

Mauritz8 commented Aug 4, 2024

@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?

I'll add it back in.

@veloce veloce merged commit 993ceae into lichess-org:main Aug 5, 2024
1 check passed
@veloce
Copy link
Contributor

veloce commented Aug 5, 2024

Thanks again for this!

@Mauritz8 Mauritz8 deleted the filter-games branch August 5, 2024 13:54
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

Successfully merging this pull request may close these issues.

4 participants