diff --git a/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt b/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt index 0e881a161..0d6909461 100644 --- a/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt @@ -15,7 +15,6 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.OpenInNew import androidx.compose.material.icons.outlined.NewReleases -import androidx.compose.material3.Button import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.NavigationBarDefaults @@ -68,7 +67,7 @@ fun NewUpdateScreen( vertical = MaterialTheme.padding.small, ), ) { - Button( + TextButton( modifier = Modifier.fillMaxWidth(), onClick = onAcceptUpdate, ) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt index f8478882d..ba4148a36 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt @@ -50,7 +50,6 @@ import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.ui.browse.migration.MigrationFlags -import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreenModel.Listing import eu.kanade.tachiyomi.ui.manga.MangaScreen import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchUI @@ -78,7 +77,7 @@ class MigrateSearchScreen(private val mangaId: Long) : Screen { if (!screenModel.incognitoMode.get()) { screenModel.lastUsedSourceId.set(it.id) } - navigator.push(SourceSearchScreen(state.manga!!, it.id, Listing.Search(state.searchQuery, it.getFilterList()))) + navigator.push(SourceSearchScreen(state.manga!!, it.id, state.searchQuery)) }, onClickItem = { screenModel.setDialog(MigrateSearchDialog.Migrate(it)) }, onLongClickItem = { navigator.push(MangaScreen(it.id, true)) }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchScreen.kt index 2c8188d05..9960d6d00 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchScreen.kt @@ -40,7 +40,7 @@ import kotlinx.coroutines.launch data class SourceSearchScreen( private val oldManga: Manga, private val sourceId: Long, - private val listing: BrowseSourceScreenModel.Listing, + private val query: String?, ) : Screen { @Composable @@ -50,7 +50,7 @@ data class SourceSearchScreen( val navigator = LocalNavigator.currentOrThrow val scope = rememberCoroutineScope() - val screenModel = rememberScreenModel { BrowseSourceScreenModel(sourceId, listing) } + val screenModel = rememberScreenModel { BrowseSourceScreenModel(sourceId, query) } val state by screenModel.state.collectAsState() val snackbarHostState = remember { SnackbarHostState() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesTab.kt index ce88e582d..e44296f4d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesTab.kt @@ -48,7 +48,7 @@ fun Screen.sourcesTab(): TabContent { contentPadding = contentPadding, onClickItem = { source, listing -> screenModel.onOpenSource(source) - navigator.push(BrowseSourceScreen(source.id, listing)) + navigator.push(BrowseSourceScreen(source.id, listing.query)) }, onClickPin = screenModel::togglePin, onLongClickItem = screenModel::showSourceDialog, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt index 0c2dd8355..bb3e91cf3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt @@ -62,7 +62,7 @@ import kotlinx.coroutines.flow.receiveAsFlow data class BrowseSourceScreen( private val sourceId: Long, - private val listing: Listing, + private val listingQuery: String?, ) : Screen, AssistContentScreen { private var assistUrl: String? = null @@ -79,7 +79,7 @@ data class BrowseSourceScreen( val haptic = LocalHapticFeedback.current val uriHandler = LocalUriHandler.current - val screenModel = rememberScreenModel { BrowseSourceScreenModel(sourceId, listing) } + val screenModel = rememberScreenModel { BrowseSourceScreenModel(sourceId, listingQuery) } val state by screenModel.state.collectAsState() val snackbarHostState = remember { SnackbarHostState() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt index a89284706..799d266ad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt @@ -79,7 +79,7 @@ import eu.kanade.tachiyomi.source.model.Filter as SourceModelFilter class BrowseSourceScreenModel( private val sourceId: Long, - listing: Listing, + listingQuery: String?, private val sourceManager: SourceManager = Injekt.get(), sourcePreferences: SourcePreferences = Injekt.get(), private val libraryPreferences: LibraryPreferences = Injekt.get(), @@ -95,7 +95,7 @@ class BrowseSourceScreenModel( private val updateManga: UpdateManga = Injekt.get(), private val insertTrack: InsertTrack = Injekt.get(), private val syncChaptersWithTrackServiceTwoWay: SyncChaptersWithTrackServiceTwoWay = Injekt.get(), -) : StateScreenModel(State(listing)) { +) : StateScreenModel(State(Listing.valueOf(listingQuery))) { private val loggedServices by lazy { Injekt.get().services.filter { it.isLogged } } @@ -133,7 +133,19 @@ class BrowseSourceScreenModel( .stateIn(coroutineScope, SharingStarted.Lazily, emptyFlow()) init { - mutableState.update { it.copy(filters = source.getFilterList()) } + mutableState.update { + val initialListing = it.listing + val listing = if (initialListing is Listing.Search) { + initialListing.copy(filters = source.getFilterList()) + } else { + initialListing + } + + it.copy( + listing = listing, + filters = source.getFilterList(), + ) + } } fun getColumnsPreference(orientation: Int): GridCells { @@ -374,6 +386,16 @@ class BrowseSourceScreenModel( object Popular : Listing(query = GetRemoteManga.QUERY_POPULAR, filters = FilterList()) object Latest : Listing(query = GetRemoteManga.QUERY_LATEST, filters = FilterList()) data class Search(override val query: String?, override val filters: FilterList) : Listing(query = query, filters = filters) + + companion object { + fun valueOf(query: String?): Listing { + return when (query) { + GetRemoteManga.QUERY_POPULAR -> Popular + GetRemoteManga.QUERY_LATEST -> Latest + else -> Search(query = query, filters = FilterList()) // filters are filled in later + } + } + } } sealed class Dialog { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreen.kt index 71dfa6d1f..368806bb2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreen.kt @@ -10,7 +10,6 @@ import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow import eu.kanade.presentation.browse.GlobalSearchScreen import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreen -import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreenModel.Listing import eu.kanade.tachiyomi.ui.manga.MangaScreen class GlobalSearchScreen( @@ -47,7 +46,7 @@ class GlobalSearchScreen( if (!screenModel.incognitoMode.get()) { screenModel.lastUsedSourceId.set(it.id) } - navigator.push(BrowseSourceScreen(it.id, Listing.Search(state.searchQuery, it.getFilterList()))) + navigator.push(BrowseSourceScreen(it.id, state.searchQuery)) }, onClickItem = { navigator.push(MangaScreen(it.id, true)) }, onLongClickItem = { navigator.push(MangaScreen(it.id, true)) },