From e0b65184e24e3a032d758add9f09f8dda9cc1682 Mon Sep 17 00:00:00 2001 From: GG Bond Date: Sat, 10 Feb 2024 12:45:29 +0800 Subject: [PATCH] BaseGalleryInfo.asDestination() --- .../kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt | 3 +-- .../kotlin/com/hippo/ehviewer/ui/screen/FavoritesScreen.kt | 7 +++---- .../com/hippo/ehviewer/ui/screen/GalleryListScreen.kt | 4 ++-- .../kotlin/com/hippo/ehviewer/ui/screen/HistoryScreen.kt | 3 +-- .../main/kotlin/com/hippo/ehviewer/ui/screen/MainNav.kt | 3 +++ 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt index 122715e74..4d376e578 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt @@ -81,7 +81,6 @@ import com.hippo.ehviewer.ui.LocalSideSheetState import com.hippo.ehviewer.ui.LockDrawer import com.hippo.ehviewer.ui.MainActivity import com.hippo.ehviewer.ui.confirmRemoveDownloadRange -import com.hippo.ehviewer.ui.destinations.GalleryDetailScreenDestination import com.hippo.ehviewer.ui.main.DownloadCard import com.hippo.ehviewer.ui.main.FabLayout import com.hippo.ehviewer.ui.navToReader @@ -455,7 +454,7 @@ fun DownloadsScreen(navigator: DestinationsNavigator) { } }, onThumbClick = { - navigator.navigate(GalleryDetailScreenDestination(GalleryInfoArgs(info.galleryInfo))) + navigator.navigate(info.galleryInfo.asDestination()) }, onLongClick = { checkedInfoMap[info.gid] = info diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/FavoritesScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/FavoritesScreen.kt index 7158c2323..639d0d8e1 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/FavoritesScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/FavoritesScreen.kt @@ -69,7 +69,6 @@ import com.hippo.ehviewer.icons.filled.GoTo import com.hippo.ehviewer.ui.LocalSideSheetState import com.hippo.ehviewer.ui.LockDrawer import com.hippo.ehviewer.ui.MainActivity -import com.hippo.ehviewer.ui.destinations.GalleryDetailScreenDestination import com.hippo.ehviewer.ui.main.FAB_ANIMATE_TIME import com.hippo.ehviewer.ui.main.FabLayout import com.hippo.ehviewer.ui.main.GalleryInfoGridItem @@ -280,7 +279,7 @@ fun FavouritesScreen(navigator: DestinationsNavigator) { checkedInfoMap[info.gid] = info } } else { - navigator.navigate(GalleryDetailScreenDestination(GalleryInfoArgs(info))) + navigator.navigate(info.asDestination()) } }, onLongClick = { @@ -305,7 +304,7 @@ fun FavouritesScreen(navigator: DestinationsNavigator) { checkedInfoMap[info.gid] = info } } else { - navigator.navigate(GalleryDetailScreenDestination(GalleryInfoArgs(info))) + navigator.navigate(info.asDestination()) } }, onLongClick = { @@ -344,7 +343,7 @@ fun FavouritesScreen(navigator: DestinationsNavigator) { onClick(Icons.Default.Shuffle) { val random = EhDB.randomLocalFav() withUIContext { - navigator.navigate(GalleryDetailScreenDestination(GalleryInfoArgs(random))) + navigator.navigate(random.asDestination()) } } } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt index 5766a6343..3a228a70b 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt @@ -698,7 +698,7 @@ fun GalleryListScreen(lub: ListUrlBuilder, navigator: DestinationsNavigator) { detailItemContent = { info -> GalleryInfoListItem( onClick = { - navigator.navigate(GalleryDetailScreenDestination(GalleryInfoArgs(info))) + navigator.navigate(info.asDestination()) }, onLongClick = { coroutineScope.launch { @@ -715,7 +715,7 @@ fun GalleryListScreen(lub: ListUrlBuilder, navigator: DestinationsNavigator) { thumbItemContent = { info -> GalleryInfoGridItem( onClick = { - navigator.navigate(GalleryDetailScreenDestination(GalleryInfoArgs(info))) + navigator.navigate(info.asDestination()) }, onLongClick = { coroutineScope.launch { diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/HistoryScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/HistoryScreen.kt index 0bc9804fb..a9d1feee2 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/HistoryScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/HistoryScreen.kt @@ -41,7 +41,6 @@ import com.hippo.ehviewer.R import com.hippo.ehviewer.icons.EhIcons import com.hippo.ehviewer.icons.big.History import com.hippo.ehviewer.ui.LocalNavDrawerState -import com.hippo.ehviewer.ui.destinations.GalleryDetailScreenDestination import com.hippo.ehviewer.ui.doGalleryInfoAction import com.hippo.ehviewer.ui.main.GalleryInfoListItem import com.hippo.ehviewer.ui.tools.Deferred @@ -128,7 +127,7 @@ fun HistoryScreen(navigator: DestinationsNavigator) { ) { GalleryInfoListItem( onClick = { - navigator.navigate(GalleryDetailScreenDestination(GalleryInfoArgs(info))) + navigator.navigate(info.asDestination()) }, onLongClick = { coroutineScope.launchIO { diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/MainNav.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/MainNav.kt index a154b2eb0..54c0c4b6e 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/MainNav.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/MainNav.kt @@ -2,6 +2,7 @@ package com.hippo.ehviewer.ui.screen import androidx.annotation.MainThread import androidx.navigation.NavController +import com.hippo.ehviewer.client.data.BaseGalleryInfo import com.hippo.ehviewer.client.parser.GalleryDetailUrlParser import com.hippo.ehviewer.client.parser.GalleryListUrlParser import com.hippo.ehviewer.client.parser.GalleryPageUrlParser @@ -44,3 +45,5 @@ fun NavController.navWithUrl(url: String): Boolean { @MainThread fun NavController.navigate(direction: Direction) = navigate(direction.route) + +fun BaseGalleryInfo.asDestination() = GalleryDetailScreenDestination(GalleryInfoArgs(this))