-
Notifications
You must be signed in to change notification settings - Fork 1
PrezelCheckbox 구현 #39
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5a67f73
feat: PrezelCheckbox 컴포넌트 추가
HamBeomJoon 3f3b7b2
Merge remote-tracking branch 'origin/develop' into feat/#31-prezel-ch…
HamBeomJoon 506ad56
feat: PrezelCheckbox 컴포넌트 리팩터링 및 기능 개선
HamBeomJoon 29c858c
feat: 디자인시스템 리소스 네이밍 규칙 적용 및 하드코딩된 문자열 추출
HamBeomJoon 1352d28
feat: PrezelCheckbox contentDescription 필수 파라미터 추가 및 접근성 개선
HamBeomJoon 36c1c1b
refactor: PrezelCheckbox 클릭 로직 개선
HamBeomJoon 0f38df6
feat: PrezelCheckbox 터치 영역 확장 및 아이콘 참조 방식 변경
HamBeomJoon 00299d5
feat: PrezelCheckbox 터치 영역 확장 및 아이콘 참조 방식 변경
HamBeomJoon 02c8d55
feat: PrezelCheckbox 내 contentDescription 제거 및 내부 리소스로 대체
HamBeomJoon 46d9e50
refactor: PrezelCheckbox 내 불필요한 상수 제거
HamBeomJoon 40f9eb9
refactor: PrezelCheckbox 내 interactionSource를 null로 변경
HamBeomJoon 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
156 changes: 156 additions & 0 deletions
156
.../designsystem/src/main/java/com/team/prezel/core/designsystem/component/PrezelCheckbox.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,156 @@ | ||
| package com.team.prezel.core.designsystem.component | ||
|
|
||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.RowScope | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.foundation.selection.toggleable | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.semantics.Role | ||
| import androidx.compose.ui.unit.dp | ||
| import com.team.prezel.core.designsystem.R | ||
| import com.team.prezel.core.designsystem.foundation.typography.PrezelTextStyles | ||
| import com.team.prezel.core.designsystem.icon.PrezelIcons | ||
| import com.team.prezel.core.designsystem.preview.ThemePreview | ||
| import com.team.prezel.core.designsystem.theme.PrezelTheme | ||
|
|
||
| enum class CheckboxSize { | ||
| REGULAR, | ||
| LARGE, | ||
| } | ||
|
|
||
| @Composable | ||
| fun PrezelCheckbox( | ||
| checked: Boolean, | ||
| modifier: Modifier = Modifier, | ||
| size: CheckboxSize = CheckboxSize.REGULAR, | ||
| onCheckedChange: (Boolean) -> Unit, | ||
| ) { | ||
| val checkboxSize = when (size) { | ||
| CheckboxSize.REGULAR -> 24.dp | ||
| CheckboxSize.LARGE -> 32.dp | ||
| } | ||
|
|
||
| val iconRes = | ||
| if (checked) { | ||
| PrezelIcons.CheckCircleFilled | ||
| } else { | ||
| PrezelIcons.CheckCircleOutlined | ||
| } | ||
|
|
||
| val iconColor = | ||
| if (checked) { | ||
| PrezelTheme.colors.interactiveRegular | ||
| } else { | ||
| PrezelTheme.colors.iconDisabled | ||
| } | ||
|
|
||
| Box( | ||
HamBeomJoon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| modifier = modifier | ||
| .size(48.dp) | ||
| .toggleable( | ||
| value = checked, | ||
| interactionSource = null, | ||
| indication = null, | ||
| role = Role.Checkbox, | ||
| onValueChange = onCheckedChange, | ||
| ), | ||
| contentAlignment = Alignment.Center, | ||
| ) { | ||
| Icon( | ||
| painter = painterResource(id = iconRes), | ||
| contentDescription = stringResource(R.string.core_designsystem_checkbox_desc), | ||
| modifier = Modifier.size(checkboxSize), | ||
| tint = iconColor, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @ThemePreview | ||
| @Composable | ||
| private fun PrezelRegularCheckboxPreview() { | ||
| PrezelTheme { | ||
| Column( | ||
| modifier = Modifier | ||
| .background(PrezelTheme.colors.bgRegular) | ||
| .padding(16.dp), | ||
| ) { | ||
| CheckboxRowPreview(title = "Regular Checkbox") { | ||
| var checkState by remember { mutableStateOf(true) } | ||
|
|
||
| PrezelCheckbox( | ||
| size = CheckboxSize.REGULAR, | ||
| checked = checkState, | ||
| onCheckedChange = { checkState = it }, | ||
| ) | ||
|
|
||
| PrezelCheckbox( | ||
| size = CheckboxSize.REGULAR, | ||
| checked = !checkState, | ||
| onCheckedChange = { checkState = it }, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @ThemePreview | ||
| @Composable | ||
| private fun PrezelLargeCheckboxPreview() { | ||
| PrezelTheme { | ||
| Column( | ||
| modifier = Modifier | ||
| .background(PrezelTheme.colors.bgRegular) | ||
| .padding(16.dp), | ||
| ) { | ||
| CheckboxRowPreview(title = "Large Checkbox") { | ||
| var checkState by remember { mutableStateOf(true) } | ||
|
|
||
| PrezelCheckbox( | ||
| size = CheckboxSize.LARGE, | ||
| checked = checkState, | ||
| onCheckedChange = { checkState = it }, | ||
| ) | ||
|
|
||
| PrezelCheckbox( | ||
| size = CheckboxSize.LARGE, | ||
| checked = !checkState, | ||
| onCheckedChange = { checkState = it }, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun CheckboxRowPreview( | ||
| title: String, | ||
| content: @Composable RowScope.() -> Unit, | ||
| ) { | ||
| Column(modifier = Modifier.padding(bottom = 16.dp)) { | ||
| Text( | ||
| text = title, | ||
| style = PrezelTextStyles.Caption2Regular.toTextStyle(), | ||
| color = PrezelTheme.colors.textLarge, | ||
| modifier = Modifier.padding(bottom = 4.dp), | ||
| ) | ||
| Row( | ||
| horizontalArrangement = Arrangement.spacedBy(8.dp), | ||
| content = content, | ||
| ) | ||
| } | ||
| } | ||
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
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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
| <string name="close_floating_btn_content_desc">플로팅 버튼 닫기</string> | ||
| <string name="core_designsystem_close_floating_btn_content_desc">플로팅 버튼 닫기</string> | ||
| <string name="core_designsystem_checkbox_desc">체크박스</string> | ||
HamBeomJoon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </resources> | ||
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.