From 3a6fb2a6f05dc703e44f113617a64a239588d026 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Fri, 16 Aug 2024 14:13:55 +0800 Subject: [PATCH] Fix(Navigation): Fixed the bug that can not higlight store navigation icon Fixed the bug that the store navigation icon cannot be automatically highlighted when switching to the ToolStore page. --- .../fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt | 4 ++++ app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt index 9653dd9..cdd6f33 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt @@ -6,12 +6,14 @@ import top.fatweb.oxygen.toolbox.R import top.fatweb.oxygen.toolbox.icon.OxygenIcons enum class TopLevelDestination( + val route: String, val selectedIcon: ImageVector, val unselectedIcon: ImageVector, @StringRes val iconTextId: Int, @StringRes val titleTextId: Int ) { ToolStore( + route = "tool_store_route", selectedIcon = OxygenIcons.Store, unselectedIcon = OxygenIcons.StoreBorder, iconTextId = R.string.feature_store_title, @@ -19,6 +21,7 @@ enum class TopLevelDestination( ), Tools( + route = "tools_route", selectedIcon = OxygenIcons.Home, unselectedIcon = OxygenIcons.HomeBorder, iconTextId = R.string.feature_tools_title, @@ -26,6 +29,7 @@ enum class TopLevelDestination( ), Star( + route = "star_route", selectedIcon = OxygenIcons.Star, unselectedIcon = OxygenIcons.StarBorder, iconTextId = R.string.feature_star_title, diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt index 6a4cbd5..db7353f 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt @@ -252,5 +252,5 @@ private fun OxygenNavRail( private fun NavDestination?.isTopLevelDestinationInHierarchy(destination: TopLevelDestination) = this?.hierarchy?.any { - it.route?.contains(destination.name, true) ?: false + it.route?.equals(destination.route) ?: false } ?: false