forked from droidknights/DroidKnightsApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature/droidknights#300] Apply RouteModel on MainNavigator
- Loading branch information
Showing
3 changed files
with
38 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 16 additions & 12 deletions
28
feature/main/src/main/java/com/droidknights/app/feature/main/MainTab.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,42 @@ | ||
package com.droidknights.app.feature.main | ||
|
||
import com.droidknights.app.feature.bookmark.navigation.BookmarkRoute | ||
import com.droidknights.app.feature.home.navigation.HomeRoute | ||
import com.droidknights.app.feature.setting.navigation.SettingRoute | ||
import androidx.compose.runtime.Composable | ||
import com.droidknights.app.core.navigation.Bookmark | ||
import com.droidknights.app.core.navigation.Home | ||
import com.droidknights.app.core.navigation.MainTabRoute | ||
import com.droidknights.app.core.navigation.Route | ||
import com.droidknights.app.core.navigation.Setting | ||
|
||
internal enum class MainTab( | ||
val iconResId: Int, | ||
internal val contentDescription: String, | ||
val route: String, | ||
val route: MainTabRoute, | ||
) { | ||
SETTING( | ||
iconResId = R.drawable.ic_setting, | ||
contentDescription = "설정", | ||
SettingRoute.ROUTE_SETTING, | ||
Setting, | ||
), | ||
HOME( | ||
iconResId = R.drawable.ic_home, | ||
contentDescription = "홈", | ||
HomeRoute.ROUTE, | ||
Home | ||
), | ||
BOOKMARK( | ||
iconResId = R.drawable.ic_bookmark, | ||
contentDescription = "북마크", | ||
BookmarkRoute.ROUTE, | ||
Bookmark, | ||
); | ||
|
||
companion object { | ||
|
||
operator fun contains(route: String): Boolean { | ||
return entries.map { it.route }.contains(route) | ||
@Composable | ||
fun find(predicate: @Composable (MainTabRoute) -> Boolean): MainTab? { | ||
return entries.find { predicate(it.route) } | ||
} | ||
|
||
fun find(route: String): MainTab? { | ||
return entries.find { it.route == route } | ||
@Composable | ||
fun contains(predicate: @Composable (Route) -> Boolean): Boolean { | ||
return entries.map { it.route }.any { predicate(it) } | ||
} | ||
} | ||
} |