diff --git a/app/src/main/java/eu/kanade/domain/items/chapter/interactor/SetReadStatus.kt b/app/src/main/java/eu/kanade/domain/items/chapter/interactor/SetReadStatus.kt index 27cea7125..e4ff2d50f 100644 --- a/app/src/main/java/eu/kanade/domain/items/chapter/interactor/SetReadStatus.kt +++ b/app/src/main/java/eu/kanade/domain/items/chapter/interactor/SetReadStatus.kt @@ -72,9 +72,9 @@ class SetReadStatus( suspend fun await(manga: Manga, read: Boolean) = await(manga.id, read) - sealed class Result { - data object Success : Result() - data object NoChapters : Result() - data class InternalError(val error: Throwable) : Result() + sealed interface Result { + data object Success : Result + data object NoChapters : Result + data class InternalError(val error: Throwable) : Result } } diff --git a/app/src/main/java/eu/kanade/domain/items/episode/interactor/SetSeenStatus.kt b/app/src/main/java/eu/kanade/domain/items/episode/interactor/SetSeenStatus.kt index fbe5cd307..ec597f154 100644 --- a/app/src/main/java/eu/kanade/domain/items/episode/interactor/SetSeenStatus.kt +++ b/app/src/main/java/eu/kanade/domain/items/episode/interactor/SetSeenStatus.kt @@ -72,9 +72,9 @@ class SetSeenStatus( suspend fun await(anime: Anime, seen: Boolean) = await(anime.id, seen) - sealed class Result { - data object Success : Result() - data object NoEpisodes : Result() - data class InternalError(val error: Throwable) : Result() + sealed interface Result { + data object Success : Result + data object NoEpisodes : Result + data class InternalError(val error: Throwable) : Result } } diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionDetailsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionDetailsScreen.kt index 3d62f9051..08fe51005 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionDetailsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionDetailsScreen.kt @@ -22,12 +22,14 @@ import androidx.compose.material.icons.outlined.HelpOutline import androidx.compose.material.icons.outlined.History import androidx.compose.material.icons.outlined.Settings import androidx.compose.material3.Button +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedButton import androidx.compose.material3.Switch import androidx.compose.material3.Text +import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -52,11 +54,9 @@ import eu.kanade.presentation.more.settings.widget.TrailingWidgetBuffer import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension -import eu.kanade.tachiyomi.ui.browse.anime.extension.details.AnimeExtensionDetailsState +import eu.kanade.tachiyomi.ui.browse.anime.extension.details.AnimeExtensionDetailsScreenModel import eu.kanade.tachiyomi.util.system.LocaleHelper import tachiyomi.presentation.core.components.ScrollbarLazyColumn -import tachiyomi.presentation.core.components.material.DIVIDER_ALPHA -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.screens.EmptyScreen @@ -64,7 +64,7 @@ import tachiyomi.presentation.core.screens.EmptyScreen @Composable fun AnimeExtensionDetailsScreen( navigateUp: () -> Unit, - state: AnimeExtensionDetailsState, + state: AnimeExtensionDetailsScreenModel.State, onClickSourcePreferences: (sourceId: Long) -> Unit, onClickWhatsNew: () -> Unit, onClickReadme: () -> Unit, @@ -313,7 +313,7 @@ private fun DetailsHeader( } } - Divider() + HorizontalDivider() } } @@ -355,11 +355,8 @@ private fun InfoText( @Composable private fun InfoDivider() { - Divider( - modifier = Modifier - .height(20.dp) - .width(1.dp), - color = MaterialTheme.colorScheme.onSurface.copy(alpha = DIVIDER_ALPHA), + VerticalDivider( + modifier = Modifier.height(20.dp), ) } diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt index be8a600a4..7e30fe9aa 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt @@ -43,7 +43,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.extension.InstallStep import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension import eu.kanade.tachiyomi.ui.browse.anime.extension.AnimeExtensionUiModel -import eu.kanade.tachiyomi.ui.browse.anime.extension.AnimeExtensionsState +import eu.kanade.tachiyomi.ui.browse.anime.extension.AnimeExtensionsScreenModel import eu.kanade.tachiyomi.util.system.LocaleHelper import tachiyomi.presentation.core.components.FastScrollLazyColumn import tachiyomi.presentation.core.components.material.PullRefresh @@ -56,7 +56,7 @@ import tachiyomi.presentation.core.util.secondaryItemAlpha @Composable fun AnimeExtensionScreen( - state: AnimeExtensionsState, + state: AnimeExtensionsScreenModel.State, contentPadding: PaddingValues, searchQuery: String?, onLongClickItem: (AnimeExtension) -> Unit, @@ -107,7 +107,7 @@ fun AnimeExtensionScreen( @Composable private fun AnimeExtensionContent( - state: AnimeExtensionsState, + state: AnimeExtensionsScreenModel.State, contentPadding: PaddingValues, onLongClickItem: (AnimeExtension) -> Unit, onClickItemCancel: (AnimeExtension) -> Unit, diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesFilterScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesFilterScreen.kt index 6f653256f..bc911027d 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesFilterScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesFilterScreen.kt @@ -12,7 +12,7 @@ import eu.kanade.presentation.browse.anime.components.BaseAnimeSourceItem import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.browse.anime.source.AnimeSourcesFilterState +import eu.kanade.tachiyomi.ui.browse.anime.source.AnimeSourcesFilterScreenModel import eu.kanade.tachiyomi.util.system.LocaleHelper import tachiyomi.domain.source.anime.model.AnimeSource import tachiyomi.presentation.core.components.FastScrollLazyColumn @@ -22,7 +22,7 @@ import tachiyomi.presentation.core.screens.EmptyScreen @Composable fun AnimeSourcesFilterScreen( navigateUp: () -> Unit, - state: AnimeSourcesFilterState.Success, + state: AnimeSourcesFilterScreenModel.State.Success, onClickLanguage: (String) -> Unit, onClickSource: (AnimeSource) -> Unit, ) { @@ -54,7 +54,7 @@ fun AnimeSourcesFilterScreen( @Composable private fun AnimeSourcesFilterContent( contentPadding: PaddingValues, - state: AnimeSourcesFilterState.Success, + state: AnimeSourcesFilterScreenModel.State.Success, onClickLanguage: (String) -> Unit, onClickSource: (AnimeSource) -> Unit, ) { diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesScreen.kt index 7a46d718c..3078c0617 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeSourcesScreen.kt @@ -192,7 +192,7 @@ fun AnimeSourceOptionsDialog( ) } -sealed class AnimeSourceUiModel { - data class Item(val source: AnimeSource) : AnimeSourceUiModel() - data class Header(val language: String) : AnimeSourceUiModel() +sealed interface AnimeSourceUiModel { + data class Item(val source: AnimeSource) : AnimeSourceUiModel + data class Header(val language: String) : AnimeSourceUiModel } diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeScreen.kt index 3758e83fe..c2e5de943 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeScreen.kt @@ -8,7 +8,7 @@ import androidx.compose.ui.Modifier import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.entries.anime.components.BaseAnimeListItem import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.browse.anime.migration.anime.MigrateAnimeState +import eu.kanade.tachiyomi.ui.browse.anime.migration.anime.MigrateAnimeScreenModel import tachiyomi.domain.entries.anime.model.Anime import tachiyomi.presentation.core.components.FastScrollLazyColumn import tachiyomi.presentation.core.components.material.Scaffold @@ -18,7 +18,7 @@ import tachiyomi.presentation.core.screens.EmptyScreen fun MigrateAnimeScreen( navigateUp: () -> Unit, title: String?, - state: MigrateAnimeState, + state: MigrateAnimeScreenModel.State, onClickItem: (Anime) -> Unit, onClickCover: (Anime) -> Unit, ) { @@ -51,7 +51,7 @@ fun MigrateAnimeScreen( @Composable private fun MigrateAnimeContent( contentPadding: PaddingValues, - state: MigrateAnimeState, + state: MigrateAnimeScreenModel.State, onClickItem: (Anime) -> Unit, onClickCover: (Anime) -> Unit, ) { diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeSourceScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeSourceScreen.kt index 7fcc638dc..76b10ba97 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/MigrateAnimeSourceScreen.kt @@ -26,7 +26,7 @@ import eu.kanade.domain.source.service.SetMigrateSorting import eu.kanade.presentation.browse.anime.components.AnimeSourceIcon import eu.kanade.presentation.browse.anime.components.BaseAnimeSourceItem import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.browse.anime.migration.sources.MigrateAnimeSourceState +import eu.kanade.tachiyomi.ui.browse.anime.migration.sources.MigrateAnimeSourceScreenModel import eu.kanade.tachiyomi.util.system.copyToClipboard import tachiyomi.domain.source.anime.model.AnimeSource import tachiyomi.presentation.core.components.Badge @@ -43,7 +43,7 @@ import tachiyomi.presentation.core.util.secondaryItemAlpha @Composable fun MigrateAnimeSourceScreen( - state: MigrateAnimeSourceState, + state: MigrateAnimeSourceScreenModel.State, contentPadding: PaddingValues, onClickItem: (AnimeSource) -> Unit, onToggleSortingDirection: () -> Unit, diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/components/GlobalAnimeSearchToolbar.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/components/GlobalAnimeSearchToolbar.kt index 108a40aa8..cf7dc4b9f 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/components/GlobalAnimeSearchToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/components/GlobalAnimeSearchToolbar.kt @@ -14,14 +14,15 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.DoneAll import androidx.compose.material.icons.outlined.FilterList import androidx.compose.material.icons.outlined.PushPin -import androidx.compose.material3.Divider import androidx.compose.material3.FilterChip import androidx.compose.material3.FilterChipDefaults +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TopAppBarScrollBehavior +import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -29,7 +30,6 @@ import androidx.compose.ui.res.stringResource import eu.kanade.presentation.components.SearchToolbar import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.browse.anime.source.globalsearch.AnimeSourceFilter -import tachiyomi.presentation.core.components.material.VerticalDivider import tachiyomi.presentation.core.components.material.padding @Composable @@ -123,6 +123,6 @@ fun GlobalAnimeSearchToolbar( ) } - Divider() + HorizontalDivider() } } diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionDetailsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionDetailsScreen.kt index 15467a96f..6beafc22f 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionDetailsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionDetailsScreen.kt @@ -23,6 +23,7 @@ import androidx.compose.material.icons.outlined.History import androidx.compose.material.icons.outlined.Settings import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -30,6 +31,7 @@ import androidx.compose.material3.OutlinedButton import androidx.compose.material3.Switch import androidx.compose.material3.Text import androidx.compose.material3.TextButton +import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -53,11 +55,9 @@ import eu.kanade.presentation.more.settings.widget.TrailingWidgetBuffer import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.extension.manga.model.MangaExtension import eu.kanade.tachiyomi.source.ConfigurableSource -import eu.kanade.tachiyomi.ui.browse.manga.extension.details.MangaExtensionDetailsState +import eu.kanade.tachiyomi.ui.browse.manga.extension.details.MangaExtensionDetailsScreenModel import eu.kanade.tachiyomi.util.system.LocaleHelper import tachiyomi.presentation.core.components.ScrollbarLazyColumn -import tachiyomi.presentation.core.components.material.DIVIDER_ALPHA -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.screens.EmptyScreen @@ -65,7 +65,7 @@ import tachiyomi.presentation.core.screens.EmptyScreen @Composable fun ExtensionDetailsScreen( navigateUp: () -> Unit, - state: MangaExtensionDetailsState, + state: MangaExtensionDetailsScreenModel.State, onClickSourcePreferences: (sourceId: Long) -> Unit, onClickWhatsNew: () -> Unit, onClickReadme: () -> Unit, @@ -314,7 +314,7 @@ private fun DetailsHeader( } } - Divider() + HorizontalDivider() } } @@ -356,11 +356,8 @@ private fun InfoText( @Composable private fun InfoDivider() { - Divider( - modifier = Modifier - .height(20.dp) - .width(1.dp), - color = MaterialTheme.colorScheme.onSurface.copy(alpha = DIVIDER_ALPHA), + VerticalDivider( + modifier = Modifier.height(20.dp), ) } diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt index cb77dc23b..6728e830b 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt @@ -43,7 +43,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.extension.InstallStep import eu.kanade.tachiyomi.extension.manga.model.MangaExtension import eu.kanade.tachiyomi.ui.browse.manga.extension.MangaExtensionUiModel -import eu.kanade.tachiyomi.ui.browse.manga.extension.MangaExtensionsState +import eu.kanade.tachiyomi.ui.browse.manga.extension.MangaExtensionsScreenModel import eu.kanade.tachiyomi.util.system.LocaleHelper import tachiyomi.presentation.core.components.FastScrollLazyColumn import tachiyomi.presentation.core.components.material.PullRefresh @@ -57,7 +57,7 @@ import tachiyomi.presentation.core.util.secondaryItemAlpha @Composable fun MangaExtensionScreen( - state: MangaExtensionsState, + state: MangaExtensionsScreenModel.State, contentPadding: PaddingValues, searchQuery: String?, onLongClickItem: (MangaExtension) -> Unit, @@ -108,7 +108,7 @@ fun MangaExtensionScreen( @Composable private fun ExtensionContent( - state: MangaExtensionsState, + state: MangaExtensionsScreenModel.State, contentPadding: PaddingValues, onLongClickItem: (MangaExtension) -> Unit, onClickItemCancel: (MangaExtension) -> Unit, diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesFilterScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesFilterScreen.kt index 5d8934887..cb1e790e0 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesFilterScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesFilterScreen.kt @@ -12,7 +12,7 @@ import eu.kanade.presentation.browse.manga.components.BaseMangaSourceItem import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.browse.manga.source.MangaSourcesFilterState +import eu.kanade.tachiyomi.ui.browse.manga.source.SourcesFilterScreenModel import eu.kanade.tachiyomi.util.system.LocaleHelper import tachiyomi.domain.source.manga.model.Source import tachiyomi.presentation.core.components.FastScrollLazyColumn @@ -22,7 +22,7 @@ import tachiyomi.presentation.core.screens.EmptyScreen @Composable fun MangaSourcesFilterScreen( navigateUp: () -> Unit, - state: MangaSourcesFilterState.Success, + state: SourcesFilterScreenModel.State.Success, onClickLanguage: (String) -> Unit, onClickSource: (Source) -> Unit, ) { @@ -54,7 +54,7 @@ fun MangaSourcesFilterScreen( @Composable private fun SourcesFilterContent( contentPadding: PaddingValues, - state: MangaSourcesFilterState.Success, + state: SourcesFilterScreenModel.State.Success, onClickLanguage: (String) -> Unit, onClickSource: (Source) -> Unit, ) { diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt index 44c820813..b0cacc91a 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaSourcesScreen.kt @@ -210,7 +210,7 @@ fun MangaSourceOptionsDialog( ) } -sealed class MangaSourceUiModel { - data class Item(val source: Source) : MangaSourceUiModel() - data class Header(val language: String) : MangaSourceUiModel() +sealed interface MangaSourceUiModel { + data class Item(val source: Source) : MangaSourceUiModel + data class Header(val language: String) : MangaSourceUiModel } diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaScreen.kt index ca27ada91..dd2d5faa7 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaScreen.kt @@ -8,7 +8,7 @@ import androidx.compose.ui.Modifier import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.entries.manga.components.BaseMangaListItem import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.browse.manga.migration.manga.MigrateMangaState +import eu.kanade.tachiyomi.ui.browse.manga.migration.manga.MigrateMangaScreenModel import tachiyomi.domain.entries.manga.model.Manga import tachiyomi.presentation.core.components.FastScrollLazyColumn import tachiyomi.presentation.core.components.material.Scaffold @@ -18,7 +18,7 @@ import tachiyomi.presentation.core.screens.EmptyScreen fun MigrateMangaScreen( navigateUp: () -> Unit, title: String?, - state: MigrateMangaState, + state: MigrateMangaScreenModel.State, onClickItem: (Manga) -> Unit, onClickCover: (Manga) -> Unit, ) { @@ -51,7 +51,7 @@ fun MigrateMangaScreen( @Composable private fun MigrateMangaContent( contentPadding: PaddingValues, - state: MigrateMangaState, + state: MigrateMangaScreenModel.State, onClickItem: (Manga) -> Unit, onClickCover: (Manga) -> Unit, ) { diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaSourceScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaSourceScreen.kt index c8f027d33..d3453a23c 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/MigrateMangaSourceScreen.kt @@ -26,7 +26,7 @@ import eu.kanade.domain.source.service.SetMigrateSorting import eu.kanade.presentation.browse.manga.components.BaseMangaSourceItem import eu.kanade.presentation.browse.manga.components.MangaSourceIcon import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.browse.manga.migration.sources.MigrateMangaSourceState +import eu.kanade.tachiyomi.ui.browse.manga.migration.sources.MigrateSourceScreenModel import eu.kanade.tachiyomi.util.system.copyToClipboard import tachiyomi.domain.source.manga.model.Source import tachiyomi.presentation.core.components.Badge @@ -43,7 +43,7 @@ import tachiyomi.presentation.core.util.secondaryItemAlpha @Composable fun MigrateMangaSourceScreen( - state: MigrateMangaSourceState, + state: MigrateSourceScreenModel.State, contentPadding: PaddingValues, onClickItem: (Source) -> Unit, onToggleSortingDirection: () -> Unit, diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/components/GlobalMangaSearchToolbar.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/components/GlobalMangaSearchToolbar.kt index 5b993be5b..a208119eb 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/components/GlobalMangaSearchToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/components/GlobalMangaSearchToolbar.kt @@ -14,14 +14,15 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.DoneAll import androidx.compose.material.icons.outlined.FilterList import androidx.compose.material.icons.outlined.PushPin -import androidx.compose.material3.Divider import androidx.compose.material3.FilterChip import androidx.compose.material3.FilterChipDefaults +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TopAppBarScrollBehavior +import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -29,7 +30,6 @@ import androidx.compose.ui.res.stringResource import eu.kanade.presentation.components.SearchToolbar import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.browse.manga.source.globalsearch.MangaSourceFilter -import tachiyomi.presentation.core.components.material.VerticalDivider import tachiyomi.presentation.core.components.material.padding @Composable @@ -123,6 +123,6 @@ fun GlobalMangaSearchToolbar( ) } - Divider() + HorizontalDivider() } } diff --git a/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt b/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt index 240c93df8..3b070402f 100644 --- a/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt @@ -10,6 +10,7 @@ import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.MoreVert +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -31,7 +32,6 @@ import androidx.compose.ui.util.fastForEachIndexed import eu.kanade.tachiyomi.R import kotlinx.coroutines.launch import tachiyomi.presentation.core.components.HorizontalPager -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.TabIndicator object TabbedDialogPaddings { @@ -87,7 +87,7 @@ fun TabbedDialog( MoreMenu(onOverflowMenuClicked, tabOverflowMenuContent, overflowIcon) } - Divider() + HorizontalDivider() HorizontalPager( modifier = Modifier.animateContentSize(), diff --git a/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt b/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt index c04791e88..837b55c1b 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/anime/AnimeScreen.kt @@ -72,7 +72,7 @@ import eu.kanade.tachiyomi.animesource.model.SAnime import eu.kanade.tachiyomi.data.download.anime.model.AnimeDownload import eu.kanade.tachiyomi.source.anime.getNameForAnimeInfo import eu.kanade.tachiyomi.ui.browse.anime.extension.details.SourcePreferencesScreen -import eu.kanade.tachiyomi.ui.entries.anime.AnimeScreenState +import eu.kanade.tachiyomi.ui.entries.anime.AnimeScreenModel import eu.kanade.tachiyomi.ui.entries.anime.EpisodeItem import eu.kanade.tachiyomi.util.lang.toRelativeString import eu.kanade.tachiyomi.util.system.copyToClipboard @@ -95,7 +95,7 @@ import java.util.concurrent.TimeUnit @Composable fun AnimeScreen( - state: AnimeScreenState.Success, + state: AnimeScreenModel.State.Success, snackbarHostState: SnackbarHostState, dateRelativeTime: Int, dateFormat: DateFormat, @@ -240,7 +240,7 @@ fun AnimeScreen( @OptIn(ExperimentalMaterial3Api::class) @Composable private fun AnimeScreenSmallImpl( - state: AnimeScreenState.Success, + state: AnimeScreenModel.State.Success, snackbarHostState: SnackbarHostState, dateRelativeTime: Int, dateFormat: DateFormat, @@ -506,7 +506,7 @@ private fun AnimeScreenSmallImpl( @OptIn(ExperimentalMaterial3Api::class) @Composable fun AnimeScreenLargeImpl( - state: AnimeScreenState.Success, + state: AnimeScreenModel.State.Success, snackbarHostState: SnackbarHostState, dateRelativeTime: Int, dateFormat: DateFormat, diff --git a/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt index 9512f5316..a6bcd0af6 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/manga/MangaScreen.kt @@ -68,7 +68,7 @@ import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.manga.getNameForMangaInfo import eu.kanade.tachiyomi.ui.browse.manga.extension.details.MangaSourcePreferencesScreen import eu.kanade.tachiyomi.ui.entries.manga.ChapterItem -import eu.kanade.tachiyomi.ui.entries.manga.MangaScreenState +import eu.kanade.tachiyomi.ui.entries.manga.MangaScreenModel import eu.kanade.tachiyomi.util.lang.toRelativeString import eu.kanade.tachiyomi.util.system.copyToClipboard import tachiyomi.domain.entries.manga.model.Manga @@ -88,7 +88,7 @@ import java.util.Date @Composable fun MangaScreen( - state: MangaScreenState.Success, + state: MangaScreenModel.State.Success, snackbarHostState: SnackbarHostState, dateRelativeTime: Int, dateFormat: DateFormat, @@ -223,7 +223,7 @@ fun MangaScreen( @Composable private fun MangaScreenSmallImpl( - state: MangaScreenState.Success, + state: MangaScreenModel.State.Success, snackbarHostState: SnackbarHostState, dateRelativeTime: Int, dateFormat: DateFormat, @@ -454,7 +454,7 @@ private fun MangaScreenSmallImpl( @Composable fun MangaScreenLargeImpl( - state: MangaScreenState.Success, + state: MangaScreenModel.State.Success, snackbarHostState: SnackbarHostState, dateRelativeTime: Int, dateFormat: DateFormat, diff --git a/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt index 25484a302..1a65c63cf 100644 --- a/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt @@ -9,7 +9,6 @@ import androidx.compose.ui.Modifier import eu.kanade.presentation.animehistory.components.AnimeHistoryContent import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.history.anime.AnimeHistoryScreenModel -import eu.kanade.tachiyomi.ui.history.anime.AnimeHistoryState import tachiyomi.domain.history.anime.model.AnimeHistoryWithRelations import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen @@ -18,7 +17,7 @@ import java.util.Date @Composable fun AnimeHistoryScreen( - state: AnimeHistoryState, + state: AnimeHistoryScreenModel.State, contentPadding: PaddingValues, searchQuery: String? = null, snackbarHostState: SnackbarHostState, @@ -55,7 +54,7 @@ fun AnimeHistoryScreen( } } -sealed class AnimeHistoryUiModel { - data class Header(val date: Date) : AnimeHistoryUiModel() - data class Item(val item: AnimeHistoryWithRelations) : AnimeHistoryUiModel() +sealed interface AnimeHistoryUiModel { + data class Header(val date: Date) : AnimeHistoryUiModel + data class Item(val item: AnimeHistoryWithRelations) : AnimeHistoryUiModel } diff --git a/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt index 8d5e73ae4..64aad4e69 100644 --- a/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt @@ -7,7 +7,6 @@ import androidx.compose.material3.SnackbarHostState import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.history.manga.HistoryState import eu.kanade.tachiyomi.ui.history.manga.MangaHistoryScreenModel import tachiyomi.domain.history.manga.model.MangaHistoryWithRelations import tachiyomi.presentation.core.components.material.Scaffold @@ -17,7 +16,7 @@ import java.util.Date @Composable fun MangaHistoryScreen( - state: HistoryState, + state: MangaHistoryScreenModel.State, contentPadding: PaddingValues, searchQuery: String? = null, snackbarHostState: SnackbarHostState, @@ -54,7 +53,7 @@ fun MangaHistoryScreen( } } -sealed class MangaHistoryUiModel { - data class Header(val date: Date) : MangaHistoryUiModel() - data class Item(val item: MangaHistoryWithRelations) : MangaHistoryUiModel() +sealed interface MangaHistoryUiModel { + data class Header(val date: Date) : MangaHistoryUiModel + data class Item(val item: MangaHistoryWithRelations) : MangaHistoryUiModel } diff --git a/app/src/main/java/eu/kanade/presentation/library/LibraryTabs.kt b/app/src/main/java/eu/kanade/presentation/library/LibraryTabs.kt index 936dfd138..6d7ff5bf8 100644 --- a/app/src/main/java/eu/kanade/presentation/library/LibraryTabs.kt +++ b/app/src/main/java/eu/kanade/presentation/library/LibraryTabs.kt @@ -2,6 +2,7 @@ package eu.kanade.presentation.library import androidx.compose.foundation.layout.Column import androidx.compose.foundation.pager.PagerState +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ScrollableTabRow import androidx.compose.material3.Tab @@ -9,7 +10,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.unit.dp import eu.kanade.presentation.category.visualName import tachiyomi.domain.category.model.Category -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.TabIndicator import tachiyomi.presentation.core.components.material.TabText @@ -44,6 +44,6 @@ fun LibraryTabs( } } - Divider() + HorizontalDivider() } } diff --git a/app/src/main/java/eu/kanade/presentation/more/LogoHeader.kt b/app/src/main/java/eu/kanade/presentation/more/LogoHeader.kt index cdcc384c0..5c34f07e3 100644 --- a/app/src/main/java/eu/kanade/presentation/more/LogoHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/more/LogoHeader.kt @@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable @@ -12,7 +13,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import eu.kanade.tachiyomi.R -import tachiyomi.presentation.core.components.material.Divider @Composable fun LogoHeader() { @@ -29,6 +29,6 @@ fun LogoHeader() { .size(64.dp), ) - Divider() + HorizontalDivider() } } diff --git a/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt b/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt index e8032a572..48e903882 100644 --- a/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/MoreScreen.kt @@ -20,6 +20,7 @@ import androidx.compose.material.icons.outlined.QueryStats import androidx.compose.material.icons.outlined.Settings import androidx.compose.material.icons.outlined.SettingsBackupRestore import androidx.compose.material.icons.outlined.Storage +import androidx.compose.material3.HorizontalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector @@ -35,7 +36,6 @@ import eu.kanade.tachiyomi.core.Constants import eu.kanade.tachiyomi.ui.more.DownloadQueueState import tachiyomi.domain.library.service.LibraryPreferences import tachiyomi.presentation.core.components.ScrollbarLazyColumn -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.Scaffold import uy.kohesive.injekt.injectLazy @@ -101,7 +101,7 @@ fun MoreScreen( ) } - item { Divider() } + item { HorizontalDivider() } val libraryPreferences: LibraryPreferences by injectLazy() @@ -182,7 +182,7 @@ fun MoreScreen( ) } - item { Divider() } + item { HorizontalDivider() } item { TextPreferenceWidget( diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceItem.kt b/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceItem.kt index a7c6bfa29..5aa1b24e9 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceItem.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceItem.kt @@ -13,8 +13,6 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.structuralEqualityPolicy import androidx.compose.ui.unit.dp import eu.kanade.domain.track.service.TrackPreferences -import eu.kanade.domain.ui.UiPreferences -import eu.kanade.presentation.more.settings.widget.AppThemePreferenceWidget import eu.kanade.presentation.more.settings.widget.EditTextPreferenceWidget import eu.kanade.presentation.more.settings.widget.InfoWidget import eu.kanade.presentation.more.settings.widget.ListPreferenceWidget @@ -173,16 +171,6 @@ internal fun PreferenceItem( singleLine = false, ) } - is Preference.PreferenceItem.AppThemePreference -> { - val value by item.pref.collectAsState() - val amoled by Injekt.get().themeDarkAmoled().collectAsState() - AppThemePreferenceWidget( - title = item.title, - value = value, - amoled = amoled, - onItemClick = { scope.launch { item.pref.set(it) } }, - ) - } is Preference.PreferenceItem.TrackingPreference -> { val uName by Injekt.get() .getString(TrackPreferences.trackUsername(item.service.id)) @@ -198,6 +186,9 @@ internal fun PreferenceItem( is Preference.PreferenceItem.InfoPreference -> { InfoWidget(text = item.title) } + is Preference.PreferenceItem.CustomPreference -> { + item.content(item) + } } } } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceModel.kt b/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceModel.kt index f72d19774..814730a35 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceModel.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceModel.kt @@ -4,7 +4,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource -import eu.kanade.domain.ui.model.AppTheme import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.track.TrackService import tachiyomi.core.preference.Preference as PreferenceData @@ -144,19 +143,6 @@ sealed class Preference { override val onValueChanged: suspend (newValue: String) -> Boolean = { true }, ) : PreferenceItem() - /** - * A [PreferenceItem] that shows previews of [AppTheme] selection. - */ - data class AppThemePreference( - val pref: PreferenceData, - override val title: String, - ) : PreferenceItem() { - override val enabled: Boolean = true - override val subtitle: String? = null - override val icon: ImageVector? = null - override val onValueChanged: suspend (newValue: AppTheme) -> Boolean = { true } - } - /** * A [PreferenceItem] for individual tracking service. */ @@ -180,6 +166,16 @@ sealed class Preference { override val icon: ImageVector? = null override val onValueChanged: suspend (newValue: String) -> Boolean = { true } } + + data class CustomPreference( + override val title: String, + val content: @Composable (PreferenceItem) -> Unit, + ) : PreferenceItem() { + override val enabled: Boolean = true + override val subtitle: String? = null + override val icon: ImageVector? = null + override val onValueChanged: suspend (newValue: String) -> Boolean = { true } + } } data class PreferenceGroup( diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt index 9a8549917..4730cf226 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt @@ -21,6 +21,7 @@ import eu.kanade.domain.ui.model.TabletUiMode import eu.kanade.domain.ui.model.ThemeMode import eu.kanade.domain.ui.model.setAppCompatDelegateThemeMode import eu.kanade.presentation.more.settings.Preference +import eu.kanade.presentation.more.settings.widget.AppThemePreferenceWidget import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.home.HomeScreen import eu.kanade.tachiyomi.util.system.LocaleHelper @@ -61,8 +62,11 @@ object SettingsAppearanceScreen : SearchableSettings { ): Preference.PreferenceGroup { val themeModePref = uiPreferences.themeMode() val themeMode by themeModePref.collectAsState() + val appThemePref = uiPreferences.appTheme() + val amoledPref = uiPreferences.themeDarkAmoled() + val amoled by amoledPref.collectAsState() LaunchedEffect(themeMode) { setAppCompatDelegateThemeMode(themeMode) @@ -93,10 +97,17 @@ object SettingsAppearanceScreen : SearchableSettings { ) }, ), - Preference.PreferenceItem.AppThemePreference( + Preference.PreferenceItem.CustomPreference( title = stringResource(R.string.pref_app_theme), - pref = appThemePref, - ), + ) { item -> + val value by appThemePref.collectAsState() + AppThemePreferenceWidget( + title = item.title, + value = value, + amoled = amoled, + onItemClick = { appThemePref.set(it) }, + ) + }, Preference.PreferenceItem.SwitchPreference( pref = amoledPref, title = stringResource(R.string.pref_dark_theme_pure_black), diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupScreen.kt index 28f7479c1..16f1e74a7 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupScreen.kt @@ -20,6 +20,7 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.AlertDialog import androidx.compose.material3.Checkbox +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextButton @@ -62,7 +63,6 @@ import tachiyomi.domain.backup.service.FLAG_HISTORY import tachiyomi.domain.backup.service.FLAG_SETTINGS import tachiyomi.domain.backup.service.FLAG_TRACK import tachiyomi.presentation.core.components.ScrollbarLazyColumn -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.util.collectAsState import tachiyomi.presentation.core.util.isScrolledToEnd import tachiyomi.presentation.core.util.isScrolledToStart @@ -197,8 +197,8 @@ object SettingsBackupScreen : SearchableSettings { } } } - if (!state.isScrolledToStart()) Divider(modifier = Modifier.align(Alignment.TopCenter)) - if (!state.isScrolledToEnd()) Divider(modifier = Modifier.align(Alignment.BottomCenter)) + if (!state.isScrolledToStart()) HorizontalDivider(modifier = Modifier.align(Alignment.TopCenter)) + if (!state.isScrolledToEnd()) HorizontalDivider(modifier = Modifier.align(Alignment.BottomCenter)) } }, dismissButton = { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt index 21a9b42e9..fa1b46043 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsSearchScreen.kt @@ -17,6 +17,7 @@ import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Close +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -53,7 +54,6 @@ import eu.kanade.presentation.components.UpIcon import eu.kanade.presentation.more.settings.Preference import eu.kanade.presentation.util.Screen import eu.kanade.tachiyomi.R -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen import tachiyomi.presentation.core.util.runOnEnterKeyPressed @@ -138,7 +138,7 @@ class SettingsSearchScreen : Screen() { } }, ) - Divider() + HorizontalDivider() } }, ) { contentPadding -> diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearAnimeDatabaseScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearAnimeDatabaseScreen.kt index f6ccaa1a1..754639de1 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearAnimeDatabaseScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearAnimeDatabaseScreen.kt @@ -15,10 +15,12 @@ import androidx.compose.material.icons.outlined.SelectAll import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button import androidx.compose.material3.Checkbox +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.rememberCoroutineScope @@ -48,7 +50,6 @@ import tachiyomi.domain.source.anime.interactor.GetAnimeSourcesWithNonLibraryAni import tachiyomi.domain.source.anime.model.AnimeSource import tachiyomi.domain.source.anime.model.AnimeSourceWithCount import tachiyomi.mi.data.AnimeDatabase -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen import tachiyomi.presentation.core.screens.LoadingScreen @@ -148,7 +149,7 @@ class ClearAnimeDatabaseScreen : Screen() { } } - Divider() + HorizontalDivider() Button( modifier = Modifier @@ -269,12 +270,15 @@ private class ClearAnimeDatabaseScreenModel : StateScreenModel, val selection: List = emptyList(), val showConfirmation: Boolean = false, - ) : State() + ) : State } } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearDatabaseScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearDatabaseScreen.kt index f278c0bb7..a1c4eb57e 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearDatabaseScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/advanced/ClearDatabaseScreen.kt @@ -15,10 +15,12 @@ import androidx.compose.material.icons.outlined.SelectAll import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button import androidx.compose.material3.Checkbox +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.rememberCoroutineScope @@ -48,7 +50,6 @@ import tachiyomi.data.Database import tachiyomi.domain.source.manga.interactor.GetMangaSourcesWithNonLibraryManga import tachiyomi.domain.source.manga.model.MangaSourceWithCount import tachiyomi.domain.source.manga.model.Source -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen import tachiyomi.presentation.core.screens.LoadingScreen @@ -148,7 +149,7 @@ class ClearDatabaseScreen : Screen() { } } - Divider() + HorizontalDivider() Button( modifier = Modifier @@ -269,12 +270,15 @@ private class ClearDatabaseScreenModel : StateScreenModel, val selection: List = emptyList(), val showConfirmation: Boolean = false, - ) : State() + ) : State } } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/AppThemePreferenceWidget.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/AppThemePreferenceWidget.kt index 60d679386..28b538215 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/AppThemePreferenceWidget.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/AppThemePreferenceWidget.kt @@ -22,6 +22,7 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.CheckCircle +import androidx.compose.material3.DividerDefaults import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface @@ -44,7 +45,6 @@ import eu.kanade.presentation.theme.TachiyomiTheme import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.DeviceUtil import eu.kanade.tachiyomi.util.system.isDynamicColorAvailable -import tachiyomi.presentation.core.components.material.DIVIDER_ALPHA import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.util.ThemePreviews import tachiyomi.presentation.core.util.secondaryItemAlpha @@ -123,7 +123,6 @@ fun AppThemePreviewItem( selected: Boolean, onClick: () -> Unit, ) { - val dividerColor = MaterialTheme.colorScheme.onSurface.copy(alpha = DIVIDER_ALPHA) Column( modifier = Modifier .fillMaxWidth() @@ -133,7 +132,7 @@ fun AppThemePreviewItem( color = if (selected) { MaterialTheme.colorScheme.primary } else { - dividerColor + DividerDefaults.color }, shape = RoundedCornerShape(17.dp), ) @@ -180,7 +179,7 @@ fun AppThemePreviewItem( modifier = Modifier .padding(start = 8.dp, top = 2.dp) .background( - color = dividerColor, + color = DividerDefaults.color, shape = MaterialTheme.shapes.small, ) .fillMaxWidth(0.5f) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt index ebc8f1bda..0742140f6 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/ListPreferenceWidget.kt @@ -8,6 +8,7 @@ import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.selection.selectable import androidx.compose.material.minimumInteractiveComponentSize import androidx.compose.material3.AlertDialog +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.RadioButton import androidx.compose.material3.Text @@ -25,7 +26,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import eu.kanade.tachiyomi.R import tachiyomi.presentation.core.components.ScrollbarLazyColumn -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.util.isScrolledToEnd import tachiyomi.presentation.core.util.isScrolledToStart @@ -69,8 +69,8 @@ fun ListPreferenceWidget( } } } - if (!state.isScrolledToStart()) Divider(modifier = Modifier.align(Alignment.TopCenter)) - if (!state.isScrolledToEnd()) Divider(modifier = Modifier.align(Alignment.BottomCenter)) + if (!state.isScrolledToStart()) HorizontalDivider(modifier = Modifier.align(Alignment.TopCenter)) + if (!state.isScrolledToEnd()) HorizontalDivider(modifier = Modifier.align(Alignment.BottomCenter)) } }, confirmButton = { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/TriStateListDialog.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/TriStateListDialog.kt index 82ababc88..87e3d7da0 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/TriStateListDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/TriStateListDialog.kt @@ -15,6 +15,7 @@ import androidx.compose.material.icons.rounded.CheckBox import androidx.compose.material.icons.rounded.CheckBoxOutlineBlank import androidx.compose.material.icons.rounded.DisabledByDefault import androidx.compose.material3.AlertDialog +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme @@ -29,7 +30,6 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import eu.kanade.tachiyomi.R -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.util.isScrolledToEnd import tachiyomi.presentation.core.util.isScrolledToStart @@ -115,8 +115,8 @@ fun TriStateListDialog( } } - if (!listState.isScrolledToStart()) Divider(modifier = Modifier.align(Alignment.TopCenter)) - if (!listState.isScrolledToEnd()) Divider(modifier = Modifier.align(Alignment.BottomCenter)) + if (!listState.isScrolledToStart()) HorizontalDivider(modifier = Modifier.align(Alignment.TopCenter)) + if (!listState.isScrolledToEnd()) HorizontalDivider(modifier = Modifier.align(Alignment.BottomCenter)) } } }, diff --git a/app/src/main/java/eu/kanade/presentation/more/stats/StatsScreenState.kt b/app/src/main/java/eu/kanade/presentation/more/stats/StatsScreenState.kt index e120cf51b..7038b71c0 100644 --- a/app/src/main/java/eu/kanade/presentation/more/stats/StatsScreenState.kt +++ b/app/src/main/java/eu/kanade/presentation/more/stats/StatsScreenState.kt @@ -3,9 +3,9 @@ package eu.kanade.presentation.more.stats import androidx.compose.runtime.Immutable import eu.kanade.presentation.more.stats.data.StatsData -sealed class StatsScreenState { +sealed interface StatsScreenState { @Immutable - data object Loading : StatsScreenState() + data object Loading : StatsScreenState @Immutable data class SuccessManga( @@ -13,7 +13,7 @@ sealed class StatsScreenState { val titles: StatsData.MangaTitles, val chapters: StatsData.Chapters, val trackers: StatsData.Trackers, - ) : StatsScreenState() + ) : StatsScreenState @Immutable data class SuccessAnime( @@ -21,5 +21,5 @@ sealed class StatsScreenState { val titles: StatsData.AnimeTitles, val episodes: StatsData.Episodes, val trackers: StatsData.Trackers, - ) : StatsScreenState() + ) : StatsScreenState } diff --git a/app/src/main/java/eu/kanade/presentation/more/stats/data/StatsData.kt b/app/src/main/java/eu/kanade/presentation/more/stats/data/StatsData.kt index 9518a73b7..47eb82191 100644 --- a/app/src/main/java/eu/kanade/presentation/more/stats/data/StatsData.kt +++ b/app/src/main/java/eu/kanade/presentation/more/stats/data/StatsData.kt @@ -1,46 +1,46 @@ package eu.kanade.presentation.more.stats.data -sealed class StatsData { +sealed interface StatsData { data class MangaOverview( val libraryMangaCount: Int, val completedMangaCount: Int, val totalReadDuration: Long, - ) : StatsData() + ) : StatsData data class AnimeOverview( val libraryAnimeCount: Int, val completedAnimeCount: Int, val totalSeenDuration: Long, - ) : StatsData() + ) : StatsData data class MangaTitles( val globalUpdateItemCount: Int, val startedMangaCount: Int, val localMangaCount: Int, - ) : StatsData() + ) : StatsData data class AnimeTitles( val globalUpdateItemCount: Int, val startedAnimeCount: Int, val localAnimeCount: Int, - ) : StatsData() + ) : StatsData data class Chapters( val totalChapterCount: Int, val readChapterCount: Int, val downloadCount: Int, - ) : StatsData() + ) : StatsData data class Episodes( val totalEpisodeCount: Int, val readEpisodeCount: Int, val downloadCount: Int, - ) : StatsData() + ) : StatsData data class Trackers( val trackedTitleCount: Int, val meanScore: Double, val trackerCount: Int, - ) : StatsData() + ) : StatsData } diff --git a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt index 4b6d76a11..862ba2ce8 100644 --- a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt +++ b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt @@ -17,6 +17,7 @@ import androidx.compose.foundation.selection.selectable import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.minimumInteractiveComponentSize import androidx.compose.material3.DatePicker +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.RadioButton import androidx.compose.material3.SelectableDates @@ -36,7 +37,6 @@ import tachiyomi.presentation.core.components.ScrollbarLazyColumn import tachiyomi.presentation.core.components.WheelNumberPicker import tachiyomi.presentation.core.components.WheelTextPicker import tachiyomi.presentation.core.components.material.AlertDialogContent -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.util.isScrolledToEnd import tachiyomi.presentation.core.util.isScrolledToStart @@ -81,8 +81,8 @@ fun TrackStatusSelector( } } } - if (!state.isScrolledToStart()) Divider(modifier = Modifier.align(Alignment.TopCenter)) - if (!state.isScrolledToEnd()) Divider(modifier = Modifier.align(Alignment.BottomCenter)) + if (!state.isScrolledToStart()) HorizontalDivider(modifier = Modifier.align(Alignment.TopCenter)) + if (!state.isScrolledToEnd()) HorizontalDivider(modifier = Modifier.align(Alignment.BottomCenter)) }, onConfirm = onConfirm, onDismissRequest = onDismissRequest, diff --git a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt index 763f729cf..fa3428ac3 100644 --- a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt +++ b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt @@ -18,9 +18,11 @@ import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextButton +import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment @@ -39,8 +41,6 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.ui.entries.anime.track.AnimeTrackItem import eu.kanade.tachiyomi.util.system.copyToClipboard -import tachiyomi.presentation.core.components.material.Divider -import tachiyomi.presentation.core.components.material.VerticalDivider import java.text.DateFormat private const val UnsetStatusTextAlpha = 0.5F @@ -200,7 +200,7 @@ private fun TrackInfoItem( } if (onStartDateClick != null && onEndDateClick != null) { - Divider() + HorizontalDivider() Row(modifier = Modifier.height(IntrinsicSize.Min)) { TrackDetailsItem( modifier = Modifier.weight(1F), diff --git a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackServiceSearch.kt b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackServiceSearch.kt index c4dbed2bf..81b2b72de 100644 --- a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackServiceSearch.kt +++ b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackServiceSearch.kt @@ -22,6 +22,7 @@ import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.filled.Close import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -45,7 +46,6 @@ import eu.kanade.presentation.track.manga.SearchResultItem import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.track.model.AnimeTrackSearch import tachiyomi.presentation.core.components.ScrollbarLazyColumn -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.screens.EmptyScreen import tachiyomi.presentation.core.screens.LoadingScreen @@ -126,7 +126,7 @@ fun AnimeTrackServiceSearch( } }, ) - Divider() + HorizontalDivider() } }, bottomBar = { diff --git a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt index 9123e819d..7d337d46e 100644 --- a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt +++ b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt @@ -24,11 +24,13 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.MoreVert import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextButton +import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -50,8 +52,6 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.ui.entries.manga.track.MangaTrackItem import eu.kanade.tachiyomi.util.system.copyToClipboard -import tachiyomi.presentation.core.components.material.Divider -import tachiyomi.presentation.core.components.material.VerticalDivider import java.text.DateFormat private const val UnsetStatusTextAlpha = 0.5F @@ -211,7 +211,7 @@ private fun TrackInfoItem( } if (onStartDateClick != null && onEndDateClick != null) { - Divider() + HorizontalDivider() Row(modifier = Modifier.height(IntrinsicSize.Min)) { TrackDetailsItem( modifier = Modifier.weight(1F), diff --git a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackServiceSearch.kt b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackServiceSearch.kt index c7cff6b0a..95dfc76a8 100644 --- a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackServiceSearch.kt +++ b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackServiceSearch.kt @@ -33,6 +33,7 @@ import androidx.compose.material.icons.filled.CheckCircle import androidx.compose.material.icons.filled.Close import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -60,7 +61,6 @@ import eu.kanade.presentation.entries.ItemCover import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.track.model.MangaTrackSearch import tachiyomi.presentation.core.components.ScrollbarLazyColumn -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.screens.EmptyScreen @@ -143,7 +143,7 @@ fun MangaTrackServiceSearch( } }, ) - Divider() + HorizontalDivider() } }, bottomBar = { diff --git a/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesScreen.kt b/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesScreen.kt index 7a2036890..2eb2b37ab 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/anime/AnimeUpdatesScreen.kt @@ -22,7 +22,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.anime.model.AnimeDownload import eu.kanade.tachiyomi.ui.player.settings.PlayerPreferences import eu.kanade.tachiyomi.ui.updates.anime.AnimeUpdatesItem -import eu.kanade.tachiyomi.ui.updates.anime.AnimeUpdatesState +import eu.kanade.tachiyomi.ui.updates.anime.AnimeUpdatesScreenModel import kotlinx.coroutines.delay import kotlinx.coroutines.launch import tachiyomi.presentation.core.components.FastScrollLazyColumn @@ -36,7 +36,7 @@ import kotlin.time.Duration.Companion.seconds @Composable fun AnimeUpdateScreen( - state: AnimeUpdatesState, + state: AnimeUpdatesScreenModel.State, snackbarHostState: SnackbarHostState, contentPadding: PaddingValues, lastUpdated: Long, @@ -158,7 +158,7 @@ private fun AnimeUpdatesBottomBar( ) } -sealed class AnimeUpdatesUiModel { - data class Header(val date: String) : AnimeUpdatesUiModel() - data class Item(val item: AnimeUpdatesItem) : AnimeUpdatesUiModel() +sealed interface AnimeUpdatesUiModel { + data class Header(val date: String) : AnimeUpdatesUiModel + data class Item(val item: AnimeUpdatesItem) : AnimeUpdatesUiModel } diff --git a/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesScreen.kt b/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesScreen.kt index a6ead88e6..47e5b2419 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/manga/MangaUpdatesScreen.kt @@ -21,7 +21,7 @@ import eu.kanade.presentation.entries.manga.components.ChapterDownloadAction import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.manga.model.MangaDownload import eu.kanade.tachiyomi.ui.updates.manga.MangaUpdatesItem -import eu.kanade.tachiyomi.ui.updates.manga.UpdatesState +import eu.kanade.tachiyomi.ui.updates.manga.MangaUpdatesScreenModel import kotlinx.coroutines.delay import kotlinx.coroutines.launch import tachiyomi.presentation.core.components.FastScrollLazyColumn @@ -33,7 +33,7 @@ import kotlin.time.Duration.Companion.seconds @Composable fun MangaUpdateScreen( - state: UpdatesState, + state: MangaUpdatesScreenModel.State, snackbarHostState: SnackbarHostState, contentPadding: PaddingValues, lastUpdated: Long, @@ -147,7 +147,7 @@ private fun MangaUpdatesBottomBar( ) } -sealed class MangaUpdatesUiModel { - data class Header(val date: String) : MangaUpdatesUiModel() - data class Item(val item: MangaUpdatesItem) : MangaUpdatesUiModel() +sealed interface MangaUpdatesUiModel { + data class Header(val date: String) : MangaUpdatesUiModel + data class Item(val item: MangaUpdatesItem) : MangaUpdatesUiModel } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt index b0ce4e3f8..9656c0fd9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt @@ -152,8 +152,8 @@ sealed class Image( } } -sealed class Location { - data class Pictures private constructor(val relativePath: String) : Location() { +sealed interface Location { + data class Pictures private constructor(val relativePath: String) : Location { companion object { fun create(relativePath: String = ""): Pictures { return Pictures(relativePath) @@ -161,7 +161,7 @@ sealed class Location { } } - data object Cache : Location() + data object Cache : Location fun directory(context: Context): File { return when (this) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/model/AnimeLoadResult.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/model/AnimeLoadResult.kt index cef80d5d9..5f1c43f05 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/model/AnimeLoadResult.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/model/AnimeLoadResult.kt @@ -1,7 +1,7 @@ package eu.kanade.tachiyomi.extension.anime.model -sealed class AnimeLoadResult { - data class Success(val extension: AnimeExtension.Installed) : AnimeLoadResult() - data class Untrusted(val extension: AnimeExtension.Untrusted) : AnimeLoadResult() - data object Error : AnimeLoadResult() +sealed interface AnimeLoadResult { + data class Success(val extension: AnimeExtension.Installed) : AnimeLoadResult + data class Untrusted(val extension: AnimeExtension.Untrusted) : AnimeLoadResult + data object Error : AnimeLoadResult } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/model/MangaLoadResult.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/model/MangaLoadResult.kt index 8c805c09a..51a68fdbe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/model/MangaLoadResult.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/model/MangaLoadResult.kt @@ -1,7 +1,7 @@ package eu.kanade.tachiyomi.extension.manga.model -sealed class MangaLoadResult { - data class Success(val extension: MangaExtension.Installed) : MangaLoadResult() - data class Untrusted(val extension: MangaExtension.Untrusted) : MangaLoadResult() - data object Error : MangaLoadResult() +sealed interface MangaLoadResult { + data class Success(val extension: MangaExtension.Installed) : MangaLoadResult + data class Untrusted(val extension: MangaExtension.Untrusted) : MangaLoadResult + data object Error : MangaLoadResult } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionFilterScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionFilterScreenModel.kt index 6858d881f..c5283ce07 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionFilterScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionFilterScreenModel.kt @@ -54,20 +54,20 @@ class AnimeExtensionFilterScreenModel( } } -sealed class AnimeExtensionFilterEvent { - data object FailedFetchingLanguages : AnimeExtensionFilterEvent() +sealed interface AnimeExtensionFilterEvent { + data object FailedFetchingLanguages : AnimeExtensionFilterEvent } -sealed class AnimeExtensionFilterState { +sealed interface AnimeExtensionFilterState { @Immutable - data object Loading : AnimeExtensionFilterState() + data object Loading : AnimeExtensionFilterState @Immutable data class Success( val languages: List, val enabledLanguages: Set = emptySet(), - ) : AnimeExtensionFilterState() { + ) : AnimeExtensionFilterState { val isEmpty: Boolean get() = languages.isEmpty() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsScreenModel.kt index 324bcc826..34d81fdfe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsScreenModel.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.browse.anime.extension import android.app.Application import androidx.annotation.StringRes +import androidx.compose.runtime.Immutable import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.coroutineScope import eu.kanade.domain.extension.anime.interactor.GetAnimeExtensionsByType @@ -35,7 +36,7 @@ class AnimeExtensionsScreenModel( preferences: SourcePreferences = Injekt.get(), private val extensionManager: AnimeExtensionManager = Injekt.get(), private val getExtensions: GetAnimeExtensionsByType = Injekt.get(), -) : StateScreenModel(AnimeExtensionsState()) { +) : StateScreenModel(State()) { private var _currentDownloads = MutableStateFlow>(hashMapOf()) @@ -189,16 +190,17 @@ class AnimeExtensionsScreenModel( fun trustSignature(signatureHash: String) { extensionManager.trustSignature(signatureHash) } -} -data class AnimeExtensionsState( - val isLoading: Boolean = true, - val isRefreshing: Boolean = false, - val items: ItemGroups = mutableMapOf(), - val updates: Int = 0, - val searchQuery: String? = null, -) { - val isEmpty = items.isEmpty() + @Immutable + data class State( + val isLoading: Boolean = true, + val isRefreshing: Boolean = false, + val items: ItemGroups = mutableMapOf(), + val updates: Int = 0, + val searchQuery: String? = null, + ) { + val isEmpty = items.isEmpty() + } } typealias ItemGroups = MutableMap> diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreenModel.kt index ac084ebc7..b64ed4867 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/details/AnimeExtensionDetailsScreenModel.kt @@ -38,7 +38,7 @@ class AnimeExtensionDetailsScreenModel( private val extensionManager: AnimeExtensionManager = Injekt.get(), private val getExtensionSources: GetAnimeExtensionSources = Injekt.get(), private val toggleSource: ToggleAnimeSource = Injekt.get(), -) : StateScreenModel(AnimeExtensionDetailsState()) { +) : StateScreenModel(State()) { private val _events: Channel = Channel() val events: Flow = _events.receiveAsFlow() @@ -160,21 +160,21 @@ class AnimeExtensionDetailsScreenModel( url + "/src/" + pkgName.replace(".", "/") + path } } + + @Immutable + data class State( + val extension: AnimeExtension.Installed? = null, + private val _sources: List? = null, + ) { + + val sources: List + get() = _sources.orEmpty() + + val isLoading: Boolean + get() = extension == null || _sources == null + } } -sealed class AnimeExtensionDetailsEvent { - data object Uninstalled : AnimeExtensionDetailsEvent() -} - -@Immutable -data class AnimeExtensionDetailsState( - val extension: AnimeExtension.Installed? = null, - private val _sources: List? = null, -) { - - val sources: List - get() = _sources.orEmpty() - - val isLoading: Boolean - get() = extension == null || _sources == null +sealed interface AnimeExtensionDetailsEvent { + data object Uninstalled : AnimeExtensionDetailsEvent } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrationAnimeScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrateAnimeScreen.kt similarity index 93% rename from app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrationAnimeScreen.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrateAnimeScreen.kt index bf8cdfee5..c61a5b2b7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrationAnimeScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrateAnimeScreen.kt @@ -17,7 +17,7 @@ import eu.kanade.tachiyomi.util.system.toast import kotlinx.coroutines.flow.collectLatest import tachiyomi.presentation.core.screens.LoadingScreen -data class MigrationAnimeScreen( +data class MigrateAnimeScreen( private val sourceId: Long, ) : Screen() { @@ -25,7 +25,7 @@ data class MigrationAnimeScreen( override fun Content() { val context = LocalContext.current val navigator = LocalNavigator.currentOrThrow - val screenModel = rememberScreenModel { MigrationAnimeScreenModel(sourceId) } + val screenModel = rememberScreenModel { MigrateAnimeScreenModel(sourceId) } val state by screenModel.state.collectAsState() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrationAnimeScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrateAnimeScreenModel.kt similarity index 78% rename from app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrationAnimeScreenModel.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrateAnimeScreenModel.kt index 0d85983a4..f334a73ac 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrationAnimeScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/anime/MigrateAnimeScreenModel.kt @@ -20,11 +20,11 @@ import tachiyomi.domain.source.anime.service.AnimeSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -class MigrationAnimeScreenModel( +class MigrateAnimeScreenModel( private val sourceId: Long, private val sourceManager: AnimeSourceManager = Injekt.get(), private val getFavorites: GetAnimeFavorites = Injekt.get(), -) : StateScreenModel(MigrateAnimeState()) { +) : StateScreenModel(State()) { private val _events: Channel = Channel() val events: Flow = _events.receiveAsFlow() @@ -51,24 +51,24 @@ class MigrationAnimeScreenModel( } } } + + @Immutable + data class State( + val source: AnimeSource? = null, + private val titleList: List? = null, + ) { + + val titles: List + get() = titleList.orEmpty() + + val isLoading: Boolean + get() = source == null || titleList == null + + val isEmpty: Boolean + get() = titles.isEmpty() + } } -sealed class MigrationAnimeEvent { - data object FailedFetchingFavorites : MigrationAnimeEvent() -} - -@Immutable -data class MigrateAnimeState( - val source: AnimeSource? = null, - private val titleList: List? = null, -) { - - val titles: List - get() = titleList.orEmpty() - - val isLoading: Boolean - get() = source == null || titleList == null - - val isEmpty: Boolean - get() = titles.isEmpty() +sealed interface MigrationAnimeEvent { + data object FailedFetchingFavorites : MigrationAnimeEvent } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/AnimeMigrateSearchScreenDialogScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/AnimeMigrateSearchScreenDialogScreenModel.kt index fda477baf..83bd3e3fc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/AnimeMigrateSearchScreenDialogScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/search/AnimeMigrateSearchScreenDialogScreenModel.kt @@ -37,7 +37,7 @@ class AnimeMigrateSearchScreenDialogScreenModel( val dialog: Dialog? = null, ) - sealed class Dialog { - data class Migrate(val anime: Anime) : Dialog() + sealed interface Dialog { + data class Migrate(val anime: Anime) : Dialog } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/sources/MigrateAnimeSourceScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/sources/MigrateAnimeSourceScreenModel.kt index 1c9763684..b975573aa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/sources/MigrateAnimeSourceScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/sources/MigrateAnimeSourceScreenModel.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.ui.browse.anime.migration.sources +import androidx.compose.runtime.Immutable import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.coroutineScope import eu.kanade.domain.source.anime.interactor.GetAnimeSourcesWithFavoriteCount @@ -23,7 +24,7 @@ class MigrateAnimeSourceScreenModel( preferences: SourcePreferences = Injekt.get(), private val getSourcesWithFavoriteCount: GetAnimeSourcesWithFavoriteCount = Injekt.get(), private val setMigrateSorting: SetMigrateSorting = Injekt.get(), -) : StateScreenModel(MigrateAnimeSourceState()) { +) : StateScreenModel(State()) { private val _channel = Channel(Int.MAX_VALUE) val channel = _channel.receiveAsFlow() @@ -76,16 +77,17 @@ class MigrateAnimeSourceScreenModel( } } - sealed class Event { - data object FailedFetchingSourcesWithCount : Event() + @Immutable + data class State( + val isLoading: Boolean = true, + val items: List> = emptyList(), + val sortingMode: SetMigrateSorting.Mode = SetMigrateSorting.Mode.ALPHABETICAL, + val sortingDirection: SetMigrateSorting.Direction = SetMigrateSorting.Direction.ASCENDING, + ) { + val isEmpty = items.isEmpty() + } + + sealed interface Event { + data object FailedFetchingSourcesWithCount : Event } } - -data class MigrateAnimeSourceState( - val isLoading: Boolean = true, - val items: List> = emptyList(), - val sortingMode: SetMigrateSorting.Mode = SetMigrateSorting.Mode.ALPHABETICAL, - val sortingDirection: SetMigrateSorting.Direction = SetMigrateSorting.Direction.ASCENDING, -) { - val isEmpty = items.isEmpty() -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/sources/MigrateAnimeSourceTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/sources/MigrateAnimeSourceTab.kt index cef1154cc..bf59b9135 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/sources/MigrateAnimeSourceTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/migration/sources/MigrateAnimeSourceTab.kt @@ -15,7 +15,7 @@ import eu.kanade.presentation.browse.anime.MigrateAnimeSourceScreen import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.TabContent import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.browse.anime.migration.anime.MigrationAnimeScreen +import eu.kanade.tachiyomi.ui.browse.anime.migration.anime.MigrateAnimeScreen @Composable fun Screen.migrateAnimeSourceTab(): TabContent { @@ -39,7 +39,9 @@ fun Screen.migrateAnimeSourceTab(): TabContent { MigrateAnimeSourceScreen( state = state, contentPadding = contentPadding, - onClickItem = { source -> navigator.push(MigrationAnimeScreen(source.id)) }, + onClickItem = { source -> + navigator.push(MigrateAnimeScreen(source.id)) + }, onToggleSortingDirection = screenModel::toggleSortingDirection, onToggleSortingMode = screenModel::toggleSortingMode, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreen.kt index adab8e96d..66b8b6261 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreen.kt @@ -22,12 +22,12 @@ class AnimeSourcesFilterScreen : Screen() { val screenModel = rememberScreenModel { AnimeSourcesFilterScreenModel() } val state by screenModel.state.collectAsState() - if (state is AnimeSourcesFilterState.Loading) { + if (state is AnimeSourcesFilterScreenModel.State.Loading) { LoadingScreen() return } - if (state is AnimeSourcesFilterState.Error) { + if (state is AnimeSourcesFilterScreenModel.State.Error) { val context = LocalContext.current LaunchedEffect(Unit) { context.toast(R.string.internal_error) @@ -36,7 +36,7 @@ class AnimeSourcesFilterScreen : Screen() { return } - val successState = state as AnimeSourcesFilterState.Success + val successState = state as AnimeSourcesFilterScreenModel.State.Success AnimeSourcesFilterScreen( navigateUp = navigator::pop, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreenModel.kt index 1e5386742..113ca7d44 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesFilterScreenModel.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.ui.browse.anime.source +import androidx.compose.runtime.Immutable import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.coroutineScope import eu.kanade.domain.source.anime.interactor.GetLanguagesWithAnimeSources @@ -21,7 +22,7 @@ class AnimeSourcesFilterScreenModel( private val getLanguagesWithSources: GetLanguagesWithAnimeSources = Injekt.get(), private val toggleSource: ToggleAnimeSource = Injekt.get(), private val toggleLanguage: ToggleLanguage = Injekt.get(), -) : StateScreenModel(AnimeSourcesFilterState.Loading) { +) : StateScreenModel(State.Loading) { init { coroutineScope.launch { @@ -32,14 +33,14 @@ class AnimeSourcesFilterScreenModel( ) { a, b, c -> Triple(a, b, c) } .catch { throwable -> mutableState.update { - AnimeSourcesFilterState.Error( + State.Error( throwable = throwable, ) } } .collectLatest { (languagesWithSources, enabledLanguages, disabledSources) -> mutableState.update { - AnimeSourcesFilterState.Success( + State.Success( items = languagesWithSources, enabledLanguages = enabledLanguages, disabledSources = disabledSources, @@ -56,23 +57,26 @@ class AnimeSourcesFilterScreenModel( fun toggleLanguage(language: String) { toggleLanguage.await(language) } -} -sealed class AnimeSourcesFilterState { + sealed interface State { - object Loading : AnimeSourcesFilterState() + @Immutable + data object Loading : State - data class Error( - val throwable: Throwable, - ) : AnimeSourcesFilterState() + @Immutable + data class Error( + val throwable: Throwable, + ) : State - data class Success( - val items: SortedMap>, - val enabledLanguages: Set, - val disabledSources: Set, - ) : AnimeSourcesFilterState() { + @Immutable + data class Success( + val items: SortedMap>, + val enabledLanguages: Set, + val disabledSources: Set, + ) : State { - val isEmpty: Boolean - get() = items.isEmpty() + val isEmpty: Boolean + get() = items.isEmpty() + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesScreenModel.kt index 2495ac6df..64f3777c5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/AnimeSourcesScreenModel.kt @@ -99,8 +99,8 @@ class AnimeSourcesScreenModel( mutableState.update { it.copy(dialog = null) } } - sealed class Event { - data object FailedFetchingSources : Event() + sealed interface Event { + data object FailedFetchingSources : Event } data class Dialog(val source: AnimeSource) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreen.kt index ecfcbf93e..733c2fde7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreen.kt @@ -14,6 +14,7 @@ import androidx.compose.material.icons.outlined.FilterList import androidx.compose.material.icons.outlined.NewReleases import androidx.compose.material3.FilterChip import androidx.compose.material3.FilterChipDefaults +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SnackbarHost @@ -57,7 +58,6 @@ import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.receiveAsFlow import tachiyomi.core.util.lang.launchIO import tachiyomi.domain.source.anime.model.StubAnimeSource -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.components.material.padding import tachiyomi.source.local.entries.anime.LocalAnimeSource @@ -192,7 +192,7 @@ data class BrowseAnimeSourceScreen( } } - Divider() + HorizontalDivider() } }, snackbarHost = { SnackbarHost(hostState = snackbarHostState) }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreenModel.kt index e7178189d..3c243f378 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/BrowseAnimeSourceScreenModel.kt @@ -373,15 +373,15 @@ class BrowseAnimeSourceScreenModel( } } - sealed class Dialog { - data object Filter : Dialog() - data class RemoveAnime(val anime: Anime) : Dialog() - data class AddDuplicateAnime(val anime: Anime, val duplicate: Anime) : Dialog() + sealed interface Dialog { + data object Filter : Dialog + data class RemoveAnime(val anime: Anime) : Dialog + data class AddDuplicateAnime(val anime: Anime, val duplicate: Anime) : Dialog data class ChangeAnimeCategory( val anime: Anime, val initialSelection: List>, - ) : Dialog() - data class Migrate(val newAnime: Anime) : Dialog() + ) : Dialog + data class Migrate(val newAnime: Anime) : Dialog } @Immutable diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/SourceFilterAnimeDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/SourceFilterAnimeDialog.kt index be4e8b42b..a8016a2b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/SourceFilterAnimeDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/browse/SourceFilterAnimeDialog.kt @@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.material3.Button -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -68,7 +68,7 @@ fun SourceFilterAnimeDialog( Text(stringResource(R.string.action_filter)) } } - Divider() + HorizontalDivider() } items(filters) { @@ -85,7 +85,7 @@ private fun FilterItem(filter: AnimeFilter<*>, onUpdate: () -> Unit) { HeadingItem(filter.name) } is AnimeFilter.Separator -> { - Divider() + HorizontalDivider() } is AnimeFilter.CheckBox -> { CheckboxItem( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/AnimeSearchScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/AnimeSearchScreenModel.kt index 2de41158a..dd5ff6ed3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/AnimeSearchScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/source/globalsearch/AnimeSearchScreenModel.kt @@ -186,16 +186,16 @@ enum class AnimeSourceFilter { PinnedOnly, } -sealed class AnimeSearchItemResult { - data object Loading : AnimeSearchItemResult() +sealed interface AnimeSearchItemResult { + data object Loading : AnimeSearchItemResult data class Error( val throwable: Throwable, - ) : AnimeSearchItemResult() + ) : AnimeSearchItemResult data class Success( val result: List, - ) : AnimeSearchItemResult() { + ) : AnimeSearchItemResult { val isEmpty: Boolean get() = result.isEmpty() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionFilterScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionFilterScreenModel.kt index 2378cd6b8..5a82a6b46 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionFilterScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionFilterScreenModel.kt @@ -54,20 +54,20 @@ class MangaExtensionFilterScreenModel( } } -sealed class MangaExtensionFilterEvent { - data object FailedFetchingLanguages : MangaExtensionFilterEvent() +sealed interface MangaExtensionFilterEvent { + data object FailedFetchingLanguages : MangaExtensionFilterEvent } -sealed class MangaExtensionFilterState { +sealed interface MangaExtensionFilterState { @Immutable - data object Loading : MangaExtensionFilterState() + data object Loading : MangaExtensionFilterState @Immutable data class Success( val languages: List, val enabledLanguages: Set = emptySet(), - ) : MangaExtensionFilterState() { + ) : MangaExtensionFilterState { val isEmpty: Boolean get() = languages.isEmpty() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsScreenModel.kt index 211942bb2..db2d49424 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsScreenModel.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.browse.manga.extension import android.app.Application import androidx.annotation.StringRes +import androidx.compose.runtime.Immutable import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.coroutineScope import eu.kanade.domain.extension.manga.interactor.GetMangaExtensionsByType @@ -35,7 +36,7 @@ class MangaExtensionsScreenModel( preferences: SourcePreferences = Injekt.get(), private val extensionManager: MangaExtensionManager = Injekt.get(), private val getExtensions: GetMangaExtensionsByType = Injekt.get(), -) : StateScreenModel(MangaExtensionsState()) { +) : StateScreenModel(State()) { private var _currentDownloads = MutableStateFlow>(hashMapOf()) @@ -191,16 +192,17 @@ class MangaExtensionsScreenModel( fun trustSignature(signatureHash: String) { extensionManager.trustSignature(signatureHash) } -} -data class MangaExtensionsState( - val isLoading: Boolean = true, - val isRefreshing: Boolean = false, - val items: ItemGroups = mutableMapOf(), - val updates: Int = 0, - val searchQuery: String? = null, -) { - val isEmpty = items.isEmpty() + @Immutable + data class State( + val isLoading: Boolean = true, + val isRefreshing: Boolean = false, + val items: ItemGroups = mutableMapOf(), + val updates: Int = 0, + val searchQuery: String? = null, + ) { + val isEmpty = items.isEmpty() + } } typealias ItemGroups = MutableMap> diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreenModel.kt index 91be7d00b..bc4f916e1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/details/MangaExtensionDetailsScreenModel.kt @@ -38,7 +38,7 @@ class MangaExtensionDetailsScreenModel( private val extensionManager: MangaExtensionManager = Injekt.get(), private val getExtensionSources: GetExtensionSources = Injekt.get(), private val toggleSource: ToggleMangaSource = Injekt.get(), -) : StateScreenModel(MangaExtensionDetailsState()) { +) : StateScreenModel(State()) { private val _events: Channel = Channel() val events: Flow = _events.receiveAsFlow() @@ -160,21 +160,21 @@ class MangaExtensionDetailsScreenModel( url + "/src/" + pkgName.replace(".", "/") + path } } + + @Immutable + data class State( + val extension: MangaExtension.Installed? = null, + private val _sources: List? = null, + ) { + + val sources: List + get() = _sources.orEmpty() + + val isLoading: Boolean + get() = extension == null || _sources == null + } } -sealed class MangaExtensionDetailsEvent { - data object Uninstalled : MangaExtensionDetailsEvent() -} - -@Immutable -data class MangaExtensionDetailsState( - val extension: MangaExtension.Installed? = null, - private val _sources: List? = null, -) { - - val sources: List - get() = _sources.orEmpty() - - val isLoading: Boolean - get() = extension == null || _sources == null +sealed interface MangaExtensionDetailsEvent { + data object Uninstalled : MangaExtensionDetailsEvent } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrationMangaScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrateMangaScreen.kt similarity index 93% rename from app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrationMangaScreen.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrateMangaScreen.kt index f45a82cb9..e1bac7d61 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrationMangaScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrateMangaScreen.kt @@ -17,7 +17,7 @@ import eu.kanade.tachiyomi.util.system.toast import kotlinx.coroutines.flow.collectLatest import tachiyomi.presentation.core.screens.LoadingScreen -data class MigrationMangaScreen( +data class MigrateMangaScreen( private val sourceId: Long, ) : Screen() { @@ -25,7 +25,7 @@ data class MigrationMangaScreen( override fun Content() { val context = LocalContext.current val navigator = LocalNavigator.currentOrThrow - val screenModel = rememberScreenModel { MigrationMangaScreenModel(sourceId) } + val screenModel = rememberScreenModel { MigrateMangaScreenModel(sourceId) } val state by screenModel.state.collectAsState() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrationMangaScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrateMangaScreenModel.kt similarity index 78% rename from app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrationMangaScreenModel.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrateMangaScreenModel.kt index aa181fb5f..2406a7ba9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrationMangaScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/manga/MigrateMangaScreenModel.kt @@ -20,11 +20,11 @@ import tachiyomi.domain.source.manga.service.MangaSourceManager import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -class MigrationMangaScreenModel( +class MigrateMangaScreenModel( private val sourceId: Long, private val sourceManager: MangaSourceManager = Injekt.get(), private val getFavorites: GetMangaFavorites = Injekt.get(), -) : StateScreenModel(MigrateMangaState()) { +) : StateScreenModel(State()) { private val _events: Channel = Channel() val events: Flow = _events.receiveAsFlow() @@ -51,24 +51,24 @@ class MigrationMangaScreenModel( } } } + + @Immutable + data class State( + val source: MangaSource? = null, + private val titleList: List? = null, + ) { + + val titles: List + get() = titleList.orEmpty() + + val isLoading: Boolean + get() = source == null || titleList == null + + val isEmpty: Boolean + get() = titles.isEmpty() + } } -sealed class MigrationMangaEvent { - data object FailedFetchingFavorites : MigrationMangaEvent() -} - -@Immutable -data class MigrateMangaState( - val source: MangaSource? = null, - private val titleList: List? = null, -) { - - val titles: List - get() = titleList.orEmpty() - - val isLoading: Boolean - get() = source == null || titleList == null - - val isEmpty: Boolean - get() = titles.isEmpty() +sealed interface MigrationMangaEvent { + data object FailedFetchingFavorites : MigrationMangaEvent } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MangaMigrateSearchScreenDialogScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MangaMigrateSearchScreenDialogScreenModel.kt index e6577b09e..fa9267434 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MangaMigrateSearchScreenDialogScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/search/MangaMigrateSearchScreenDialogScreenModel.kt @@ -37,7 +37,7 @@ class MangaMigrateSearchScreenDialogScreenModel( val dialog: Dialog? = null, ) - sealed class Dialog { - data class Migrate(val manga: Manga) : Dialog() + sealed interface Dialog { + data class Migrate(val manga: Manga) : Dialog } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/sources/MigrateMangaSourceScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/sources/MigrateMangaSourceScreenModel.kt index f3b2bcbc3..6c4c758c7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/sources/MigrateMangaSourceScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/sources/MigrateMangaSourceScreenModel.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.ui.browse.manga.migration.sources +import androidx.compose.runtime.Immutable import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.coroutineScope import eu.kanade.domain.source.manga.interactor.GetMangaSourcesWithFavoriteCount @@ -23,7 +24,7 @@ class MigrateSourceScreenModel( preferences: SourcePreferences = Injekt.get(), private val getSourcesWithFavoriteCount: GetMangaSourcesWithFavoriteCount = Injekt.get(), private val setMigrateSorting: SetMigrateSorting = Injekt.get(), -) : StateScreenModel(MigrateMangaSourceState()) { +) : StateScreenModel(State()) { private val _channel = Channel(Int.MAX_VALUE) val channel = _channel.receiveAsFlow() @@ -76,16 +77,17 @@ class MigrateSourceScreenModel( } } - sealed class Event { - data object FailedFetchingSourcesWithCount : Event() + @Immutable + data class State( + val isLoading: Boolean = true, + val items: List> = emptyList(), + val sortingMode: SetMigrateSorting.Mode = SetMigrateSorting.Mode.ALPHABETICAL, + val sortingDirection: SetMigrateSorting.Direction = SetMigrateSorting.Direction.ASCENDING, + ) { + val isEmpty = items.isEmpty() + } + + sealed interface Event { + data object FailedFetchingSourcesWithCount : Event } } - -data class MigrateMangaSourceState( - val isLoading: Boolean = true, - val items: List> = emptyList(), - val sortingMode: SetMigrateSorting.Mode = SetMigrateSorting.Mode.ALPHABETICAL, - val sortingDirection: SetMigrateSorting.Direction = SetMigrateSorting.Direction.ASCENDING, -) { - val isEmpty = items.isEmpty() -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/sources/MigrateMangaSourceTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/sources/MigrateMangaSourceTab.kt index fa5f6dac2..7c1319d48 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/sources/MigrateMangaSourceTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/migration/sources/MigrateMangaSourceTab.kt @@ -15,7 +15,7 @@ import eu.kanade.presentation.browse.manga.MigrateMangaSourceScreen import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.TabContent import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.browse.manga.migration.manga.MigrationMangaScreen +import eu.kanade.tachiyomi.ui.browse.manga.migration.manga.MigrateMangaScreen @Composable fun Screen.migrateMangaSourceTab(): TabContent { @@ -40,7 +40,7 @@ fun Screen.migrateMangaSourceTab(): TabContent { state = state, contentPadding = contentPadding, onClickItem = { source -> - navigator.push(MigrationMangaScreen(source.id)) + navigator.push(MigrateMangaScreen(source.id)) }, onToggleSortingDirection = screenModel::toggleSortingDirection, onToggleSortingMode = screenModel::toggleSortingMode, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreen.kt index 5c36d8655..cf7179d83 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreen.kt @@ -22,12 +22,12 @@ class MangaSourcesFilterScreen : Screen() { val screenModel = rememberScreenModel { SourcesFilterScreenModel() } val state by screenModel.state.collectAsState() - if (state is MangaSourcesFilterState.Loading) { + if (state is SourcesFilterScreenModel.State.Loading) { LoadingScreen() return } - if (state is MangaSourcesFilterState.Error) { + if (state is SourcesFilterScreenModel.State.Error) { val context = LocalContext.current LaunchedEffect(Unit) { context.toast(R.string.internal_error) @@ -36,7 +36,7 @@ class MangaSourcesFilterScreen : Screen() { return } - val successState = state as MangaSourcesFilterState.Success + val successState = state as SourcesFilterScreenModel.State.Success MangaSourcesFilterScreen( navigateUp = navigator::pop, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreenModel.kt index 28ce3221c..b1a5b865f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesFilterScreenModel.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.ui.browse.manga.source +import androidx.compose.runtime.Immutable import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.coroutineScope import eu.kanade.domain.source.manga.interactor.GetLanguagesWithMangaSources @@ -21,7 +22,7 @@ class SourcesFilterScreenModel( private val getLanguagesWithSources: GetLanguagesWithMangaSources = Injekt.get(), private val toggleSource: ToggleMangaSource = Injekt.get(), private val toggleLanguage: ToggleLanguage = Injekt.get(), -) : StateScreenModel(MangaSourcesFilterState.Loading) { +) : StateScreenModel(State.Loading) { init { coroutineScope.launch { @@ -32,14 +33,14 @@ class SourcesFilterScreenModel( ) { a, b, c -> Triple(a, b, c) } .catch { throwable -> mutableState.update { - MangaSourcesFilterState.Error( + State.Error( throwable = throwable, ) } } .collectLatest { (languagesWithSources, enabledLanguages, disabledSources) -> mutableState.update { - MangaSourcesFilterState.Success( + State.Success( items = languagesWithSources, enabledLanguages = enabledLanguages, disabledSources = disabledSources, @@ -56,23 +57,26 @@ class SourcesFilterScreenModel( fun toggleLanguage(language: String) { toggleLanguage.await(language) } -} -sealed class MangaSourcesFilterState { + sealed interface State { - object Loading : MangaSourcesFilterState() + @Immutable + data object Loading : State - data class Error( - val throwable: Throwable, - ) : MangaSourcesFilterState() + @Immutable + data class Error( + val throwable: Throwable, + ) : State - data class Success( - val items: SortedMap>, - val enabledLanguages: Set, - val disabledSources: Set, - ) : MangaSourcesFilterState() { + @Immutable + data class Success( + val items: SortedMap>, + val enabledLanguages: Set, + val disabledSources: Set, + ) : State { - val isEmpty: Boolean - get() = items.isEmpty() + val isEmpty: Boolean + get() = items.isEmpty() + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt index 04bc7d172..13b14bfcd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/MangaSourcesScreenModel.kt @@ -123,8 +123,8 @@ class MangaSourcesScreenModel( mutableState.update { it.copy(dialog = null) } } - sealed class Event { - data object FailedFetchingSources : Event() + sealed interface Event { + data object FailedFetchingSources : Event } data class Dialog(val source: Source) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreen.kt index b5e6304b8..8722a2bb4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreen.kt @@ -14,6 +14,7 @@ import androidx.compose.material.icons.outlined.FilterList import androidx.compose.material.icons.outlined.NewReleases import androidx.compose.material3.FilterChip import androidx.compose.material3.FilterChipDefaults +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SnackbarHost @@ -57,7 +58,6 @@ import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.receiveAsFlow import tachiyomi.core.util.lang.launchIO import tachiyomi.domain.source.manga.model.StubMangaSource -import tachiyomi.presentation.core.components.material.Divider import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.components.material.padding import tachiyomi.source.local.entries.manga.LocalMangaSource @@ -192,7 +192,7 @@ data class BrowseMangaSourceScreen( } } - Divider() + HorizontalDivider() } }, snackbarHost = { SnackbarHost(hostState = snackbarHostState) }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreenModel.kt index ef6c3faf3..c3c6ffb80 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/BrowseMangaSourceScreenModel.kt @@ -367,15 +367,15 @@ class BrowseMangaSourceScreenModel( } } - sealed class Dialog { - data object Filter : Dialog() - data class RemoveManga(val manga: Manga) : Dialog() - data class AddDuplicateManga(val manga: Manga, val duplicate: Manga) : Dialog() + sealed interface Dialog { + data object Filter : Dialog + data class RemoveManga(val manga: Manga) : Dialog + data class AddDuplicateManga(val manga: Manga, val duplicate: Manga) : Dialog data class ChangeMangaCategory( val manga: Manga, val initialSelection: List>, - ) : Dialog() - data class Migrate(val newManga: Manga) : Dialog() + ) : Dialog + data class Migrate(val newManga: Manga) : Dialog } @Immutable diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/SourceFilterMangaDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/SourceFilterMangaDialog.kt index 93c4f758c..120af68e8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/SourceFilterMangaDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/browse/SourceFilterMangaDialog.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -28,7 +29,6 @@ import tachiyomi.presentation.core.components.SortItem import tachiyomi.presentation.core.components.TextItem import tachiyomi.presentation.core.components.TriStateItem import tachiyomi.presentation.core.components.material.Button -import tachiyomi.presentation.core.components.material.Divider @Composable fun SourceFilterMangaDialog( @@ -68,7 +68,7 @@ fun SourceFilterMangaDialog( Text(stringResource(R.string.action_filter)) } } - Divider() + HorizontalDivider() } items(filters) { @@ -85,7 +85,7 @@ private fun FilterItem(filter: Filter<*>, onUpdate: () -> Unit) { HeadingItem(filter.name) } is Filter.Separator -> { - Divider() + HorizontalDivider() } is Filter.CheckBox -> { CheckboxItem( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/MangaSearchScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/MangaSearchScreenModel.kt index dfdedbea6..101f5cc82 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/MangaSearchScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/source/globalsearch/MangaSearchScreenModel.kt @@ -186,16 +186,16 @@ enum class MangaSourceFilter { PinnedOnly, } -sealed class MangaSearchItemResult { - data object Loading : MangaSearchItemResult() +sealed interface MangaSearchItemResult { + data object Loading : MangaSearchItemResult data class Error( val throwable: Throwable, - ) : MangaSearchItemResult() + ) : MangaSearchItemResult data class Success( val result: List, - ) : MangaSearchItemResult() { + ) : MangaSearchItemResult { val isEmpty: Boolean get() = result.isEmpty() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/anime/AnimeCategoryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/anime/AnimeCategoryScreenModel.kt index fdca78633..5d091033c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/anime/AnimeCategoryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/anime/AnimeCategoryScreenModel.kt @@ -130,27 +130,27 @@ class AnimeCategoryScreenModel( } } -sealed class AnimeCategoryDialog { - data object Create : AnimeCategoryDialog() - data class Rename(val category: Category) : AnimeCategoryDialog() - data class Delete(val category: Category) : AnimeCategoryDialog() +sealed interface AnimeCategoryDialog { + data object Create : AnimeCategoryDialog + data class Rename(val category: Category) : AnimeCategoryDialog + data class Delete(val category: Category) : AnimeCategoryDialog } -sealed class AnimeCategoryEvent { - sealed class LocalizedMessage(@StringRes val stringRes: Int) : AnimeCategoryEvent() +sealed interface AnimeCategoryEvent { + sealed class LocalizedMessage(@StringRes val stringRes: Int) : AnimeCategoryEvent data object InternalError : LocalizedMessage(R.string.internal_error) } -sealed class AnimeCategoryScreenState { +sealed interface AnimeCategoryScreenState { @Immutable - data object Loading : AnimeCategoryScreenState() + data object Loading : AnimeCategoryScreenState @Immutable data class Success( val categories: List, val dialog: AnimeCategoryDialog? = null, - ) : AnimeCategoryScreenState() { + ) : AnimeCategoryScreenState { val isEmpty: Boolean get() = categories.isEmpty() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/manga/MangaCategoryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/manga/MangaCategoryScreenModel.kt index 4a6799124..f0de34ed5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/manga/MangaCategoryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/manga/MangaCategoryScreenModel.kt @@ -130,27 +130,27 @@ class MangaCategoryScreenModel( } } -sealed class MangaCategoryDialog { - data object Create : MangaCategoryDialog() - data class Rename(val category: Category) : MangaCategoryDialog() - data class Delete(val category: Category) : MangaCategoryDialog() +sealed interface MangaCategoryDialog { + data object Create : MangaCategoryDialog + data class Rename(val category: Category) : MangaCategoryDialog + data class Delete(val category: Category) : MangaCategoryDialog } -sealed class MangaCategoryEvent { - sealed class LocalizedMessage(@StringRes val stringRes: Int) : MangaCategoryEvent() +sealed interface MangaCategoryEvent { + sealed class LocalizedMessage(@StringRes val stringRes: Int) : MangaCategoryEvent data object InternalError : LocalizedMessage(R.string.internal_error) } -sealed class MangaCategoryScreenState { +sealed interface MangaCategoryScreenState { @Immutable - data object Loading : MangaCategoryScreenState() + data object Loading : MangaCategoryScreenState @Immutable data class Success( val categories: List, val dialog: MangaCategoryDialog? = null, - ) : MangaCategoryScreenState() { + ) : MangaCategoryScreenState { val isEmpty: Boolean get() = categories.isEmpty() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt index 8e0db8d95..0fbdb780b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreen.kt @@ -81,12 +81,12 @@ class AnimeScreen( val state by screenModel.state.collectAsState() - if (state is AnimeScreenState.Loading) { + if (state is AnimeScreenModel.State.Loading) { LoadingScreen() return } - val successState = state as AnimeScreenState.Success + val successState = state as AnimeScreenModel.State.Success val isAnimeHttpSource = remember { successState.source is AnimeHttpSource } LaunchedEffect(successState.anime, screenModel.source) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreenModel.kt index c37e968df..8508bbaac 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/anime/AnimeScreenModel.kt @@ -105,10 +105,10 @@ class AnimeScreenModel( private val setAnimeCategories: SetAnimeCategories = Injekt.get(), internal val setAnimeViewerFlags: SetAnimeViewerFlags = Injekt.get(), val snackbarHostState: SnackbarHostState = SnackbarHostState(), -) : StateScreenModel(AnimeScreenState.Loading) { +) : StateScreenModel(State.Loading) { - private val successState: AnimeScreenState.Success? - get() = state.value as? AnimeScreenState.Success + private val successState: State.Success? + get() = state.value as? State.Success private val loggedServices by lazy { trackManager.services.filter { it.isLogged && it is AnimeTrackService } } @@ -145,11 +145,11 @@ class AnimeScreenModel( /** * Helper function to update the UI state only if it's currently in success state */ - private inline fun updateSuccessState(func: (AnimeScreenState.Success) -> AnimeScreenState.Success) { + private inline fun updateSuccessState(func: (State.Success) -> State.Success) { mutableState.update { when (it) { - AnimeScreenState.Loading -> it - is AnimeScreenState.Success -> func(it) + State.Loading -> it + is State.Success -> func(it) } } } @@ -187,7 +187,7 @@ class AnimeScreenModel( // Show what we have earlier mutableState.update { - AnimeScreenState.Success( + State.Success( anime = anime, source = Injekt.get().getOrStub(anime.source), isFromSource = isFromSource, @@ -351,8 +351,7 @@ class AnimeScreenModel( } fun promptChangeCategories() { - val state = successState ?: return - val anime = state.anime + val anime = successState?.anime ?: return coroutineScope.launch { val categories = getCategories() val selection = getAnimeCategoryIds(anime) @@ -685,9 +684,9 @@ class AnimeScreenModel( } fun markPreviousEpisodeSeen(pointer: Episode) { - val successState = successState ?: return + val anime = successState?.anime ?: return val episodes = processedEpisodes.orEmpty().map { it.episode }.toList() - val prevEpisodes = if (successState.anime.sortDescending()) episodes.asReversed() else episodes + val prevEpisodes = if (anime.sortDescending()) episodes.asReversed() else episodes val pointerPos = prevEpisodes.indexOf(pointer) if (pointerPos != -1) markEpisodesSeen(prevEpisodes.take(pointerPos), true) } @@ -969,15 +968,15 @@ class AnimeScreenModel( // Track sheet - end - sealed class Dialog { - data class ChangeCategory(val anime: Anime, val initialSelection: List>) : Dialog() - data class DeleteEpisodes(val episodes: List) : Dialog() - data class DuplicateAnime(val anime: Anime, val duplicate: Anime) : Dialog() - data class ShowQualities(val episode: Episode, val anime: Anime, val source: AnimeSource) : Dialog() - data object ChangeAnimeSkipIntro : Dialog() - data object SettingsSheet : Dialog() - data object TrackSheet : Dialog() - data object FullCover : Dialog() + sealed interface Dialog { + data class ChangeCategory(val anime: Anime, val initialSelection: List>) : Dialog + data class DeleteEpisodes(val episodes: List) : Dialog + data class DuplicateAnime(val anime: Anime, val duplicate: Anime) : Dialog + data class ShowQualities(val episode: Episode, val anime: Anime, val source: AnimeSource) : Dialog + data object ChangeAnimeSkipIntro : Dialog + data object SettingsSheet : Dialog + data object TrackSheet : Dialog + data object FullCover : Dialog } fun dismissDialog() { @@ -1007,55 +1006,60 @@ class AnimeScreenModel( private fun showQualitiesDialog(episode: Episode) { updateSuccessState { it.copy(dialog = Dialog.ShowQualities(episode, it.anime, it.source)) } } -} -sealed class AnimeScreenState { - @Immutable - object Loading : AnimeScreenState() + sealed interface State { + @Immutable + object Loading : State - @Immutable - data class Success( - val anime: Anime, - val source: AnimeSource, - val isFromSource: Boolean, - val episodes: List, - val trackItems: List = emptyList(), - val isRefreshingData: Boolean = false, - val dialog: AnimeScreenModel.Dialog? = null, - val hasPromptedToAddBefore: Boolean = false, - val nextAiringEpisode: Pair = Pair(anime.nextEpisodeToAir, anime.nextEpisodeAiringAt), - ) : AnimeScreenState() { + @Immutable + data class Success( + val anime: Anime, + val source: AnimeSource, + val isFromSource: Boolean, + val episodes: List, + val trackItems: List = emptyList(), + val isRefreshingData: Boolean = false, + val dialog: Dialog? = null, + val hasPromptedToAddBefore: Boolean = false, + val nextAiringEpisode: Pair = Pair(anime.nextEpisodeToAir, anime.nextEpisodeAiringAt), + ) : State { - val processedEpisodes by lazy { - episodes.applyFilters(anime).toList() - } + val processedEpisodes by lazy { + episodes.applyFilters(anime).toList() + } - val trackingAvailable: Boolean - get() = trackItems.isNotEmpty() + val trackingAvailable: Boolean + get() = trackItems.isNotEmpty() - val trackingCount: Int - get() = trackItems.count { it.track != null } + val trackingCount: Int + get() = trackItems.count { it.track != null } - val airingEpisodeNumber: Double - get() = nextAiringEpisode.first.toDouble() + val airingEpisodeNumber: Double + get() = nextAiringEpisode.first.toDouble() - val airingTime: Long - get() = nextAiringEpisode.second.times(1000L).minus(Calendar.getInstance().timeInMillis) + val airingTime: Long + get() = nextAiringEpisode.second.times(1000L).minus(Calendar.getInstance().timeInMillis) - /** - * Applies the view filters to the list of episodes obtained from the database. - * @return an observable of the list of episodes filtered and sorted. - */ - private fun List.applyFilters(anime: Anime): Sequence { - val isLocalAnime = anime.isLocal() - val unseenFilter = anime.unseenFilter - val downloadedFilter = anime.downloadedFilter - val bookmarkedFilter = anime.bookmarkedFilter - return asSequence() - .filter { (episode) -> applyFilter(unseenFilter) { !episode.seen } } - .filter { (episode) -> applyFilter(bookmarkedFilter) { episode.bookmark } } - .filter { applyFilter(downloadedFilter) { it.isDownloaded || isLocalAnime } } - .sortedWith { (episode1), (episode2) -> getEpisodeSort(anime).invoke(episode1, episode2) } + /** + * Applies the view filters to the list of episodes obtained from the database. + * @return an observable of the list of episodes filtered and sorted. + */ + private fun List.applyFilters(anime: Anime): Sequence { + val isLocalAnime = anime.isLocal() + val unseenFilter = anime.unseenFilter + val downloadedFilter = anime.downloadedFilter + val bookmarkedFilter = anime.bookmarkedFilter + return asSequence() + .filter { (episode) -> applyFilter(unseenFilter) { !episode.seen } } + .filter { (episode) -> applyFilter(bookmarkedFilter) { episode.bookmark } } + .filter { applyFilter(downloadedFilter) { it.isDownloaded || isLocalAnime } } + .sortedWith { (episode1), (episode2) -> + getEpisodeSort(anime).invoke( + episode1, + episode2, + ) + } + } } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt index b56e6ba94..f80fb4fd5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreen.kt @@ -76,12 +76,12 @@ class MangaScreen( val state by screenModel.state.collectAsState() - if (state is MangaScreenState.Loading) { + if (state is MangaScreenModel.State.Loading) { LoadingScreen() return } - val successState = state as MangaScreenState.Success + val successState = state as MangaScreenModel.State.Success val isHttpSource = remember { successState.source is HttpSource } LaunchedEffect(successState.manga, screenModel.source) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreenModel.kt index 224f692b2..4cbb17fd0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/entries/manga/MangaScreenModel.kt @@ -100,10 +100,10 @@ class MangaScreenModel( private val getTracks: GetMangaTracks = Injekt.get(), private val setMangaCategories: SetMangaCategories = Injekt.get(), val snackbarHostState: SnackbarHostState = SnackbarHostState(), -) : StateScreenModel(MangaScreenState.Loading) { +) : StateScreenModel(State.Loading) { - private val successState: MangaScreenState.Success? - get() = state.value as? MangaScreenState.Success + private val successState: State.Success? + get() = state.value as? State.Success private val loggedServices by lazy { trackManager.services.filter { it.isLogged && it is MangaTrackService } } @@ -140,11 +140,11 @@ class MangaScreenModel( /** * Helper function to update the UI state only if it's currently in success state */ - private inline fun updateSuccessState(func: (MangaScreenState.Success) -> MangaScreenState.Success) { + private inline fun updateSuccessState(func: (State.Success) -> State.Success) { mutableState.update { when (it) { - MangaScreenState.Loading -> it - is MangaScreenState.Success -> func(it) + State.Loading -> it + is State.Success -> func(it) } } } @@ -182,7 +182,7 @@ class MangaScreenModel( // Show what we have earlier mutableState.update { - MangaScreenState.Success( + State.Success( manga = manga, source = Injekt.get().getOrStub(manga.source), isFromSource = isFromSource, @@ -347,8 +347,7 @@ class MangaScreenModel( } fun promptChangeCategories() { - val state = successState ?: return - val manga = state.manga + val manga = successState?.manga ?: return coroutineScope.launch { val categories = getCategories() val selection = getMangaCategoryIds(manga) @@ -675,9 +674,9 @@ class MangaScreenModel( } fun markPreviousChapterRead(pointer: Chapter) { - val successState = successState ?: return + val manga = successState?.manga ?: return val chapters = filteredChapters.orEmpty().map { it.chapter } - val prevChapters = if (successState.manga.sortDescending()) chapters.asReversed() else chapters + val prevChapters = if (manga.sortDescending()) chapters.asReversed() else chapters val pointerPos = prevChapters.indexOf(pointer) if (pointerPos != -1) markChaptersRead(prevChapters.take(pointerPos), true) } @@ -953,13 +952,13 @@ class MangaScreenModel( // Track sheet - end - sealed class Dialog { - data class ChangeCategory(val manga: Manga, val initialSelection: List>) : Dialog() - data class DeleteChapters(val chapters: List) : Dialog() - data class DuplicateManga(val manga: Manga, val duplicate: Manga) : Dialog() - data object SettingsSheet : Dialog() - data object TrackSheet : Dialog() - data object FullCover : Dialog() + sealed interface Dialog { + data class ChangeCategory(val manga: Manga, val initialSelection: List>) : Dialog + data class DeleteChapters(val chapters: List) : Dialog + data class DuplicateManga(val manga: Manga, val duplicate: Manga) : Dialog + data object SettingsSheet : Dialog + data object TrackSheet : Dialog + data object FullCover : Dialog } fun dismissDialog() { @@ -981,48 +980,53 @@ class MangaScreenModel( fun showCoverDialog() { updateSuccessState { it.copy(dialog = Dialog.FullCover) } } -} -sealed class MangaScreenState { - @Immutable - object Loading : MangaScreenState() + sealed interface State { + @Immutable + object Loading : State - @Immutable - data class Success( - val manga: Manga, - val source: MangaSource, - val isFromSource: Boolean, - val chapters: List, - val trackItems: List = emptyList(), - val isRefreshingData: Boolean = false, - val dialog: MangaScreenModel.Dialog? = null, - val hasPromptedToAddBefore: Boolean = false, - ) : MangaScreenState() { + @Immutable + data class Success( + val manga: Manga, + val source: MangaSource, + val isFromSource: Boolean, + val chapters: List, + val trackItems: List = emptyList(), + val isRefreshingData: Boolean = false, + val dialog: Dialog? = null, + val hasPromptedToAddBefore: Boolean = false, + ) : State { - val processedChapters by lazy { - chapters.applyFilters(manga).toList() - } + val processedChapters by lazy { + chapters.applyFilters(manga).toList() + } - val trackingAvailable: Boolean - get() = trackItems.isNotEmpty() + val trackingAvailable: Boolean + get() = trackItems.isNotEmpty() - val trackingCount: Int - get() = trackItems.count { it.track != null } + val trackingCount: Int + get() = trackItems.count { it.track != null } - /** - * Applies the view filters to the list of chapters obtained from the database. - * @return an observable of the list of chapters filtered and sorted. - */ - private fun List.applyFilters(manga: Manga): Sequence { - val isLocalManga = manga.isLocal() - val unreadFilter = manga.unreadFilter - val downloadedFilter = manga.downloadedFilter - val bookmarkedFilter = manga.bookmarkedFilter - return asSequence() - .filter { (chapter) -> applyFilter(unreadFilter) { !chapter.read } } - .filter { (chapter) -> applyFilter(bookmarkedFilter) { chapter.bookmark } } - .filter { applyFilter(downloadedFilter) { it.isDownloaded || isLocalManga } } - .sortedWith { (chapter1), (chapter2) -> getChapterSort(manga).invoke(chapter1, chapter2) } + /** + * Applies the view filters to the list of chapters obtained from the database. + * @return an observable of the list of chapters filtered and sorted. + */ + private fun List.applyFilters(manga: Manga): Sequence { + val isLocalManga = manga.isLocal() + val unreadFilter = manga.unreadFilter + val downloadedFilter = manga.downloadedFilter + val bookmarkedFilter = manga.bookmarkedFilter + return asSequence() + .filter { (chapter) -> applyFilter(unreadFilter) { !chapter.read } } + .filter { (chapter) -> applyFilter(bookmarkedFilter) { chapter.bookmark } } + .filter { applyFilter(downloadedFilter) { it.isDownloaded || isLocalManga } } + .sortedWith { (chapter1), (chapter2) -> + getChapterSort(manga).invoke( + chapter1, + chapter2, + ) + } + } } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryScreenModel.kt index 1b1d0a6c4..2c8385890 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/history/anime/AnimeHistoryScreenModel.kt @@ -37,7 +37,7 @@ class AnimeHistoryScreenModel( private val getHistory: GetAnimeHistory = Injekt.get(), private val getNextEpisodes: GetNextEpisodes = Injekt.get(), private val removeHistory: RemoveAnimeHistory = Injekt.get(), -) : StateScreenModel(AnimeHistoryState()) { +) : StateScreenModel(State()) { private val _events: Channel = Channel(Channel.UNLIMITED) val events: Flow = _events.receiveAsFlow() @@ -119,20 +119,21 @@ class AnimeHistoryScreenModel( mutableState.update { it.copy(dialog = dialog) } } - sealed class Dialog { - data object DeleteAll : Dialog() - data class Delete(val history: AnimeHistoryWithRelations) : Dialog() + @Immutable + data class State( + val searchQuery: String? = null, + val list: List? = null, + val dialog: Dialog? = null, + ) + + sealed interface Dialog { + data object DeleteAll : Dialog + data class Delete(val history: AnimeHistoryWithRelations) : Dialog } - sealed class Event { - data class OpenEpisode(val episode: Episode?) : Event() - data object InternalError : Event() - data object HistoryCleared : Event() + sealed interface Event { + data class OpenEpisode(val episode: Episode?) : Event + data object InternalError : Event + data object HistoryCleared : Event } } - -@Immutable -data class AnimeHistoryState( - val list: List? = null, - val dialog: AnimeHistoryScreenModel.Dialog? = null, -) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryScreenModel.kt index cab14a60f..222e73f4f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/history/manga/MangaHistoryScreenModel.kt @@ -37,7 +37,7 @@ class MangaHistoryScreenModel( private val getHistory: GetMangaHistory = Injekt.get(), private val getNextChapters: GetNextChapters = Injekt.get(), private val removeHistory: RemoveMangaHistory = Injekt.get(), -) : StateScreenModel(HistoryState()) { +) : StateScreenModel(State()) { private val _events: Channel = Channel(Channel.UNLIMITED) val events: Flow = _events.receiveAsFlow() @@ -119,20 +119,21 @@ class MangaHistoryScreenModel( mutableState.update { it.copy(dialog = dialog) } } - sealed class Dialog { - data object DeleteAll : Dialog() - data class Delete(val history: MangaHistoryWithRelations) : Dialog() + @Immutable + data class State( + val searchQuery: String? = null, + val list: List? = null, + val dialog: Dialog? = null, + ) + + sealed interface Dialog { + data object DeleteAll : Dialog + data class Delete(val history: MangaHistoryWithRelations) : Dialog } - sealed class Event { - data class OpenChapter(val chapter: Chapter?) : Event() - data object InternalError : Event() - data object HistoryCleared : Event() + sealed interface Event { + data class OpenChapter(val chapter: Chapter?) : Event + data object InternalError : Event + data object HistoryCleared : Event } } - -@Immutable -data class HistoryState( - val list: List? = null, - val dialog: MangaHistoryScreenModel.Dialog? = null, -) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt index 4986fa03b..ef74eee93 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt @@ -336,12 +336,12 @@ object HomeScreen : Screen() { showBottomNavEvent.send(show) } - sealed class Tab { - data class Animelib(val animeIdToOpen: Long? = null) : Tab() - data class Library(val mangaIdToOpen: Long? = null) : Tab() - data object Updates : Tab() - data object History : Tab() - data class Browse(val toExtensions: Boolean = false) : Tab() - data class More(val toDownloads: Boolean) : Tab() + sealed interface Tab { + data class Animelib(val animeIdToOpen: Long? = null) : Tab + data class Library(val mangaIdToOpen: Long? = null) : Tab + data object Updates : Tab + data object History : Tab + data class Browse(val toExtensions: Boolean = false) : Tab + data class More(val toDownloads: Boolean) : Tab } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryScreenModel.kt index 8ea7a66b8..49e0d8fee 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/anime/AnimeLibraryScreenModel.kt @@ -664,10 +664,10 @@ class AnimeLibraryScreenModel( mutableState.update { it.copy(dialog = null) } } - sealed class Dialog { - data object SettingsSheet : Dialog() - data class ChangeCategory(val anime: List, val initialSelection: List>) : Dialog() - data class DeleteAnime(val anime: List) : Dialog() + sealed interface Dialog { + data object SettingsSheet : Dialog + data class ChangeCategory(val anime: List, val initialSelection: List>) : Dialog + data class DeleteAnime(val anime: List) : Dialog } @Immutable diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryScreenModel.kt index 8c9419bc3..18464c71e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/manga/MangaLibraryScreenModel.kt @@ -658,10 +658,10 @@ class MangaLibraryScreenModel( mutableState.update { it.copy(dialog = null) } } - sealed class Dialog { - data object SettingsSheet : Dialog() - data class ChangeCategory(val manga: List, val initialSelection: List>) : Dialog() - data class DeleteManga(val manga: List) : Dialog() + sealed interface Dialog { + data object SettingsSheet : Dialog + data class ChangeCategory(val manga: List, val initialSelection: List>) : Dialog + data class DeleteManga(val manga: List) : Dialog } @Immutable diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt index e04f76db8..0e9b5d03d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreTab.kt @@ -134,8 +134,8 @@ private class MoreScreenModel( } } -sealed class DownloadQueueState { - data object Stopped : DownloadQueueState() - data class Paused(val pending: Int) : DownloadQueueState() - data class Downloading(val pending: Int) : DownloadQueueState() +sealed interface DownloadQueueState { + data object Stopped : DownloadQueueState + data class Paused(val pending: Int) : DownloadQueueState + data class Downloading(val pending: Int) : DownloadQueueState } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt index 24163c94a..59c6a5029 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt @@ -815,9 +815,9 @@ class ReaderViewModel @JvmOverloads constructor( Error, } - sealed class SaveImageResult { - class Success(val uri: Uri) : SaveImageResult() - class Error(val error: Throwable) : SaveImageResult() + sealed interface SaveImageResult { + class Success(val uri: Uri) : SaveImageResult + class Error(val error: Throwable) : SaveImageResult } /** @@ -907,18 +907,18 @@ class ReaderViewModel @JvmOverloads constructor( get() = viewerChapters?.currChapter?.pages?.size ?: -1 } - sealed class Dialog { - data object Loading : Dialog() - data object Settings : Dialog() - data class PageActions(val page: ReaderPage) : Dialog() + sealed interface Dialog { + data object Loading : Dialog + data object Settings : Dialog + data class PageActions(val page: ReaderPage) : Dialog } - sealed class Event { - data object ReloadViewerChapters : Event() - data class SetOrientation(val orientation: Int) : Event() - data class SetCoverResult(val result: SetAsCoverResult) : Event() + sealed interface Event { + data object ReloadViewerChapters : Event + data class SetOrientation(val orientation: Int) : Event + data class SetCoverResult(val result: SetAsCoverResult) : Event - data class SavedImage(val result: SaveImageResult) : Event() - data class ShareImage(val uri: Uri, val page: ReaderPage) : Event() + data class SavedImage(val result: SaveImageResult) : Event + data class ShareImage(val uri: Uri, val page: ReaderPage) : Event } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/model/ReaderChapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/model/ReaderChapter.kt index 7db453bd1..633f27d69 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/model/ReaderChapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/model/ReaderChapter.kt @@ -39,10 +39,10 @@ data class ReaderChapter(val chapter: Chapter) { } } - sealed class State { - data object Wait : State() - data object Loading : State() - data class Error(val error: Throwable) : State() - data class Loaded(val pages: List) : State() + sealed interface State { + data object Wait : State + data object Loading : State + data class Error(val error: Throwable) : State + data class Loaded(val pages: List) : State } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/updates/anime/AnimeUpdatesScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/anime/AnimeUpdatesScreenModel.kt index 4e2b075c2..914fce7f5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/updates/anime/AnimeUpdatesScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/anime/AnimeUpdatesScreenModel.kt @@ -62,7 +62,7 @@ class AnimeUpdatesScreenModel( val snackbarHostState: SnackbarHostState = SnackbarHostState(), downloadPreferences: DownloadPreferences = Injekt.get(), uiPreferences: UiPreferences = Injekt.get(), -) : StateScreenModel(AnimeUpdatesState()) { +) : StateScreenModel(State()) { private val _events: Channel = Channel(Int.MAX_VALUE) val events: Flow = _events.receiveAsFlow() @@ -378,47 +378,47 @@ class AnimeUpdatesScreenModel( libraryPreferences.newAnimeUpdatesCount().set(0) } - sealed class Dialog { - data class DeleteConfirmation(val toDelete: List) : Dialog() - data class ShowQualities(val episodeTitle: String, val episodeId: Long, val animeId: Long, val sourceId: Long) : Dialog() - } + @Immutable + data class State( + val isLoading: Boolean = true, + val items: List = emptyList(), + val dialog: AnimeUpdatesScreenModel.Dialog? = null, + ) { + val selected = items.filter { it.selected } + val selectionMode = selected.isNotEmpty() - sealed class Event { - data object InternalError : Event() - data class LibraryUpdateTriggered(val started: Boolean) : Event() - } -} + fun getUiModel(context: Context, relativeTime: Int): List { + val dateFormat by mutableStateOf(UiPreferences.dateFormat(Injekt.get().dateFormat().get())) -@Immutable -data class AnimeUpdatesState( - val isLoading: Boolean = true, - val items: List = emptyList(), - val dialog: AnimeUpdatesScreenModel.Dialog? = null, -) { - val selected = items.filter { it.selected } - val selectionMode = selected.isNotEmpty() - - fun getUiModel(context: Context, relativeTime: Int): List { - val dateFormat by mutableStateOf(UiPreferences.dateFormat(Injekt.get().dateFormat().get())) - - return items - .map { AnimeUpdatesUiModel.Item(it) } - .insertSeparators { before, after -> - val beforeDate = before?.item?.update?.dateFetch?.toDateKey() ?: Date(0) - val afterDate = after?.item?.update?.dateFetch?.toDateKey() ?: Date(0) - when { - beforeDate.time != afterDate.time && afterDate.time != 0L -> { - val text = afterDate.toRelativeString( - context = context, - range = relativeTime, - dateFormat = dateFormat, - ) - AnimeUpdatesUiModel.Header(text) + return items + .map { AnimeUpdatesUiModel.Item(it) } + .insertSeparators { before, after -> + val beforeDate = before?.item?.update?.dateFetch?.toDateKey() ?: Date(0) + val afterDate = after?.item?.update?.dateFetch?.toDateKey() ?: Date(0) + when { + beforeDate.time != afterDate.time && afterDate.time != 0L -> { + val text = afterDate.toRelativeString( + context = context, + range = relativeTime, + dateFormat = dateFormat, + ) + AnimeUpdatesUiModel.Header(text) + } + // Return null to avoid adding a separator between two items. + else -> null } - // Return null to avoid adding a separator between two items. - else -> null } - } + } + } + + sealed interface Dialog { + data class DeleteConfirmation(val toDelete: List) : Dialog + data class ShowQualities(val episodeTitle: String, val episodeId: Long, val animeId: Long, val sourceId: Long) : Dialog + } + + sealed interface Event { + data object InternalError : Event + data class LibraryUpdateTriggered(val started: Boolean) : Event } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/updates/manga/MangaUpdatesScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/manga/MangaUpdatesScreenModel.kt index 3e56d5e74..843fe39db 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/updates/manga/MangaUpdatesScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/manga/MangaUpdatesScreenModel.kt @@ -60,7 +60,7 @@ class MangaUpdatesScreenModel( private val libraryPreferences: LibraryPreferences = Injekt.get(), val snackbarHostState: SnackbarHostState = SnackbarHostState(), uiPreferences: UiPreferences = Injekt.get(), -) : StateScreenModel(UpdatesState()) { +) : StateScreenModel(State()) { private val _events: Channel = Channel(Int.MAX_VALUE) val events: Flow = _events.receiveAsFlow() @@ -366,46 +366,46 @@ class MangaUpdatesScreenModel( libraryPreferences.newMangaUpdatesCount().set(0) } - sealed class Dialog { - data class DeleteConfirmation(val toDelete: List) : Dialog() - } + @Immutable + data class State( + val isLoading: Boolean = true, + val items: List = emptyList(), + val dialog: MangaUpdatesScreenModel.Dialog? = null, + ) { + val selected = items.filter { it.selected } + val selectionMode = selected.isNotEmpty() - sealed class Event { - data object InternalError : Event() - data class LibraryUpdateTriggered(val started: Boolean) : Event() - } -} + fun getUiModel(context: Context, relativeTime: Int): List { + val dateFormat by mutableStateOf(UiPreferences.dateFormat(Injekt.get().dateFormat().get())) -@Immutable -data class UpdatesState( - val isLoading: Boolean = true, - val items: List = emptyList(), - val dialog: MangaUpdatesScreenModel.Dialog? = null, -) { - val selected = items.filter { it.selected } - val selectionMode = selected.isNotEmpty() - - fun getUiModel(context: Context, relativeTime: Int): List { - val dateFormat by mutableStateOf(UiPreferences.dateFormat(Injekt.get().dateFormat().get())) - - return items - .map { MangaUpdatesUiModel.Item(it) } - .insertSeparators { before, after -> - val beforeDate = before?.item?.update?.dateFetch?.toDateKey() ?: Date(0) - val afterDate = after?.item?.update?.dateFetch?.toDateKey() ?: Date(0) - when { - beforeDate.time != afterDate.time && afterDate.time != 0L -> { - val text = afterDate.toRelativeString( - context = context, - range = relativeTime, - dateFormat = dateFormat, - ) - MangaUpdatesUiModel.Header(text) + return items + .map { MangaUpdatesUiModel.Item(it) } + .insertSeparators { before, after -> + val beforeDate = before?.item?.update?.dateFetch?.toDateKey() ?: Date(0) + val afterDate = after?.item?.update?.dateFetch?.toDateKey() ?: Date(0) + when { + beforeDate.time != afterDate.time && afterDate.time != 0L -> { + val text = afterDate.toRelativeString( + context = context, + range = relativeTime, + dateFormat = dateFormat, + ) + MangaUpdatesUiModel.Header(text) + } + // Return null to avoid adding a separator between two items. + else -> null } - // Return null to avoid adding a separator between two items. - else -> null } - } + } + } + + sealed interface Dialog { + data class DeleteConfirmation(val toDelete: List) : Dialog + } + + sealed interface Event { + data object InternalError : Event + data class LibraryUpdateTriggered(val started: Boolean) : Event } } diff --git a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/CreateAnimeCategoryWithName.kt b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/CreateAnimeCategoryWithName.kt index ef4de2513..e1d7b219d 100644 --- a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/CreateAnimeCategoryWithName.kt +++ b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/CreateAnimeCategoryWithName.kt @@ -38,8 +38,8 @@ class CreateAnimeCategoryWithName( } } - sealed class Result { - data object Success : Result() - data class InternalError(val error: Throwable) : Result() + sealed interface Result { + data object Success : Result + data class InternalError(val error: Throwable) : Result } } diff --git a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/DeleteAnimeCategory.kt b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/DeleteAnimeCategory.kt index 8cdb13b75..2b6882377 100644 --- a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/DeleteAnimeCategory.kt +++ b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/DeleteAnimeCategory.kt @@ -35,8 +35,8 @@ class DeleteAnimeCategory( } } - sealed class Result { - data object Success : Result() - data class InternalError(val error: Throwable) : Result() + sealed interface Result { + data object Success : Result + data class InternalError(val error: Throwable) : Result } } diff --git a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/HideAnimeCategory.kt b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/HideAnimeCategory.kt index 7d4eaf3fb..667ab0e45 100644 --- a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/HideAnimeCategory.kt +++ b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/HideAnimeCategory.kt @@ -27,7 +27,7 @@ class HideAnimeCategory( } sealed class Result { - object Success : Result() + data object Success : Result() data class InternalError(val error: Throwable) : Result() } } diff --git a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/RenameAnimeCategory.kt b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/RenameAnimeCategory.kt index 0dd524e97..6939cfa57 100644 --- a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/RenameAnimeCategory.kt +++ b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/RenameAnimeCategory.kt @@ -28,8 +28,8 @@ class RenameAnimeCategory( suspend fun await(category: Category, name: String) = await(category.id, name) - sealed class Result { - object Success : Result() - data class InternalError(val error: Throwable) : Result() + sealed interface Result { + data object Success : Result + data class InternalError(val error: Throwable) : Result } } diff --git a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/ReorderAnimeCategory.kt b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/ReorderAnimeCategory.kt index 213d023b6..0c7625ecc 100644 --- a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/ReorderAnimeCategory.kt +++ b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/ReorderAnimeCategory.kt @@ -57,10 +57,10 @@ class ReorderAnimeCategory( } } - sealed class Result { - data object Success : Result() - data object Unchanged : Result() - data class InternalError(val error: Throwable) : Result() + sealed interface Result { + data object Success : Result + data object Unchanged : Result + data class InternalError(val error: Throwable) : Result } private enum class MoveTo { diff --git a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/UpdateAnimeCategory.kt b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/UpdateAnimeCategory.kt index 5a4372066..84fa22784 100644 --- a/domain/src/main/java/tachiyomi/domain/category/anime/interactor/UpdateAnimeCategory.kt +++ b/domain/src/main/java/tachiyomi/domain/category/anime/interactor/UpdateAnimeCategory.kt @@ -17,8 +17,8 @@ class UpdateAnimeCategory( } } - sealed class Result { - data object Success : Result() - data class Error(val error: Exception) : Result() + sealed interface Result { + data object Success : Result + data class Error(val error: Exception) : Result } } diff --git a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/CreateMangaCategoryWithName.kt b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/CreateMangaCategoryWithName.kt index e587c3986..cb5138e5e 100644 --- a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/CreateMangaCategoryWithName.kt +++ b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/CreateMangaCategoryWithName.kt @@ -38,8 +38,8 @@ class CreateMangaCategoryWithName( } } - sealed class Result { - data object Success : Result() - data class InternalError(val error: Throwable) : Result() + sealed interface Result { + data object Success : Result + data class InternalError(val error: Throwable) : Result } } diff --git a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/DeleteMangaCategory.kt b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/DeleteMangaCategory.kt index 0043a3022..53da0847b 100644 --- a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/DeleteMangaCategory.kt +++ b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/DeleteMangaCategory.kt @@ -35,8 +35,8 @@ class DeleteMangaCategory( } } - sealed class Result { - data object Success : Result() - data class InternalError(val error: Throwable) : Result() + sealed interface Result { + data object Success : Result + data class InternalError(val error: Throwable) : Result } } diff --git a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/HideMangaCategory.kt b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/HideMangaCategory.kt index 11f26c3ed..36c9d3fb3 100644 --- a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/HideMangaCategory.kt +++ b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/HideMangaCategory.kt @@ -27,7 +27,7 @@ class HideMangaCategory( } sealed class Result { - object Success : Result() + data object Success : Result() data class InternalError(val error: Throwable) : Result() } } diff --git a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/RenameMangaCategory.kt b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/RenameMangaCategory.kt index ea1813a56..ec135f53a 100644 --- a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/RenameMangaCategory.kt +++ b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/RenameMangaCategory.kt @@ -28,8 +28,8 @@ class RenameMangaCategory( suspend fun await(category: Category, name: String) = await(category.id, name) - sealed class Result { - object Success : Result() - data class InternalError(val error: Throwable) : Result() + sealed interface Result { + data object Success : Result + data class InternalError(val error: Throwable) : Result } } diff --git a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/ReorderMangaCategory.kt b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/ReorderMangaCategory.kt index 993b45882..ac47e62c3 100644 --- a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/ReorderMangaCategory.kt +++ b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/ReorderMangaCategory.kt @@ -57,10 +57,10 @@ class ReorderMangaCategory( } } - sealed class Result { - data object Success : Result() - data object Unchanged : Result() - data class InternalError(val error: Throwable) : Result() + sealed interface Result { + data object Success : Result + data object Unchanged : Result + data class InternalError(val error: Throwable) : Result } private enum class MoveTo { diff --git a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/UpdateMangaCategory.kt b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/UpdateMangaCategory.kt index f68a6140b..305403a14 100644 --- a/domain/src/main/java/tachiyomi/domain/category/manga/interactor/UpdateMangaCategory.kt +++ b/domain/src/main/java/tachiyomi/domain/category/manga/interactor/UpdateMangaCategory.kt @@ -17,8 +17,8 @@ class UpdateMangaCategory( } } - sealed class Result { - data object Success : Result() - data class Error(val error: Exception) : Result() + sealed interface Result { + data object Success : Result + data class Error(val error: Exception) : Result } } diff --git a/domain/src/main/java/tachiyomi/domain/library/model/LibraryDisplayMode.kt b/domain/src/main/java/tachiyomi/domain/library/model/LibraryDisplayMode.kt index ee05c22ff..cded2c688 100644 --- a/domain/src/main/java/tachiyomi/domain/library/model/LibraryDisplayMode.kt +++ b/domain/src/main/java/tachiyomi/domain/library/model/LibraryDisplayMode.kt @@ -1,11 +1,11 @@ package tachiyomi.domain.library.model -sealed class LibraryDisplayMode { +sealed interface LibraryDisplayMode { - data object CompactGrid : LibraryDisplayMode() - data object ComfortableGrid : LibraryDisplayMode() - data object List : LibraryDisplayMode() - data object CoverOnlyGrid : LibraryDisplayMode() + data object CompactGrid : LibraryDisplayMode + data object ComfortableGrid : LibraryDisplayMode + data object List : LibraryDisplayMode + data object CoverOnlyGrid : LibraryDisplayMode object Serializer { fun deserialize(serialized: String): LibraryDisplayMode { diff --git a/domain/src/main/java/tachiyomi/domain/release/interactor/GetApplicationRelease.kt b/domain/src/main/java/tachiyomi/domain/release/interactor/GetApplicationRelease.kt index 89950d30d..735782fd2 100644 --- a/domain/src/main/java/tachiyomi/domain/release/interactor/GetApplicationRelease.kt +++ b/domain/src/main/java/tachiyomi/domain/release/interactor/GetApplicationRelease.kt @@ -71,9 +71,9 @@ class GetApplicationRelease( val forceCheck: Boolean = false, ) - sealed class Result { - data class NewUpdate(val release: Release) : Result() - data object NoNewUpdate : Result() - data object ThirdPartyInstallation : Result() + sealed interface Result { + data class NewUpdate(val release: Release) : Result + data object NoNewUpdate : Result + data object ThirdPartyInstallation : Result } } diff --git a/gradle/androidx.versions.toml b/gradle/androidx.versions.toml index 02fd78c8f..6f8bb1b89 100644 --- a/gradle/androidx.versions.toml +++ b/gradle/androidx.versions.toml @@ -1,20 +1,20 @@ [versions] -agp_version = "8.0.2" +agp_version = "8.1.0" lifecycle_version = "2.6.1" -paging_version = "3.2.0-rc01" +paging_version = "3.2.0" [libraries] gradle = { module = "com.android.tools.build:gradle", version.ref = "agp_version" } -annotation = "androidx.annotation:annotation:1.7.0-alpha02" +annotation = "androidx.annotation:annotation:1.7.0-alpha03" appcompat = "androidx.appcompat:appcompat:1.6.1" biometricktx = "androidx.biometric:biometric-ktx:1.2.0-alpha05" constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4" -corektx = "androidx.core:core-ktx:1.11.0-beta02" +corektx = "androidx.core:core-ktx:1.12.0-beta01" splashscreen = "androidx.core:core-splashscreen:1.0.1" -recyclerview = "androidx.recyclerview:recyclerview:1.3.1-rc01" +recyclerview = "androidx.recyclerview:recyclerview:1.3.1" viewpager = "androidx.viewpager:viewpager:1.1.0-alpha01" -glance = "androidx.glance:glance-appwidget:1.0.0-beta01" +glance = "androidx.glance:glance-appwidget:1.0.0-rc01" profileinstaller = "androidx.profileinstaller:profileinstaller:1.3.1" mediasession = "androidx.media:media:1.6.0" diff --git a/gradle/compose.versions.toml b/gradle/compose.versions.toml index 01ee818ab..1bb8d0e44 100644 --- a/gradle/compose.versions.toml +++ b/gradle/compose.versions.toml @@ -1,6 +1,6 @@ [versions] -compiler = "1.5.0" -compose-bom = "2023.07.00-alpha01" +compiler = "1.5.1" +compose-bom = "2023.07.00-alpha02" accompanist = "0.31.5-beta" [libraries] diff --git a/gradle/kotlinx.versions.toml b/gradle/kotlinx.versions.toml index 717ad74ee..b60ab95b4 100644 --- a/gradle/kotlinx.versions.toml +++ b/gradle/kotlinx.versions.toml @@ -7,7 +7,7 @@ xml_serialization_version = "0.86.1" reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin_version" } gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin_version" } -coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version = "1.7.2" } +coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version = "1.7.3" } coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core" } coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android" } coroutines-guava = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-guava" } diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/components/material/Divider.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/components/material/Divider.kt deleted file mode 100644 index a434d6354..000000000 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/components/material/Divider.kt +++ /dev/null @@ -1,44 +0,0 @@ -package tachiyomi.presentation.core.components.material - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.width -import androidx.compose.material3.DividerDefaults -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp - -const val DIVIDER_ALPHA = 0.2f - -@Composable -fun Divider( - modifier: Modifier = Modifier, - color: Color = DividerDefaults.color, -) { - Box( - modifier - .fillMaxWidth() - .height(1.dp) - .background(color = color) - .alpha(DIVIDER_ALPHA), - ) -} - -@Composable -fun VerticalDivider( - modifier: Modifier = Modifier, - color: Color = DividerDefaults.color, -) { - Box( - modifier - .fillMaxHeight() - .width(1.dp) - .background(color = color) - .alpha(DIVIDER_ALPHA), - ) -} diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/components/material/SegmentedButtons.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/components/material/SegmentedButtons.kt deleted file mode 100644 index 7656af007..000000000 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/components/material/SegmentedButtons.kt +++ /dev/null @@ -1,90 +0,0 @@ -package tachiyomi.presentation.core.components.material - -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.OutlinedButton -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.tooling.preview.Preview - -val StartItemShape = RoundedCornerShape(topStartPercent = 100, bottomStartPercent = 100) -val MiddleItemShape = RoundedCornerShape(0) -val EndItemShape = RoundedCornerShape(topEndPercent = 100, bottomEndPercent = 100) - -@Composable -fun SegmentedButtons( - modifier: Modifier = Modifier, - entries: List, - selectedIndex: Int, - onClick: (Int) -> Unit, -) { - Row( - modifier = modifier, - ) { - entries.mapIndexed { index, label -> - val shape = remember(entries, index) { - when (index) { - 0 -> StartItemShape - entries.lastIndex -> EndItemShape - else -> MiddleItemShape - } - } - - if (index == selectedIndex) { - Button( - modifier = Modifier.weight(1f), - shape = shape, - onClick = { onClick(index) }, - ) { - Text( - text = label, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - } - } else { - OutlinedButton( - modifier = Modifier.weight(1f), - shape = shape, - onClick = { onClick(index) }, - ) { - Text( - text = label, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - } - } - } - } -} - -@Preview -@Composable -private fun SegmentedButtonsPreview() { - Column { - SegmentedButtons( - entries = listOf( - "Day", - "Week", - "Month", - "Year", - ), - selectedIndex = 1, - onClick = {}, - ) - - SegmentedButtons( - entries = listOf( - "Foo", - "Bar", - ), - selectedIndex = 1, - onClick = {}, - ) - } -} diff --git a/source-local/src/commonMain/kotlin/tachiyomi/source/local/io/Format.kt b/source-local/src/commonMain/kotlin/tachiyomi/source/local/io/Format.kt index a73534f21..53406b5de 100644 --- a/source-local/src/commonMain/kotlin/tachiyomi/source/local/io/Format.kt +++ b/source-local/src/commonMain/kotlin/tachiyomi/source/local/io/Format.kt @@ -2,11 +2,11 @@ package tachiyomi.source.local.io import java.io.File -sealed class Format { - data class Directory(val file: File) : Format() - data class Zip(val file: File) : Format() - data class Rar(val file: File) : Format() - data class Epub(val file: File) : Format() +sealed interface Format { + data class Directory(val file: File) : Format + data class Zip(val file: File) : Format + data class Rar(val file: File) : Format + data class Epub(val file: File) : Format class UnknownFormatException : Exception()