-
Notifications
You must be signed in to change notification settings - Fork 1.3k
For #7698: Adds search back button animation #7840
Conversation
d1fa838
to
1bf9958
Compare
Codecov Report
@@ Coverage Diff @@
## master #7840 +/- ##
============================================
- Coverage 19.18% 19.16% -0.02%
Complexity 451 451
============================================
Files 301 301
Lines 11639 11659 +20
Branches 1577 1579 +2
============================================
+ Hits 2233 2235 +2
- Misses 9222 9240 +18
Partials 184 184
Continue to review full report at Codecov.
|
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.
Looks good to me. I think this really cleans up the animation, so I'm happy to see the change. Nice job!
@@ -352,7 +357,17 @@ class SearchFragment : Fragment(), UserInteractionHandler { | |||
} | |||
} | |||
|
|||
private fun animateBackButtonAway() { | |||
val xTranslation = | |||
requireView().back_button.width.toFloat() * BACK_BUTTON_ANIMATION_WIDTH_MULTIPLIER |
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 looks like this constant is to make up for padding + margin? That works, but it's a little bit messy, opens us up to weird bugs if we ever adjust either of those values, and requires a reader to figure out what it's handling. What about something like this:
val backButton = requireView().back_button
val xTranslation = with(backButton) {
-(width + marginStart + paddingStart).toFloat()
}
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.
Seems reasonable to me!
view.back_button.apply { | ||
setOnClickListener { | ||
animateBackButtonAway() | ||
findNavController().navigateUp() |
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 think it's a bad sign that this animates then navigates up, while the ToolbarView
animates then calls the interactor, which calls the controller, and... navigates up. This is one of the things our architecture is meant to unify, so let's clean it up while we're here.
If we:
- move
animateBackButtonAway
off ofToolbarView
and on toSearchController
- replace 205 & 206 in
SearchFragment
withsearchInteractor.onEditingCanceled()
then we have a more reasonable and consistent data flow.
It seems to me that we want back press and back button clicks to behave the same here, so I'm happy to have them call the same interactor method. If that ever changes in the future, we can break them out as needed.
fc80cc5
to
faca280
Compare
faca280
to
4191987
Compare
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.
LGTM from the engineering side
@@ -76,6 +76,7 @@ class DefaultSearchController( | |||
} | |||
|
|||
override fun handleEditingCancelled() { | |||
store.dispatch(SearchFragmentAction.EditingCancelled) |
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.
Nit: there's nothing wrong with this name, but just to align with AC I'd prefer to name it UpdateEditingCanceled
.
-(width + marginStart + paddingStart).toFloat() | ||
} | ||
|
||
requireView().back_button |
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.
Nit: you can replace this line with backButton
430f8de
to
d4d2824
Compare
d4d2824
to
3f8bd6a
Compare
Pull Request checklist
After merge
To download an APK when reviewing a PR: