mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 06:31:52 +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.Canvas
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.BlendMode
|
import androidx.compose.ui.graphics.BlendMode
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
@ -15,14 +16,19 @@ import kotlin.math.abs
|
|||||||
fun ReaderContentOverlay(
|
fun ReaderContentOverlay(
|
||||||
@IntRange(from = -100, to = 100) brightness: Int,
|
@IntRange(from = -100, to = 100) brightness: Int,
|
||||||
@ColorInt color: Int?,
|
@ColorInt color: Int?,
|
||||||
colorBlendMode: BlendMode? = BlendMode.SrcOver,
|
colorBlendMode: BlendMode?,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
if (brightness < 0) {
|
if (brightness < 0) {
|
||||||
|
val brightnessAlpha = remember(brightness) {
|
||||||
|
abs(brightness) / 100f
|
||||||
|
}
|
||||||
|
|
||||||
Canvas(
|
Canvas(
|
||||||
modifier = Modifier
|
modifier = modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.graphicsLayer {
|
.graphicsLayer {
|
||||||
alpha = abs(brightness) / 100f
|
alpha = brightnessAlpha
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
drawRect(Color.Black)
|
drawRect(Color.Black)
|
||||||
@ -31,12 +37,12 @@ fun ReaderContentOverlay(
|
|||||||
|
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
Canvas(
|
Canvas(
|
||||||
modifier = Modifier
|
modifier = modifier
|
||||||
.fillMaxSize(),
|
.fillMaxSize(),
|
||||||
) {
|
) {
|
||||||
drawRect(
|
drawRect(
|
||||||
color = Color(color),
|
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.launchNonCancellable
|
||||||
import tachiyomi.core.util.lang.withUIContext
|
import tachiyomi.core.util.lang.withUIContext
|
||||||
import tachiyomi.core.util.system.logcat
|
import tachiyomi.core.util.system.logcat
|
||||||
import tachiyomi.domain.manga.model.Manga
|
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.presentation.core.util.collectAsState
|
import tachiyomi.presentation.core.util.collectAsState
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
@ -183,7 +182,7 @@ class ReaderActivity : BaseActivity() {
|
|||||||
.map { it.manga }
|
.map { it.manga }
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
.onEach(::setManga)
|
.onEach { updateViewer() }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
viewModel.state
|
viewModel.state
|
||||||
@ -486,10 +485,9 @@ class ReaderActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from the presenter when a manga is ready. Used to instantiate the appropriate viewer
|
* Called from the presenter when a manga is ready. Used to instantiate the appropriate viewer.
|
||||||
* and the toolbar title.
|
|
||||||
*/
|
*/
|
||||||
private fun setManga(manga: Manga) {
|
private fun updateViewer() {
|
||||||
val prevViewer = viewModel.state.value.viewer
|
val prevViewer = viewModel.state.value.viewer
|
||||||
val newViewer = ReadingMode.toViewer(viewModel.getMangaReadingMode(), this)
|
val newViewer = ReadingMode.toViewer(viewModel.getMangaReadingMode(), this)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user