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

Bring selected filter to front #2809

Merged
merged 3 commits into from
May 23, 2024

Conversation

frebib
Copy link
Contributor

@frebib frebib commented May 7, 2024

It looked weird before to always have the selected chip disappear and slide behind the deselected filters.

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Selected filters in the room list filter bar now slide in front instead of behind when moving to the left

Motivation and context

It looks nicer

Screenshots / GIFs

Note that I have my animation scale set to 5x here.
After:

screen-20240507-011255.2.mp4

Before:

screen-20240507-172313.2.mp4

Tests

  • Step 1: Open app
  • Step 2: Click buttons
  • Step 3: Observe

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@frebib frebib requested a review from a team as a code owner May 7, 2024 00:14
@frebib frebib requested review from bmarty and removed request for a team May 7, 2024 00:14
Copy link
Contributor

github-actions bot commented May 7, 2024

Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:

  • Your branch should be based on origin/develop, at least when it was created.
  • There is a changelog entry in the changelog.d folder with the Towncrier format.
  • The test pass locally running ./gradlew test.
  • The code quality check suite pass locally running ./gradlew runQualityChecks.
  • If you modified anything related to the UI, including previews, you'll have to run the Record screenshots GH action in your forked repo: that will generate compatible new screenshots. However, given Github Actions limitations, it will prevent the CI from running temporarily, until you upload a new commit after that one. To do so, just pull the latest changes and push an empty commit.

Copy link

codecov bot commented May 7, 2024

Codecov Report

Attention: Patch coverage is 95.83333% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 74.22%. Comparing base (7bda5fd) to head (b852578).

Files Patch % Lines
...tures/roomlist/impl/filters/RoomListFiltersView.kt 95.83% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2809   +/-   ##
========================================
  Coverage    74.21%   74.22%           
========================================
  Files         1540     1540           
  Lines        36892    36905   +13     
  Branches      7149     7150    +1     
========================================
+ Hits         27381    27394   +13     
  Misses        5779     5779           
  Partials      3732     3732           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks nicer indeed, thanks.

When deselecting a filter, shouldn't the deselected filter also stay on top?

With this change I have this:

FilterUnselected

Please let me know what you think.

@bmarty bmarty added the Z-Community-PR Issue is solved by a community member's PR label May 7, 2024
@frebib
Copy link
Contributor Author

frebib commented May 7, 2024

Yeah, you're right, that does look a little weird. I'm not sure how we'd go about doing that though. Maybe base the zindex on the order that the buttons are last touched?

@bmarty
Copy link
Member

bmarty commented May 7, 2024

It's actually maybe OK, since the filter which is moving to the left is always visible 🤷‍♂️

@frebib
Copy link
Contributor Author

frebib commented May 7, 2024

Yeah I think it looks weird in either case. For comparison here is the old behaviour

screen-20240507-172313.2.mp4

@frebib
Copy link
Contributor Author

frebib commented May 7, 2024

I compared this to how it works on iOS and it's not quite the same. iOS seems to always bring just-deselected filters to the front too. Otherwise it's very similar to the newer behaviour. It's not as easy to tell because I don't know how to slow the animations down, and they seem to be faster anyway (I guess to fudge any remaining visual error?)

As a side note: I tried to tweak the animations to match iOS more closely, because that looks waay more fluid. The chip text/background colour fades smoothly which is easy enough to add. The only missing thing is that on iOS excluded filters fade in/out, but we can't do that until Jetpack Compose 1.7.0 is released and EXA is using it: https://issuetracker.google.com/issues/150812265#comment50

@frebib
Copy link
Contributor Author

frebib commented May 7, 2024

That looks nicer indeed, thanks.

When deselecting a filter, shouldn't the deselected filter also stay on top?

With this change I have this:

FilterUnselected FilterUnselected

Please let me know what you think.

I managed to implement this, although it's a bit clunky. I'm not too good with Kotlin. Either way, I think this does what you want. There's also one more commit on this branch to animate colours too. Let me know what you think

screen-20240507-230857.2.mp4

frebib/element-x-android@frebib/filter-in-front...frebib:element-x-android:frebib/filter-in-front-improved

@jmartinesp
Copy link
Contributor

I think I'll take over reviewing this PR since @bmarty is off for a few days. This last iteration looks really good to me and it does match iOS way more closely than the current one, good job! The code doesn't seem too complex, which is great too.

@jmartinesp jmartinesp self-requested a review May 8, 2024 06:28
@frebib
Copy link
Contributor Author

frebib commented May 8, 2024

I reinstated the LaunchedEffect that makes the filters snap back into position when clearing them (seeing as it was added on purpose), but due to the fading of the colours now, it looks kinda glitchy, especially at 1x speed. I wonder if we should get rid of it?

@jmartinesp
Copy link
Contributor

jmartinesp commented May 8, 2024

I think that can be fixed by specifying an animationSpec to the animateColorAsState like this:

val background = animateColorAsState(
    targetValue = if (selected) ElementTheme.colors.bgActionPrimaryRest else ElementTheme.colors.bgCanvasDefault,
    animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
    label = "chip background colour",
)

The animation takes longer to apply so it doesn't look that sudden. We can play with that value until we find the right stiffness, but I think medium low looks good.

@jmartinesp
Copy link
Contributor

@frebib could you add the AnimationSpec changes to your branch? I'd do it myself, but I don't have permissions.

@frebib frebib marked this pull request as draft May 8, 2024 15:27
@frebib
Copy link
Contributor Author

frebib commented May 8, 2024

As discussed in chat, this needs more work

This looks a little more "sane", and more closely matches what iOS does
with it's filter chips. This has to manually track which filters were
"just-deselected" and move those even higher up the z stack to ensure
they appear above even when sliding right. This is because the order is
determined by the position left-to-right of the _final_ destination of
the chip. In this case we want anything that's either currently
selected, or was selected and is still fading out to appear on top.

Signed-off-by: Joe Groocock <me@frebib.net>
@frebib
Copy link
Contributor Author

frebib commented May 21, 2024

I managed to fix the zindex ordering as Benoit pointed out. I also added the stiffness changes. Here is how it looks now

screen-20240521-233136.2.mp4

This is much closer to how iOS looks, and is much nicer on the eyes.

Signed-off-by: Joe Groocock <me@frebib.net>
They animate cleanly back to their original locations now, and correctly
overlap each other when doing so. The only thing that is mildly jarring
is the reappearing chips, but there's no way to animate appearance in
the current version of jetpack compose, so that'll have to be fixed
later.

Signed-off-by: Joe Groocock <me@frebib.net>
@frebib frebib marked this pull request as ready for review May 21, 2024 22:35
Copy link
Contributor

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks really good with the latest changes, thanks! @bmarty do you want to add some additional review?

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is fine, thanks @frebib thanks @jmartinesp !

@bmarty bmarty merged commit 3f46544 into element-hq:develop May 23, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants