Update compose.destinations to v2.1.0-beta02 (#1073)

* Update compose.destinations to v2.1.0-beta02

* Fix build

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: FooIbar <118464521+FooIbar@users.noreply.github.com>
This commit is contained in:
renovate[bot]andFooIbar authored and GitHub committed 2024-04-28 05:45:03 +00:00
1 parent 0c0291127c
commit 456dfd2aac
3 files changed
+12 -22

No files matched your search

@@ -127,7 +127,6 @@ import com.hippo.ehviewer.ui.destinations.WhatshotScreenDestination
import com.hippo.ehviewer.ui.screen.asDst
import com.hippo.ehviewer.ui.screen.asDstWith
import com.hippo.ehviewer.ui.screen.navWithUrl
import com.hippo.ehviewer.ui.screen.navigateTo
import com.hippo.ehviewer.ui.settings.showNewVersion
import com.hippo.ehviewer.ui.tools.DialogState
import com.hippo.ehviewer.ui.tools.LabeledCheckbox
@@ -147,6 +146,7 @@ import com.hippo.unifile.sha1
import com.ramcosta.composedestinations.DestinationsNavHost
import com.ramcosta.composedestinations.spec.DirectionDestinationSpec
import com.ramcosta.composedestinations.utils.currentDestinationAsState
import com.ramcosta.composedestinations.utils.rememberDestinationsNavigator
import eu.kanade.tachiyomi.util.lang.withIOContext
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.channels.Channel
@@ -218,6 +218,7 @@ class MainActivity : EhActivity() {
val snackbarState = remember { SnackbarHostState() }
val scope = rememberCoroutineScope()
val navController = rememberNavController()
val navigator = navController.rememberDestinationsNavigator()
fun closeDrawer(callback: () -> Unit = {}) = scope.launch {
navDrawerState.close()
callback()
@@ -236,7 +237,7 @@ class MainActivity : EhActivity() {
style = MaterialTheme.typography.titleMedium,
)
}
navController.navigateTo(DownloadScreenDestination)
navigator.navigate(DownloadScreenDestination)
}
}
@@ -260,7 +261,7 @@ class MainActivity : EhActivity() {
when (intent.action) {
Intent.ACTION_VIEW -> {
val url = intent.data?.toString()
if (url != null && !navController.navWithUrl(url)) {
if (url != null && !navigator.navWithUrl(url)) {
val new = dialogState.awaitInputText(initial = url, title = cannotParse)
addTextToClipboard(new)
}
@@ -269,14 +270,14 @@ class MainActivity : EhActivity() {
val type = intent.type
if ("text/plain" == type) {
val keyword = intent.getStringExtra(Intent.EXTRA_TEXT)
if (keyword != null && !navController.navWithUrl(keyword)) {
navController.navigateTo(ListUrlBuilder(mKeyword = keyword).asDst())
if (keyword != null && !navigator.navWithUrl(keyword)) {
navigator.navigate(ListUrlBuilder(mKeyword = keyword).asDst())
}
} else if (type != null && type.startsWith("image/")) {
val uri = intent.getParcelableExtraCompat<Uri>(Intent.EXTRA_STREAM)
if (null != uri) {
val hash = withIOContext { uri.asUniFile().sha1() }
navController.navigateTo(
navigator.navigate(
ListUrlBuilder(
mode = ListUrlBuilder.MODE_IMAGE_SEARCH,
hash = hash,
@@ -287,7 +288,7 @@ class MainActivity : EhActivity() {
}
DownloadService.ACTION_START_DOWNLOADSCENE -> {
val args = intent.getBundleExtra(DownloadService.ACTION_START_DOWNLOADSCENE_ARGS)
navController.navigateTo(DownloadsScreenDestination)
navigator.navigate(DownloadsScreenDestination)
}
}
}
@@ -327,11 +328,11 @@ class MainActivity : EhActivity() {
val result1 = GalleryDetailUrlParser.parse(text, false)
var launch: (() -> Unit)? = null
if (result1 != null) {
launch = { navController.navigateTo(result1.gid asDstWith result1.token) }
launch = { navigator.navigate(result1.gid asDstWith result1.token) }
}
val result2 = GalleryPageUrlParser.parse(text, false)
if (result2 != null) {
launch = { navController.navigateTo(ProgressScreenDestination(result2.gid, result2.pToken, result2.page)) }
launch = { navigator.navigate(ProgressScreenDestination(result2.gid, result2.pToken, result2.page)) }
}
launch?.let {
val ret = snackbarState.showSnackbar(snackMessage, snackAction, true)
@@ -1,7 +1,6 @@
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.data.ListUrlBuilder
import com.hippo.ehviewer.client.parser.GalleryDetailUrlParser
@@ -34,19 +33,9 @@ fun DestinationsNavigator.navWithUrl(url: String): Boolean {
@MainThread
fun DestinationsNavigator.popNavigate(direction: Direction) = navigate(direction) {
popUpTo(NavGraphs.root.route)
popUpTo(NavGraphs.root)
}
@MainThread
fun NavController.navWithUrl(url: String): Boolean {
val dest = urlToDestination(url) ?: return false
navigateTo(dest)
return true
}
@MainThread
fun NavController.navigateTo(direction: Direction) = navigate(direction.route)
fun BaseGalleryInfo.asDst() = GalleryDetailScreenDestination(GalleryInfoArgs(this))
infix fun Long.asDstWith(token: String) = GalleryDetailScreenDestination(TokenArgs(this, token))
+1 -1
View File
@@ -19,7 +19,7 @@ androidx-work = "2.10.0-alpha02"
arrow = "1.2.4"
coil = "3.0.0-alpha06"
compose-bom = "2024.04.00-alpha02"
compose-destinations = "2.1.0-beta01"
compose-destinations = "2.1.0-beta02"
kotlin = "2.0.0-RC1"
kotlinx-coroutines = "1.8.0"
kotlinx-datetime = "0.6.0-RC.2"