From a54875e7623301c56b870bf1f150d1bacdbfb7cb Mon Sep 17 00:00:00 2001 From: ryokuno Date: Sat, 17 Aug 2024 16:12:19 +0900 Subject: [PATCH 1/6] Add contentDescription parameter to AnimatedLargeTopAppBar --- .../confsched/ui/component/AnimatedLargeTopAppBar.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt b/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt index 1437795c2..202b19469 100644 --- a/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt +++ b/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt @@ -39,6 +39,7 @@ fun AnimatedLargeTopAppBar( windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, colors: TopAppBarColors = TopAppBarDefaults.largeTopAppBarColors(), scrollBehavior: TopAppBarScrollBehavior? = null, + navIconContentDescription: String? ) { val density = LocalDensity.current.density var navigationIconWidthDp by remember { mutableStateOf(0f) } @@ -92,7 +93,7 @@ fun AnimatedLargeTopAppBar( ) { Icon( imageVector = Filled.ArrowBack, - contentDescription = "Back", + contentDescription = navIconContentDescription, ) } }, From b1e89016d01eb800f95c23cda6b062b798b843bc Mon Sep 17 00:00:00 2001 From: ryokuno Date: Sat, 17 Aug 2024 16:20:25 +0900 Subject: [PATCH 2/6] Refactor to use AnimatedLargeTopAppBar --- .../contributors/ContributorsScreen.kt | 27 +++++-------------- .../confsched/sponsors/SponsorsScreen.kt | 27 +++++-------------- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt b/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt index 545874374..abd23ba63 100644 --- a/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt +++ b/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt @@ -5,16 +5,10 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.material.icons.Icons.AutoMirrored.Filled -import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton -import androidx.compose.material3.LargeTopAppBar import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState -import androidx.compose.material3.Text import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.remember @@ -29,6 +23,7 @@ import io.github.droidkaigi.confsched.contributors.component.ContributorsItem import io.github.droidkaigi.confsched.model.Contributor import io.github.droidkaigi.confsched.ui.SnackbarMessageEffect import io.github.droidkaigi.confsched.ui.UserMessageStateHolder +import io.github.droidkaigi.confsched.ui.component.AnimatedLargeTopAppBar import io.github.droidkaigi.confsched.ui.handleOnClickIfNotNavigating import kotlinx.collections.immutable.PersistentList @@ -106,22 +101,12 @@ fun ContributorsScreen( modifier = modifier.testTag(ContributorsScreenTestTag), snackbarHost = { SnackbarHost(hostState = snackbarHostState) }, topBar = { - if (scrollBehavior != null) { - LargeTopAppBar( - title = { - Text(text = "Contributor") - }, - navigationIcon = { - IconButton( - onClick = onBackClick, - ) { - Icon( - imageVector = Filled.ArrowBack, - contentDescription = "Back", - ) - } - }, + if (!isTopAppBarHidden){ + AnimatedLargeTopAppBar( + title = "Contributor", + onBackClick = onBackClick, scrollBehavior = scrollBehavior, + navIconContentDescription = "Back" ) } }, diff --git a/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt b/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt index f9989e569..30d0d606e 100644 --- a/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt +++ b/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt @@ -1,17 +1,11 @@ package io.github.droidkaigi.confsched.sponsors import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.icons.Icons.AutoMirrored.Filled -import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton -import androidx.compose.material3.LargeTopAppBar import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Surface -import androidx.compose.material3.Text import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.remember @@ -33,6 +27,7 @@ import io.github.droidkaigi.confsched.sponsors.section.SponsorsList import io.github.droidkaigi.confsched.ui.SnackbarMessageEffect import io.github.droidkaigi.confsched.ui.UserMessageStateHolder import io.github.droidkaigi.confsched.ui.UserMessageStateHolderImpl +import io.github.droidkaigi.confsched.ui.component.AnimatedLargeTopAppBar import io.github.droidkaigi.confsched.ui.handleOnClickIfNotNavigating import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.toPersistentList @@ -118,22 +113,12 @@ fun SponsorsScreen( modifier = modifier.testTag(SponsorsScreenTestTag), snackbarHost = { SnackbarHost(hostState = snackbarHostState) }, topBar = { - if (scrollBehavior != null) { - LargeTopAppBar( - title = { - Text(text = stringResource(SponsorsRes.string.sponsor)) - }, - navigationIcon = { - IconButton( - onClick = onBackClick, - ) { - Icon( - imageVector = Filled.ArrowBack, - contentDescription = stringResource(SponsorsRes.string.content_description_back), - ) - } - }, + if (!isTopAppBarHidden) { + AnimatedLargeTopAppBar( + title = stringResource(SponsorsRes.string.sponsor), + onBackClick =onBackClick, scrollBehavior = scrollBehavior, + navIconContentDescription = stringResource(SponsorsRes.string.content_description_back) ) } }, From 5438e9cef4249e2c0a5ffe97b6c99ac1e22ffafb Mon Sep 17 00:00:00 2001 From: ryokuno Date: Sat, 17 Aug 2024 16:22:09 +0900 Subject: [PATCH 3/6] add contentDescription argument --- .../kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt b/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt index af8649ade..751e577e8 100644 --- a/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt +++ b/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt @@ -111,6 +111,7 @@ fun StaffScreen( title = "Staff", onBackClick = onBackClick, scrollBehavior = scrollBehavior, + navIconContentDescription = "Back" ) } }, From 2d11996b657c083d484b99fa6802731725b1107d Mon Sep 17 00:00:00 2001 From: ryokuno Date: Sat, 17 Aug 2024 16:29:22 +0900 Subject: [PATCH 4/6] fix correct code format --- .../confsched/ui/component/AnimatedLargeTopAppBar.kt | 2 +- .../droidkaigi/confsched/contributors/ContributorsScreen.kt | 4 ++-- .../io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt | 4 ++-- .../io/github/droidkaigi/confsched/staff/StaffScreen.kt | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt b/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt index 202b19469..666be3890 100644 --- a/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt +++ b/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt @@ -39,7 +39,7 @@ fun AnimatedLargeTopAppBar( windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, colors: TopAppBarColors = TopAppBarDefaults.largeTopAppBarColors(), scrollBehavior: TopAppBarScrollBehavior? = null, - navIconContentDescription: String? + navIconContentDescription: String?, ) { val density = LocalDensity.current.density var navigationIconWidthDp by remember { mutableStateOf(0f) } diff --git a/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt b/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt index abd23ba63..84e198984 100644 --- a/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt +++ b/feature/contributors/src/commonMain/kotlin/io/github/droidkaigi/confsched/contributors/ContributorsScreen.kt @@ -101,12 +101,12 @@ fun ContributorsScreen( modifier = modifier.testTag(ContributorsScreenTestTag), snackbarHost = { SnackbarHost(hostState = snackbarHostState) }, topBar = { - if (!isTopAppBarHidden){ + if (!isTopAppBarHidden) { AnimatedLargeTopAppBar( title = "Contributor", onBackClick = onBackClick, scrollBehavior = scrollBehavior, - navIconContentDescription = "Back" + navIconContentDescription = "Back", ) } }, diff --git a/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt b/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt index 30d0d606e..a7fd855df 100644 --- a/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt +++ b/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt @@ -116,9 +116,9 @@ fun SponsorsScreen( if (!isTopAppBarHidden) { AnimatedLargeTopAppBar( title = stringResource(SponsorsRes.string.sponsor), - onBackClick =onBackClick, + onBackClick = onBackClick, scrollBehavior = scrollBehavior, - navIconContentDescription = stringResource(SponsorsRes.string.content_description_back) + navIconContentDescription = stringResource(SponsorsRes.string.content_description_back), ) } }, diff --git a/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt b/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt index 751e577e8..68cb1843d 100644 --- a/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt +++ b/feature/staff/src/commonMain/kotlin/io/github/droidkaigi/confsched/staff/StaffScreen.kt @@ -111,7 +111,7 @@ fun StaffScreen( title = "Staff", onBackClick = onBackClick, scrollBehavior = scrollBehavior, - navIconContentDescription = "Back" + navIconContentDescription = "Back", ) } }, From 44cc80995eafd7eb203a2212afd987c578ae02c0 Mon Sep 17 00:00:00 2001 From: ryokuno Date: Sat, 17 Aug 2024 16:33:18 +0900 Subject: [PATCH 5/6] fix params order --- .../droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt b/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt index 666be3890..8a0a6412b 100644 --- a/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt +++ b/core/ui/src/commonMain/kotlin/io/github/droidkaigi/confsched/ui/component/AnimatedLargeTopAppBar.kt @@ -34,12 +34,12 @@ import androidx.compose.ui.unit.dp fun AnimatedLargeTopAppBar( title: String, onBackClick: () -> Unit, + navIconContentDescription: String?, modifier: Modifier = Modifier, actions: @Composable RowScope.() -> Unit = {}, windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, colors: TopAppBarColors = TopAppBarDefaults.largeTopAppBarColors(), scrollBehavior: TopAppBarScrollBehavior? = null, - navIconContentDescription: String?, ) { val density = LocalDensity.current.density var navigationIconWidthDp by remember { mutableStateOf(0f) } From 4f91e5f482c502fedb04eb43b3c1817d9be5329b Mon Sep 17 00:00:00 2001 From: ryokuno Date: Sat, 17 Aug 2024 17:12:55 +0900 Subject: [PATCH 6/6] delete unnecessary imports --- .../io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt b/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt index 92a292062..79c0d7e8b 100644 --- a/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt +++ b/feature/sponsors/src/commonMain/kotlin/io/github/droidkaigi/confsched/sponsors/SponsorsScreen.kt @@ -3,8 +3,6 @@ package io.github.droidkaigi.confsched.sponsors import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.material.icons.Icons.AutoMirrored.Filled -import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost