Skip to content

Commit

Permalink
[feat/#76] 출석 현황 아이템 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnseo committed Feb 3, 2024
1 parent 854fa3c commit 0d143c0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import com.kusitms.presentation.common.ui.theme.KusitmsColorPalette
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import java.text.SimpleDateFormat
import java.util.*
import javax.inject.Inject


Expand Down Expand Up @@ -39,12 +41,26 @@ class AttendViewModel @Inject constructor(
_attendScore.value = attendModel
}

fun formatDate(dateString: String): String {
val originalFormat = SimpleDateFormat("MM월 dd일", Locale.KOREA)
val targetFormat = SimpleDateFormat("M월 d일", Locale.KOREA)
return try {
val parsedDate = originalFormat.parse(dateString)
parsedDate?.let { targetFormat.format(it) } ?: dateString
} catch (e: Exception) {
// 파싱에 실패시, 원본 날짜를 그대로 사용
dateString
}
}

init {
viewModelScope.launch {
getAttendCurrentListUseCase().catch {

}.collect() {
_attendCurrentList.value = it
_attendCurrentList.value = it.map { attendModel ->
attendModel.copy(date = formatDate(attendModel.date))
}
}
}
}
Expand All @@ -69,6 +85,4 @@ class AttendViewModel @Inject constructor(
}
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ fun AttendScreen() {
AttendPreColumn()
KusitmsMarginVerticalSpacer(size = 24)
AttendRecordColumn()
KusitmsMarginVerticalSpacer(size = 32)
AttendNotAttend()
}
ScrollBtn(scrollState = scrollState)
}
Expand Down Expand Up @@ -150,6 +152,16 @@ fun AttendNotComplete() {
Text(text = stringResource(R.string.attend_box3_subTitle_fail), style = KusitmsTypo.current.Text_Semibold, color = KusitmsColorPalette.current.Sub2)
}

@Composable
fun AttendNotAttend() {
KusitmsMarginVerticalSpacer(size = 88)
Box(modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()) {
Text(text = stringResource(R.string.attend_not_attend), style = KusitmsTypo.current.Caption1, color = KusitmsColorPalette.current.Grey400, modifier = Modifier.align(Alignment.Center))
}
}

@Composable
fun ScrollBtn(scrollState: ScrollState) {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomEnd) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.modifier.modifierLocalMapOf
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.kusitms.domain.model.home.AttendCurrentModel
import com.kusitms.presentation.common.ui.KusitmsMarginHorizontalSpacer
Expand All @@ -25,6 +26,7 @@ fun CurriItem(
) {
Row(modifier = Modifier
.fillMaxWidth()
.background(color = KusitmsColorPalette.current.Grey600)
.height(78.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
Expand All @@ -45,8 +47,8 @@ fun CurriBadge(
else -> KusitmsColorPalette.current.Grey600
}
Column(
modifier = Modifier
.width(52.dp)
modifier = Modifier
.width(92.dp)
.fillMaxHeight(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(2.dp, Alignment.CenterVertically)
Expand All @@ -62,7 +64,9 @@ fun CurriBadge(
Text(text = model.status,
style = KusitmsTypo.current.Text_Semibold,
color = statusColor,
modifier = Modifier.align(Alignment.Center)
modifier = Modifier
.align(Alignment.Center)
.padding(vertical = 4.dp)
)
}
Text(text = model.time,
Expand Down Expand Up @@ -105,4 +109,14 @@ fun CurriTitleRow(
)
}
}
}
}

@Preview
@Composable
fun priviewModel() {
CurriItem(model = dummyData)
}

val dummyData = AttendCurrentModel(
57, "파트 크로스 스터디", "1월 24일", "오후 8:40", "출석"
)
2 changes: 2 additions & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@
<string name="attend_box3_subTitle_ok">수료 가능한 점수예요</string>
<string name="attend_box3_subTitle_fail">벌점 6점부터 수료가 어려워요</string>

<string name="attend_not_attend">아직 출석현황이 없어요</string>

<string name="attend_box4_attend">출석</string>
<string name="attend_box4_non_attend">결석</string>
<string name="attend_box4_non_late">지각</string>
Expand Down

0 comments on commit 0d143c0

Please sign in to comment.