From 6b04a1153f98dda69f0a9ca0928eb2d2998f7a7e Mon Sep 17 00:00:00 2001 From: takahirom Date: Tue, 18 Jun 2024 10:31:37 +0900 Subject: [PATCH] Add event map to tabs --- app-android/build.gradle.kts | 1 + .../io/github/droidkaigi/confsched/KaigiApp.kt | 14 ++++++++++---- app-ios-shared/build.gradle.kts | 1 + .../confsched/shared/IosComposeKaigiApp.kt | 9 +++++---- .../confsched/testing/robot/KaigiAppRobot.kt | 4 ++-- .../confsched/eventmap/EventMapScreen.kt | 16 ++++++++++++++-- .../droidkaigi/confsched/main/MainScreen.kt | 8 ++++---- .../confsched/main/strings/MainStrings.kt | 6 +++--- 8 files changed, 40 insertions(+), 19 deletions(-) diff --git a/app-android/build.gradle.kts b/app-android/build.gradle.kts index 287a18875..f19bf69ea 100644 --- a/app-android/build.gradle.kts +++ b/app-android/build.gradle.kts @@ -99,6 +99,7 @@ dependencies { implementation(projects.feature.main) implementation(projects.feature.contributors) implementation(projects.feature.sessions) + implementation(projects.feature.eventmap) implementation(projects.core.model) implementation(projects.core.data) implementation(projects.core.designsystem) diff --git a/app-android/src/main/java/io/github/droidkaigi/confsched/KaigiApp.kt b/app-android/src/main/java/io/github/droidkaigi/confsched/KaigiApp.kt index 0e8004370..58a4efabe 100644 --- a/app-android/src/main/java/io/github/droidkaigi/confsched/KaigiApp.kt +++ b/app-android/src/main/java/io/github/droidkaigi/confsched/KaigiApp.kt @@ -29,11 +29,13 @@ import com.google.android.gms.oss.licenses.OssLicensesMenuActivity import io.github.droidkaigi.confsched.contributors.contributorsScreenRoute import io.github.droidkaigi.confsched.contributors.contributorsScreens import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme +import io.github.droidkaigi.confsched.eventmap.eventMapScreens +import io.github.droidkaigi.confsched.eventmap.navigateEventMapScreen import io.github.droidkaigi.confsched.main.MainNestedGraphStateHolder import io.github.droidkaigi.confsched.main.MainScreenTab import io.github.droidkaigi.confsched.main.MainScreenTab.About -import io.github.droidkaigi.confsched.main.MainScreenTab.Achievements -import io.github.droidkaigi.confsched.main.MainScreenTab.FloorMap +import io.github.droidkaigi.confsched.main.MainScreenTab.EventMap +import io.github.droidkaigi.confsched.main.MainScreenTab.ProfileCard import io.github.droidkaigi.confsched.main.MainScreenTab.Timetable import io.github.droidkaigi.confsched.main.mainScreen import io.github.droidkaigi.confsched.main.mainScreenRoute @@ -109,6 +111,10 @@ private fun NavGraphBuilder.mainScreen( onTimetableItemClick = navController::navigateToTimetableItemDetailScreen, contentPadding = contentPadding, ) + eventMapScreens( + onNavigationIconClick = navController::popBackStack, + onEventMapItemClick = externalNavController::navigate, + ) }, ) } @@ -129,9 +135,9 @@ class KaigiAppMainNestedGraphStateHolder : MainNestedGraphStateHolder { ) { when (tab) { Timetable -> mainNestedNavController.navigateTimetableScreen() + EventMap -> mainNestedNavController.navigateEventMapScreen() About -> TODO() - FloorMap -> TODO() - Achievements -> TODO() + ProfileCard -> TODO() } } } diff --git a/app-ios-shared/build.gradle.kts b/app-ios-shared/build.gradle.kts index f75da8a62..f23a4a5ea 100644 --- a/app-ios-shared/build.gradle.kts +++ b/app-ios-shared/build.gradle.kts @@ -53,6 +53,7 @@ kotlin { api(projects.core.ui) api(projects.feature.main) api(projects.feature.sessions) + api(projects.feature.eventmap) api(projects.feature.contributors) implementation(libs.kotlinxCoroutinesCore) implementation(libs.skieAnnotation) diff --git a/app-ios-shared/src/commonMain/kotlin/io/github/droidkaigi/confsched/shared/IosComposeKaigiApp.kt b/app-ios-shared/src/commonMain/kotlin/io/github/droidkaigi/confsched/shared/IosComposeKaigiApp.kt index 6810506d6..9b61da96e 100644 --- a/app-ios-shared/src/commonMain/kotlin/io/github/droidkaigi/confsched/shared/IosComposeKaigiApp.kt +++ b/app-ios-shared/src/commonMain/kotlin/io/github/droidkaigi/confsched/shared/IosComposeKaigiApp.kt @@ -20,11 +20,12 @@ import io.github.droidkaigi.confsched.contributors.ContributorsScreen import io.github.droidkaigi.confsched.contributors.contributorsScreenRoute import io.github.droidkaigi.confsched.data.Repositories import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme +import io.github.droidkaigi.confsched.eventmap.navigateEventMapScreen import io.github.droidkaigi.confsched.main.MainNestedGraphStateHolder import io.github.droidkaigi.confsched.main.MainScreenTab import io.github.droidkaigi.confsched.main.MainScreenTab.About -import io.github.droidkaigi.confsched.main.MainScreenTab.Achievements -import io.github.droidkaigi.confsched.main.MainScreenTab.FloorMap +import io.github.droidkaigi.confsched.main.MainScreenTab.EventMap +import io.github.droidkaigi.confsched.main.MainScreenTab.ProfileCard import io.github.droidkaigi.confsched.main.MainScreenTab.Timetable import io.github.droidkaigi.confsched.main.mainScreen import io.github.droidkaigi.confsched.main.mainScreenRoute @@ -138,9 +139,9 @@ class KaigiAppMainNestedGraphStateHolder : MainNestedGraphStateHolder { ) { when (tab) { Timetable -> mainNestedNavController.navigateTimetableScreen() + EventMap -> mainNestedNavController.navigateEventMapScreen() About -> TODO() - FloorMap -> TODO() - Achievements -> TODO() + ProfileCard -> TODO() } } } diff --git a/core/testing/src/main/java/io/github/droidkaigi/confsched/testing/robot/KaigiAppRobot.kt b/core/testing/src/main/java/io/github/droidkaigi/confsched/testing/robot/KaigiAppRobot.kt index 28fac9b44..73caa7eab 100644 --- a/core/testing/src/main/java/io/github/droidkaigi/confsched/testing/robot/KaigiAppRobot.kt +++ b/core/testing/src/main/java/io/github/droidkaigi/confsched/testing/robot/KaigiAppRobot.kt @@ -22,7 +22,7 @@ class KaigiAppRobot @Inject constructor( fun goToFloorMap() { composeTestRule - .onNode(hasTestTag(MainScreenTab.FloorMap.testTag)) + .onNode(hasTestTag(MainScreenTab.About.testTag)) .performClick() waitUntilIdle() } @@ -30,7 +30,7 @@ class KaigiAppRobot @Inject constructor( fun goToAchievements() { composeTestRule .onAllNodes( - matcher = hasTestTag(MainScreenTab.Achievements.testTag), + matcher = hasTestTag(MainScreenTab.ProfileCard.testTag), useUnmergedTree = true, ) .onFirst() diff --git a/feature/eventmap/src/commonMain/kotlin/io/github/droidkaigi/confsched/eventmap/EventMapScreen.kt b/feature/eventmap/src/commonMain/kotlin/io/github/droidkaigi/confsched/eventmap/EventMapScreen.kt index c0b4c6f5f..b77cda763 100644 --- a/feature/eventmap/src/commonMain/kotlin/io/github/droidkaigi/confsched/eventmap/EventMapScreen.kt +++ b/feature/eventmap/src/commonMain/kotlin/io/github/droidkaigi/confsched/eventmap/EventMapScreen.kt @@ -22,6 +22,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.platform.testTag +import androidx.navigation.NavController +import androidx.navigation.NavGraph.Companion.findStartDestination import androidx.navigation.NavGraphBuilder import androidx.navigation.compose.composable import co.touchlab.kermit.Logger @@ -38,7 +40,7 @@ const val EventMapScreenTestTag = "EventMapScreenTestTag" fun NavGraphBuilder.eventMapScreens( onNavigationIconClick: () -> Unit, - onContributorItemClick: (url: String) -> Unit, + onEventMapItemClick: (url: String) -> Unit, ) { composable(eventMapScreenRoute) { val lifecycleOwner = LocalLifecycleOwner.current @@ -49,11 +51,21 @@ fun NavGraphBuilder.eventMapScreens( onNavigationIconClick, ) }, - onEventMapItemClick = onContributorItemClick, + onEventMapItemClick = onEventMapItemClick, ) } } +fun NavController.navigateEventMapScreen() { + navigate(eventMapScreenRoute) { + popUpTo(route = checkNotNull(graph.findStartDestination().route)) { + saveState = true + } + launchSingleTop = true + restoreState = true + } +} + data class EventMapUiState( val eventMap: PersistentList, val userMessageStateHolder: UserMessageStateHolder, diff --git a/feature/main/src/commonMain/kotlin/io/github/droidkaigi/confsched/main/MainScreen.kt b/feature/main/src/commonMain/kotlin/io/github/droidkaigi/confsched/main/MainScreen.kt index 05d597106..a84b9e860 100644 --- a/feature/main/src/commonMain/kotlin/io/github/droidkaigi/confsched/main/MainScreen.kt +++ b/feature/main/src/commonMain/kotlin/io/github/droidkaigi/confsched/main/MainScreen.kt @@ -130,15 +130,15 @@ enum class MainScreenTab( ), @OptIn(ExperimentalResourceApi::class) - FloorMap( + EventMap( icon = IconRepresentation.Vector(Icons.Outlined.Map), selectedIcon = IconRepresentation.Drawable(drawableId = Res.drawable.icon_map_fill), - label = MainStrings.FloorMap.asString(), - contentDescription = MainStrings.FloorMap.asString(), + label = MainStrings.EventMap.asString(), + contentDescription = MainStrings.EventMap.asString(), ), @OptIn(ExperimentalResourceApi::class) - Achievements( + ProfileCard( icon = IconRepresentation.Drawable(drawableId = Res.drawable.icon_achievement_outline), selectedIcon = IconRepresentation.Drawable(drawableId = Res.drawable.icon_achievement_fill), label = MainStrings.Achievements.asString(), diff --git a/feature/main/src/commonMain/kotlin/io/github/droidkaigi/confsched/main/strings/MainStrings.kt b/feature/main/src/commonMain/kotlin/io/github/droidkaigi/confsched/main/strings/MainStrings.kt index 5103b6f15..eadd34847 100644 --- a/feature/main/src/commonMain/kotlin/io/github/droidkaigi/confsched/main/strings/MainStrings.kt +++ b/feature/main/src/commonMain/kotlin/io/github/droidkaigi/confsched/main/strings/MainStrings.kt @@ -6,7 +6,7 @@ import io.github.droidkaigi.confsched.designsystem.strings.StringsBindings sealed class MainStrings : Strings(Bindings) { data object Timetable : MainStrings() - data object FloorMap : MainStrings() + data object EventMap : MainStrings() data object Achievements : MainStrings() data object About : MainStrings() data object Contributors : MainStrings() @@ -16,7 +16,7 @@ sealed class MainStrings : Strings(Bindings) { Lang.Japanese to { item, _ -> when (item) { Timetable -> "Timetable" - FloorMap -> "Floor Map" + EventMap -> "Event Map" Achievements -> "Achievements" About -> "About" Contributors -> "Contributors" @@ -26,7 +26,7 @@ sealed class MainStrings : Strings(Bindings) { Lang.English to { item, bindings -> when (item) { Timetable -> "Timetable" - FloorMap -> "Floor Map" + EventMap -> "Event Map" Achievements -> "Achievements" About -> "About" Contributors -> "Contributors"