From 15c6b6ea627389ae374082df450356fd976f09b5 Mon Sep 17 00:00:00 2001 From: kagg886 Date: Sat, 18 Jan 2025 14:53:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E8=BF=94=E5=9B=9E=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E6=89=80=E6=9C=89=E9=A1=B5=E9=9D=A2=E9=83=BD?= =?UTF-8?q?=E5=85=B7=E5=A4=87=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kagg886/pmf/ui/component/error-page.kt | 20 ++++++++++--------- .../route/main/detail/author/AuthorScreen.kt | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/top/kagg886/pmf/ui/component/error-page.kt b/composeApp/src/commonMain/kotlin/top/kagg886/pmf/ui/component/error-page.kt index 50aa3aa..37db43d 100644 --- a/composeApp/src/commonMain/kotlin/top/kagg886/pmf/ui/component/error-page.kt +++ b/composeApp/src/commonMain/kotlin/top/kagg886/pmf/ui/component/error-page.kt @@ -17,7 +17,7 @@ import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow @Composable -fun ErrorPage(modifier: Modifier = Modifier, text: String, onClick: () -> Unit) { +fun ErrorPage(modifier: Modifier = Modifier, showBackButton: Boolean = false, text: String, onClick: () -> Unit) { Box(modifier.fillMaxSize(), contentAlignment = Alignment.Center) { Column(modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) { Text(text) @@ -27,14 +27,16 @@ fun ErrorPage(modifier: Modifier = Modifier, text: String, onClick: () -> Unit) } } - val nav = LocalNavigator.currentOrThrow - IconButton( - onClick = { - nav.pop() - }, - modifier = Modifier.align(Alignment.TopStart).padding(16.dp) - ) { - Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null) + if (showBackButton) { + val nav = LocalNavigator.currentOrThrow + IconButton( + onClick = { + nav.pop() + }, + modifier = Modifier.align(Alignment.TopStart).padding(16.dp) + ) { + Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null) + } } } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/top/kagg886/pmf/ui/route/main/detail/author/AuthorScreen.kt b/composeApp/src/commonMain/kotlin/top/kagg886/pmf/ui/route/main/detail/author/AuthorScreen.kt index cf64580..3ee11aa 100644 --- a/composeApp/src/commonMain/kotlin/top/kagg886/pmf/ui/route/main/detail/author/AuthorScreen.kt +++ b/composeApp/src/commonMain/kotlin/top/kagg886/pmf/ui/route/main/detail/author/AuthorScreen.kt @@ -62,7 +62,7 @@ class AuthorScreen(val id: Int, val isOpenInSideBar: Boolean = false) : Screen { } } - @OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class) + @OptIn(ExperimentalMaterial3Api::class) @Composable fun AuthorContent(state: AuthorScreenState) { val model = rememberScreenModel { @@ -70,7 +70,7 @@ class AuthorScreen(val id: Int, val isOpenInSideBar: Boolean = false) : Screen { } when (state) { AuthorScreenState.Error -> { - ErrorPage(text = "加载失败") { + ErrorPage(text = "加载失败", showBackButton = true) { model.loadUserById(id) } }