Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Setting] 설정 화면 Route 추가 #60

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions feature/main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android {

dependencies {
implementation(project(":feature:home"))
implementation(project(":feature:setting"))

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.activity.compose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.droidknights.app2023.feature.home.navigation.HomeRoute
import com.droidknights.app2023.feature.home.navigation.navigateHome
import com.droidknights.app2023.feature.setting.navigation.SettingRoute
import com.droidknights.app2023.feature.setting.navigation.navigateSetting

internal class MainNavigator(
startTab: MainTab = MainTab.HOME,
val navController: NavHostController,
) {
val startDestination: String = when (startTab) {
MainTab.HOME -> HomeRoute.route
MainTab.SETTING -> "setting"
MainTab.SETTING -> SettingRoute.route
MainTab.TEMP -> "temp"
}

var currentTab: MainTab by mutableStateOf(startTab)
private set

fun navigate(tab: MainTab) {
if (tab == currentTab) return
when (tab) {
MainTab.SETTING -> navController.navigate("setting") // TODO: navigate settings
MainTab.SETTING -> navController.navigateSetting()
MainTab.HOME -> navController.navigateHome()
MainTab.TEMP -> navController.navigate("temp") // TODO: ???
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.ui.unit.dp
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import com.droidknights.app2023.feature.home.navigation.homeNavGraph
import com.droidknights.app2023.feature.setting.navigation.settingNavGraph

@Composable
internal fun MainScreen(navigator: MainNavigator = rememberMainNavigator()) {
Expand All @@ -46,6 +47,8 @@ internal fun MainScreen(navigator: MainNavigator = rememberMainNavigator()) {
) {
homeNavGraph()

settingNavGraph()

// TODO: 각 모듈로 이동
val content: @Composable (String) -> Unit = {
Box(
Expand All @@ -54,7 +57,6 @@ internal fun MainScreen(navigator: MainNavigator = rememberMainNavigator()) {
content = { Text(text = it) }
)
}
composable("setting") { content("setting") }
composable("temp") { content("temp") }
}
}
Expand Down
4 changes: 4 additions & 0 deletions feature/setting/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ plugins {
android {
namespace = "com.droidknights.app2023.feature.setting"
}

dependencies {
implementation(libs.androidx.compose.navigation)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.droidknights.app2023.feature.setting

import androidx.compose.runtime.Composable

@Composable
internal fun SettingScreen() {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.droidknights.app2023.feature.setting.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import com.droidknights.app2023.feature.setting.SettingScreen

fun NavController.navigateSetting() {
navigate(SettingRoute.route)
}

fun NavGraphBuilder.settingNavGraph() {
composable(route = SettingRoute.route) {
SettingScreen()
}
}

object SettingRoute {
const val route = "setting"
}