-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Logo animation on Input Screen #6821
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
Changes from all commits
dcb153d
8a0d4f5
0aa61b2
bfcae65
17b675a
7dd7397
da3315b
be29276
5fd14ab
0df1aa0
9cd0865
4b07168
8759087
a389199
6683a16
bb75b5e
0b1f143
1a844f1
b3de3d1
e18b823
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,11 +124,13 @@ class InputScreenViewModel @AssistedInject constructor( | |
| ) : ViewModel() { | ||
|
|
||
| private var hasUserSeenHistoryIAM = false | ||
| private var isTapTransition = false | ||
|
|
||
| private val newTabPageHasContent = MutableStateFlow(false) | ||
| private val voiceServiceAvailable = MutableStateFlow(voiceSearchAvailability.isVoiceSearchAvailable) | ||
| private val voiceInputAllowed = MutableStateFlow(true) | ||
| private var userSelectedMode: UserSelectedMode = NONE | ||
| private var currentPagePosition: Int = 0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to think about this a little, will fix in a follow-up. |
||
| private val _visibilityState = MutableStateFlow( | ||
| InputScreenVisibilityState( | ||
| voiceInputButtonVisible = voiceServiceAvailable.value && voiceInputAllowed.value, | ||
|
|
@@ -445,6 +447,44 @@ class InputScreenViewModel @AssistedInject constructor( | |
| userSelectedMode = SEARCH | ||
| } | ||
|
|
||
| fun onPageScrolled(position: Int, positionOffset: Float) { | ||
| if (!isTapTransition) { | ||
| val logoProgress = calculateLogoProgress(position, positionOffset) | ||
| command.value = Command.SetLogoProgress(logoProgress) | ||
| val widgetOffset = calculateInputModeWidgetScrollPosition(positionOffset) | ||
| command.value = Command.SetInputModeWidgetScrollPosition(position, widgetOffset) | ||
| } | ||
| } | ||
|
|
||
| private fun calculateLogoProgress(position: Int, positionOffset: Float): Float { | ||
| if (newTabPageHasContent.value) return 1f | ||
| return if (position == 0) positionOffset else 1f - positionOffset | ||
| } | ||
|
|
||
| private fun calculateInputModeWidgetScrollPosition(positionOffset: Float): Float { | ||
| return when { | ||
| positionOffset <= 0.5f -> positionOffset * positionOffset * 2f | ||
| else -> 1f - (1f - positionOffset) * (1f - positionOffset) * 2f | ||
| } | ||
| } | ||
|
|
||
joshliebe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fun onTabTapped(index: Int) { | ||
| if (currentPagePosition != index) { | ||
| isTapTransition = true | ||
| if (!newTabPageHasContent.value) { | ||
| command.value = Command.AnimateLogoToProgress(index.toFloat()) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fun onPageSelected(position: Int) { | ||
| currentPagePosition = position | ||
| } | ||
|
|
||
| fun onScrollStateIdle() { | ||
| isTapTransition = false | ||
| } | ||
|
|
||
| fun onSendButtonClicked() { | ||
| val pixelParams = inputScreenPixelsModeParam(isSearchMode = userSelectedMode == SEARCH) | ||
| pixel.fire(DuckChatPixelName.DUCK_CHAT_EXPERIMENTAL_OMNIBAR_FLOATING_SUBMIT_PRESSED, parameters = pixelParams) | ||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.