mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-21 20:27:06 +03:00
Add stable marker to Manga data class
Co-authored-by: ivan <12537387+ivaniskandar@users.noreply.github.com> Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
parent
2abb7be491
commit
dd17832428
12 changed files with 93 additions and 120 deletions
|
@ -427,13 +427,9 @@ private fun AnimeScreenSmallImpl(
|
|||
AnimeInfoBox(
|
||||
isTabletUi = false,
|
||||
appBarPadding = topPadding,
|
||||
title = state.anime.title,
|
||||
author = state.anime.author,
|
||||
artist = state.anime.artist,
|
||||
anime = state.anime,
|
||||
sourceName = remember { state.source.getNameForAnimeInfo() },
|
||||
isStubSource = remember { state.source is StubAnimeSource },
|
||||
coverDataProvider = { state.anime },
|
||||
status = state.anime.status,
|
||||
onCoverClick = onCoverClicked,
|
||||
doSearch = onSearch,
|
||||
)
|
||||
|
@ -708,13 +704,9 @@ fun AnimeScreenLargeImpl(
|
|||
AnimeInfoBox(
|
||||
isTabletUi = true,
|
||||
appBarPadding = contentPadding.calculateTopPadding(),
|
||||
title = state.anime.title,
|
||||
author = state.anime.author,
|
||||
artist = state.anime.artist,
|
||||
anime = state.anime,
|
||||
sourceName = remember { state.source.getNameForAnimeInfo() },
|
||||
isStubSource = remember { state.source is StubAnimeSource },
|
||||
coverDataProvider = { state.anime },
|
||||
status = state.anime.status,
|
||||
onCoverClick = onCoverClicked,
|
||||
doSearch = onSearch,
|
||||
)
|
||||
|
|
|
@ -56,7 +56,7 @@ import tachiyomi.presentation.core.util.clickableNoIndication
|
|||
|
||||
@Composable
|
||||
fun AnimeCoverDialog(
|
||||
coverDataProvider: () -> Anime,
|
||||
anime: Anime,
|
||||
isCustomCover: Boolean,
|
||||
snackbarHostState: SnackbarHostState,
|
||||
onShareClick: () -> Unit,
|
||||
|
@ -168,7 +168,7 @@ fun AnimeCoverDialog(
|
|||
},
|
||||
update = { view ->
|
||||
val request = ImageRequest.Builder(view.context)
|
||||
.data(coverDataProvider())
|
||||
.data(anime)
|
||||
.size(Size.ORIGINAL)
|
||||
.memoryCachePolicy(CachePolicy.DISABLED)
|
||||
.target { image ->
|
||||
|
|
|
@ -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.presentation.entries.components.DotSeparatorText
|
||||
import eu.kanade.presentation.entries.components.ItemCover
|
||||
|
@ -100,13 +102,9 @@ private val whitespaceLineRegex = Regex("[\\r\\n]{2,}", setOf(RegexOption.MULTIL
|
|||
fun AnimeInfoBox(
|
||||
isTabletUi: Boolean,
|
||||
appBarPadding: Dp,
|
||||
title: String,
|
||||
author: String?,
|
||||
artist: String?,
|
||||
anime: Anime,
|
||||
sourceName: String,
|
||||
isStubSource: Boolean,
|
||||
coverDataProvider: () -> Anime,
|
||||
status: Long,
|
||||
onCoverClick: () -> Unit,
|
||||
doSearch: (query: String, global: Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
|
@ -118,7 +116,10 @@ fun AnimeInfoBox(
|
|||
MaterialTheme.colorScheme.background,
|
||||
)
|
||||
AsyncImage(
|
||||
model = coverDataProvider(),
|
||||
model = ImageRequest.Builder(LocalContext.current)
|
||||
.data(anime)
|
||||
.crossfade(true)
|
||||
.build(),
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier
|
||||
|
@ -138,28 +139,20 @@ fun AnimeInfoBox(
|
|||
if (!isTabletUi) {
|
||||
AnimeAndSourceTitlesSmall(
|
||||
appBarPadding = appBarPadding,
|
||||
coverDataProvider = coverDataProvider,
|
||||
onCoverClick = onCoverClick,
|
||||
title = title,
|
||||
doSearch = doSearch,
|
||||
author = author,
|
||||
artist = artist,
|
||||
status = status,
|
||||
anime = anime,
|
||||
sourceName = sourceName,
|
||||
isStubSource = isStubSource,
|
||||
onCoverClick = onCoverClick,
|
||||
doSearch = doSearch,
|
||||
)
|
||||
} else {
|
||||
AnimeAndSourceTitlesLarge(
|
||||
appBarPadding = appBarPadding,
|
||||
coverDataProvider = coverDataProvider,
|
||||
onCoverClick = onCoverClick,
|
||||
title = title,
|
||||
doSearch = doSearch,
|
||||
author = author,
|
||||
artist = artist,
|
||||
status = status,
|
||||
anime = anime,
|
||||
sourceName = sourceName,
|
||||
isStubSource = isStubSource,
|
||||
onCoverClick = onCoverClick,
|
||||
doSearch = doSearch,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -343,15 +336,11 @@ fun ExpandableAnimeDescription(
|
|||
@Composable
|
||||
private fun AnimeAndSourceTitlesLarge(
|
||||
appBarPadding: Dp,
|
||||
coverDataProvider: () -> Anime,
|
||||
onCoverClick: () -> Unit,
|
||||
title: String,
|
||||
doSearch: (query: String, global: Boolean) -> Unit,
|
||||
author: String?,
|
||||
artist: String?,
|
||||
status: Long,
|
||||
anime: Anime,
|
||||
sourceName: String,
|
||||
isStubSource: Boolean,
|
||||
onCoverClick: () -> Unit,
|
||||
doSearch: (query: String, global: Boolean) -> Unit,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
|
@ -361,19 +350,22 @@ private fun AnimeAndSourceTitlesLarge(
|
|||
) {
|
||||
ItemCover.Book(
|
||||
modifier = Modifier.fillMaxWidth(0.65f),
|
||||
data = coverDataProvider(),
|
||||
data = ImageRequest.Builder(LocalContext.current)
|
||||
.data(anime)
|
||||
.crossfade(true)
|
||||
.build(),
|
||||
contentDescription = stringResource(MR.strings.manga_cover),
|
||||
onClick = onCoverClick,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
AnimeContentInfo(
|
||||
title = title,
|
||||
doSearch = doSearch,
|
||||
author = author,
|
||||
artist = artist,
|
||||
status = status,
|
||||
title = anime.title,
|
||||
author = anime.author,
|
||||
artist = anime.artist,
|
||||
status = anime.status,
|
||||
sourceName = sourceName,
|
||||
isStubSource = isStubSource,
|
||||
doSearch = doSearch,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
|
@ -382,15 +374,11 @@ private fun AnimeAndSourceTitlesLarge(
|
|||
@Composable
|
||||
private fun AnimeAndSourceTitlesSmall(
|
||||
appBarPadding: Dp,
|
||||
coverDataProvider: () -> Anime,
|
||||
onCoverClick: () -> Unit,
|
||||
title: String,
|
||||
doSearch: (query: String, global: Boolean) -> Unit,
|
||||
author: String?,
|
||||
artist: String?,
|
||||
status: Long,
|
||||
anime: Anime,
|
||||
sourceName: String,
|
||||
isStubSource: Boolean,
|
||||
onCoverClick: () -> Unit,
|
||||
doSearch: (query: String, global: Boolean) -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
|
@ -403,7 +391,10 @@ private fun AnimeAndSourceTitlesSmall(
|
|||
modifier = Modifier
|
||||
.sizeIn(maxWidth = 100.dp)
|
||||
.align(Alignment.Top),
|
||||
data = coverDataProvider(),
|
||||
data = ImageRequest.Builder(LocalContext.current)
|
||||
.data(anime)
|
||||
.crossfade(true)
|
||||
.build(),
|
||||
contentDescription = stringResource(MR.strings.manga_cover),
|
||||
onClick = onCoverClick,
|
||||
)
|
||||
|
@ -411,13 +402,13 @@ private fun AnimeAndSourceTitlesSmall(
|
|||
verticalArrangement = Arrangement.spacedBy(2.dp),
|
||||
) {
|
||||
AnimeContentInfo(
|
||||
title = title,
|
||||
doSearch = doSearch,
|
||||
author = author,
|
||||
artist = artist,
|
||||
status = status,
|
||||
title = anime.title,
|
||||
author = anime.author,
|
||||
artist = anime.artist,
|
||||
status = anime.status,
|
||||
sourceName = sourceName,
|
||||
isStubSource = isStubSource,
|
||||
doSearch = doSearch,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -426,12 +417,12 @@ private fun AnimeAndSourceTitlesSmall(
|
|||
@Composable
|
||||
private fun ColumnScope.AnimeContentInfo(
|
||||
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
|
||||
|
|
|
@ -397,13 +397,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 StubMangaSource },
|
||||
coverDataProvider = { state.manga },
|
||||
status = state.manga.status,
|
||||
onCoverClick = onCoverClicked,
|
||||
doSearch = onSearch,
|
||||
)
|
||||
|
@ -644,13 +640,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 StubMangaSource },
|
||||
coverDataProvider = { state.manga },
|
||||
status = state.manga.status,
|
||||
onCoverClick = onCoverClicked,
|
||||
doSearch = onSearch,
|
||||
)
|
||||
|
|
|
@ -56,7 +56,7 @@ import tachiyomi.presentation.core.util.clickableNoIndication
|
|||
|
||||
@Composable
|
||||
fun MangaCoverDialog(
|
||||
coverDataProvider: () -> Manga,
|
||||
manga: Manga,
|
||||
isCustomCover: Boolean,
|
||||
snackbarHostState: SnackbarHostState,
|
||||
onShareClick: () -> Unit,
|
||||
|
@ -168,7 +168,7 @@ fun MangaCoverDialog(
|
|||
},
|
||||
update = { view ->
|
||||
val request = ImageRequest.Builder(view.context)
|
||||
.data(coverDataProvider())
|
||||
.data(manga)
|
||||
.size(Size.ORIGINAL)
|
||||
.memoryCachePolicy(CachePolicy.DISABLED)
|
||||
.target { image ->
|
||||
|
|
|
@ -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.presentation.entries.components.DotSeparatorText
|
||||
import eu.kanade.presentation.entries.components.ItemCover
|
||||
|
@ -100,13 +102,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,
|
||||
|
@ -118,7 +116,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
|
||||
|
@ -138,28 +139,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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -342,15 +335,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
|
||||
|
@ -360,19 +349,22 @@ private fun MangaAndSourceTitlesLarge(
|
|||
) {
|
||||
ItemCover.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,
|
||||
)
|
||||
}
|
||||
|
@ -381,15 +373,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
|
||||
|
@ -402,7 +390,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,
|
||||
)
|
||||
|
@ -410,13 +401,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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -425,12 +416,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
|
||||
|
|
|
@ -277,7 +277,7 @@ class AnimeScreen(
|
|||
sm.editCover(context, it)
|
||||
}
|
||||
AnimeCoverDialog(
|
||||
coverDataProvider = { anime!! },
|
||||
anime = anime!!,
|
||||
snackbarHostState = sm.snackbarHostState,
|
||||
isCustomCover = remember(anime) { anime!!.hasCustomCover() },
|
||||
onShareClick = { sm.shareCover(context) },
|
||||
|
|
|
@ -261,7 +261,7 @@ class MangaScreen(
|
|||
sm.editCover(context, it)
|
||||
}
|
||||
MangaCoverDialog(
|
||||
coverDataProvider = { manga!! },
|
||||
manga = manga!!,
|
||||
snackbarHostState = sm.snackbarHostState,
|
||||
isCustomCover = remember(manga) { manga!!.hasCustomCover() },
|
||||
onShareClick = { sm.shareCover(context) },
|
||||
|
|
|
@ -25,6 +25,8 @@ dependencies {
|
|||
|
||||
api(libs.sqldelight.android.paging)
|
||||
|
||||
compileOnly(libs.compose.stablemarker)
|
||||
|
||||
testImplementation(libs.bundles.test)
|
||||
testImplementation(kotlinx.coroutines.test)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package tachiyomi.domain.entries.anime.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeUpdateStrategy
|
||||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||
import tachiyomi.core.common.preference.TriState
|
||||
|
@ -7,6 +8,7 @@ import java.io.Serializable
|
|||
import java.time.Instant
|
||||
import kotlin.math.pow
|
||||
|
||||
@Immutable
|
||||
data class Anime(
|
||||
val id: Long,
|
||||
val source: Long,
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package tachiyomi.domain.entries.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,
|
||||
|
|
|
@ -63,6 +63,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"
|
||||
|
||||
|
|
Loading…
Reference in a new issue