mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 18:51:49 +01:00
Minor cleanup
This commit is contained in:
parent
0c860c0fe9
commit
427fbfdf5e
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,6 @@ import tachiyomi.core.util.lang.launchIO
|
||||
import tachiyomi.core.util.lang.launchNonCancellable
|
||||
import tachiyomi.core.util.lang.withUIContext
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import uy.kohesive.injekt.Injekt
|
||||
@ -183,7 +182,7 @@ class ReaderActivity : BaseActivity() {
|
||||
.map { it.manga }
|
||||
.distinctUntilChanged()
|
||||
.filterNotNull()
|
||||
.onEach(::setManga)
|
||||
.onEach { updateViewer() }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
viewModel.state
|
||||
@ -486,10 +485,9 @@ class ReaderActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the presenter when a manga is ready. Used to instantiate the appropriate viewer
|
||||
* and the toolbar title.
|
||||
* Called from the presenter when a manga is ready. Used to instantiate the appropriate viewer.
|
||||
*/
|
||||
private fun setManga(manga: Manga) {
|
||||
private fun updateViewer() {
|
||||
val prevViewer = viewModel.state.value.viewer
|
||||
val newViewer = ReadingMode.toViewer(viewModel.getMangaReadingMode(), this)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user