diff --git a/core/designsystem/src/main/java/com/droidknights/app2023/core/designsystem/component/Card.kt b/core/designsystem/src/main/java/com/droidknights/app2023/core/designsystem/component/Card.kt index 9f3f51f8..9d1969da 100644 --- a/core/designsystem/src/main/java/com/droidknights/app2023/core/designsystem/component/Card.kt +++ b/core/designsystem/src/main/java/com/droidknights/app2023/core/designsystem/component/Card.kt @@ -32,7 +32,7 @@ fun KnightsCard( fun KnightsCard( modifier: Modifier = Modifier, onClick: () -> Unit = {}, - color: Color = Color(0xFFFFFFFF), + color: Color = MaterialTheme.colorScheme.surface, content: @Composable () -> Unit, ) { Surface( diff --git a/feature/main/src/main/java/com/droidknights/app2023/feature/main/MainNavigator.kt b/feature/main/src/main/java/com/droidknights/app2023/feature/main/MainNavigator.kt index 9ba08f54..93ecff9e 100644 --- a/feature/main/src/main/java/com/droidknights/app2023/feature/main/MainNavigator.kt +++ b/feature/main/src/main/java/com/droidknights/app2023/feature/main/MainNavigator.kt @@ -11,6 +11,7 @@ import androidx.navigation.navOptions import com.droidknights.app2023.feature.contributor.navigation.navigateContributor import com.droidknights.app2023.feature.home.navigation.navigateHome import com.droidknights.app2023.feature.session.navigation.navigateSession +import com.droidknights.app2023.feature.session.navigation.navigateSessionDetail import com.droidknights.app2023.feature.setting.navigation.navigateSetting internal class MainNavigator( @@ -51,6 +52,10 @@ internal class MainNavigator( fun navigateSession() { navController.navigateSession() } + + fun navigateSessionDetail(sessionId: String) { + navController.navigateSessionDetail(sessionId) + } fun popBackStack() { navController.popBackStack() diff --git a/feature/main/src/main/java/com/droidknights/app2023/feature/main/MainScreen.kt b/feature/main/src/main/java/com/droidknights/app2023/feature/main/MainScreen.kt index ee6a3bb2..aea10648 100644 --- a/feature/main/src/main/java/com/droidknights/app2023/feature/main/MainScreen.kt +++ b/feature/main/src/main/java/com/droidknights/app2023/feature/main/MainScreen.kt @@ -75,7 +75,8 @@ internal fun MainScreen(navigator: MainNavigator = rememberMainNavigator()) { ) sessionNavGraph( - onBackClick = { navigator.popBackStack() } + onBackClick = { navigator.popBackStack() }, + onSessionClick = { navigator.navigateSessionDetail("TODO") } ) composable("temp") { content("temp") } diff --git a/feature/session/src/main/java/com/droidknights/app2023/feature/session/SessionCard.kt b/feature/session/src/main/java/com/droidknights/app2023/feature/session/SessionCard.kt index d5c1e4e3..42bd047f 100644 --- a/feature/session/src/main/java/com/droidknights/app2023/feature/session/SessionCard.kt +++ b/feature/session/src/main/java/com/droidknights/app2023/feature/session/SessionCard.kt @@ -41,8 +41,9 @@ import java.time.format.DateTimeFormatter internal fun SessionCard( session: Session, modifier: Modifier = Modifier, + onSessionClick: (Session) -> Unit = { }, ) { - KnightsCard(modifier = modifier) { + KnightsCard(modifier = modifier, onClick = { onSessionClick(session) }) { Column( modifier = Modifier.padding(CardContentPadding) ) { diff --git a/feature/session/src/main/java/com/droidknights/app2023/feature/session/SessionDetailScreen.kt b/feature/session/src/main/java/com/droidknights/app2023/feature/session/SessionDetailScreen.kt new file mode 100644 index 00000000..131e12bc --- /dev/null +++ b/feature/session/src/main/java/com/droidknights/app2023/feature/session/SessionDetailScreen.kt @@ -0,0 +1,11 @@ +package com.droidknights.app2023.feature.session + +import androidx.compose.runtime.Composable + +@Composable +internal fun SessionDetailScreen( + sessionId: String, + onBackClick: () -> Unit, +) { + // TODO : UI 구현 +} diff --git a/feature/session/src/main/java/com/droidknights/app2023/feature/session/SessionScreen.kt b/feature/session/src/main/java/com/droidknights/app2023/feature/session/SessionScreen.kt index f0b2b4e5..e0f250f9 100644 --- a/feature/session/src/main/java/com/droidknights/app2023/feature/session/SessionScreen.kt +++ b/feature/session/src/main/java/com/droidknights/app2023/feature/session/SessionScreen.kt @@ -28,6 +28,7 @@ import com.droidknights.app2023.core.model.Session @Composable internal fun SessionScreen( onBackClick: () -> Unit, + onSessionClick: (Session) -> Unit, sessionViewModel: SessionViewModel = hiltViewModel(), ) { val sessionUiState by sessionViewModel.uiState.collectAsStateWithLifecycle() @@ -43,7 +44,8 @@ internal fun SessionScreen( modifier = Modifier .systemBarsPadding() .padding(top = 48.dp) - .fillMaxSize() + .fillMaxSize(), + onSessionClick = onSessionClick, ) } } @@ -51,6 +53,7 @@ internal fun SessionScreen( @Composable private fun SessionContent( sessionState: SessionState, + onSessionClick: (Session) -> Unit, modifier: Modifier = Modifier, ) { LazyColumn( @@ -65,7 +68,12 @@ private fun SessionContent( } else { SessionGroupSpace } - sessionItems(room = group.room, items = group.sessions, topPadding = topPadding) + sessionItems( + room = group.room, + items = group.sessions, + topPadding = topPadding, + onItemClick = onSessionClick, + ) } } } @@ -73,9 +81,20 @@ private fun SessionContent( private val SessionTopSpace = 4.dp private val SessionGroupSpace = 16.dp -private fun LazyListScope.sessionItems(room: Room, items: List, topPadding: Dp) { +private fun LazyListScope.sessionItems( + room: Room, + items: List, + topPadding: Dp, + onItemClick: (Session) -> Unit, +) { itemsIndexed(items) { index, item -> - SessionItem(index = index, item = item, room = room, topPadding = topPadding) + SessionItem( + index = index, + item = item, + room = room, + topPadding = topPadding, + onItemClick = onItemClick + ) } } @@ -85,12 +104,13 @@ private fun SessionItem( item: Session, room: Room, topPadding: Dp, + onItemClick: (Session) -> Unit, ) { Column { if (index == 0) { RoomTitle(room = room, topPadding = topPadding) } - SessionCard(item) + SessionCard(session = item, onSessionClick = onItemClick) } } diff --git a/feature/session/src/main/java/com/droidknights/app2023/feature/session/navigation/SessionNavigation.kt b/feature/session/src/main/java/com/droidknights/app2023/feature/session/navigation/SessionNavigation.kt index aa4e9e22..bfc7c8e5 100644 --- a/feature/session/src/main/java/com/droidknights/app2023/feature/session/navigation/SessionNavigation.kt +++ b/feature/session/src/main/java/com/droidknights/app2023/feature/session/navigation/SessionNavigation.kt @@ -2,18 +2,43 @@ package com.droidknights.app2023.feature.session.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavType import androidx.navigation.compose.composable +import androidx.navigation.navArgument +import com.droidknights.app2023.core.model.Session +import com.droidknights.app2023.feature.session.SessionDetailScreen import com.droidknights.app2023.feature.session.SessionScreen fun NavController.navigateSession() { navigate(SessionRoute.route) } +fun NavController.navigateSessionDetail(sessionId: String) { + navigate(SessionRoute.detailRoute(sessionId)) +} + fun NavGraphBuilder.sessionNavGraph( onBackClick: () -> Unit, + onSessionClick: (Session) -> Unit, ) { composable(SessionRoute.route) { SessionScreen( + onBackClick = onBackClick, + onSessionClick = onSessionClick, + ) + } + + composable( + route = SessionRoute.detailRoute("{id}"), + arguments = listOf( + navArgument("id") { + type = NavType.StringType + } + ) + ) { navBackStackEntry -> + val sessionId = navBackStackEntry.arguments?.getString("id") ?: "" + SessionDetailScreen( + sessionId = sessionId, onBackClick = onBackClick ) } @@ -21,4 +46,6 @@ fun NavGraphBuilder.sessionNavGraph( object SessionRoute { val route: String = "session" + + fun detailRoute(sessionId: String): String = "${route}/$sessionId" }