Add stable marker to Manga data class

Co-authored-by: ivan <12537387+ivaniskandar@users.noreply.github.com>
This commit is contained in:
AntsyLich 2024-09-02 21:54:53 +06:00
parent 03eb756ecb
commit 4ee31bfea5
No known key found for this signature in database
7 changed files with 48 additions and 60 deletions

View File

@ -380,13 +380,9 @@ private fun MangaScreenSmallImpl(
MangaInfoBox(
isTabletUi = false,
appBarPadding = topPadding,
title = state.manga.title,
author = state.manga.author,
artist = state.manga.artist,
manga = state.manga,
sourceName = remember { state.source.getNameForMangaInfo() },
isStubSource = remember { state.source is StubSource },
coverDataProvider = { state.manga },
status = state.manga.status,
onCoverClick = onCoverClicked,
doSearch = onSearch,
)
@ -622,13 +618,9 @@ fun MangaScreenLargeImpl(
MangaInfoBox(
isTabletUi = true,
appBarPadding = contentPadding.calculateTopPadding(),
title = state.manga.title,
author = state.manga.author,
artist = state.manga.artist,
manga = state.manga,
sourceName = remember { state.source.getNameForMangaInfo() },
isStubSource = remember { state.source is StubSource },
coverDataProvider = { state.manga },
status = state.manga.status,
onCoverClick = onCoverClicked,
doSearch = onSearch,
)

View File

@ -56,7 +56,7 @@ import tachiyomi.presentation.core.util.clickableNoIndication
@Composable
fun MangaCoverDialog(
coverDataProvider: () -> Manga,
manga: Manga,
isCustomCover: Boolean,
snackbarHostState: SnackbarHostState,
onShareClick: () -> Unit,
@ -166,7 +166,7 @@ fun MangaCoverDialog(
},
update = { view ->
val request = ImageRequest.Builder(view.context)
.data(coverDataProvider())
.data(manga)
.size(Size.ORIGINAL)
.memoryCachePolicy(CachePolicy.DISABLED)
.target { image ->

View File

@ -75,6 +75,8 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil3.compose.AsyncImage
import coil3.request.ImageRequest
import coil3.request.crossfade
import eu.kanade.presentation.components.DropdownMenu
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.model.SManga
@ -98,13 +100,9 @@ private val whitespaceLineRegex = Regex("[\\r\\n]{2,}", setOf(RegexOption.MULTIL
fun MangaInfoBox(
isTabletUi: Boolean,
appBarPadding: Dp,
title: String,
author: String?,
artist: String?,
manga: Manga,
sourceName: String,
isStubSource: Boolean,
coverDataProvider: () -> Manga,
status: Long,
onCoverClick: () -> Unit,
doSearch: (query: String, global: Boolean) -> Unit,
modifier: Modifier = Modifier,
@ -116,7 +114,10 @@ fun MangaInfoBox(
MaterialTheme.colorScheme.background,
)
AsyncImage(
model = coverDataProvider(),
model = ImageRequest.Builder(LocalContext.current)
.data(manga)
.crossfade(true)
.build(),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier
@ -136,28 +137,20 @@ fun MangaInfoBox(
if (!isTabletUi) {
MangaAndSourceTitlesSmall(
appBarPadding = appBarPadding,
coverDataProvider = coverDataProvider,
onCoverClick = onCoverClick,
title = title,
doSearch = doSearch,
author = author,
artist = artist,
status = status,
manga = manga,
sourceName = sourceName,
isStubSource = isStubSource,
onCoverClick = onCoverClick,
doSearch = doSearch,
)
} else {
MangaAndSourceTitlesLarge(
appBarPadding = appBarPadding,
coverDataProvider = coverDataProvider,
onCoverClick = onCoverClick,
title = title,
doSearch = doSearch,
author = author,
artist = artist,
status = status,
manga = manga,
sourceName = sourceName,
isStubSource = isStubSource,
onCoverClick = onCoverClick,
doSearch = doSearch,
)
}
}
@ -338,15 +331,11 @@ fun ExpandableMangaDescription(
@Composable
private fun MangaAndSourceTitlesLarge(
appBarPadding: Dp,
coverDataProvider: () -> Manga,
onCoverClick: () -> Unit,
title: String,
doSearch: (query: String, global: Boolean) -> Unit,
author: String?,
artist: String?,
status: Long,
manga: Manga,
sourceName: String,
isStubSource: Boolean,
onCoverClick: () -> Unit,
doSearch: (query: String, global: Boolean) -> Unit,
) {
Column(
modifier = Modifier
@ -356,19 +345,22 @@ private fun MangaAndSourceTitlesLarge(
) {
MangaCover.Book(
modifier = Modifier.fillMaxWidth(0.65f),
data = coverDataProvider(),
data = ImageRequest.Builder(LocalContext.current)
.data(manga)
.crossfade(true)
.build(),
contentDescription = stringResource(MR.strings.manga_cover),
onClick = onCoverClick,
)
Spacer(modifier = Modifier.height(16.dp))
MangaContentInfo(
title = title,
doSearch = doSearch,
author = author,
artist = artist,
status = status,
title = manga.title,
author = manga.author,
artist = manga.artist,
status = manga.status,
sourceName = sourceName,
isStubSource = isStubSource,
doSearch = doSearch,
textAlign = TextAlign.Center,
)
}
@ -377,15 +369,11 @@ private fun MangaAndSourceTitlesLarge(
@Composable
private fun MangaAndSourceTitlesSmall(
appBarPadding: Dp,
coverDataProvider: () -> Manga,
onCoverClick: () -> Unit,
title: String,
doSearch: (query: String, global: Boolean) -> Unit,
author: String?,
artist: String?,
status: Long,
manga: Manga,
sourceName: String,
isStubSource: Boolean,
onCoverClick: () -> Unit,
doSearch: (query: String, global: Boolean) -> Unit,
) {
Row(
modifier = Modifier
@ -398,7 +386,10 @@ private fun MangaAndSourceTitlesSmall(
modifier = Modifier
.sizeIn(maxWidth = 100.dp)
.align(Alignment.Top),
data = coverDataProvider(),
data = ImageRequest.Builder(LocalContext.current)
.data(manga)
.crossfade(true)
.build(),
contentDescription = stringResource(MR.strings.manga_cover),
onClick = onCoverClick,
)
@ -406,13 +397,13 @@ private fun MangaAndSourceTitlesSmall(
verticalArrangement = Arrangement.spacedBy(2.dp),
) {
MangaContentInfo(
title = title,
doSearch = doSearch,
author = author,
artist = artist,
status = status,
title = manga.title,
author = manga.author,
artist = manga.artist,
status = manga.status,
sourceName = sourceName,
isStubSource = isStubSource,
doSearch = doSearch,
)
}
}
@ -421,12 +412,12 @@ private fun MangaAndSourceTitlesSmall(
@Composable
private fun ColumnScope.MangaContentInfo(
title: String,
doSearch: (query: String, global: Boolean) -> Unit,
author: String?,
artist: String?,
status: Long,
sourceName: String,
isStubSource: Boolean,
doSearch: (query: String, global: Boolean) -> Unit,
textAlign: TextAlign? = LocalTextStyle.current.textAlign,
) {
val context = LocalContext.current

View File

@ -251,7 +251,7 @@ class MangaScreen(
sm.editCover(context, it)
}
MangaCoverDialog(
coverDataProvider = { manga!! },
manga = manga!!,
snackbarHostState = sm.snackbarHostState,
isCustomCover = remember(manga) { manga!!.hasCustomCover() },
onShareClick = { sm.shareCover(context) },

View File

@ -25,6 +25,8 @@ dependencies {
api(libs.sqldelight.android.paging)
compileOnly(libs.compose.stablemarker)
testImplementation(libs.bundles.test)
testImplementation(kotlinx.coroutines.test)
}

View File

@ -1,11 +1,13 @@
package tachiyomi.domain.manga.model
import androidx.compose.runtime.Immutable
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.model.UpdateStrategy
import tachiyomi.core.common.preference.TriState
import java.io.Serializable
import java.time.Instant
@Immutable
data class Manga(
val id: Long,
val source: Long,

View File

@ -64,6 +64,7 @@ insetter = "dev.chrisbanes.insetter:insetter:0.6.1"
compose-materialmotion = "io.github.fornewid:material-motion-compose-core:2.0.1"
compose-webview = "io.github.kevinnzou:compose-webview:0.33.6"
compose-grid = "io.woong.compose.grid:grid:1.2.2"
compose-stablemarker = "com.github.skydoves:compose-stable-marker:1.0.5"
swipe = "me.saket.swipe:swipe:1.3.0"