Minor cleanup

This commit is contained in:
arkon
2023-12-03 15:56:51 -05:00
parent 0c860c0fe9
commit 427fbfdf5e
2 changed files with 14 additions and 10 deletions

View File

@@ -5,6 +5,7 @@ import androidx.annotation.IntRange
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Color
@@ -15,14 +16,19 @@ import kotlin.math.abs
fun ReaderContentOverlay(
@IntRange(from = -100, to = 100) brightness: Int,
@ColorInt color: Int?,
colorBlendMode: BlendMode? = BlendMode.SrcOver,
colorBlendMode: BlendMode?,
modifier: Modifier = Modifier,
) {
if (brightness < 0) {
val brightnessAlpha = remember(brightness) {
abs(brightness) / 100f
}
Canvas(
modifier = Modifier
modifier = modifier
.fillMaxSize()
.graphicsLayer {
alpha = abs(brightness) / 100f
alpha = brightnessAlpha
},
) {
drawRect(Color.Black)
@@ -31,12 +37,12 @@ fun ReaderContentOverlay(
if (color != null) {
Canvas(
modifier = Modifier
modifier = modifier
.fillMaxSize(),
) {
drawRect(
color = Color(color),
blendMode = colorBlendMode,
blendMode = colorBlendMode ?: BlendMode.SrcOver,
)
}
}