Skip to content

Commit

Permalink
Update Headline Background Blur Effect.
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyroid committed Jun 8, 2024
1 parent ed2ecac commit 8235086
Showing 1 changed file with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.m3u.androidApp.ui.internal
package com.m3u.features.foryou.components

import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -21,14 +22,15 @@ import coil.compose.AsyncImage
import coil.request.CachePolicy
import coil.request.ImageRequest
import com.m3u.core.architecture.preferences.hiltPreferences
import com.m3u.material.transformation.BlurTransformation
import com.m3u.material.ktx.Edge
import com.m3u.material.transformation.EdgeTransparentTransformation
import com.m3u.ui.helper.LocalHelper
import com.m3u.ui.helper.Metadata
import com.m3u.ui.helper.useRailNav
import kotlin.math.roundToInt

@Composable
fun HeadlineBackground(modifier: Modifier = Modifier) {
internal fun HeadlineBackground(modifier: Modifier = Modifier) {
val context = LocalContext.current
val configuration = LocalConfiguration.current
val helper = LocalHelper.current
Expand All @@ -51,25 +53,27 @@ fun HeadlineBackground(modifier: Modifier = Modifier) {
stop = colorScheme.surface,
fraction = fraction
),
label = "scaffold-main-content-mask-color"
label = "headline-background-mask-color"
)

if (!preferences.noPictureMode) {
AsyncImage(
model = remember(url, colorScheme.background) {
model = remember(url) {
ImageRequest.Builder(context)
.data(url)
.crossfade(800)
.memoryCachePolicy(CachePolicy.DISABLED)
.transformations(
BlurTransformation(context)
EdgeTransparentTransformation(Edge.Bottom),
// BlurTransformation(context)
)
.build()
},
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.background)
.offset {
IntOffset(
x = 0,
Expand All @@ -79,14 +83,14 @@ fun HeadlineBackground(modifier: Modifier = Modifier) {
.aspectRatio(headlineAspectRatio)
.drawWithContent {
drawContent()
if (url.isNotEmpty()) {
drawRect(
color = currentMaskColor,
// size = size.copy(
// height = size.height * 0.95f
// )
)
}
// if (url.isNotEmpty()) {
// drawRect(
// color = currentMaskColor,
//// size = size.copy(
//// height = size.height * 0.95f
//// )
// )
// }
}
)
}
Expand Down

0 comments on commit 8235086

Please sign in to comment.