-
Notifications
You must be signed in to change notification settings - Fork 1
PrezelList 구현 #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
PrezelList 구현 #72
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dd256ea
feat: 리스트 컴포넌트 스타일 정의 및 유틸리티 함수 추가
HamBeomJoon fc574d7
feat: PrezelList 공통 컴포넌트 추가
HamBeomJoon ee3fe36
refactor: PrezelList 컴포넌트 구조 개선 및 프리뷰 코드 분리
HamBeomJoon bd9f91b
Merge remote-tracking branch 'origin/develop' into feat/#71-prezel-list
HamBeomJoon 1eb1f10
refactor: PrezelList 컴포넌트 구조 개선 및 내부 로직 최적화
HamBeomJoon 3a98db6
refactor: PrezelList 컴포넌트의 Trailing Content 구조 개선
HamBeomJoon c1bbf76
refactor: PrezelList 컴포넌트 구조 개선 및 불필요한 파라미터 제거
HamBeomJoon 0f6da17
refactor: PrezelList 내부 로직 개선 및 프리뷰 코드 정리
HamBeomJoon 1c26a1e
Merge remote-tracking branch 'origin/develop' into feat/#71-prezel-list
HamBeomJoon 2797442
refactor: PrezelList 슬롯 구현 방식 개선 및 색상 적용
HamBeomJoon 27d9114
refactor: PrezelList 프리뷰 코드 구조 개선 및 스타일 정리
HamBeomJoon 910dfe7
refactor: PrezelList 컴포넌트의 콘텐츠 파라미터 타입 및 구현 방식 개선
HamBeomJoon e163a88
refactor: PrezelList의 CompositionLocalProvider 적용 범위 최적화
HamBeomJoon 28f2850
refactor: PrezelList 내 불필요한 CompositionLocalProvider 제거
HamBeomJoon 11a7f5a
refactor: PrezelList 텍스트 색상 설정 방식 수정
HamBeomJoon 0f87053
refactor: PrezelList 프리뷰 코드 구조 개선
HamBeomJoon 928a1da
feat: 점선 테두리(Dash Border) Modifier 구현
moondev03 13ec1f9
refactor: PrezelList 컴포넌트 구조 개선 및 Preview 코드 정리
moondev03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
157 changes: 157 additions & 0 deletions
157
...designsystem/src/main/java/com/team/prezel/core/designsystem/component/list/PrezelList.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| package com.team.prezel.core.designsystem.component.list | ||
|
|
||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.RowScope | ||
| import androidx.compose.foundation.layout.Spacer | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.width | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.LocalContentColor | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.unit.dp | ||
| import com.team.prezel.core.designsystem.icon.PrezelIcons | ||
| import com.team.prezel.core.designsystem.preview.PreviewScaffold | ||
| import com.team.prezel.core.designsystem.preview.SectionTitle | ||
| import com.team.prezel.core.designsystem.preview.ThemePreview | ||
| import com.team.prezel.core.designsystem.theme.PrezelTheme | ||
| import com.team.prezel.core.designsystem.util.drawDashBorder | ||
|
|
||
| @Composable | ||
| fun PrezelList( | ||
| title: String, | ||
| modifier: Modifier = Modifier, | ||
| size: PrezelListSize = PrezelListSize.REGULAR, | ||
| nested: Boolean = false, | ||
| leadingContent: @Composable (RowScope.() -> Unit)? = null, | ||
| trailingContent: @Composable (RowScope.() -> Unit)? = null, | ||
| ) { | ||
| Row( | ||
| modifier = modifier | ||
| .fillMaxWidth() | ||
| .padding(prezelListContentPadding(size, nested)), | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| ) { | ||
| leadingContent?.let { content -> | ||
| content() | ||
| Spacer(modifier = Modifier.width(prezelListIconTextSpacing(size))) | ||
| } | ||
|
|
||
| PrezelListTitle(title, size) | ||
|
|
||
| trailingContent?.let { content -> | ||
| Spacer(modifier = Modifier.width(prezelListTextTrailingSpacing(size))) | ||
|
|
||
| Row( | ||
| horizontalArrangement = Arrangement.spacedBy(prezelListTrailingIconSpacing(size)), | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| ) { | ||
| content() | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun RowScope.PrezelListTitle( | ||
| title: String, | ||
| size: PrezelListSize, | ||
| ) { | ||
| Text( | ||
| text = title, | ||
| modifier = Modifier.weight(1f), | ||
| maxLines = 1, | ||
| style = prezelListTextStyle(size), | ||
| color = LocalContentColor.current, | ||
| ) | ||
| } | ||
|
|
||
| @ThemePreview | ||
| @Composable | ||
| private fun PrezelListSmallPreview() { | ||
| PrezelTheme { | ||
| PreviewScaffold { | ||
| PrezelListPreviewBySize(PrezelListSize.SMALL) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @ThemePreview | ||
| @Composable | ||
| private fun PrezelListRegularPreview() { | ||
| PrezelTheme { | ||
| PreviewScaffold { | ||
| PrezelListPreviewBySize(PrezelListSize.REGULAR) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun PrezelListPreviewItem( | ||
| size: PrezelListSize, | ||
| nested: Boolean, | ||
| showLeadingContent: Boolean, | ||
| showTrailingContent: Boolean, | ||
| ) { | ||
| val leadingContent: @Composable RowScope.() -> Unit = { | ||
| Icon( | ||
| painter = painterResource(id = PrezelIcons.Blank), | ||
| contentDescription = "leading", | ||
| ) | ||
| } | ||
|
|
||
| val trailingContent: @Composable RowScope.() -> Unit = { | ||
| Icon( | ||
| painter = painterResource(id = PrezelIcons.Blank), | ||
| contentDescription = "trailing", | ||
| ) | ||
| Icon( | ||
| painter = painterResource(id = PrezelIcons.Blank), | ||
| contentDescription = "trailing", | ||
| ) | ||
| } | ||
|
|
||
| PrezelList( | ||
| title = "Title", | ||
| size = size, | ||
| nested = nested, | ||
| leadingContent = if (showLeadingContent) leadingContent else null, | ||
| trailingContent = if (showTrailingContent) trailingContent else null, | ||
| modifier = Modifier.drawDashBorder(), | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| private fun PrezelListPreviewBySize(size: PrezelListSize) { | ||
| SectionTitle(title = "PrezelList - $size") | ||
| Text( | ||
| text = "점선 테두리는 컴포넌트 경계를 의미하며,\nnested 상태별 leading/trailing 조합을 확인할 수 있습니다.", | ||
| style = PrezelTheme.typography.body3Regular, | ||
| color = PrezelTheme.colors.textMedium, | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .background(Color.LightGray.copy(alpha = 0.5f)) | ||
| .padding(8.dp), | ||
| ) | ||
|
|
||
| Text(text = "Nested: False", style = PrezelTheme.typography.body2Bold) | ||
| PrezelListPreviewItem(size, nested = false, showLeadingContent = true, showTrailingContent = true) | ||
| PrezelListPreviewItem(size, nested = false, showLeadingContent = true, showTrailingContent = false) | ||
| PrezelListPreviewItem(size, nested = false, showLeadingContent = false, showTrailingContent = true) | ||
| PrezelListPreviewItem(size, nested = false, showLeadingContent = false, showTrailingContent = false) | ||
|
|
||
| Spacer(modifier = Modifier.height(8.dp)) | ||
| Text(text = "Nested: True", style = PrezelTheme.typography.body2Bold) | ||
| PrezelListPreviewItem(size, nested = true, showLeadingContent = true, showTrailingContent = true) | ||
| PrezelListPreviewItem(size, nested = true, showLeadingContent = true, showTrailingContent = false) | ||
| PrezelListPreviewItem(size, nested = true, showLeadingContent = false, showTrailingContent = true) | ||
| PrezelListPreviewItem(size, nested = true, showLeadingContent = false, showTrailingContent = false) | ||
| } | ||
73 changes: 73 additions & 0 deletions
73
...nsystem/src/main/java/com/team/prezel/core/designsystem/component/list/PrezelListStyle.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package com.team.prezel.core.designsystem.component.list | ||
|
|
||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.Immutable | ||
| import androidx.compose.ui.text.TextStyle | ||
| import androidx.compose.ui.unit.Dp | ||
| import com.team.prezel.core.designsystem.foundation.number.PrezelSpacing | ||
| import com.team.prezel.core.designsystem.theme.PrezelTheme | ||
|
|
||
| @Immutable | ||
| enum class PrezelListSize { | ||
| SMALL, | ||
| REGULAR, | ||
| } | ||
|
|
||
| @Composable | ||
| internal fun prezelListContentPadding( | ||
| size: PrezelListSize, | ||
| nested: Boolean, | ||
| spacing: PrezelSpacing = PrezelTheme.spacing, | ||
| ): PaddingValues { | ||
| if (nested) { | ||
| return PaddingValues(spacing.V0) | ||
| } | ||
|
|
||
| val vertical = when (size) { | ||
| PrezelListSize.SMALL -> spacing.V10 | ||
| PrezelListSize.REGULAR -> spacing.V14 | ||
| } | ||
|
|
||
| return PaddingValues( | ||
| horizontal = spacing.V12, | ||
| vertical = vertical, | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| internal fun prezelListTextStyle(size: PrezelListSize): TextStyle = | ||
| when (size) { | ||
| PrezelListSize.SMALL -> PrezelTheme.typography.body3Medium | ||
| PrezelListSize.REGULAR -> PrezelTheme.typography.body2Medium | ||
| } | ||
|
|
||
| @Composable | ||
| internal fun prezelListIconTextSpacing( | ||
| size: PrezelListSize, | ||
| spacing: PrezelSpacing = PrezelTheme.spacing, | ||
| ): Dp = | ||
| when (size) { | ||
| PrezelListSize.SMALL -> spacing.V8 | ||
| PrezelListSize.REGULAR -> spacing.V12 | ||
| } | ||
|
|
||
| @Composable | ||
| internal fun prezelListTextTrailingSpacing( | ||
| size: PrezelListSize, | ||
| spacing: PrezelSpacing = PrezelTheme.spacing, | ||
| ): Dp = | ||
| when (size) { | ||
| PrezelListSize.SMALL -> spacing.V6 | ||
| PrezelListSize.REGULAR -> spacing.V12 | ||
| } | ||
|
|
||
| @Composable | ||
| internal fun prezelListTrailingIconSpacing( | ||
| size: PrezelListSize, | ||
| spacing: PrezelSpacing = PrezelTheme.spacing, | ||
| ): Dp = | ||
| when (size) { | ||
| PrezelListSize.SMALL -> spacing.V6 | ||
| PrezelListSize.REGULAR -> spacing.V8 | ||
| } |
44 changes: 44 additions & 0 deletions
44
.../core/designsystem/src/main/java/com/team/prezel/core/designsystem/util/DrowDashBorder.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.team.prezel.core.designsystem.util | ||
|
|
||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| 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.draw.drawBehind | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.graphics.PathEffect | ||
| import androidx.compose.ui.graphics.drawscope.Stroke | ||
| import androidx.compose.ui.unit.dp | ||
| import com.team.prezel.core.designsystem.preview.ThemePreview | ||
| import com.team.prezel.core.designsystem.theme.PrezelTheme | ||
|
|
||
| fun Modifier.drawDashBorder( | ||
| color: Color = Color.Gray, | ||
| width: Float = 1f, | ||
| interval: Float = 10f, | ||
| phase: Float = 0f, | ||
| ) = this.drawBehind { | ||
| drawRoundRect( | ||
| color = color, | ||
| style = Stroke( | ||
| width = width, | ||
| pathEffect = PathEffect.dashPathEffect(floatArrayOf(interval, interval), phase), | ||
| ), | ||
| ) | ||
| } | ||
|
|
||
| @ThemePreview | ||
| @Composable | ||
| private fun DrawDashBorderPreview() { | ||
| PrezelTheme { | ||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .height(100.dp) | ||
| .padding(12.dp) | ||
| .drawDashBorder(), | ||
| ) | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.