Skip to content

Commit

Permalink
refactor: SessionItem을 별도의 파일로 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdgh1592 committed Jun 5, 2024
1 parent ae16637 commit 6e342c9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@ package com.droidknights.app.feature.session

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -31,8 +26,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.droidknights.app.core.designsystem.theme.KnightsTheme
import com.droidknights.app.core.model.Room
import com.droidknights.app.core.model.Session
import com.droidknights.app.core.ui.RoomText
import com.droidknights.app.feature.session.component.SessionCard
import com.droidknights.app.feature.session.component.SessionItem
import com.droidknights.app.feature.session.component.SessionTopAppBar
import com.droidknights.app.feature.session.model.SessionState
import com.droidknights.app.feature.session.model.SessionUiState
Expand Down Expand Up @@ -128,42 +122,6 @@ private fun LazyListScope.sessionItems(
}
}

@Composable
private fun SessionItem(
index: Int,
item: Session,
room: Room,
topPadding: Dp,
onItemClick: (Session) -> Unit,
) {
Column {
if (index == 0) {
RoomTitle(room = room, topPadding = topPadding)
}
SessionCard(session = item, onSessionClick = onItemClick)
}
}

@Composable
private fun RoomTitle(
room: Room,
topPadding: Dp,
) {
Column(modifier = Modifier.padding(start = 20.dp, top = topPadding, end = 20.dp)) {
RoomText(
room = room,
style = KnightsTheme.typography.titleLargeB,
color = MaterialTheme.colorScheme.onPrimaryContainer,
)

Spacer(modifier = Modifier.height(8.dp))

HorizontalDivider(thickness = 2.dp, color = MaterialTheme.colorScheme.onPrimaryContainer)

Spacer(modifier = Modifier.height(32.dp))
}
}

@Composable
private fun DroidKnightsFooter() {
Text(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.droidknights.app.feature.session.component

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.droidknights.app.core.designsystem.theme.KnightsTheme
import com.droidknights.app.core.model.Room
import com.droidknights.app.core.model.Session
import com.droidknights.app.core.ui.RoomText

@Composable
internal fun SessionItem(
index: Int,
item: Session,
room: Room,
topPadding: Dp,
onItemClick: (Session) -> Unit,
) {
Column {
if (index == 0) {
RoomTitle(room = room, topPadding = topPadding)
}
SessionCard(session = item, onSessionClick = onItemClick)
}
}

@Composable
private fun RoomTitle(
room: Room,
topPadding: Dp,
) {
Column(modifier = Modifier.padding(start = 20.dp, top = topPadding, end = 20.dp)) {
RoomText(
room = room,
style = KnightsTheme.typography.titleLargeB,
color = MaterialTheme.colorScheme.onPrimaryContainer,
)

Spacer(modifier = Modifier.height(8.dp))

HorizontalDivider(thickness = 2.dp, color = MaterialTheme.colorScheme.onPrimaryContainer)

Spacer(modifier = Modifier.height(32.dp))
}
}

0 comments on commit 6e342c9

Please sign in to comment.