Bug 1868260 – Sync navbar position with toolbar

fenix/125.0
mike a 5 months ago committed by mergify[bot]
parent 5534804101
commit 5bba669077

@ -128,13 +128,13 @@ import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.FindInPageIntegration
import org.mozilla.fenix.components.StoreProvider
import org.mozilla.fenix.components.metrics.MetricsUtils
import org.mozilla.fenix.components.toolbar.BottomToolbarContainerView
import org.mozilla.fenix.components.toolbar.BrowserFragmentState
import org.mozilla.fenix.components.toolbar.BrowserFragmentStore
import org.mozilla.fenix.components.toolbar.BrowserToolbarView
import org.mozilla.fenix.components.toolbar.DefaultBrowserToolbarController
import org.mozilla.fenix.components.toolbar.DefaultBrowserToolbarMenuController
import org.mozilla.fenix.components.toolbar.IncompleteRedesignToolbarFeature
import org.mozilla.fenix.components.toolbar.NavigationBarView
import org.mozilla.fenix.components.toolbar.ToolbarIntegration
import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.components.toolbar.interactor.BrowserToolbarInteractor
@ -452,9 +452,19 @@ abstract class BaseBrowserFragment :
)
if (IncompleteRedesignToolbarFeature(context.settings()).isEnabled) {
NavigationBarView(
val toolbarView = if (context.components.settings.toolbarPosition == ToolbarPosition.BOTTOM) {
// Should refactor this so there is no added view to remove to begin with
// https://bugzilla.mozilla.org/show_bug.cgi?id=1870976
binding.browserLayout.removeView(browserToolbarView.view)
browserToolbarView.view
} else {
null
}
BottomToolbarContainerView(
context = context,
container = binding.browserLayout,
androidToolbarView = toolbarView,
)
}

@ -6,9 +6,13 @@ package org.mozilla.fenix.components.toolbar
import android.content.Context
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import androidx.compose.foundation.layout.Column
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.viewinterop.AndroidView
import androidx.coordinatorlayout.widget.CoordinatorLayout
import org.mozilla.fenix.compose.Divider
import org.mozilla.fenix.theme.FirefoxTheme
/**
@ -17,19 +21,29 @@ import org.mozilla.fenix.theme.FirefoxTheme
* @param context The Context the view is running in.
* @param container The ViewGroup into which the NavigationBar composable will be added.
* @param navigationItems A list of [ActionItem] objects representing the items to be displayed in the navigation bar.
* @param androidToolbarView An option toolbar view that will be added atop of the navigation bar.
* Defaults to [NavigationItems.defaultItems] which provides a standard set of navigation items.
*/
class NavigationBarView(
class BottomToolbarContainerView(
context: Context,
container: ViewGroup,
navigationItems: List<ActionItem> = NavigationItems.defaultItems,
androidToolbarView: View? = null,
) {
init {
val composeView = ComposeView(context).apply {
setContent {
FirefoxTheme {
NavigationBar(navigationItems)
Column {
if (androidToolbarView != null) {
AndroidView(factory = { _ -> androidToolbarView })
} else {
Divider()
}
NavigationBar(actionItems = navigationItems)
}
}
}
}

@ -25,7 +25,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.Divider
import org.mozilla.fenix.compose.annotation.LightDarkPreview
import org.mozilla.fenix.theme.FirefoxTheme
import org.mozilla.fenix.theme.Theme
@ -43,8 +42,6 @@ fun NavigationBar(actionItems: List<ActionItem>) {
.height(48.dp)
.fillMaxWidth(),
) {
Divider()
Row(
modifier = Modifier
.align(Alignment.Center)

@ -91,8 +91,8 @@ import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.PrivateShortcutCreateManager
import org.mozilla.fenix.components.TabCollectionStorage
import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.components.toolbar.BottomToolbarContainerView
import org.mozilla.fenix.components.toolbar.IncompleteRedesignToolbarFeature
import org.mozilla.fenix.components.toolbar.NavigationBarView
import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.databinding.FragmentHomeBinding
import org.mozilla.fenix.ext.components
@ -434,9 +434,20 @@ class HomeFragment : Fragment() {
)
if (IncompleteRedesignToolbarFeature(requireContext().settings()).isEnabled) {
NavigationBarView(
val toolbarView = if (requireContext().components.settings.toolbarPosition == ToolbarPosition.BOTTOM) {
val toolbar = binding.toolbarLayout
// Should refactor this so there is no added view to remove to begin with
// https://bugzilla.mozilla.org/show_bug.cgi?id=1870976
binding.root.removeView(toolbar)
toolbar
} else {
null
}
BottomToolbarContainerView(
context = requireContext(),
container = binding.homeLayout,
androidToolbarView = toolbarView,
)
}

Loading…
Cancel
Save