-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[feature/#300] Apply Type Safe Navigation
- Loading branch information
Showing
11 changed files
with
76 additions
and
72 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
Empty file.
25 changes: 25 additions & 0 deletions
25
core/navigation/src/main/java/com/droidknights/app/core/navigation/RouteModel.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.droidknights.app.core.navigation | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
sealed interface Route { | ||
@Serializable | ||
data object Contributor : Route | ||
|
||
@Serializable | ||
data object Session : Route | ||
|
||
@Serializable | ||
data class SessionDetail(val sessionId: String) : Route | ||
} | ||
|
||
sealed interface MainTabRoute : Route { | ||
@Serializable | ||
data object Home : MainTabRoute | ||
|
||
@Serializable | ||
data object Setting : MainTabRoute | ||
|
||
@Serializable | ||
data object Bookmark : MainTabRoute | ||
} |
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
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
25 changes: 13 additions & 12 deletions
25
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,39 @@ | ||
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.MainTabRoute | ||
import com.droidknights.app.core.navigation.Route | ||
|
||
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, | ||
MainTabRoute.Setting, | ||
), | ||
HOME( | ||
iconResId = R.drawable.ic_home, | ||
contentDescription = "홈", | ||
HomeRoute.ROUTE, | ||
MainTabRoute.Home | ||
), | ||
BOOKMARK( | ||
iconResId = R.drawable.ic_bookmark, | ||
contentDescription = "북마크", | ||
BookmarkRoute.ROUTE, | ||
MainTabRoute.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) } | ||
} | ||
} | ||
} |
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
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