mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 22:37:03 +05:30
Make bottom nav icons part of destination classes
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
41521cca95
commit
b195c0d203
2 changed files with 5 additions and 10 deletions
|
@ -62,14 +62,7 @@ fun LobstersApp() {
|
|||
val currentRoute = navBackStackEntry?.arguments?.getString(KEY_ROUTE)
|
||||
destinations.forEach { screen ->
|
||||
BottomNavigationItem(
|
||||
icon = {
|
||||
IconResource(
|
||||
resourceId = when (screen) {
|
||||
Destination.Hottest -> R.drawable.ic_whatshot_24px
|
||||
Destination.Saved -> R.drawable.ic_favorite_24px
|
||||
}
|
||||
)
|
||||
},
|
||||
icon = { IconResource(resourceId = screen.badgeRes) },
|
||||
label = { Text(stringResource(id = screen.labelRes)) },
|
||||
selected = currentRoute == screen.route,
|
||||
onClick = {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.msfjarvis.lobsters.ui
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import dev.msfjarvis.lobsters.R
|
||||
|
||||
|
@ -9,7 +10,8 @@ import dev.msfjarvis.lobsters.R
|
|||
sealed class Destination(
|
||||
val route: String,
|
||||
@StringRes val labelRes: Int,
|
||||
@DrawableRes val badgeRes: Int,
|
||||
) {
|
||||
object Hottest : Destination("hottest", R.string.hottest_posts)
|
||||
object Saved : Destination("saved", R.string.saved_posts)
|
||||
object Hottest : Destination("hottest", R.string.hottest_posts, R.drawable.ic_whatshot_24px)
|
||||
object Saved : Destination("saved", R.string.saved_posts, R.drawable.ic_favorite_24px)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue