Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.kuit.afternote.feature.afternote.domain.model

import com.kuit.afternote.core.domain.model.AfternoteServiceType
import com.kuit.afternote.feature.dailyrecord.presentation.uimodel.MindRecordUiModel

/**
* 애프터노트 아이템 도메인 모델
Expand Down Expand Up @@ -30,3 +31,30 @@ data class AfternoteItem(
val processingMethods: List<AfternoteProcessingMethod> = emptyList(),
val galleryProcessingMethods: List<AfternoteProcessingMethod> = emptyList()
)

fun AfternoteItem.toMindRecordUiModel(): MindRecordUiModel {
// 1. 날짜 포맷팅 로직 (안정성을 위해 java.time 사용)
val inputFormatter = java.time.format.DateTimeFormatter.ofPattern("yyyy.MM.dd")
val isoFormatter = java.time.format.DateTimeFormatter.ISO_LOCAL_DATE // yyyy-MM-dd

val parsedDate = runCatching {
java.time.LocalDate.parse(this.date, inputFormatter)
}.getOrElse {
java.time.LocalDate.now() // 파싱 실패 시 오늘 날짜로 폴백 (시스템 안정성)
}

val originalDateStr = parsedDate.format(isoFormatter) // "2026-02-06"
val formattedDateStr = "${parsedDate.monthValue}월 ${parsedDate.dayOfMonth}일"

return MindRecordUiModel(
// String ID를 Long으로 변환 (UI용 unique key 확보)
id = this.id.hashCode().toLong(),
title = this.serviceName,
formattedDate = formattedDateStr,
draftLabel = "완료", // 애프터노트는 도메인상 완료된 데이터로 간주
content = this.message,
type = this.type.name,
category = null, // 필요 시 mapping 로직 추가
originalDate = originalDateStr
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kuit.afternote.feature.dailyrecord.data.api

import com.kuit.afternote.data.remote.ApiResponse
import com.kuit.afternote.feature.dailyrecord.data.dto.*
import retrofit2.Response
import retrofit2.http.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.kuit.afternote.feature.dailyrecord.presentation.component

import android.R.attr.top
import android.os.Build
import androidx.annotation.RequiresApi
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.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.kuit.afternote.feature.dailyrecord.presentation.viewmodel.MindRecordViewModel
import java.time.LocalDate

/**
Expand All @@ -16,25 +19,28 @@ import java.time.LocalDate
@Composable
fun RecordAllSeeReport(
modifier: Modifier = Modifier,
today: LocalDate
dailySummary: MindRecordViewModel.WeeklySummaryUiState,
afterNoteSummary: MindRecordViewModel.WeeklySummaryUiState
) {
Column(
modifier = Modifier
.padding(top = 32.dp)
.padding(horizontal = 20.dp)
modifier = modifier
.padding(top = 32.dp, start = 20.dp, end = 20.dp)
) {
RecordTextComponent(
title = "활동 한 눈에 보기"
)
RecordTextComponent(title = "활동 한 눈에 보기")
Spacer(Modifier.height(16.dp))

// 1. 데일리 질문 리포트
RecordShowWeekReport(
standard = "데일리 질문 답변을 3번 작성했어요.",
today = today
titlePrefix = "데일리 질문 답변을",
summary = dailySummary
)

Spacer(Modifier.height(8.dp))

// 2. 애프터노트 전체 리포트
RecordShowWeekReport(
standard = "애프터노트에 3번 등록했어요.",
today = today
titlePrefix = "애프터노트에",
summary = afterNoteSummary
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.kuit.afternote.feature.dailyrecord.presentation.component

import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
Expand All @@ -25,128 +26,76 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.kuit.afternote.R
import com.kuit.afternote.feature.dailyrecord.presentation.viewmodel.MindRecordViewModel
import com.kuit.afternote.feature.home.presentation.component.CalendarDayStyle
import com.kuit.afternote.ui.expand.dropShadow
import com.kuit.afternote.ui.theme.Sansneo
import com.kuit.afternote.ui.theme.White
import java.time.DayOfWeek
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.time.temporal.TemporalAdjusters
import java.util.Locale

@RequiresApi(Build.VERSION_CODES.O)
@Composable
fun RecordShowWeekReport(
modifier: Modifier = Modifier,
standard: String,
today: LocalDate
titlePrefix: String,
summary: MindRecordViewModel.WeeklySummaryUiState
) {
var isExpanded by remember { mutableStateOf(false) }
val startOfWeek = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))

if (!isExpanded) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(height = 56.dp)
.dropShadow(
shape = RoundedCornerShape(16.dp),
color = Color.Black.copy(alpha = 0.05f),
blur = 5.dp,
offsetY = 2.dp,
offsetX = 0.dp,
spread = 0.dp
).clip(RoundedCornerShape(16.dp))
.background(color = White)
.clickable { isExpanded = !isExpanded }
) {
Box(
modifier = Modifier
.fillMaxWidth()
.animateContentSize() // 확장 시 애니메이션 추가
.dropShadow(
shape = RoundedCornerShape(16.dp),
color = Color.Black.copy(alpha = 0.05f),
blur = 5.dp,
offsetY = 2.dp
)
.clip(RoundedCornerShape(16.dp))
.background(Color.White)
.clickable { isExpanded = !isExpanded }
) {
Column(modifier = Modifier.padding(17.dp)) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(all = 17.dp),
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
text = standard,
text = "$titlePrefix ${summary.totalWeeklyCount}번 작성했어요.",
fontSize = 16.sp,
fontWeight = FontWeight.Medium
fontWeight = FontWeight.Medium,
fontFamily = Sansneo
)
Box(
Image(
painter = painterResource(R.drawable.ic_under_direct_foreground),
contentDescription = null,
modifier = Modifier
) {
Image(
painter = painterResource(R.drawable.ic_under_direct_foreground),
contentDescription = null,
modifier = Modifier
.size(30.dp)
)
}
.size(30.dp)
.rotate(if (isExpanded) 180f else 0f) // 화살표 회전
)
}
}
} else {
Box(
modifier = Modifier
.fillMaxWidth()
.height(height = 144.dp)
.dropShadow(
shape = RoundedCornerShape(16.dp),
color = Color.Black.copy(alpha = 0.05f),
blur = 5.dp,
offsetY = 2.dp,
offsetX = 0.dp,
spread = 0.dp
).clip(RoundedCornerShape(16.dp))
.background(color = White)
.clickable { isExpanded = !isExpanded }
) {
Column(
modifier = Modifier
.padding(all = 17.dp),
) {
Row(
modifier = Modifier
.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
text = standard,
fontSize = 16.sp,
fontWeight = FontWeight.Medium
)
Box(
modifier = Modifier
) {
Image(
painter = painterResource(R.drawable.ic_under_direct_foreground),
contentDescription = null,
modifier = Modifier
.size(30.dp)
)
}
}

if (isExpanded) {
Spacer(Modifier.height(16.dp))
val formatter = DateTimeFormatter.ofPattern("d", Locale.KOREA) // 일(day)만
val allItems = (0..6).map { offset ->
val date = startOfWeek.plusDays(offset.toLong())
val dayLabel = date.format(formatter) // "10", "11", ...
listOf("월", "화", "수", "목", "금", "토", "일")[offset] to dayLabel
}
Row(
modifier = Modifier
.fillMaxWidth()
) {
allItems.forEach { (today, day) ->
Row(modifier = Modifier.fillMaxWidth()) {
summary.calendarDays.forEach { dayState ->
SubWeekCheck(
modifier = Modifier.weight(1f), // 각 아이템이 동일한 너비 차지
today = today,
day = day
modifier = Modifier.weight(1f),
dayLabel = dayState.dayLabel,
dateLabel = dayState.date.toString(),
isRecorded = dayState.style == CalendarDayStyle.FILLED,
isToday = dayState.style == CalendarDayStyle.TODAY
)
}
}
Expand Down
Loading
Loading