Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package mozilla.components.compose.base

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -31,23 +30,17 @@ import mozilla.components.ui.icons.R as iconsR
* Default layout of a selectable chip.
*
* @param text [String] displayed in this chip.
* @param selected Whether this chip should be shown as selected.
* @param selected Whether this should be shown as selected.
* @param modifier [Modifier] used to be applied to the layout of the chip.
* @param enabled Whether this chip is enabled.
* @param showIcon Whether to show an icon at the beginning of the chip.
* @param colors The color set defined by [SelectableChipColors] used to style the chip.
* @param border The border to draw around the container of this chip.
* @param selectableChipColors The color set defined by [SelectableChipColors] used to style the chip.
* @param onClick Callback for when the user taps this chip.
*/
@Composable
fun SelectableChip(
text: String,
selected: Boolean,
modifier: Modifier = Modifier,
enabled: Boolean = true,
showIcon: Boolean = true,
colors: SelectableChipColors = FilterChipDefaults.filterChipColors(),
border: BorderStroke? = FilterChipDefaults.filterChipBorder(enabled, selected),
onClick: () -> Unit,
) {
FilterChip(
Expand All @@ -60,7 +53,7 @@ fun SelectableChip(
style = if (selected) AcornTheme.typography.headline8 else AcornTheme.typography.body2,
)
},
leadingIcon = if (showIcon && selected) {
leadingIcon = if (selected) {
{
Icon(
painter = painterResource(id = iconsR.drawable.mozac_ic_checkmark_16),
Expand All @@ -70,9 +63,8 @@ fun SelectableChip(
} else {
null
},
shape = RoundedCornerShape(16.dp),
colors = colors,
border = border,
shape = RoundedCornerShape(16.dp),
)
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,8 @@ class HomeFragment : Fragment() {
toolbarStore = toolbarStore,
appStore = activity.components.appStore,
browserStore = activity.components.core.store,
browsingModeManager = activity.browsingModeManager,
settings = activity.settings(),
browsingModeManager = browsingModeManager,
directToSearchConfig = DirectToSearchConfig(
startSearch = bundleArgs.getBoolean(FOCUS_ON_ADDRESS_BAR) ||
FxNimbus.features.oneClickSearch.value().enabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.DividerDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
Expand All @@ -24,7 +21,6 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.unit.dp
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.updateLayoutParams
import androidx.navigation.NavController
Expand Down Expand Up @@ -53,7 +49,6 @@ import org.mozilla.fenix.components.appstate.AppAction.SearchAction.SearchStarte
import org.mozilla.fenix.components.metrics.MetricsUtils
import org.mozilla.fenix.components.toolbar.ToolbarPosition.BOTTOM
import org.mozilla.fenix.components.toolbar.ToolbarPosition.TOP
import org.mozilla.fenix.components.toolbar.ui.SearchSuggestionsContainer
import org.mozilla.fenix.databinding.FragmentHomeBinding
import org.mozilla.fenix.theme.FirefoxTheme
import org.mozilla.fenix.utils.Settings
Expand All @@ -69,8 +64,9 @@ import org.mozilla.fenix.wallpapers.Wallpaper
* @param toolbarStore [BrowserToolbarStore] containing the composable toolbar state.
* @param appStore [AppStore] to sync from.
* @param browserStore [BrowserStore] to sync from.
* @param browsingModeManager [BrowsingModeManager] Manager holding current state of whether
* the browser is in private mode or not.
* @param settings [Settings] for querying various application settings.
* @param browsingModeManager [BrowsingModeManager] used to read/update the current [BrowsingMode].
* @param directToSearchConfig [DirectToSearchConfig] configuration for starting with the toolbar in search mode.
* @param tabStripContent [Composable] as the tab strip content to be displayed together with this toolbar.
* @param searchSuggestionsContent [Composable] as the search suggestions content to be displayed
Expand All @@ -85,8 +81,8 @@ internal class HomeToolbarComposable(
private val toolbarStore: BrowserToolbarStore,
private val appStore: AppStore,
private val browserStore: BrowserStore,
private val settings: Settings,
private val browsingModeManager: BrowsingModeManager,
private val settings: Settings,
private val directToSearchConfig: DirectToSearchConfig,
private val tabStripContent: @Composable () -> Unit,
private val searchSuggestionsContent: @Composable (Modifier) -> Unit,
Expand Down Expand Up @@ -116,7 +112,6 @@ internal class HomeToolbarComposable(
val isSearchEmpty =
toolbarStore.observeAsComposableState { it.editState.query.current.isEmpty() }.value
val shouldShowTabStrip: Boolean = remember { settings.isTabStripEnabled }
val shouldShowBrowserModeToggle: Boolean = remember { settings.enableBrowserModeToggle }
val isAddressBarVisible = remember { addressBarVisibility }

BackInvokedHandler(isSearching) {
Expand All @@ -134,31 +129,15 @@ internal class HomeToolbarComposable(
tabStripContent()
}

val isSearchActive = appStore.state.searchState.isSearchActive
val showBrowserModeToggle =
shouldShowBrowserModeToggle && isSearchActive && !isSearchEmpty

if (settings.shouldUseBottomToolbar) {
SearchSuggestionsContainer(
selectedMode = browsingModeManager.mode,
showBrowserModeToggle = showBrowserModeToggle,
onModeSelected = { newMode ->
browsingModeManager.mode = newMode
},
searchSuggestionsContent = {
searchSuggestionsContent(Modifier.fillMaxSize())
},
browserModeSelectorModifier = Modifier.padding(bottom = 16.dp),
)
searchSuggestionsContent(Modifier.weight(1f))
}

Box {
if (settings.enableHomepageSearchBar) {
BrowserSimpleToolbar(toolbarStore, appStore)
}

this@Column.AnimatedVisibility(
visible = isAddressBarVisible.value || isSearchActive,
visible = isAddressBarVisible.value || appStore.state.searchState.isSearchActive,
enter = fadeIn(
animationSpec = tween(
durationMillis = 250,
Expand All @@ -173,7 +152,7 @@ internal class HomeToolbarComposable(
),
) {
val (backgroundColor, outlineColor) =
if (browsingModeManager.mode.isPrivate) {
if (browsingModeManager.mode == BrowsingMode.Private) {
MaterialTheme.colorScheme.surface to
colorResource(R.color.homepage_tab_edge_to_edge_private_toolbar_outline)
} else if (isEdgeToEdgeBackgroundEnabled && isSearchEmpty) {
Expand All @@ -190,28 +169,15 @@ internal class HomeToolbarComposable(
)
}
}

if (settings.toolbarPosition == BOTTOM) {
navigationBarContent?.invoke()
}

if (!settings.shouldUseBottomToolbar) {
SearchSuggestionsContainer(
selectedMode = browsingModeManager.mode,
showBrowserModeToggle = showBrowserModeToggle,
onModeSelected = { newMode ->
browsingModeManager.mode = newMode
},
searchSuggestionsContent = {
searchSuggestionsContent(Modifier.fillMaxSize())
},
browserModeSelectorModifier = Modifier.imePadding(),
)
searchSuggestionsContent(Modifier.weight(1f))
}
}
}
}

translationZ = context.resources.getDimension(R.dimen.browser_fragment_above_toolbar_panels_elevation)
homeBinding.homeLayout.addView(this)
}
Expand Down
Loading
Loading