diff --git a/core/ui/src/main/kotlin/com/afternote/core/ui/AfternoteFieldContainer.kt b/core/ui/src/main/kotlin/com/afternote/core/ui/AfternoteFieldContainer.kt index b148abfe..ae50994e 100644 --- a/core/ui/src/main/kotlin/com/afternote/core/ui/AfternoteFieldContainer.kt +++ b/core/ui/src/main/kotlin/com/afternote/core/ui/AfternoteFieldContainer.kt @@ -27,6 +27,10 @@ import com.afternote.core.ui.theme.AfternoteTheme * * [onClick] 을 주면 ripple 이 둥근 코너 안쪽으로 잘리도록 `clip` 뒤에 `clickable` 이 걸린다. * + * [enabled] 가 false 면 클릭이 차단될 뿐 아니라 배경이 흰색→gray2, 보더가 gray2→gray3 로 바뀌어 + * 비활성 상태가 시각적으로 드러난다 (비활성 버튼 `AfternoteButtonType.Un` 과 동일 팔레트). 내부 [content] + * 의 색은 슬롯 주입이라 호출부가 상태에 맞춰 결정한다. + * * 폭 / 크기 정책은 호출부가 [modifier] 로 결정 (Compose API 가이드라인: element function 의 modifier * default 는 빈 `Modifier`). 부모 폭 차지가 필요하면 `Modifier.fillMaxWidth()`, Row 안에서 * 가변 비율이면 `Modifier.weight(...)` 등을 명시적으로 넘긴다. @@ -39,12 +43,14 @@ fun AfternoteFieldContainer( enabled: Boolean = true, content: @Composable RowScope.() -> Unit, ) { + val backgroundColor = if (enabled) AfternoteDesign.colors.white else AfternoteDesign.colors.gray2 + val borderColor = if (enabled) AfternoteDesign.colors.gray2 else AfternoteDesign.colors.gray3 Row( modifier = modifier .clip(RoundedCornerShape(8.dp)) - .background(AfternoteDesign.colors.white) - .border(1.dp, AfternoteDesign.colors.gray2, RoundedCornerShape(8.dp)) + .background(backgroundColor) + .border(1.dp, borderColor, RoundedCornerShape(8.dp)) .then( if (onClick != null) { Modifier.clickable(enabled = enabled, onClick = onClick) diff --git a/core/ui/src/screenshotTest/kotlin/com/afternote/core/ui/AfternoteFieldContainerScreenshotTest.kt b/core/ui/src/screenshotTest/kotlin/com/afternote/core/ui/AfternoteFieldContainerScreenshotTest.kt new file mode 100644 index 00000000..8217a982 --- /dev/null +++ b/core/ui/src/screenshotTest/kotlin/com/afternote/core/ui/AfternoteFieldContainerScreenshotTest.kt @@ -0,0 +1,60 @@ +package com.afternote.core.ui + +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.afternote.core.ui.theme.AfternoteDesign +import com.afternote.core.ui.theme.AfternoteTheme +import com.android.tools.screenshot.PreviewTest + +/** + * [AfternoteFieldContainer] 의 시각 회귀 baseline — enabled / disabled 두 상태 (이슈 #342). + * + * disabled 일 때 배경(흰색→gray2)·보더(gray2→gray3) 가 비활성 색으로 전환되는지 고정한다. + * 의도된 시각 변경 시 `./gradlew :core:ui:updateScreenshotTest` 로 baseline 갱신. + */ +@PreviewTest +@Preview(showBackground = true) +@Composable +internal fun afternoteFieldContainerEnabledScreenshot() { + AfternoteTheme { + AfternoteFieldContainer( + onClick = {}, + enabled = true, + modifier = + Modifier + .padding(16.dp) + .fillMaxWidth(), + ) { + Text( + text = "활성 필드", + style = AfternoteDesign.typography.bodyLargeR, + ) + } + } +} + +@PreviewTest +@Preview(showBackground = true) +@Composable +internal fun afternoteFieldContainerDisabledScreenshot() { + AfternoteTheme { + AfternoteFieldContainer( + onClick = {}, + enabled = false, + modifier = + Modifier + .padding(16.dp) + .fillMaxWidth(), + ) { + Text( + text = "비활성 필드", + style = AfternoteDesign.typography.bodyLargeR, + ) + } + } +} diff --git a/core/ui/src/screenshotTestDebug/reference/com/afternote/core/ui/AfternoteFieldContainerScreenshotTestKt/afternoteFieldContainerDisabledScreenshot_748aa731_0.png b/core/ui/src/screenshotTestDebug/reference/com/afternote/core/ui/AfternoteFieldContainerScreenshotTestKt/afternoteFieldContainerDisabledScreenshot_748aa731_0.png new file mode 100644 index 00000000..ae6a24c4 Binary files /dev/null and b/core/ui/src/screenshotTestDebug/reference/com/afternote/core/ui/AfternoteFieldContainerScreenshotTestKt/afternoteFieldContainerDisabledScreenshot_748aa731_0.png differ diff --git a/core/ui/src/screenshotTestDebug/reference/com/afternote/core/ui/AfternoteFieldContainerScreenshotTestKt/afternoteFieldContainerEnabledScreenshot_748aa731_0.png b/core/ui/src/screenshotTestDebug/reference/com/afternote/core/ui/AfternoteFieldContainerScreenshotTestKt/afternoteFieldContainerEnabledScreenshot_748aa731_0.png new file mode 100644 index 00000000..437e36f9 Binary files /dev/null and b/core/ui/src/screenshotTestDebug/reference/com/afternote/core/ui/AfternoteFieldContainerScreenshotTestKt/afternoteFieldContainerEnabledScreenshot_748aa731_0.png differ