Skip to content

Commit

Permalink
add support for highlighting buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
malmstein committed Sep 6, 2024
1 parent ef74c70 commit 8a8976e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
33 changes: 26 additions & 7 deletions app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3837,9 +3837,20 @@ class BrowserTabFragment :
renderIfChanged(viewState, lastSeenOmnibarViewState) {
Timber.d("Omnibar: renderOmnibar $viewState")

lastSeenOmnibarViewState = viewState

browserOmnibar.decorate(OmnibarStateChanged(viewState))
val browserViewState = lastSeenBrowserViewState
if (browserViewState != null) {
val omnibarViewState = viewState.copy(
fireButton = browserViewState.fireButton,
showMenuButton = browserViewState.showMenuButton,
showPrivacyShield = browserViewState.showPrivacyShield,
)
browserOmnibar.decorate(OmnibarStateChanged(omnibarViewState))
renderToolbarMenus(browserViewState)
lastSeenOmnibarViewState = omnibarViewState
} else {
browserOmnibar.decorate(OmnibarStateChanged(viewState))
lastSeenOmnibarViewState = viewState
}

if (viewState.isEditing) {
cancelTrackersAnimation()
Expand All @@ -3854,10 +3865,6 @@ class BrowserTabFragment :
omnibar.omnibarTextInput.setSelection(viewState.omnibarText.length)
}
}

lastSeenBrowserViewState?.let {
renderToolbarMenus(it)
}
}
}

Expand Down Expand Up @@ -3999,7 +4006,19 @@ class BrowserTabFragment :
}
}

val omnibarViewState = lastSeenOmnibarViewState
if (omnibarViewState != null) {
val newOmnibarViewState = omnibarViewState.copy(
fireButton = viewState.fireButton,
showMenuButton = viewState.showMenuButton,
showPrivacyShield = viewState.showPrivacyShield,
)
lastSeenOmnibarViewState = newOmnibarViewState
browserOmnibar.decorate(OmnibarStateChanged(omnibarViewState))
}

renderToolbarMenus(viewState)

popupMenu.renderState(browserShowing, viewState, tabDisplayedInCustomTabScreen)
renderFullscreenMode(viewState)
renderVoiceSearch(viewState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ class OmnibarViewModel @Inject constructor(
private val dispatcherProvider: DispatcherProvider,
) : ViewModel(), DefaultLifecycleObserver {

// create a FocusedViewState / UnfocusedViewState so we can toggle between the two
// loading a query or site will update the FocusedViewState but won't be displayed

data class ViewState(
val leadingIconState: LeadingIconState = LeadingIconState.SEARCH,
val privacyShield: PrivacyShield = PrivacyShield.UNKNOWN,
Expand All @@ -83,11 +80,6 @@ class OmnibarViewModel @Inject constructor(
val tabs: List<TabEntity> = emptyList(),
)

data class FocusedViewState(
val omnibarText: String = "",

)

enum class LeadingIconState {
SEARCH,
PRIVACY_SHIELD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ data class OmnibarViewState(
val showTabsButton: Boolean = true,
val fireButton: HighlightableButton = HighlightableButton.Visible(),
val showMenuButton: HighlightableButton = HighlightableButton.Visible(),
val showPrivacyShield: HighlightableButton = HighlightableButton.Visible(),
)

0 comments on commit 8a8976e

Please sign in to comment.