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
Expand Up @@ -124,6 +124,20 @@ fun rememberMindRecordNavActions(navController: NavController): MindRecordNavAct
navController.popBackStack()
}

override fun onOpenRecordDetail(
recordId: Long,
isDiary: Boolean,
yearMonth: String?,
) {
navController.navigate(
MindRecordRoute.RecordDetailRoute(
recordId = recordId,
isDiary = isDiary,
yearMonth = yearMonth,
),
)
}

override fun onEditDiaryDraft(
draftId: Long,
draftYearMonth: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ data class DailyQuestionListItemDto(
@SerialName("isDraft")
@JsonNames("draft")
val isDraft: Boolean = false,
// 상세 화면의 "수신인 OOO" 표시용 (#759).
@SerialName("receivers") val receivers: List<MindRecordReceiverDto> = emptyList(),
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ data class DiaryListItemDto(
@SerialName("isDraft")
@JsonNames("draft")
val isDraft: Boolean = false,
// 상세 화면이 "수신인 OOO" 로 보여준다. 서버가 늘 함께 내려주는데 종전에는 선언하지
// 않아 버려졌다 (#759).
@SerialName("receivers") val receivers: List<MindRecordReceiverDto> = emptyList(),
)

/** 기록에 지정된 수신자 요약 (OpenAPI `MindRecordReceiverSummaryResponse`). */
@Serializable
data class MindRecordReceiverDto(
@SerialName("receiverId") val receiverId: Long,
@SerialName("name") val name: String,
)

// `/diary` 응답의 `data` 는 객체 — `diaries` 외에 조회 대상 달의 비-임시 다이어리 수
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fun DailyQuestionListItemDto.toDomain(): DailyQuestion =
createdAt = createdAt,
imageUrl = imageUrl,
isDraft = isDraft,
receiverNames = receivers.map { it.name },
)

fun TodayDailyQuestionDto.toDomain(): TodayDailyQuestion =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fun DiaryListItemDto.toDomain(): Diary =
todayMood = todayMood?.toDomain(),
imageUrl = imageUrl,
isDraft = isDraft,
receiverNames = receivers.map { it.name },
)

fun DiaryListDto.toDomain(): DiaryList =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ data class DailyQuestion(
val createdAt: String,
val imageUrl: String? = null,
val isDraft: Boolean = false,
/** 이 기록을 전달받을 수신자 이름들 (#759). */
val receiverNames: List<String> = emptyList(),
)

data class TodayDailyQuestion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ data class Diary(
val todayMood: TodayMood?,
val imageUrl: String? = null,
val isDraft: Boolean = false,
/** 이 기록을 전달받을 수신자 이름들. 상세 화면이 "수신인 OOO" 로 보여준다 (#759). */
val receiverNames: List<String> = emptyList(),
)

data class DiaryList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ private val DateFormatter = DateTimeFormatter.ofPattern("yyyy.MM.dd")
fun DailyQuestionListCard(
answer: DailyQuestion,
modifier: Modifier = Modifier,
/** 카드 전체 탭 — 저장된 기록 본문을 여는 상세 화면으로 간다 (#759). */
onClick: () -> Unit = {},
onEdit: () -> Unit = {},
onDelete: () -> Unit = {},
) {
Expand All @@ -60,7 +62,7 @@ fun DailyQuestionListCard(
),
border = BorderStroke(1.dp, color = AfternoteDesign.colors.gray2),
shape = CardShape,
modifier = modifier.fillMaxWidth(),
modifier = modifier.fillMaxWidth().clickable(role = Role.Button, onClick = onClick),
) {
if (answer.imageUrl != null) {
ThumbnailCardContent(answer = answer, onEdit = onEdit, onDelete = onDelete)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ private val DateFormatter = DateTimeFormatter.ofPattern("yyyy.MM.dd")
fun DiaryCard(
diary: DailyDiary,
modifier: Modifier = Modifier,
/** 카드 전체 탭 — 저장된 기록 본문을 여는 상세 화면으로 간다 (#759). */
onClick: () -> Unit = {},
onEdit: () -> Unit = {},
onDelete: () -> Unit = {},
) {
Expand All @@ -66,7 +68,8 @@ fun DiaryCard(
modifier =
modifier
.fillMaxWidth()
.clip(RoundedCornerShape(6.dp)),
.clip(RoundedCornerShape(6.dp))
.clickable(role = Role.Button, onClick = onClick),
) {
Column {
if (diary.imageUrl != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ private val DateFormatter = DateTimeFormatter.ofPattern("yyyy.MM.dd")
fun DiaryComponent(
diary: DailyDiary,
modifier: Modifier = Modifier,
/** 카드 전체 탭 — 저장된 기록 본문을 여는 상세 화면으로 간다 (#759). */
onClick: () -> Unit = {},
onEdit: () -> Unit = {},
onDelete: () -> Unit = {},
) {
Expand All @@ -61,7 +63,7 @@ fun DiaryComponent(
containerColor = AfternoteDesign.colors.white,
),
border = BorderStroke(1.dp, color = AfternoteDesign.colors.gray2),
modifier = modifier.fillMaxWidth(),
modifier = modifier.fillMaxWidth().clickable(role = Role.Button, onClick = onClick),
shape = RoundedCornerShape(6.dp),
) {
Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ interface MindRecordNavActions {

fun onDraftListBack()

/** 목록 항목 탭 — 저장된 기록 본문을 여는 상세 화면 (#759). */
fun onOpenRecordDetail(
recordId: Long,
isDiary: Boolean,
yearMonth: String?,
)

/** 임시저장 목록에서 일기 draft 를 탭 — 일기 작성 화면을 이어쓰기 모드로 연다. */
fun onEditDiaryDraft(
draftId: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.afternote.feature.mindrecord.presentation.navigation

import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.toRoute
import com.afternote.core.ui.Route
import com.afternote.feature.mindrecord.presentation.model.MindRecordCategoryUi
import com.afternote.feature.mindrecord.presentation.screen.memoryspace.MemorySpaceScreen
Expand All @@ -10,6 +11,8 @@ import com.afternote.feature.mindrecord.presentation.screen.sender.DailyQuestion
import com.afternote.feature.mindrecord.presentation.screen.sender.DiaryWriteScreen
import com.afternote.feature.mindrecord.presentation.screen.sender.DraftListScreen
import com.afternote.feature.mindrecord.presentation.screen.sender.HomeScreen
import com.afternote.feature.mindrecord.presentation.screen.sender.RecordDetailScreen
import java.time.YearMonth

/**
* 마인드레코드 피처의 루트 [NavHost] 등록 묶음.
Expand All @@ -20,6 +23,15 @@ import com.afternote.feature.mindrecord.presentation.screen.sender.HomeScreen
fun NavGraphBuilder.mindRecordNavGraph(actions: MindRecordNavActions) {
composable<Route.MindRecord> {
HomeScreen(
onRecordClick = { recordId, isDiary, yearMonth ->
// 목록이 보고 있던 달을 그대로 넘긴다. 이번 달로 고정하면 지난달 기록이
// 상세에서 조회되지 않아 통째로 열리지 않는다 (#759 리뷰).
actions.onOpenRecordDetail(
recordId = recordId,
isDiary = isDiary,
yearMonth = yearMonth.toString(),
)
},
onWriteClick = { category ->
when (category) {
MindRecordCategoryUi.DailyQuestion -> actions.onWriteDailyQuestion()
Expand Down Expand Up @@ -49,6 +61,12 @@ fun NavGraphBuilder.mindRecordNavGraph(actions: MindRecordNavActions) {
onDraftListClick = actions::onNavigateToDraftList,
)
}
composable<MindRecordRoute.RecordDetailRoute> { entry ->
RecordDetailScreen(
isDiary = entry.toRoute<MindRecordRoute.RecordDetailRoute>().isDiary,
onBackClick = actions::onWriteBack,
)
}
composable<MindRecordRoute.DraftListRoute> {
DraftListScreen(
onBackClick = actions::onDraftListBack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ sealed interface MindRecordRoute {
val draftYearMonth: String? = null,
) : MindRecordRoute

/**
* 기록 상세(열람) 화면 (#759).
*
* 데일리질문과 일기가 같은 화면을 쓴다 — 시안 4종의 차이는 첨부 이미지 유무와
* 기록 종류뿐이다. [yearMonth](`yyyy-MM`)는 일기를 찾을 달이다.
*/
@Serializable
data class RecordDetailRoute(
val recordId: Long,
val isDiary: Boolean,
val yearMonth: String? = null,
) : MindRecordRoute

/** 작성 화면 키보드 툴바의 "임시저장 N" 영역에서 진입하는 임시저장 목록 화면. */
@Serializable
data object DraftListRoute : MindRecordRoute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ import com.afternote.feature.mindrecord.presentation.viewmodel.DailyQuestionList
import com.afternote.feature.mindrecord.presentation.viewmodel.DailyQuestionListViewModel
import java.time.YearMonth

/**
* @param onItemClick 카드를 눌렀을 때 상세로 보낼 기록 ID 와 **보고 있는 달** (#759 리뷰).
* 기본값을 두지 않는다 —
* 기본값이 있으면 호출부에서 빠뜨려도 컴파일이 되고, 카드가 눌리지 않는 채로 나간다 (#759).
*/
@Composable
fun DailyQuestionAnswerListScreen(
onItemClick: (Long, YearMonth) -> Unit,
modifier: Modifier = Modifier,
isListView: Boolean = true,
viewModel: DailyQuestionListViewModel = hiltViewModel(),
Expand All @@ -63,6 +69,7 @@ fun DailyQuestionAnswerListScreen(
modifier = modifier,
isListView = isListView,
answers = state.answers,
onItemClick = onItemClick,
onDelete = viewModel::delete,
)
}
Expand All @@ -74,6 +81,7 @@ private fun DailyQuestionListContent(
isListView: Boolean,
answers: List<DailyQuestion>,
modifier: Modifier = Modifier,
onItemClick: (Long, YearMonth) -> Unit = { _, _ -> },
onDelete: (Long) -> Unit = {},
) {
var yearMonth by remember { mutableStateOf(YearMonth.now()) }
Expand Down Expand Up @@ -128,7 +136,11 @@ private fun DailyQuestionListContent(
}

items(visibleAnswers, key = { it.id }) { answer ->
DailyQuestionListCard(answer = answer, onDelete = { onDelete(answer.id) })
DailyQuestionListCard(
answer = answer,
onClick = { onItemClick(answer.id, yearMonth) },
onDelete = { onDelete(answer.id) },
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ import androidx.compose.foundation.lazy.staggeredgrid.items as gridItems

private val PreviewYearMonth = YearMonth.of(2026, 7)

/**
* @param onItemClick 카드를 눌렀을 때 상세로 보낼 기록 ID 와 **보고 있는 달**. 달을 함께
* 싣지 않으면 상세가 이번 달 목록에서 그 기록을 찾다 실패한다 — 목록은 달을 바꿀 수
* 있으므로 지난달 기록이 통째로 열리지 않는다 (#759 리뷰). 기본값을 두지 않는다 —
* 기본값이 있으면 호출부에서 빠뜨려도 컴파일이 되고, 카드가 눌리지 않는 채로 나간다 (#759).
*/
@Composable
fun DiaryScreen(
onItemClick: (Long, YearMonth) -> Unit,
modifier: Modifier = Modifier,
isListView: Boolean = true,
viewModel: DiaryListViewModel = hiltViewModel(),
Expand Down Expand Up @@ -80,6 +87,7 @@ fun DiaryScreen(
yearMonth = state.yearMonth,
monthDiaryCount = state.monthDiaryCount,
weeklyMoodEmoji = state.weeklyDominantMood?.toEmoji(),
onItemClick = onItemClick,
onDelete = viewModel::delete,
onYearMonthChanged = viewModel::selectYearMonth,
)
Expand All @@ -88,7 +96,7 @@ fun DiaryScreen(
}

@Composable
private fun DiaryListContent(
internal fun DiaryListContent(
isListView: Boolean,
diaries: List<DailyDiary>,
// 조회 중인 월은 VM 이 들고 있다 — 자동 갱신이 같은 월을 다시 조회해야 하고,
Expand All @@ -98,6 +106,7 @@ private fun DiaryListContent(
modifier: Modifier = Modifier,
monthDiaryCount: Int = 0,
weeklyMoodEmoji: String? = null,
onItemClick: (Long, YearMonth) -> Unit = { _, _ -> },
onDelete: (Long) -> Unit = {},
onYearMonthChanged: (YearMonth) -> Unit = {},
) {
Expand Down Expand Up @@ -163,6 +172,7 @@ private fun DiaryListContent(
items(visibleDiaries, key = { it.id }) { diary ->
DiaryComponent(
diary = diary,
onClick = { onItemClick(diary.id, yearMonth) },
modifier = Modifier.padding(vertical = 8.dp),
onDelete = { onDelete(diary.id) },
)
Expand All @@ -186,6 +196,7 @@ private fun DiaryListContent(
gridItems(diaries, key = { it.id }) { diary ->
DiaryCard(
diary = diary,
onClick = { onItemClick(diary.id, yearMonth) },
onDelete = { onDelete(diary.id) },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ import com.afternote.feature.mindrecord.presentation.viewmodel.DiaryListViewMode
import com.afternote.feature.mindrecord.presentation.viewmodel.WeeklyReportViewModel
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.launch
import java.time.YearMonth
import com.afternote.feature.mindrecord.presentation.R as MindRecordR

@Composable
fun HomeScreen(
modifier: Modifier = Modifier,
onWriteClick: (MindRecordCategoryUi) -> Unit = {},
// 목록 항목 탭 → 상세(열람) 화면. (기록 ID, 일기 여부, 목록이 보고 있던 달) (#759).
onRecordClick: (Long, Boolean, YearMonth) -> Unit = { _, _, _ -> },
) {
// Figma 2757:16116 — 마음의 기록 탭은 데일리 질문 / 일기 / 주간리포트 3개
val categories =
Expand Down Expand Up @@ -164,11 +167,17 @@ fun HomeScreen(
HorizontalPager(state = pagerState) { page ->
when (categories[page]) {
MindRecordCategoryUi.DailyQuestion -> {
DailyQuestionAnswerListScreen(isListView = dailyQuestionListView)
DailyQuestionAnswerListScreen(
isListView = dailyQuestionListView,
onItemClick = { id, yearMonth -> onRecordClick(id, false, yearMonth) },
)
}

MindRecordCategoryUi.Diary -> {
DiaryScreen(isListView = diaryListView)
DiaryScreen(
isListView = diaryListView,
onItemClick = { id, yearMonth -> onRecordClick(id, true, yearMonth) },
)
}

else -> {
Expand Down
Loading
Loading