From c01c57f399582a314f829605e3cece3187efd0d9 Mon Sep 17 00:00:00 2001 From: Ham BeomJoon Date: Mon, 26 Jan 2026 01:23:24 +0900 Subject: [PATCH 01/10] =?UTF-8?q?feat:=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EC=8B=9C=EC=8A=A4=ED=85=9C=20Chip=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `PrezelChip` 및 `PrezelIconChip` 컴포넌트를 새롭게 추가했습니다. * `PrezelChipType` (FILLED, OUTLINED), `PrezelChipSize` (SMALL, REGULAR) 등 다양한 스타일 옵션 제공 * `PrezelChipInteraction` (DEFAULT, ACTIVE, DISABLED) 및 `PrezelChipFeedback` (DEFAULT, BAD) 상태 지원 * 아이콘 유무 및 텍스트 포함 여부에 따른 유연한 레이아웃 구성 * 컴포넌트별 테마 적용 및 스타일링 로직(`PrezelChipStyle.kt`) 분리 * 미리보기를 위한 `PrezelChipPreview` 유틸리티 추가 --- .../designsystem/component/chip/PrezelChip.kt | 144 ++++++++++++ .../component/chip/PrezelChipPreview.kt | 130 +++++++++++ .../component/chip/PrezelChipStyle.kt | 209 ++++++++++++++++++ .../component/chip/PrezelIconChip.kt | 50 +++++ 4 files changed, 533 insertions(+) create mode 100644 Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt create mode 100644 Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipPreview.kt create mode 100644 Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt create mode 100644 Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelIconChip.kt diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt new file mode 100644 index 0000000..f44d9a7 --- /dev/null +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt @@ -0,0 +1,144 @@ +package com.team.prezel.core.designsystem.component.chip + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.LocalContentColor +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import com.team.prezel.core.designsystem.foundation.color.PrezelColors +import com.team.prezel.core.designsystem.icon.DrawableIcon +import com.team.prezel.core.designsystem.icon.IconSource +import com.team.prezel.core.designsystem.icon.PrezelIcons +import com.team.prezel.core.designsystem.preview.PreviewScaffold +import com.team.prezel.core.designsystem.preview.ThemePreview +import com.team.prezel.core.designsystem.theme.PrezelTheme + +@Composable +fun PrezelChip( + modifier: Modifier = Modifier, + text: String? = null, + icon: IconSource? = null, + style: PrezelChipStyle = PrezelChipStyle(), +) { + val hasText = text != null + val hasIcon = icon != null + val iconOnly = hasIcon && !hasText + require(hasText || hasIcon) { "Chip은 text 또는 icon 중 하나는 반드시 필요합니다." } + val (chipType, chipSize, interaction, feedback) = style + + Surface( + modifier = modifier, + shape = prezelChipShape(chipSize), + color = prezelChipContainerColor(type = chipType, interaction = interaction, feedback = feedback, iconOnly = iconOnly), + border = prezelChipBorderStroke(type = chipType, interaction = interaction, feedback = feedback), + ) { + CompositionLocalProvider( + LocalTextStyle provides prezelChipTextStyle(chipSize), + LocalContentColor provides prezelChipContentColor(interaction = interaction, feedback = feedback), + ) { + Row( + modifier = Modifier.padding(prezelChipContentPadding(size = chipSize, onlyIcon = hasIcon && !hasText)), + horizontalArrangement = Arrangement.Center, + verticalAlignment = Alignment.CenterVertically, + ) { + PrezelChipIcon(icon = icon, size = chipSize) + + if (!hasText) return@Row + if (hasIcon) { + val spacing = if (chipSize == PrezelChipSize.REGULAR) PrezelTheme.spacing.V4 else PrezelTheme.spacing.V2 + Spacer(modifier = Modifier.width(width = spacing)) + } + + Text(text = text) + } + } + } +} + +@Composable +fun PrezelChip( + containerColor: PrezelColors, + contentColor: PrezelColors, + modifier: Modifier = Modifier, + text: String? = null, + icon: IconSource? = null, + style: PrezelChipStyle = PrezelChipStyle(), +) { + val hasText = text != null + val hasIcon = icon != null + val iconOnly = hasIcon && !hasText + require(hasText || hasIcon) { "Chip은 text 또는 icon 중 하나는 반드시 필요합니다." } + val (chipType, chipSize, interaction, feedback) = style + + Surface( + modifier = modifier, + shape = prezelChipShape(chipSize), + color = prezelChipContainerColor( + type = chipType, + interaction = interaction, + feedback = feedback, + iconOnly = iconOnly, + colors = containerColor, + ), + border = prezelChipBorderStroke(type = chipType, interaction = interaction, feedback = feedback), + ) { + CompositionLocalProvider( + LocalTextStyle provides prezelChipTextStyle(chipSize), + LocalContentColor provides prezelChipContentColor(interaction = interaction, feedback = feedback, colors = contentColor), + ) { + Row( + modifier = Modifier.padding(prezelChipContentPadding(size = chipSize, onlyIcon = hasIcon && !hasText)), + horizontalArrangement = Arrangement.Center, + verticalAlignment = Alignment.CenterVertically, + ) { + PrezelChipIcon(icon = icon, size = chipSize) + + if (!hasText) return@Row + if (hasIcon) { + val spacing = if (chipSize == PrezelChipSize.REGULAR) PrezelTheme.spacing.V4 else PrezelTheme.spacing.V2 + Spacer(modifier = Modifier.width(width = spacing)) + } + + Text(text = text) + } + } + } +} + +@ThemePreview +@Composable +private fun PrezelChipPreview() { + PrezelTheme { + PrezelTheme { + PreviewScaffold { + PrezelChipPreviewByType( + type = PrezelChipType.FILLED, + ) { style -> PrezelChipPreviewItem(style) } + + HorizontalDivider() + + PrezelChipPreviewByType( + type = PrezelChipType.OUTLINED, + ) { style -> PrezelChipPreviewItem(style) } + } + } + } +} + +@Composable +private fun PrezelChipPreviewItem(style: PrezelChipStyle) { + PrezelChip( + text = "Label", + icon = DrawableIcon(resId = PrezelIcons.Blank), + style = style, + ) +} diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipPreview.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipPreview.kt new file mode 100644 index 0000000..5c2a74d --- /dev/null +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipPreview.kt @@ -0,0 +1,130 @@ +package com.team.prezel.core.designsystem.component.chip + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import com.team.prezel.core.designsystem.theme.PrezelTheme +import kotlinx.collections.immutable.persistentListOf + +internal typealias PrezelChipPreviewContent = @Composable (PrezelChipStyle) -> Unit + +private val DefaultInteractionVariants = persistentListOf( + PrezelChipInteraction.DEFAULT, + PrezelChipInteraction.ACTIVE, + PrezelChipInteraction.DISABLED, +) + +private val PreviewSizes = persistentListOf( + PrezelChipSize.SMALL, + PrezelChipSize.REGULAR, +) + +@Composable +internal fun PrezelChipPreviewByType( + type: PrezelChipType, + content: PrezelChipPreviewContent, +) { + Text( + text = type.name, + style = PrezelTheme.typography.title2Medium, + ) + + HorizontalDivider() + + PrezelChipBadSection( + type = type, + content = content, + ) + + HorizontalDivider() + + PrezelChipDefaultSection( + type = type, + content = content, + ) +} + +@Composable +private fun PrezelChipBadSection( + type: PrezelChipType, + content: PrezelChipPreviewContent, + modifier: Modifier = Modifier, +) { + Column( + modifier = modifier, + verticalArrangement = Arrangement.spacedBy(12.dp), + ) { + Text( + text = "Feedback: BAD", + style = PrezelTheme.typography.body2Medium, + ) + + PrezelChipPreviewBlock( + type = type, + feedback = PrezelChipFeedback.BAD, + interaction = PrezelChipInteraction.DEFAULT, + content = content, + ) + } +} + +@Composable +private fun PrezelChipDefaultSection( + type: PrezelChipType, + content: PrezelChipPreviewContent, + modifier: Modifier = Modifier, +) { + Column( + modifier = modifier, + verticalArrangement = Arrangement.spacedBy(12.dp), + ) { + Text( + text = "Feedback: DEFAULT", + style = PrezelTheme.typography.body2Medium, + ) + + DefaultInteractionVariants.forEach { interaction -> + Text( + text = "Interaction: $interaction", + style = PrezelTheme.typography.body3Medium, + ) + + PrezelChipPreviewBlock( + type = type, + feedback = PrezelChipFeedback.DEFAULT, + interaction = interaction, + content = content, + ) + } + } +} + +@Composable +private fun PrezelChipPreviewBlock( + type: PrezelChipType, + interaction: PrezelChipInteraction, + feedback: PrezelChipFeedback, + content: PrezelChipPreviewContent, + modifier: Modifier = Modifier, +) { + Row( + modifier = modifier, + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + PreviewSizes.forEach { size -> + content( + PrezelChipStyle( + type = type, + size = size, + interaction = interaction, + feedback = feedback, + ), + ) + } + } +} diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt new file mode 100644 index 0000000..f5a478a --- /dev/null +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt @@ -0,0 +1,209 @@ +package com.team.prezel.core.designsystem.component.chip + +import androidx.compose.foundation.BorderStroke +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Icon +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.unit.dp +import com.team.prezel.core.designsystem.foundation.color.PrezelColors +import com.team.prezel.core.designsystem.foundation.number.PrezelShapes +import com.team.prezel.core.designsystem.foundation.number.PrezelSpacing +import com.team.prezel.core.designsystem.foundation.number.PrezelStroke +import com.team.prezel.core.designsystem.icon.IconSource +import com.team.prezel.core.designsystem.theme.PrezelTheme + +enum class PrezelChipType { + FILLED, + OUTLINED, +} + +enum class PrezelChipInteraction { + DEFAULT, + ACTIVE, + DISABLED, +} + +enum class PrezelChipFeedback { + DEFAULT, + BAD, +} + +enum class PrezelChipSize { + SMALL, + REGULAR, +} + +@Immutable +data class PrezelChipStyle( + val type: PrezelChipType = PrezelChipType.FILLED, + val size: PrezelChipSize = PrezelChipSize.REGULAR, + val interaction: PrezelChipInteraction = PrezelChipInteraction.DEFAULT, + val feedback: PrezelChipFeedback = PrezelChipFeedback.DEFAULT, +) + +@Composable +internal fun PrezelChipIcon( + icon: IconSource?, + size: PrezelChipSize, + modifier: Modifier = Modifier, +) { + if (icon == null) return + + Icon( + painter = icon.painter(), + contentDescription = icon.contentDescription(), + modifier = modifier.size( + when (size) { + PrezelChipSize.SMALL -> 12.dp + PrezelChipSize.REGULAR -> 14.dp + }, + ), + ) +} + +@Composable +internal fun prezelChipShape( + size: PrezelChipSize, + shapes: PrezelShapes = PrezelTheme.shapes, +): Shape = + when (size) { + PrezelChipSize.SMALL -> shapes.V4 + PrezelChipSize.REGULAR -> shapes.V8 + } + +@Composable +internal fun prezelChipBorderStroke( + type: PrezelChipType, + interaction: PrezelChipInteraction, + feedback: PrezelChipFeedback, + colors: PrezelColors = PrezelTheme.colors, + stroke: PrezelStroke = PrezelTheme.stroke, +): BorderStroke { + if (type == PrezelChipType.FILLED) return BorderStroke(0.dp, Color.Transparent) + + val borderColor = + when { + feedback == PrezelChipFeedback.BAD -> { + colors.feedbackBadRegular + } + + interaction == PrezelChipInteraction.ACTIVE -> { + colors.interactiveRegular + } + + interaction == PrezelChipInteraction.DISABLED -> { + colors.borderRegular + } + + else -> { + colors.borderMedium + } + } + + return BorderStroke( + width = stroke.V1, + color = borderColor, + ) +} + +@Composable +internal fun prezelChipTextStyle(size: PrezelChipSize): TextStyle = + when (size) { + PrezelChipSize.SMALL -> PrezelTheme.typography.caption2Regular + PrezelChipSize.REGULAR -> PrezelTheme.typography.caption1Regular + } + +@Composable +internal fun prezelChipContainerColor( + type: PrezelChipType, + interaction: PrezelChipInteraction, + feedback: PrezelChipFeedback, + iconOnly: Boolean, + colors: PrezelColors = PrezelTheme.colors, +): Color { + if (type == PrezelChipType.OUTLINED && iconOnly) { + return Color.Transparent + } + + return when { + feedback == PrezelChipFeedback.BAD -> { + colors.feedbackBadSmall + } + + interaction == PrezelChipInteraction.ACTIVE -> { + colors.interactiveXSmall + } + + interaction == PrezelChipInteraction.DISABLED -> { + colors.bgLarge + } + + else -> { + when (type) { + PrezelChipType.FILLED -> colors.bgMedium + PrezelChipType.OUTLINED -> colors.bgRegular + } + } + } +} + +@Composable +internal fun prezelChipContentColor( + interaction: PrezelChipInteraction, + feedback: PrezelChipFeedback, + colors: PrezelColors = PrezelTheme.colors, +): Color = + when { + feedback == PrezelChipFeedback.BAD -> { + colors.feedbackBadRegular + } + + interaction == PrezelChipInteraction.ACTIVE -> { + colors.interactiveRegular + } + + interaction == PrezelChipInteraction.DISABLED -> { + colors.iconDisabled + } + + else -> { + colors.iconRegular + } + } + +@Composable +internal fun prezelChipContentPadding( + size: PrezelChipSize, + onlyIcon: Boolean = false, + spacing: PrezelSpacing = PrezelTheme.spacing, +): PaddingValues { + if (onlyIcon) return prezelIconChipContentPadding(size) + + val horizontal = when (size) { + PrezelChipSize.SMALL -> spacing.V6 + PrezelChipSize.REGULAR -> spacing.V8 + } + + val vertical = when (size) { + PrezelChipSize.SMALL -> spacing.V4 + PrezelChipSize.REGULAR -> spacing.V6 + } + + return PaddingValues(horizontal = horizontal, vertical = vertical) +} + +@Composable +private fun prezelIconChipContentPadding( + size: PrezelChipSize, + spacing: PrezelSpacing = PrezelTheme.spacing, +): PaddingValues = + when (size) { + PrezelChipSize.SMALL -> spacing.V6 + PrezelChipSize.REGULAR -> spacing.V8 + }.let { spacing -> PaddingValues(all = spacing) } diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelIconChip.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelIconChip.kt new file mode 100644 index 0000000..e4fb034 --- /dev/null +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelIconChip.kt @@ -0,0 +1,50 @@ +package com.team.prezel.core.designsystem.component.chip + +import androidx.compose.material3.HorizontalDivider +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import com.team.prezel.core.designsystem.icon.DrawableIcon +import com.team.prezel.core.designsystem.icon.IconSource +import com.team.prezel.core.designsystem.icon.PrezelIcons +import com.team.prezel.core.designsystem.preview.PreviewScaffold +import com.team.prezel.core.designsystem.preview.ThemePreview +import com.team.prezel.core.designsystem.theme.PrezelTheme + +@Composable +fun PrezelIconChip( + icon: IconSource, + modifier: Modifier = Modifier, + style: PrezelChipStyle = PrezelChipStyle(), +) { + PrezelChip( + modifier = modifier, + icon = icon, + style = style, + ) +} + +@ThemePreview +@Composable +private fun PrezelIconChipPreview() { + PrezelTheme { + PreviewScaffold { + PrezelChipPreviewByType( + type = PrezelChipType.FILLED, + ) { style -> PrezelIconChipPreviewItem(style) } + + HorizontalDivider() + + PrezelChipPreviewByType( + type = PrezelChipType.OUTLINED, + ) { style -> PrezelIconChipPreviewItem(style) } + } + } +} + +@Composable +private fun PrezelIconChipPreviewItem(style: PrezelChipStyle) { + PrezelIconChip( + icon = DrawableIcon(resId = PrezelIcons.Blank), + style = style, + ) +} From bd054a1012510467f0c6be6db54bdd42d346df9c Mon Sep 17 00:00:00 2001 From: Ham BeomJoon Date: Mon, 26 Jan 2026 01:43:15 +0900 Subject: [PATCH 02/10] =?UTF-8?q?feat:=20PrezelChip=20=EC=BB=A4=EC=8A=A4?= =?UTF-8?q?=ED=85=80=20=EC=83=89=EC=83=81=20=EC=A7=80=EC=9B=90=20=EB=B0=8F?= =?UTF-8?q?=20=ED=94=84=EB=A6=AC=EB=B7=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PrezelChip 컴포넌트에서 외부로부터 직접 색상을 주입받을 수 있도록 개선하고, 이를 확인하기 위한 커스텀 프리뷰 코드를 추가했습니다. * `PrezelChip` 파라미터에서 `containerColor`와 `contentColor` 타입을 `PrezelColors`에서 `Color?`로 변경 및 기본값(null) 설정 * 외부 색상 주입 시 테두리(border)를 투명하게 처리하도록 로직 수정 * 다양한 색상 조합을 테스트할 수 있는 `PrezelCustomChipPreview.kt` 추가 --- .../designsystem/component/chip/PrezelChip.kt | 42 +++-- .../component/chip/PrezelCustomChipPreview.kt | 170 ++++++++++++++++++ 2 files changed, 201 insertions(+), 11 deletions(-) create mode 100644 Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt index f44d9a7..2d6e9f6 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt @@ -1,5 +1,6 @@ package com.team.prezel.core.designsystem.component.chip +import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -14,7 +15,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import com.team.prezel.core.designsystem.foundation.color.PrezelColors +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp import com.team.prezel.core.designsystem.icon.DrawableIcon import com.team.prezel.core.designsystem.icon.IconSource import com.team.prezel.core.designsystem.icon.PrezelIcons @@ -66,12 +68,12 @@ fun PrezelChip( @Composable fun PrezelChip( - containerColor: PrezelColors, - contentColor: PrezelColors, modifier: Modifier = Modifier, text: String? = null, icon: IconSource? = null, style: PrezelChipStyle = PrezelChipStyle(), + containerColor: Color? = null, + contentColor: Color? = null, ) { val hasText = text != null val hasIcon = icon != null @@ -79,21 +81,39 @@ fun PrezelChip( require(hasText || hasIcon) { "Chip은 text 또는 icon 중 하나는 반드시 필요합니다." } val (chipType, chipSize, interaction, feedback) = style - Surface( - modifier = modifier, - shape = prezelChipShape(chipSize), - color = prezelChipContainerColor( + val resolvedContainerColor = + containerColor ?: prezelChipContainerColor( type = chipType, interaction = interaction, feedback = feedback, iconOnly = iconOnly, - colors = containerColor, - ), - border = prezelChipBorderStroke(type = chipType, interaction = interaction, feedback = feedback), + ) + + val resolvedContentColor = contentColor ?: prezelChipContentColor( + interaction = interaction, + feedback = feedback, + ) + + val resolvedBorder = + if (containerColor != null) { + BorderStroke(0.dp, Color.Transparent) + } else { + prezelChipBorderStroke( + type = chipType, + interaction = interaction, + feedback = feedback, + ) + } + + Surface( + modifier = modifier, + shape = prezelChipShape(chipSize), + color = resolvedContainerColor, + border = resolvedBorder, ) { CompositionLocalProvider( LocalTextStyle provides prezelChipTextStyle(chipSize), - LocalContentColor provides prezelChipContentColor(interaction = interaction, feedback = feedback, colors = contentColor), + LocalContentColor provides resolvedContentColor, ) { Row( modifier = Modifier.padding(prezelChipContentPadding(size = chipSize, onlyIcon = hasIcon && !hasText)), diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt new file mode 100644 index 0000000..fc7313f --- /dev/null +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt @@ -0,0 +1,170 @@ +package com.team.prezel.core.designsystem.component.chip + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.FlowRow +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import com.team.prezel.core.designsystem.icon.DrawableIcon +import com.team.prezel.core.designsystem.icon.PrezelIcons +import com.team.prezel.core.designsystem.preview.PreviewScaffold +import com.team.prezel.core.designsystem.preview.ThemePreview +import com.team.prezel.core.designsystem.theme.PrezelTheme + +@ThemePreview +@Composable +private fun PrezelChip_CustomColors_Preview() { + PrezelTheme { + PreviewScaffold { + CustomChipHeader() + + Spacer(modifier = Modifier.height(12.dp)) + + CustomChipLabelSection() + + Spacer(modifier = Modifier.height(16.dp)) + + CustomChipIconOnlySection() + } + } +} + +@Composable +private fun CustomChipHeader() { + Text( + text = "Custom Chip", + style = PrezelTheme.typography.title2Medium, + ) +} + +@Composable +private fun CustomChipLabelSection() { + FlowRow( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(8.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), + maxItemsInEachRow = 3, + ) { + CustomYellowLabelChip() + CustomRedLabelChip() + CustomGreenLabelChip() + } +} + +@Composable +private fun CustomChipIconOnlySection() { + Text( + text = "Icon only", + style = PrezelTheme.typography.body3Medium, + ) + + Spacer(modifier = Modifier.height(8.dp)) + + Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { + CustomYellowIconChip() + CustomRedIconChip() + CustomGreenIconChip() + } +} + +@Composable +private fun CustomYellowLabelChip() { + PrezelChip( + text = "느려요", + icon = DrawableIcon(resId = PrezelIcons.Blank), + style = PrezelChipStyle( + type = PrezelChipType.FILLED, + size = PrezelChipSize.REGULAR, + interaction = PrezelChipInteraction.DISABLED, + feedback = PrezelChipFeedback.BAD, + ), + containerColor = PrezelTheme.colors.feedbackWarningSmall, + contentColor = PrezelTheme.colors.feedbackWarningRegular, + ) +} + +@Composable +private fun CustomRedLabelChip() { + PrezelChip( + text = "빨라요", + icon = null, + style = PrezelChipStyle( + type = PrezelChipType.OUTLINED, + size = PrezelChipSize.REGULAR, + interaction = PrezelChipInteraction.DEFAULT, + feedback = PrezelChipFeedback.DEFAULT, + ), + containerColor = PrezelTheme.colors.feedbackBadSmall, + contentColor = PrezelTheme.colors.feedbackBadRegular, + ) +} + +@Composable +private fun CustomGreenLabelChip() { + PrezelChip( + text = "적당해요", + icon = null, + style = PrezelChipStyle( + type = PrezelChipType.FILLED, + size = PrezelChipSize.SMALL, + interaction = PrezelChipInteraction.ACTIVE, + feedback = PrezelChipFeedback.DEFAULT, + ), + containerColor = Color(0xFFDBFFF6), + contentColor = Color(0xFF00A37A), + ) +} + +@Composable +private fun CustomYellowIconChip() { + PrezelChip( + text = null, + icon = DrawableIcon(resId = PrezelIcons.Blank), + style = PrezelChipStyle( + type = PrezelChipType.FILLED, + size = PrezelChipSize.REGULAR, + interaction = PrezelChipInteraction.DISABLED, + feedback = PrezelChipFeedback.BAD, + ), + containerColor = PrezelTheme.colors.feedbackWarningSmall, + contentColor = PrezelTheme.colors.feedbackWarningRegular, + ) +} + +@Composable +private fun CustomRedIconChip() { + PrezelChip( + text = null, + icon = DrawableIcon(resId = PrezelIcons.Blank), + style = PrezelChipStyle( + type = PrezelChipType.OUTLINED, + size = PrezelChipSize.REGULAR, + interaction = PrezelChipInteraction.DEFAULT, + feedback = PrezelChipFeedback.DEFAULT, + ), + containerColor = PrezelTheme.colors.feedbackBadSmall, + contentColor = PrezelTheme.colors.feedbackBadRegular, + ) +} + +@Composable +private fun CustomGreenIconChip() { + PrezelChip( + text = null, + icon = DrawableIcon(resId = PrezelIcons.Blank), + style = PrezelChipStyle( + type = PrezelChipType.FILLED, + size = PrezelChipSize.SMALL, + interaction = PrezelChipInteraction.ACTIVE, + feedback = PrezelChipFeedback.DEFAULT, + ), + containerColor = Color(0xFFDBFFF6), + contentColor = Color(0xFF00A37A), + ) +} From faef1628cac2fc26ec94315694a05ae060504561 Mon Sep 17 00:00:00 2001 From: Ham BeomJoon Date: Mon, 26 Jan 2026 01:51:02 +0900 Subject: [PATCH 03/10] =?UTF-8?q?refactor:=20PrezelChip=20=EC=8A=A4?= =?UTF-8?q?=ED=83=80=EC=9D=BC=20=EA=B2=B0=EC=A0=95=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=20=EB=B0=8F=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `PrezelChip` 컴포저블 내부의 복잡한 색상 및 테두리 결정 로직을 별도의 private 함수로 분리하여 가독성을 개선했습니다. * `resolveChipBorder`, `resolveChipContainerColor`, `resolveChipContentColor` 함수 추가 * 커스텀 색상이 지정된 경우의 테두리 처리 로직 수정 (0.dp 대신 null 반환) * 불필요한 import 제거 및 코드 구조 정리 --- .../designsystem/component/chip/PrezelChip.kt | 74 +++++++++++++------ 1 file changed, 53 insertions(+), 21 deletions(-) diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt index 2d6e9f6..753adcc 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt @@ -16,7 +16,6 @@ import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp import com.team.prezel.core.designsystem.icon.DrawableIcon import com.team.prezel.core.designsystem.icon.IconSource import com.team.prezel.core.designsystem.icon.PrezelIcons @@ -79,31 +78,26 @@ fun PrezelChip( val hasIcon = icon != null val iconOnly = hasIcon && !hasText require(hasText || hasIcon) { "Chip은 text 또는 icon 중 하나는 반드시 필요합니다." } - val (chipType, chipSize, interaction, feedback) = style + val (_, chipSize, _, _) = style + + val resolvedBorder = + resolveChipBorder( + style = style, + hasCustomContainerColor = containerColor != null, + ) val resolvedContainerColor = - containerColor ?: prezelChipContainerColor( - type = chipType, - interaction = interaction, - feedback = feedback, + resolveChipContainerColor( + style = style, iconOnly = iconOnly, + overrideColor = containerColor, ) - val resolvedContentColor = contentColor ?: prezelChipContentColor( - interaction = interaction, - feedback = feedback, - ) - - val resolvedBorder = - if (containerColor != null) { - BorderStroke(0.dp, Color.Transparent) - } else { - prezelChipBorderStroke( - type = chipType, - interaction = interaction, - feedback = feedback, - ) - } + val resolvedContentColor = + resolveChipContentColor( + style = style, + overrideColor = contentColor, + ) Surface( modifier = modifier, @@ -134,6 +128,44 @@ fun PrezelChip( } } +@Composable +private fun resolveChipBorder( + style: PrezelChipStyle, + hasCustomContainerColor: Boolean, +): BorderStroke? = + if (hasCustomContainerColor) { + null + } else { + prezelChipBorderStroke( + type = style.type, + interaction = style.interaction, + feedback = style.feedback, + ) + } + +@Composable +private fun resolveChipContainerColor( + style: PrezelChipStyle, + iconOnly: Boolean, + overrideColor: Color?, +): Color = + overrideColor ?: prezelChipContainerColor( + type = style.type, + interaction = style.interaction, + feedback = style.feedback, + iconOnly = iconOnly, + ) + +@Composable +private fun resolveChipContentColor( + style: PrezelChipStyle, + overrideColor: Color?, +): Color = + overrideColor ?: prezelChipContentColor( + interaction = style.interaction, + feedback = style.feedback, + ) + @ThemePreview @Composable private fun PrezelChipPreview() { From 646b69e755075e2449a1ec9eeacf375e887a50af Mon Sep 17 00:00:00 2001 From: Ham BeomJoon Date: Tue, 27 Jan 2026 00:58:42 +0900 Subject: [PATCH 04/10] =?UTF-8?q?style:=20PrezelChip=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=EC=BD=98=20=ED=81=AC=EA=B8=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PrezelChip의 사이즈별 아이콘 크기를 다음과 같이 수정했습니다. * SMALL: 12.dp -> 14.dp * REGULAR: 14.dp -> 16.dp --- .../core/designsystem/component/chip/PrezelChipStyle.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt index f5a478a..4377901 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt @@ -60,8 +60,8 @@ internal fun PrezelChipIcon( contentDescription = icon.contentDescription(), modifier = modifier.size( when (size) { - PrezelChipSize.SMALL -> 12.dp - PrezelChipSize.REGULAR -> 14.dp + PrezelChipSize.SMALL -> 14.dp + PrezelChipSize.REGULAR -> 16.dp }, ), ) From 46666129349592cf060e6fd585ad530308477ec9 Mon Sep 17 00:00:00 2001 From: Ham BeomJoon Date: Tue, 27 Jan 2026 01:01:12 +0900 Subject: [PATCH 05/10] =?UTF-8?q?feat:=20PrezelChip=20=EC=83=89=EC=83=81?= =?UTF-8?q?=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EA=B8=B0=EB=B3=B8?= =?UTF-8?q?=EA=B0=92=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `PrezelChip` 컴포넌트의 `containerColor` 및 `contentColor` 파라미터 기본값을 `null`에서 `Color.Unspecified`로 변경했습니다. --- .../prezel/core/designsystem/component/chip/PrezelChip.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt index 753adcc..54ac7b1 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt @@ -71,8 +71,8 @@ fun PrezelChip( text: String? = null, icon: IconSource? = null, style: PrezelChipStyle = PrezelChipStyle(), - containerColor: Color? = null, - contentColor: Color? = null, + containerColor: Color = Color.Unspecified, + contentColor: Color = Color.Unspecified, ) { val hasText = text != null val hasIcon = icon != null From 4ac5ccce1e86240f037ecdce40d936eed66edde1 Mon Sep 17 00:00:00 2001 From: Ham BeomJoon Date: Tue, 27 Jan 2026 01:46:45 +0900 Subject: [PATCH 06/10] =?UTF-8?q?refactor:=20PrezelChip=20=EC=8A=A4?= =?UTF-8?q?=ED=83=80=EC=9D=BC=20=EB=B0=8F=20=EA=B5=AC=EC=A1=B0=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `PrezelChipStyle` 내부로 칩 스타일 관련 로직을 캡슐화하고 구성 방식을 개선했습니다. * `PrezelChipStyle` 클래스 내부에 `shape`, `borderStroke`, `textStyle` 등의 스타일 계산 로직을 메서드로 통합 * `PrezelChipColors` 데이터 클래스 및 `LocalPrezelChipColors` 추가를 통한 색상 관리 구조 개선 * `PrezelChip` 컴포넌트의 가독성 향상을 위해 불필요한 색상 결정 로직(resolve functions) 제거 및 내부 구조 단순화 * 아이콘 크기 계산 방식을 `PrezelChipStyle.iconSize()`로 일원화 * 코드 스타일 및 가독성을 위한 전반적인 리팩터링 수행 --- .../designsystem/component/chip/PrezelChip.kt | 136 ++++------ .../component/chip/PrezelChipStyle.kt | 239 ++++++++---------- 2 files changed, 161 insertions(+), 214 deletions(-) diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt index 54ac7b1..5d9408b 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt @@ -1,12 +1,13 @@ package com.team.prezel.core.designsystem.component.chip -import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Icon import androidx.compose.material3.LocalContentColor import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.Surface @@ -34,24 +35,24 @@ fun PrezelChip( val hasIcon = icon != null val iconOnly = hasIcon && !hasText require(hasText || hasIcon) { "Chip은 text 또는 icon 중 하나는 반드시 필요합니다." } - val (chipType, chipSize, interaction, feedback) = style + val (_, chipSize, _, _) = style Surface( modifier = modifier, - shape = prezelChipShape(chipSize), - color = prezelChipContainerColor(type = chipType, interaction = interaction, feedback = feedback, iconOnly = iconOnly), - border = prezelChipBorderStroke(type = chipType, interaction = interaction, feedback = feedback), + shape = style.shape(), + color = style.containerColor(iconOnly = iconOnly), + border = style.borderStroke(), ) { CompositionLocalProvider( - LocalTextStyle provides prezelChipTextStyle(chipSize), - LocalContentColor provides prezelChipContentColor(interaction = interaction, feedback = feedback), + LocalTextStyle provides style.textStyle(), + LocalContentColor provides style.contentColor(), ) { Row( - modifier = Modifier.padding(prezelChipContentPadding(size = chipSize, onlyIcon = hasIcon && !hasText)), + modifier = Modifier.padding(style.contentPadding(iconOnly = iconOnly)), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically, ) { - PrezelChipIcon(icon = icon, size = chipSize) + PrezelChipIcon(icon = icon, style = style) if (!hasText) return@Row if (hasIcon) { @@ -78,93 +79,64 @@ fun PrezelChip( val hasIcon = icon != null val iconOnly = hasIcon && !hasText require(hasText || hasIcon) { "Chip은 text 또는 icon 중 하나는 반드시 필요합니다." } - val (_, chipSize, _, _) = style - val resolvedBorder = - resolveChipBorder( - style = style, - hasCustomContainerColor = containerColor != null, - ) - - val resolvedContainerColor = - resolveChipContainerColor( - style = style, - iconOnly = iconOnly, - overrideColor = containerColor, - ) - - val resolvedContentColor = - resolveChipContentColor( - style = style, - overrideColor = contentColor, - ) + val colors = PrezelChipColors( + containerColor = containerColor, + contentColor = contentColor, + ) - Surface( - modifier = modifier, - shape = prezelChipShape(chipSize), - color = resolvedContainerColor, - border = resolvedBorder, - ) { - CompositionLocalProvider( - LocalTextStyle provides prezelChipTextStyle(chipSize), - LocalContentColor provides resolvedContentColor, + CompositionLocalProvider(LocalPrezelChipColors provides colors) { + val resolvedContainer = style.containerColor(iconOnly = iconOnly) + val resolvedContent = style.contentColor() + val resolvedBorder = style.borderStroke() + + Surface( + modifier = modifier, + shape = style.shape(), + color = resolvedContainer, + border = resolvedBorder, ) { - Row( - modifier = Modifier.padding(prezelChipContentPadding(size = chipSize, onlyIcon = hasIcon && !hasText)), - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically, + CompositionLocalProvider( + LocalTextStyle provides style.textStyle(), + LocalContentColor provides resolvedContent, ) { - PrezelChipIcon(icon = icon, size = chipSize) - - if (!hasText) return@Row - if (hasIcon) { - val spacing = if (chipSize == PrezelChipSize.REGULAR) PrezelTheme.spacing.V4 else PrezelTheme.spacing.V2 - Spacer(modifier = Modifier.width(width = spacing)) + Row( + modifier = Modifier.padding(style.contentPadding(iconOnly = iconOnly)), + horizontalArrangement = Arrangement.Center, + verticalAlignment = Alignment.CenterVertically, + ) { + PrezelChipIcon(icon = icon, style = style) + + if (hasText) { + if (hasIcon) { + val spacing = when (style.size) { + PrezelChipSize.REGULAR -> PrezelTheme.spacing.V4 + PrezelChipSize.SMALL -> PrezelTheme.spacing.V2 + } + Spacer(modifier = Modifier.width(spacing)) + } + Text(text = text) + } } - - Text(text = text) } } } } @Composable -private fun resolveChipBorder( - style: PrezelChipStyle, - hasCustomContainerColor: Boolean, -): BorderStroke? = - if (hasCustomContainerColor) { - null - } else { - prezelChipBorderStroke( - type = style.type, - interaction = style.interaction, - feedback = style.feedback, - ) - } - -@Composable -private fun resolveChipContainerColor( +private fun PrezelChipIcon( + icon: IconSource?, style: PrezelChipStyle, - iconOnly: Boolean, - overrideColor: Color?, -): Color = - overrideColor ?: prezelChipContainerColor( - type = style.type, - interaction = style.interaction, - feedback = style.feedback, - iconOnly = iconOnly, - ) + modifier: Modifier = Modifier, +) { + if (icon == null) return -@Composable -private fun resolveChipContentColor( - style: PrezelChipStyle, - overrideColor: Color?, -): Color = - overrideColor ?: prezelChipContentColor( - interaction = style.interaction, - feedback = style.feedback, + Icon( + painter = icon.painter(), + contentDescription = icon.contentDescription(), + modifier = modifier.size(style.iconSize()), ) +} @ThemePreview @Composable diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt index 4377901..cfb3d07 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt @@ -2,20 +2,19 @@ package com.team.prezel.core.designsystem.component.chip import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.size -import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable -import androidx.compose.ui.Modifier +import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.team.prezel.core.designsystem.foundation.color.PrezelColors import com.team.prezel.core.designsystem.foundation.number.PrezelShapes import com.team.prezel.core.designsystem.foundation.number.PrezelSpacing import com.team.prezel.core.designsystem.foundation.number.PrezelStroke -import com.team.prezel.core.designsystem.icon.IconSource +import com.team.prezel.core.designsystem.foundation.typography.PrezelTypography import com.team.prezel.core.designsystem.theme.PrezelTheme enum class PrezelChipType { @@ -45,165 +44,141 @@ data class PrezelChipStyle( val size: PrezelChipSize = PrezelChipSize.REGULAR, val interaction: PrezelChipInteraction = PrezelChipInteraction.DEFAULT, val feedback: PrezelChipFeedback = PrezelChipFeedback.DEFAULT, -) - -@Composable -internal fun PrezelChipIcon( - icon: IconSource?, - size: PrezelChipSize, - modifier: Modifier = Modifier, ) { - if (icon == null) return - - Icon( - painter = icon.painter(), - contentDescription = icon.contentDescription(), - modifier = modifier.size( - when (size) { - PrezelChipSize.SMALL -> 14.dp - PrezelChipSize.REGULAR -> 16.dp - }, - ), - ) -} + @Composable + internal fun shape(shapes: PrezelShapes = PrezelTheme.shapes): Shape = + when (size) { + PrezelChipSize.SMALL -> shapes.V4 + PrezelChipSize.REGULAR -> shapes.V8 + } + + @Composable + internal fun borderStroke( + colors: PrezelColors = PrezelTheme.colors, + stroke: PrezelStroke = PrezelTheme.stroke, + ): BorderStroke? { + if (type == PrezelChipType.FILLED) return null + + val borderColor = + when { + feedback == PrezelChipFeedback.BAD -> { + colors.feedbackBadRegular + } + + interaction == PrezelChipInteraction.ACTIVE -> { + colors.interactiveRegular + } + + interaction == PrezelChipInteraction.DISABLED -> { + colors.borderRegular + } + + else -> { + colors.borderMedium + } + } -@Composable -internal fun prezelChipShape( - size: PrezelChipSize, - shapes: PrezelShapes = PrezelTheme.shapes, -): Shape = - when (size) { - PrezelChipSize.SMALL -> shapes.V4 - PrezelChipSize.REGULAR -> shapes.V8 + return BorderStroke( + width = stroke.V1, + color = borderColor, + ) } -@Composable -internal fun prezelChipBorderStroke( - type: PrezelChipType, - interaction: PrezelChipInteraction, - feedback: PrezelChipFeedback, - colors: PrezelColors = PrezelTheme.colors, - stroke: PrezelStroke = PrezelTheme.stroke, -): BorderStroke { - if (type == PrezelChipType.FILLED) return BorderStroke(0.dp, Color.Transparent) - - val borderColor = - when { + @Composable + internal fun textStyle(typography: PrezelTypography = PrezelTheme.typography): TextStyle = + when (size) { + PrezelChipSize.SMALL -> typography.caption2Regular + PrezelChipSize.REGULAR -> typography.caption1Regular + } + + @Composable + internal fun containerColor( + iconOnly: Boolean, + colors: PrezelColors = PrezelTheme.colors, + ): Color { + if (type == PrezelChipType.OUTLINED && iconOnly) { + return Color.Transparent + } + + return when { feedback == PrezelChipFeedback.BAD -> { - colors.feedbackBadRegular + colors.feedbackBadSmall } interaction == PrezelChipInteraction.ACTIVE -> { - colors.interactiveRegular + colors.interactiveXSmall } interaction == PrezelChipInteraction.DISABLED -> { - colors.borderRegular + colors.bgLarge } else -> { - colors.borderMedium + when (type) { + PrezelChipType.FILLED -> colors.bgMedium + PrezelChipType.OUTLINED -> colors.bgRegular + } } } - - return BorderStroke( - width = stroke.V1, - color = borderColor, - ) -} - -@Composable -internal fun prezelChipTextStyle(size: PrezelChipSize): TextStyle = - when (size) { - PrezelChipSize.SMALL -> PrezelTheme.typography.caption2Regular - PrezelChipSize.REGULAR -> PrezelTheme.typography.caption1Regular } -@Composable -internal fun prezelChipContainerColor( - type: PrezelChipType, - interaction: PrezelChipInteraction, - feedback: PrezelChipFeedback, - iconOnly: Boolean, - colors: PrezelColors = PrezelTheme.colors, -): Color { - if (type == PrezelChipType.OUTLINED && iconOnly) { - return Color.Transparent - } - - return when { - feedback == PrezelChipFeedback.BAD -> { - colors.feedbackBadSmall - } - - interaction == PrezelChipInteraction.ACTIVE -> { - colors.interactiveXSmall - } + @Composable + internal fun contentColor(colors: PrezelColors = PrezelTheme.colors): Color = + when { + feedback == PrezelChipFeedback.BAD -> { + colors.feedbackBadRegular + } - interaction == PrezelChipInteraction.DISABLED -> { - colors.bgLarge - } + interaction == PrezelChipInteraction.ACTIVE -> { + colors.interactiveRegular + } - else -> { - when (type) { - PrezelChipType.FILLED -> colors.bgMedium - PrezelChipType.OUTLINED -> colors.bgRegular + interaction == PrezelChipInteraction.DISABLED -> { + colors.iconDisabled } - } - } -} -@Composable -internal fun prezelChipContentColor( - interaction: PrezelChipInteraction, - feedback: PrezelChipFeedback, - colors: PrezelColors = PrezelTheme.colors, -): Color = - when { - feedback == PrezelChipFeedback.BAD -> { - colors.feedbackBadRegular + else -> { + colors.iconRegular + } } - interaction == PrezelChipInteraction.ACTIVE -> { - colors.interactiveRegular + @Composable + internal fun contentPadding( + iconOnly: Boolean, + spacing: PrezelSpacing = PrezelTheme.spacing, + ): PaddingValues { + if (iconOnly) { + val all = when (size) { + PrezelChipSize.SMALL -> spacing.V6 + PrezelChipSize.REGULAR -> spacing.V8 + } + return PaddingValues(all = all) } - interaction == PrezelChipInteraction.DISABLED -> { - colors.iconDisabled + val horizontal = when (size) { + PrezelChipSize.SMALL -> spacing.V6 + PrezelChipSize.REGULAR -> spacing.V8 } - else -> { - colors.iconRegular + val vertical = when (size) { + PrezelChipSize.SMALL -> spacing.V4 + PrezelChipSize.REGULAR -> spacing.V6 } - } - -@Composable -internal fun prezelChipContentPadding( - size: PrezelChipSize, - onlyIcon: Boolean = false, - spacing: PrezelSpacing = PrezelTheme.spacing, -): PaddingValues { - if (onlyIcon) return prezelIconChipContentPadding(size) - - val horizontal = when (size) { - PrezelChipSize.SMALL -> spacing.V6 - PrezelChipSize.REGULAR -> spacing.V8 - } - val vertical = when (size) { - PrezelChipSize.SMALL -> spacing.V4 - PrezelChipSize.REGULAR -> spacing.V6 + return PaddingValues(horizontal = horizontal, vertical = vertical) } - return PaddingValues(horizontal = horizontal, vertical = vertical) + internal fun iconSize(): Dp = + when (size) { + PrezelChipSize.SMALL -> 14.dp + PrezelChipSize.REGULAR -> 16.dp + } } -@Composable -private fun prezelIconChipContentPadding( - size: PrezelChipSize, - spacing: PrezelSpacing = PrezelTheme.spacing, -): PaddingValues = - when (size) { - PrezelChipSize.SMALL -> spacing.V6 - PrezelChipSize.REGULAR -> spacing.V8 - }.let { spacing -> PaddingValues(all = spacing) } +@Immutable +data class PrezelChipColors( + val containerColor: Color = Color.Unspecified, + val contentColor: Color = Color.Unspecified, +) + +internal val LocalPrezelChipColors = staticCompositionLocalOf { PrezelChipColors() } From 7fa8da4571979eed0e8c34314e5eb94137fd6627 Mon Sep 17 00:00:00 2001 From: Ham BeomJoon Date: Tue, 27 Jan 2026 02:20:06 +0900 Subject: [PATCH 07/10] =?UTF-8?q?refactor:=20PrezelChip=20=EC=8A=A4?= =?UTF-8?q?=ED=83=80=EC=9D=BC=20=EC=B2=98=EB=A6=AC=20=EB=B0=8F=20=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `PrezelChip`의 내부 구현을 `PrezelChipImpl`로 통합하고, 스타일 계산 로직에서 `LocalPrezelChipColors`를 직접 참조하도록 개선했습니다. * `PrezelChipStyle` 내 `borderStroke`, `containerColor`, `contentColor`가 `LocalPrezelChipColors`를 참조하여 색상을 결정하도록 수정 * `PrezelChip`과 `PrezelCustomChip`의 공통 로직을 `PrezelChipImpl`로 추출하여 중복 제거 * `PrezelChipStyle`에 `iconTextSpacing()` 메서드를 추가하여 칩 사이즈에 따른 간격 로직 분리 * 미사용 코드 정리 및 Preview 레이아웃 수정 (불필요한 중복 Theme 래퍼 및 간격 제거) --- .../designsystem/component/chip/PrezelChip.kt | 124 +++++++----------- .../component/chip/PrezelChipStyle.kt | 70 ++++------ .../component/chip/PrezelCustomChipPreview.kt | 6 - 3 files changed, 78 insertions(+), 122 deletions(-) diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt index 5d9408b..4c0ccec 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt @@ -30,12 +30,50 @@ fun PrezelChip( text: String? = null, icon: IconSource? = null, style: PrezelChipStyle = PrezelChipStyle(), +) { + PrezelChipImpl( + modifier = modifier, + text = text, + icon = icon, + style = style, + ) +} + +@Composable +fun PrezelChip( + modifier: Modifier = Modifier, + text: String? = null, + icon: IconSource? = null, + style: PrezelChipStyle = PrezelChipStyle(), + containerColor: Color = Color.Unspecified, + contentColor: Color = Color.Unspecified, +) { + CompositionLocalProvider( + LocalPrezelChipColors provides PrezelChipColors( + containerColor = containerColor, + contentColor = contentColor, + ), + ) { + PrezelChipImpl( + modifier = modifier, + text = text, + icon = icon, + style = style, + ) + } +} + +@Composable +private fun PrezelChipImpl( + modifier: Modifier = Modifier, + text: String? = null, + icon: IconSource? = null, + style: PrezelChipStyle = PrezelChipStyle(), ) { val hasText = text != null val hasIcon = icon != null val iconOnly = hasIcon && !hasText require(hasText || hasIcon) { "Chip은 text 또는 icon 중 하나는 반드시 필요합니다." } - val (_, chipSize, _, _) = style Surface( modifier = modifier, @@ -54,69 +92,11 @@ fun PrezelChip( ) { PrezelChipIcon(icon = icon, style = style) - if (!hasText) return@Row - if (hasIcon) { - val spacing = if (chipSize == PrezelChipSize.REGULAR) PrezelTheme.spacing.V4 else PrezelTheme.spacing.V2 - Spacer(modifier = Modifier.width(width = spacing)) - } - - Text(text = text) - } - } - } -} - -@Composable -fun PrezelChip( - modifier: Modifier = Modifier, - text: String? = null, - icon: IconSource? = null, - style: PrezelChipStyle = PrezelChipStyle(), - containerColor: Color = Color.Unspecified, - contentColor: Color = Color.Unspecified, -) { - val hasText = text != null - val hasIcon = icon != null - val iconOnly = hasIcon && !hasText - require(hasText || hasIcon) { "Chip은 text 또는 icon 중 하나는 반드시 필요합니다." } - - val colors = PrezelChipColors( - containerColor = containerColor, - contentColor = contentColor, - ) - - CompositionLocalProvider(LocalPrezelChipColors provides colors) { - val resolvedContainer = style.containerColor(iconOnly = iconOnly) - val resolvedContent = style.contentColor() - val resolvedBorder = style.borderStroke() - - Surface( - modifier = modifier, - shape = style.shape(), - color = resolvedContainer, - border = resolvedBorder, - ) { - CompositionLocalProvider( - LocalTextStyle provides style.textStyle(), - LocalContentColor provides resolvedContent, - ) { - Row( - modifier = Modifier.padding(style.contentPadding(iconOnly = iconOnly)), - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically, - ) { - PrezelChipIcon(icon = icon, style = style) - - if (hasText) { - if (hasIcon) { - val spacing = when (style.size) { - PrezelChipSize.REGULAR -> PrezelTheme.spacing.V4 - PrezelChipSize.SMALL -> PrezelTheme.spacing.V2 - } - Spacer(modifier = Modifier.width(spacing)) - } - Text(text = text) + if (hasText) { + if (hasIcon) { + Spacer(modifier = Modifier.width(style.iconTextSpacing())) } + Text(text = text) } } } @@ -142,18 +122,16 @@ private fun PrezelChipIcon( @Composable private fun PrezelChipPreview() { PrezelTheme { - PrezelTheme { - PreviewScaffold { - PrezelChipPreviewByType( - type = PrezelChipType.FILLED, - ) { style -> PrezelChipPreviewItem(style) } + PreviewScaffold { + PrezelChipPreviewByType( + type = PrezelChipType.FILLED, + ) { style -> PrezelChipPreviewItem(style) } - HorizontalDivider() + HorizontalDivider() - PrezelChipPreviewByType( - type = PrezelChipType.OUTLINED, - ) { style -> PrezelChipPreviewItem(style) } - } + PrezelChipPreviewByType( + type = PrezelChipType.OUTLINED, + ) { style -> PrezelChipPreviewItem(style) } } } } diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt index cfb3d07..9107c71 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt @@ -56,26 +56,17 @@ data class PrezelChipStyle( internal fun borderStroke( colors: PrezelColors = PrezelTheme.colors, stroke: PrezelStroke = PrezelTheme.stroke, + chipColors: PrezelChipColors = LocalPrezelChipColors.current, ): BorderStroke? { if (type == PrezelChipType.FILLED) return null val borderColor = when { - feedback == PrezelChipFeedback.BAD -> { - colors.feedbackBadRegular - } - - interaction == PrezelChipInteraction.ACTIVE -> { - colors.interactiveRegular - } - - interaction == PrezelChipInteraction.DISABLED -> { - colors.borderRegular - } - - else -> { - colors.borderMedium - } + chipColors.contentColor != Color.Unspecified -> chipColors.contentColor + feedback == PrezelChipFeedback.BAD -> colors.feedbackBadRegular + interaction == PrezelChipInteraction.ACTIVE -> colors.interactiveRegular + interaction == PrezelChipInteraction.DISABLED -> colors.borderRegular + else -> colors.borderMedium } return BorderStroke( @@ -95,24 +86,17 @@ data class PrezelChipStyle( internal fun containerColor( iconOnly: Boolean, colors: PrezelColors = PrezelTheme.colors, + chipColors: PrezelChipColors = LocalPrezelChipColors.current, ): Color { if (type == PrezelChipType.OUTLINED && iconOnly) { return Color.Transparent } return when { - feedback == PrezelChipFeedback.BAD -> { - colors.feedbackBadSmall - } - - interaction == PrezelChipInteraction.ACTIVE -> { - colors.interactiveXSmall - } - - interaction == PrezelChipInteraction.DISABLED -> { - colors.bgLarge - } - + chipColors.containerColor != Color.Unspecified -> chipColors.containerColor + feedback == PrezelChipFeedback.BAD -> colors.feedbackBadSmall + interaction == PrezelChipInteraction.ACTIVE -> colors.interactiveXSmall + interaction == PrezelChipInteraction.DISABLED -> colors.bgLarge else -> { when (type) { PrezelChipType.FILLED -> colors.bgMedium @@ -123,23 +107,16 @@ data class PrezelChipStyle( } @Composable - internal fun contentColor(colors: PrezelColors = PrezelTheme.colors): Color = + internal fun contentColor( + colors: PrezelColors = PrezelTheme.colors, + chipColors: PrezelChipColors = LocalPrezelChipColors.current, + ): Color = when { - feedback == PrezelChipFeedback.BAD -> { - colors.feedbackBadRegular - } - - interaction == PrezelChipInteraction.ACTIVE -> { - colors.interactiveRegular - } - - interaction == PrezelChipInteraction.DISABLED -> { - colors.iconDisabled - } - - else -> { - colors.iconRegular - } + chipColors.contentColor != Color.Unspecified -> chipColors.contentColor + feedback == PrezelChipFeedback.BAD -> colors.feedbackBadRegular + interaction == PrezelChipInteraction.ACTIVE -> colors.interactiveRegular + interaction == PrezelChipInteraction.DISABLED -> colors.iconDisabled + else -> colors.iconRegular } @Composable @@ -168,6 +145,13 @@ data class PrezelChipStyle( return PaddingValues(horizontal = horizontal, vertical = vertical) } + @Composable + internal fun iconTextSpacing(spacing: PrezelSpacing = PrezelTheme.spacing): Dp = + when (size) { + PrezelChipSize.REGULAR -> spacing.V4 + PrezelChipSize.SMALL -> spacing.V2 + } + internal fun iconSize(): Dp = when (size) { PrezelChipSize.SMALL -> 14.dp diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt index fc7313f..21ffbf3 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt @@ -23,13 +23,7 @@ private fun PrezelChip_CustomColors_Preview() { PrezelTheme { PreviewScaffold { CustomChipHeader() - - Spacer(modifier = Modifier.height(12.dp)) - CustomChipLabelSection() - - Spacer(modifier = Modifier.height(16.dp)) - CustomChipIconOnlySection() } } From 35c73cb0d92aa0a9aef3052738e885fae906b22b Mon Sep 17 00:00:00 2001 From: Ham BeomJoon Date: Tue, 27 Jan 2026 02:29:11 +0900 Subject: [PATCH 08/10] =?UTF-8?q?refactor:=20PrezelChip=20=EC=BB=A4?= =?UTF-8?q?=EC=8A=A4=ED=85=80=20=EC=83=89=EC=83=81=20=EC=A0=84=EB=8B=AC=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `PrezelChip`의 개별 색상 파라미터(`containerColor`, `contentColor`)를 `PrezelChipColors` 객체를 사용하는 `customColors` 파라미터로 통합했습니다. * `PrezelChip` 함수 시그니처 수정 및 `CompositionLocalProvider` 로직 변경 * `PrezelCustomChipPreview` 내 파라미터 호출부 수정 * 불필요한 import 제거 --- .../designsystem/component/chip/PrezelChip.kt | 9 ++--- .../component/chip/PrezelCustomChipPreview.kt | 36 ++++++++++++------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt index 4c0ccec..80582fb 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt @@ -16,7 +16,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import com.team.prezel.core.designsystem.icon.DrawableIcon import com.team.prezel.core.designsystem.icon.IconSource import com.team.prezel.core.designsystem.icon.PrezelIcons @@ -45,14 +44,10 @@ fun PrezelChip( text: String? = null, icon: IconSource? = null, style: PrezelChipStyle = PrezelChipStyle(), - containerColor: Color = Color.Unspecified, - contentColor: Color = Color.Unspecified, + customColors: PrezelChipColors = LocalPrezelChipColors.current, ) { CompositionLocalProvider( - LocalPrezelChipColors provides PrezelChipColors( - containerColor = containerColor, - contentColor = contentColor, - ), + LocalPrezelChipColors provides customColors, ) { PrezelChipImpl( modifier = modifier, diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt index 21ffbf3..5294f03 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelCustomChipPreview.kt @@ -78,8 +78,10 @@ private fun CustomYellowLabelChip() { interaction = PrezelChipInteraction.DISABLED, feedback = PrezelChipFeedback.BAD, ), - containerColor = PrezelTheme.colors.feedbackWarningSmall, - contentColor = PrezelTheme.colors.feedbackWarningRegular, + customColors = PrezelChipColors( + containerColor = PrezelTheme.colors.feedbackWarningSmall, + contentColor = PrezelTheme.colors.feedbackWarningRegular, + ), ) } @@ -94,8 +96,10 @@ private fun CustomRedLabelChip() { interaction = PrezelChipInteraction.DEFAULT, feedback = PrezelChipFeedback.DEFAULT, ), - containerColor = PrezelTheme.colors.feedbackBadSmall, - contentColor = PrezelTheme.colors.feedbackBadRegular, + customColors = PrezelChipColors( + containerColor = PrezelTheme.colors.feedbackBadSmall, + contentColor = PrezelTheme.colors.feedbackBadRegular, + ), ) } @@ -110,8 +114,10 @@ private fun CustomGreenLabelChip() { interaction = PrezelChipInteraction.ACTIVE, feedback = PrezelChipFeedback.DEFAULT, ), - containerColor = Color(0xFFDBFFF6), - contentColor = Color(0xFF00A37A), + customColors = PrezelChipColors( + containerColor = Color(0xFFDBFFF6), + contentColor = Color(0xFF00A37A), + ), ) } @@ -126,8 +132,10 @@ private fun CustomYellowIconChip() { interaction = PrezelChipInteraction.DISABLED, feedback = PrezelChipFeedback.BAD, ), - containerColor = PrezelTheme.colors.feedbackWarningSmall, - contentColor = PrezelTheme.colors.feedbackWarningRegular, + customColors = PrezelChipColors( + containerColor = PrezelTheme.colors.feedbackWarningSmall, + contentColor = PrezelTheme.colors.feedbackWarningRegular, + ), ) } @@ -142,8 +150,10 @@ private fun CustomRedIconChip() { interaction = PrezelChipInteraction.DEFAULT, feedback = PrezelChipFeedback.DEFAULT, ), - containerColor = PrezelTheme.colors.feedbackBadSmall, - contentColor = PrezelTheme.colors.feedbackBadRegular, + customColors = PrezelChipColors( + containerColor = PrezelTheme.colors.feedbackBadSmall, + contentColor = PrezelTheme.colors.feedbackBadRegular, + ), ) } @@ -158,7 +168,9 @@ private fun CustomGreenIconChip() { interaction = PrezelChipInteraction.ACTIVE, feedback = PrezelChipFeedback.DEFAULT, ), - containerColor = Color(0xFFDBFFF6), - contentColor = Color(0xFF00A37A), + customColors = PrezelChipColors( + containerColor = Color(0xFFDBFFF6), + contentColor = Color(0xFF00A37A), + ), ) } From b63daaa6e3277321cf8bd1b455f7fd96b3beb933 Mon Sep 17 00:00:00 2001 From: Ham BeomJoon Date: Tue, 27 Jan 2026 02:30:35 +0900 Subject: [PATCH 09/10] =?UTF-8?q?refactor:=20PrezelChip=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EA=B5=AC=EC=A1=B0=20=EB=8B=A8?= =?UTF-8?q?=EC=88=9C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 불필요한 `PrezelChipImpl` 내부 함수를 제거하고 `PrezelChip`으로 로직을 통합했습니다. * `CompositionLocalProvider`를 사용하는 오버로딩 함수가 통합된 `PrezelChip`을 호출하도록 수정했습니다. --- .../designsystem/component/chip/PrezelChip.kt | 55 +++++++------------ 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt index 80582fb..fe721ec 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChip.kt @@ -29,41 +29,6 @@ fun PrezelChip( text: String? = null, icon: IconSource? = null, style: PrezelChipStyle = PrezelChipStyle(), -) { - PrezelChipImpl( - modifier = modifier, - text = text, - icon = icon, - style = style, - ) -} - -@Composable -fun PrezelChip( - modifier: Modifier = Modifier, - text: String? = null, - icon: IconSource? = null, - style: PrezelChipStyle = PrezelChipStyle(), - customColors: PrezelChipColors = LocalPrezelChipColors.current, -) { - CompositionLocalProvider( - LocalPrezelChipColors provides customColors, - ) { - PrezelChipImpl( - modifier = modifier, - text = text, - icon = icon, - style = style, - ) - } -} - -@Composable -private fun PrezelChipImpl( - modifier: Modifier = Modifier, - text: String? = null, - icon: IconSource? = null, - style: PrezelChipStyle = PrezelChipStyle(), ) { val hasText = text != null val hasIcon = icon != null @@ -98,6 +63,26 @@ private fun PrezelChipImpl( } } +@Composable +fun PrezelChip( + modifier: Modifier = Modifier, + text: String? = null, + icon: IconSource? = null, + style: PrezelChipStyle = PrezelChipStyle(), + customColors: PrezelChipColors = LocalPrezelChipColors.current, +) { + CompositionLocalProvider( + LocalPrezelChipColors provides customColors, + ) { + PrezelChip( + modifier = modifier, + text = text, + icon = icon, + style = style, + ) + } +} + @Composable private fun PrezelChipIcon( icon: IconSource?, From 9103d4a11a6521abfd30b01569109f94c99de360 Mon Sep 17 00:00:00 2001 From: Ham BeomJoon Date: Tue, 27 Jan 2026 02:33:59 +0900 Subject: [PATCH 10/10] =?UTF-8?q?refactor:=20`PrezelChipStyle.kt`=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9C=84=EC=B9=98=20=EC=A1=B0=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `PrezelChipColors` 클래스와 `LocalPrezelChipColors` 변수의 선언 위치를 파일 상단으로 이동하여 코드 가독성을 개선했습니다. --- .../component/chip/PrezelChipStyle.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt index 9107c71..2629ca5 100644 --- a/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt +++ b/Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/chip/PrezelChipStyle.kt @@ -17,6 +17,8 @@ import com.team.prezel.core.designsystem.foundation.number.PrezelStroke import com.team.prezel.core.designsystem.foundation.typography.PrezelTypography import com.team.prezel.core.designsystem.theme.PrezelTheme +internal val LocalPrezelChipColors = staticCompositionLocalOf { PrezelChipColors() } + enum class PrezelChipType { FILLED, OUTLINED, @@ -38,6 +40,12 @@ enum class PrezelChipSize { REGULAR, } +@Immutable +data class PrezelChipColors( + val containerColor: Color = Color.Unspecified, + val contentColor: Color = Color.Unspecified, +) + @Immutable data class PrezelChipStyle( val type: PrezelChipType = PrezelChipType.FILLED, @@ -158,11 +166,3 @@ data class PrezelChipStyle( PrezelChipSize.REGULAR -> 16.dp } } - -@Immutable -data class PrezelChipColors( - val containerColor: Color = Color.Unspecified, - val contentColor: Color = Color.Unspecified, -) - -internal val LocalPrezelChipColors = staticCompositionLocalOf { PrezelChipColors() }