Skip to content
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

Display featured section blurred background in light mode #825

Merged
merged 1 commit into from
Feb 24, 2025
Merged
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 @@ -186,26 +186,25 @@ internal fun FeaturedSection(
val featuredPost = featuredPosts.getOrNull(page)
if (featuredPost != null) {
Box {
if (useDarkTheme) {
FeaturedSectionBackground(
modifier =
Modifier.matchParentSize().layout { measurable, constraints ->
val topPadding = contentPadding.calculateTopPadding().roundToPx()
val horizontalContentPadding =
contentPadding.calculateStartPadding(layoutDirection) +
contentPadding.calculateEndPadding(layoutDirection)
val fullWidth = constraints.maxWidth + horizontalContentPadding.roundToPx()
val placeable = measurable.measure(constraints.copy(maxWidth = fullWidth))
FeaturedSectionBackground(
modifier =
Modifier.matchParentSize().layout { measurable, constraints ->
val topPadding = contentPadding.calculateTopPadding().roundToPx()
val horizontalContentPadding =
contentPadding.calculateStartPadding(layoutDirection) +
contentPadding.calculateEndPadding(layoutDirection)
val fullWidth = constraints.maxWidth + horizontalContentPadding.roundToPx()
val placeable = measurable.measure(constraints.copy(maxWidth = fullWidth))

layout(placeable.width, placeable.height) {
placeable.place(0, topPadding.unaryMinus())
}
},
state = pagerState,
page = page,
featuredPost = featuredPost,
)
}
layout(placeable.width, placeable.height) {
placeable.place(0, topPadding.unaryMinus())
}
},
state = pagerState,
page = page,
featuredPost = featuredPost,
useDarkTheme = useDarkTheme,
)

val postWithMetadata = featuredPost.postWithMetadata
FeaturedPostItem(
Expand All @@ -231,21 +230,27 @@ private fun FeaturedSectionBackground(
state: PagerState,
page: Int,
featuredPost: FeaturedPostItem,
useDarkTheme: Boolean,
modifier: Modifier = Modifier,
) {
Box(modifier) {
val gradientOverlayModifier =
Modifier.drawWithCache {
val gradientColor = if (useDarkTheme) Color.Black else Color.White
val radialGradient =
Brush.radialGradient(
colors =
listOf(Color.Black, Color.Black.copy(alpha = 0.0f), Color.Black.copy(alpha = 0.0f)),
listOf(
gradientColor,
gradientColor.copy(alpha = 0.0f),
gradientColor.copy(alpha = 0.0f)
),
center = Offset(x = this.size.width, y = 40f)
)

val linearGradient =
Brush.verticalGradient(
colors = listOf(Color.Black, Color.Black.copy(alpha = 0.0f)),
colors = listOf(gradientColor, gradientColor.copy(alpha = 0.0f)),
)

onDrawWithContent {
Expand Down