Skip to content

Commit

Permalink
For mozilla-mobile#26444: Replace SectionHeader with HomeSectionHeade…
Browse files Browse the repository at this point in the history
…r for home sections.
  • Loading branch information
mcarare committed Aug 31, 2022
1 parent 4b1d33e commit bccec0d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import org.mozilla.fenix.wallpapers.Wallpaper
@Composable
fun HomeSectionHeader(
headerText: String,
description: String,
description: String = "",
onShowAllClick: (() -> Unit)? = null
) {
if (inComposePreview) {
Expand Down Expand Up @@ -80,7 +80,7 @@ fun HomeSectionHeader(
@Composable
private fun HomeSectionHeaderContent(
headerText: String,
description: String,
description: String = "",
showAllTextColor: Color = FirefoxTheme.colors.textAccent,
onShowAllClick: (() -> Unit)? = null,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.res.stringResource
Expand All @@ -23,7 +21,7 @@ import mozilla.components.lib.state.ext.observeAsComposableState
import org.mozilla.fenix.R
import org.mozilla.fenix.components.components
import org.mozilla.fenix.compose.ComposeViewHolder
import org.mozilla.fenix.compose.SectionHeader
import org.mozilla.fenix.compose.home.HomeSectionHeader
import org.mozilla.fenix.theme.FirefoxTheme
import org.mozilla.fenix.theme.Theme

Expand Down Expand Up @@ -82,11 +80,8 @@ private fun PocketTopics(
onCategoryClick: (PocketRecommendedStoriesCategory) -> Unit
) {
Column {
SectionHeader(
text = stringResource(R.string.pocket_stories_categories_header),
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight(align = Alignment.Top)
HomeSectionHeader(
headerText = stringResource(R.string.pocket_stories_categories_header),
)

Spacer(Modifier.height(16.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -48,7 +47,6 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
Expand Down Expand Up @@ -211,7 +209,6 @@ fun PocketSponsoredStory(
@Composable
fun PocketStories(
@PreviewParameter(PocketStoryProvider::class) stories: List<PocketStory>,
contentPadding: Dp,
onStoryShown: (PocketStory, Pair<Int, Int>) -> Unit,
onStoryClicked: (PocketStory, Pair<Int, Int>) -> Unit,
onDiscoverMoreClicked: (String) -> Unit
Expand All @@ -224,7 +221,6 @@ fun PocketStories(
val flingBehavior = EagerFlingBehavior(lazyRowState = listState)

LazyRow(
contentPadding = PaddingValues(horizontal = contentPadding),
state = listState,
flingBehavior = flingBehavior,
horizontalArrangement = Arrangement.spacedBy(8.dp)
Expand Down Expand Up @@ -441,7 +437,6 @@ private fun PocketStoriesComposablesPreview() {
Column {
PocketStories(
stories = getFakePocketStories(8),
contentPadding = 0.dp,
onStoryShown = { _, _ -> },
onStoryClicked = { _, _ -> },
onDiscoverMoreClicked = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ package org.mozilla.fenix.home.pocket
import android.view.View
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.res.dimensionResource
Expand All @@ -27,7 +24,7 @@ import mozilla.components.service.pocket.PocketStory.PocketRecommendedStory
import org.mozilla.fenix.R
import org.mozilla.fenix.components.components
import org.mozilla.fenix.compose.ComposeViewHolder
import org.mozilla.fenix.compose.SectionHeader
import org.mozilla.fenix.compose.home.HomeSectionHeader
import org.mozilla.fenix.theme.FirefoxTheme
import org.mozilla.fenix.theme.Theme

Expand Down Expand Up @@ -78,20 +75,21 @@ class PocketStoriesViewHolder(
}
}

Column(modifier = Modifier.padding(top = 72.dp)) {
SectionHeader(
text = stringResource(R.string.pocket_stories_header_1),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = horizontalPadding)
.wrapContentHeight(align = Alignment.Top)
Column(
modifier = Modifier.padding(
top = 72.dp,
start = horizontalPadding,
end = horizontalPadding
)
) {
HomeSectionHeader(
headerText = stringResource(R.string.pocket_stories_header_1),
)

Spacer(Modifier.height(16.dp))

PocketStories(
stories ?: emptyList(),
horizontalPadding,
interactor::onStoryShown,
interactor::onStoryClicked,
interactor::onDiscoverMoreClicked
Expand All @@ -105,20 +103,15 @@ class PocketStoriesViewHolder(
fun PocketStoriesViewHolderPreview() {
FirefoxTheme(theme = Theme.getTheme()) {
Column {
SectionHeader(
text = stringResource(R.string.pocket_stories_header_1),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
.wrapContentHeight(align = Alignment.Top)
HomeSectionHeader(
headerText = stringResource(R.string.pocket_stories_header_1),
)

Spacer(Modifier.height(16.dp))

@Suppress("MagicNumber")
PocketStories(
stories = getFakePocketStories(8),
contentPadding = 0.dp,
onStoryShown = { _, _ -> },
onStoryClicked = { _, _ -> },
onDiscoverMoreClicked = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ package org.mozilla.fenix.home.sessioncontrol.viewholders

import android.view.View
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.LifecycleOwner
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.ComposeViewHolder
import org.mozilla.fenix.compose.SectionHeader
import org.mozilla.fenix.compose.home.HomeSectionHeader

/**
* View holder for the "Collections" section header with the "Show all" button.
Expand All @@ -43,11 +40,8 @@ class CollectionHeaderViewHolder(
Column {
Spacer(Modifier.height(56.dp))

SectionHeader(
text = stringResource(R.string.collections_header),
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight(align = Alignment.Top),
HomeSectionHeader(
headerText = stringResource(R.string.collections_header),
)

Spacer(Modifier.height(10.dp))
Expand Down

0 comments on commit bccec0d

Please sign in to comment.