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.
This commit is contained in:
@@ -6,12 +6,14 @@ import top.fatweb.oxygen.toolbox.R
|
|||||||
import top.fatweb.oxygen.toolbox.icon.OxygenIcons
|
import top.fatweb.oxygen.toolbox.icon.OxygenIcons
|
||||||
|
|
||||||
enum class TopLevelDestination(
|
enum class TopLevelDestination(
|
||||||
|
val route: String,
|
||||||
val selectedIcon: ImageVector,
|
val selectedIcon: ImageVector,
|
||||||
val unselectedIcon: ImageVector,
|
val unselectedIcon: ImageVector,
|
||||||
@StringRes val iconTextId: Int,
|
@StringRes val iconTextId: Int,
|
||||||
@StringRes val titleTextId: Int
|
@StringRes val titleTextId: Int
|
||||||
) {
|
) {
|
||||||
ToolStore(
|
ToolStore(
|
||||||
|
route = "tool_store_route",
|
||||||
selectedIcon = OxygenIcons.Store,
|
selectedIcon = OxygenIcons.Store,
|
||||||
unselectedIcon = OxygenIcons.StoreBorder,
|
unselectedIcon = OxygenIcons.StoreBorder,
|
||||||
iconTextId = R.string.feature_store_title,
|
iconTextId = R.string.feature_store_title,
|
||||||
@@ -19,6 +21,7 @@ enum class TopLevelDestination(
|
|||||||
),
|
),
|
||||||
|
|
||||||
Tools(
|
Tools(
|
||||||
|
route = "tools_route",
|
||||||
selectedIcon = OxygenIcons.Home,
|
selectedIcon = OxygenIcons.Home,
|
||||||
unselectedIcon = OxygenIcons.HomeBorder,
|
unselectedIcon = OxygenIcons.HomeBorder,
|
||||||
iconTextId = R.string.feature_tools_title,
|
iconTextId = R.string.feature_tools_title,
|
||||||
@@ -26,6 +29,7 @@ enum class TopLevelDestination(
|
|||||||
),
|
),
|
||||||
|
|
||||||
Star(
|
Star(
|
||||||
|
route = "star_route",
|
||||||
selectedIcon = OxygenIcons.Star,
|
selectedIcon = OxygenIcons.Star,
|
||||||
unselectedIcon = OxygenIcons.StarBorder,
|
unselectedIcon = OxygenIcons.StarBorder,
|
||||||
iconTextId = R.string.feature_star_title,
|
iconTextId = R.string.feature_star_title,
|
||||||
|
|||||||
@@ -252,5 +252,5 @@ private fun OxygenNavRail(
|
|||||||
|
|
||||||
private fun NavDestination?.isTopLevelDestinationInHierarchy(destination: TopLevelDestination) =
|
private fun NavDestination?.isTopLevelDestinationInHierarchy(destination: TopLevelDestination) =
|
||||||
this?.hierarchy?.any {
|
this?.hierarchy?.any {
|
||||||
it.route?.contains(destination.name, true) ?: false
|
it.route?.equals(destination.route) ?: false
|
||||||
} ?: false
|
} ?: false
|
||||||
|
|||||||
Reference in New Issue
Block a user