This commit is contained in:
Avently
2024-10-28 22:06:34 +07:00
parent 4c99423826
commit bebc8f2bbe
2 changed files with 8 additions and 11 deletions
@@ -15,12 +15,11 @@ import androidx.compose.ui.unit.*
import chat.simplex.common.platform.appPlatform
import chat.simplex.common.ui.theme.CurrentColors
@Composable
fun Modifier.blurredBackgroundModifier(
keyboardInset: WindowInsets,
handler: AppBarHandler?,
blurRadius: State<Int>,
prefAlpha: Float,
prefAlpha: State<Float>,
keyboardCoversBar: Boolean,
onTop: Boolean,
density: Density
@@ -28,18 +27,17 @@ fun Modifier.blurredBackgroundModifier(
val graphicsLayer = handler?.graphicsLayer
val backgroundGraphicsLayer = handler?.backgroundGraphicsLayer
val backgroundGraphicsLayerSize = handler?.backgroundGraphicsLayerSize
if (!(handler != null && graphicsLayer != null && backgroundGraphicsLayer != null && blurRadius.value > 0 && prefAlpha < 1f && backgroundGraphicsLayerSize != null))
if (!(handler != null && graphicsLayer != null && backgroundGraphicsLayer != null && blurRadius.value > 0 && prefAlpha.value < 1f && backgroundGraphicsLayerSize != null))
return this
return if (appPlatform.isAndroid) {
this.androidBlurredModifier(keyboardInset, blurRadius, keyboardCoversBar, onTop, graphicsLayer, backgroundGraphicsLayer, backgroundGraphicsLayerSize, density)
this.desktopBlurredModifier(keyboardInset, blurRadius, keyboardCoversBar, onTop, graphicsLayer, backgroundGraphicsLayer, backgroundGraphicsLayerSize, density)
} else {
this.desktopBlurredModifier(keyboardInset, blurRadius, keyboardCoversBar, onTop, graphicsLayer, backgroundGraphicsLayer, backgroundGraphicsLayerSize, density)
}
}
@Composable
fun Modifier.androidBlurredModifier(
private fun Modifier.androidBlurredModifier(
keyboardInset: WindowInsets,
blurRadius: State<Int>,
keyboardCoversBar: Boolean,
@@ -88,8 +86,7 @@ fun Modifier.androidBlurredModifier(
}
}
@Composable
fun Modifier.desktopBlurredModifier(
private fun Modifier.desktopBlurredModifier(
keyboardInset: WindowInsets,
blurRadius: State<Int>,
keyboardCoversBar: Boolean,
@@ -37,7 +37,7 @@ fun DefaultTopAppBar(
} else Modifier
val themeBackgroundMix = MaterialTheme.colors.background.mixWith(MaterialTheme.colors.onBackground, 0.97f)
val prefAlpha = remember { appPrefs.inAppBarsAlpha.state }.value
val prefAlpha = remember { appPrefs.inAppBarsAlpha.state }
val handler = LocalAppBarHandler.current
val connection = LocalAppBarHandler.current?.connection
val titleText = remember(handler?.title?.value, fixedTitleText) {
@@ -56,7 +56,7 @@ fun DefaultTopAppBar(
.blurredBackgroundModifier(keyboardInset, handler, remember { appPrefs.appearanceBarsBlurRadius.state }, prefAlpha, handler?.keyboardCoversBar == true, onTop, density)
.drawWithCache {
val backgroundColor = if (title != null || fixedTitleText != null || connection == null || !onTop) {
themeBackgroundMix.copy(prefAlpha)
themeBackgroundMix.copy(prefAlpha.value)
} else {
themeBackgroundMix.copy(topTitleAlpha(false, connection))
}
@@ -81,7 +81,7 @@ fun DefaultTopAppBar(
Row(
Modifier
.graphicsLayer {
alpha = if (fixedTitleText != null) prefAlpha else topTitleAlpha(true, connection)
alpha = if (fixedTitleText != null) prefAlpha.value else topTitleAlpha(true, connection)
}
) {
Text(