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 @@ -148,7 +148,8 @@ fun HomeTabScreen(
userName = uiState.cachedUserName ?: "\u2026",
// 조회 전이다 — 지정 여부를 결과로 확정하지 않는다 (#698).
recipientBadgeState = RecipientDesignationBadgeState.Unknown,
categoryCounts = MindRecordCategory.entries.associateWith { 0 },
// 조회 전에는 아는 값이 없다 — 0 을 채워 넣지 않는다 (#700).
categoryCounts = emptyMap(),
categoryCountsLoading = true,
todayDateText = todayDateText,
todayQuestionContent = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,9 @@ private fun HomeSummary.toHomeTabSuccess(): HomeTabUiState.Success =
userName = userName,
isRecipientDesignated = isRecipientDesignated,
todayQuestionContent = todayQuestionContent,
categoryCounts =
MindRecordCategory.entries.associateWith { category ->
when (category) {
MindRecordCategory.DIARY -> diaryCategoryCount
MindRecordCategory.DAILY_QUESTION -> 0
MindRecordCategory.WEEKLY_REPORT -> 0
}
},
// **실제로 값을 아는 카테고리만 담는다.** 종전에는 enum 전체를 돌며 데일리질문·주간
// 리포트에 0 을 박아 넣었다. 지금은 화면이 일기 카드만 그려 안 보일 뿐, 카드가 늘면
// 그 0 이 그대로 «기록 0건» 으로 노출된다 — 목업이면 눈에 띄지만 0 은 그럴듯한
// 거짓이라 사용자가 그대로 믿는다 (#700).
categoryCounts = mapOf(MindRecordCategory.DIARY to diaryCategoryCount),
)
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,9 @@ private fun successState(
HomeTabUiState.Success(
userName = userName,
isRecipientDesignated = isRecipientDesignated,
categoryCounts =
mapOf(
MindRecordCategory.DAILY_QUESTION to 0,
MindRecordCategory.DIARY to diaryCount,
MindRecordCategory.WEEKLY_REPORT to 0,
),
// 값을 아는 카테고리만 담는다 — 데일리질문·주간 리포트는 아직 카드를 그리지 않고,
// 0 을 넣어 두면 카드가 늘 때 그대로 «기록 0건» 이 된다 (#700).
categoryCounts = mapOf(MindRecordCategory.DIARY to diaryCount),
todayQuestionContent = questionContent,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.ui.unit.sp
import com.afternote.core.ui.modifierextention.shimmerLoadingPlaceholder
import com.afternote.core.ui.theme.AfternoteDesign
import com.afternote.core.ui.theme.AfternoteTheme
import com.afternote.feature.mindrecord.presentation.R.string.mindrecord_home_category_count_unavailable
import com.afternote.feature.mindrecord.presentation.R.string.mindrecord_total_label
import java.text.NumberFormat
import java.util.Locale
Expand All @@ -44,7 +45,11 @@ fun RecordCategoryCard(
iconResId: Int,
title: String,
subtitle: String,
totalCount: Int,
/**
* 이 카테고리의 총 기록 수. **null 은 «아직 모름»** — 0 으로 접으면 조회 실패나 미연결이
* «기록 없음» 으로 확정된다. 수신자 홈(#952)·주간 요약(#562)과 같은 규칙이다 (#700).
*/
totalCount: Int?,
onClick: () -> Unit,
modifier: Modifier = Modifier,
// TODO: Vector Asset(xml)의 viewport 여백을 맞추면 이 플래그를 제거할 수 있습니다.
Expand All @@ -53,7 +58,7 @@ fun RecordCategoryCard(
) {
val formattedCount =
remember(totalCount) {
NumberFormat.getNumberInstance(Locale.getDefault()).format(totalCount)
totalCount?.let { NumberFormat.getNumberInstance(Locale.getDefault()).format(it) }
}

Column(
Expand Down Expand Up @@ -141,7 +146,7 @@ fun RecordCategoryCard(
)
} else {
Text(
text = formattedCount,
text = formattedCount ?: stringResource(mindrecord_home_category_count_unavailable),
style = AfternoteDesign.typography.h3,
color = AfternoteDesign.colors.gray9,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ fun LazyListScope.homeTabMindRecordQuestionAndCategories(
iconResId = CoreUiR.drawable.core_ui_ic_diary,
title = stringResource(MindRecordCategoryUi.Diary.titleRes),
subtitle = stringResource(MindRecordCategoryUi.Diary.descriptionRes),
totalCount = categoryCounts[MindRecordCategory.DIARY] ?: 0,
// 키가 없으면 «모름» 이다 — 0 으로 접지 않는다 (#700).
totalCount = categoryCounts[MindRecordCategory.DIARY],
onClick = { onRecordCategoryClick(MindRecordCategory.DIARY) },
useDiaryIconLayout = true,
isCountLoading = isCategoryCountLoading,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,6 @@
<string name="mindrecord_receiver_load_failed">마음의 기록을 불러오지 못했어요.</string>
<string name="mindrecord_receiver_retry">다시 시도</string>
<string name="mindrecord_receiver_title">마음의 기록</string>
<!-- 카테고리 카드 기록 수를 아직 모를 때. en dash — 수신자 홈·주간 요약과 같은 표기 (#700·#952·#562). -->
<string name="mindrecord_home_category_count_unavailable">–</string>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[normal] 주석이 «수신자 홈·주간 요약과 같은 표기» 라고 적은 그대로, feature/receiver/presentation 의 receiver_home_section_count_unavailable 이 이미 같은 값(–)을 들고 있다. 여기서 세 번째가 생기면(주간 요약 #562 는 #1055 로 열려 있다) 같은 규칙이 서로 다른 세 리소스로 흩어진다.

두 모듈 다 core:ui 에 의존하므로 core_ui_count_unavailable 같은 이름으로 한 벌만 두는 편이 «규칙» 이라는 성격에 맞는다. 지금 당장 옮기지 않더라도, 세 번째가 붙기 전이 정리하기 가장 싼 시점이라 남긴다.

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.afternote.feature.mindrecord.presentation.component

import androidx.activity.ComponentActivity
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import com.afternote.core.ui.theme.AfternoteTheme
import com.afternote.feature.mindrecord.presentation.component.hometab.RecordCategoryCard
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import com.afternote.core.ui.R as CoreUiR

/**
* 기록 카테고리 카드가 «모름» 을 0 으로 접지 않는지 (#700).
*
* 홈 ViewModel 이 enum 전체를 돌며 데일리질문·주간 리포트에 0 을 박아 넣고 있었다. 화면이
* 일기 카드만 그려 안 보였을 뿐, 카드가 늘면 그 0 이 그대로 «기록 0건» 으로 노출된다.
* 목업 숫자는 눈에 띄지만 0 은 그럴듯한 거짓이라 사용자가 그대로 믿는다 — 수신자 홈(#952)·
* 주간 요약(#562)에서 같은 이유로 대시 표기를 택했다.
*/
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [35])
class RecordCategoryCountTest {
@get:Rule
val composeRule = createAndroidComposeRule<ComponentActivity>()

@Test
fun `기록 수를 모르면 0 이 아니라 대시를 그린다`() {
composeRule.setContent {
AfternoteTheme { card(totalCount = null) }
}

composeRule.onNodeWithText("–").assertIsDisplayed()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[normal] 리소스 값을 리터럴로 다시 적어 두면 문자열을 바꿀 때 테스트가 소리 없이 갈린다 — en dash(–)와 hyphen(-)·em dash(—)는 눈으로 구분되지 않아서 특히 그렇다. 같은 파일의 activity.getString(R.string.mindrecord_home_category_count_unavailable) 로 잡으면 리소스와 함께 움직인다. (수신자 쪽 ReceiverHomeCountFallbackTest 도 같은 방식이라 새 규약은 아니다.)

덧붙여 58번 줄의 @androidx.compose.runtime.Composable 은 상단 import 로 올리면 나머지 애노테이션과 표기가 맞는다.

composeRule.onNodeWithText("0").assertDoesNotExist()
}

@Test
fun `0건은 확정값이라 그대로 그린다`() {
composeRule.setContent {
AfternoteTheme { card(totalCount = 0) }
}

composeRule.onNodeWithText("0").assertIsDisplayed()
}

@Test
fun `실제 기록 수는 천 단위로 끊어 그린다`() {
composeRule.setContent {
AfternoteTheme { card(totalCount = 1234) }
}

composeRule.onNodeWithText("1,234").assertIsDisplayed()
}

@androidx.compose.runtime.Composable
private fun card(totalCount: Int?) {
RecordCategoryCard(
iconResId = CoreUiR.drawable.core_ui_ic_diary,
title = "일기",
subtitle = "나의 매일을 기록하세요",
totalCount = totalCount,
onClick = {},
)
}
}
Loading