Minor cleanup

(cherry picked from commit 427fbfdf5e58478bd9b6d35e3137f2a22db9fd96)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
This commit is contained in:
arkon 2023-12-03 15:56:51 -05:00 committed by Jobobby04
parent 66a04c4757
commit d6ab0143d9
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,
)
}
}

View File

@ -115,7 +115,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.domain.source.service.SourceManager
import tachiyomi.i18n.MR
import tachiyomi.i18n.sy.SYMR
@ -228,7 +227,7 @@ class ReaderActivity : BaseActivity() {
.map { it.manga }
.distinctUntilChanged()
.filterNotNull()
.onEach(::setManga)
.onEach { updateViewer() }
.launchIn(lifecycleScope)
viewModel.state
@ -799,10 +798,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)