Skip to content

Commit

Permalink
Merge pull request #135 from laco-dev/feature/#133
Browse files Browse the repository at this point in the history
[Session] 세션 상세 - 이동 방법 추가
  • Loading branch information
laco-dev authored Jul 29, 2023
2 parents 9a11cac + 22e0dfc commit 9da097b
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -51,6 +52,10 @@ internal class MainNavigator(
fun navigateSession() {
navController.navigateSession()
}

fun navigateSessionDetail(sessionId: String) {
navController.navigateSessionDetail(sessionId)
}

fun popBackStack() {
navController.popBackStack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 구현
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -43,14 +44,16 @@ internal fun SessionScreen(
modifier = Modifier
.systemBarsPadding()
.padding(top = 48.dp)
.fillMaxSize()
.fillMaxSize(),
onSessionClick = onSessionClick,
)
}
}

@Composable
private fun SessionContent(
sessionState: SessionState,
onSessionClick: (Session) -> Unit,
modifier: Modifier = Modifier,
) {
LazyColumn(
Expand All @@ -65,17 +68,33 @@ 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,
)
}
}
}

private val SessionTopSpace = 4.dp
private val SessionGroupSpace = 16.dp

private fun LazyListScope.sessionItems(room: Room, items: List<Session>, topPadding: Dp) {
private fun LazyListScope.sessionItems(
room: Room,
items: List<Session>,
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
)
}
}

Expand All @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,50 @@ 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
)
}
}

object SessionRoute {
val route: String = "session"

fun detailRoute(sessionId: String): String = "${route}/$sessionId"
}

0 comments on commit 9da097b

Please sign in to comment.