-
Notifications
You must be signed in to change notification settings - Fork 1
PrezelRadio 구현 #44
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
Open
moondev03
wants to merge
6
commits into
develop
Choose a base branch
from
feat/#35-ds-prezelradio
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
PrezelRadio 구현 #44
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4bb7273
feat: PrezelRadio 컴포넌트 추가
moondev03 029a29e
style: Detekt `LongParameterList` 규칙 임계값 조정
moondev03 c2ded48
refactor: `PreviewScaffold` 구조를 Material3 Scaffold 기반으로 변경
moondev03 7e8b718
refactor: `PrezelRadio` 컴포넌트 내부 패딩 로직 수정
moondev03 8b76eb6
refactor: PrezelRadio 컴포넌트 구조 개선
moondev03 6f274eb
fix: PrezelRadio 미리보기 텍스트 수정
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
...ore/designsystem/src/main/java/com/team/prezel/core/designsystem/component/PrezelRadio.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 | ||
|
|
||
| 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.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.foundation.layout.width | ||
| import androidx.compose.foundation.selection.toggleable | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.material3.ripple | ||
| 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.draw.clip | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.semantics.Role | ||
| import androidx.compose.ui.text.TextStyle | ||
| import androidx.compose.ui.unit.Dp | ||
| 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 | ||
|
|
||
| /** | ||
| * 라디오 버튼의 크기 정의. | ||
| * | ||
| * @property value 라디오 버튼의 터치 영역 크기 | ||
| */ | ||
| enum class PrezelRadioSize( | ||
| val value: Dp, | ||
| ) { | ||
| REGULAR(40.dp), | ||
| LARGE(48.dp), | ||
| } | ||
|
|
||
| /** | ||
| * 아이콘만 표시되는 라디오 버튼. | ||
| * | ||
| * @param checked 현재 선택 여부 | ||
| * @param onCheckedChange 선택 상태 변경 콜백 | ||
| * @param size 라디오 버튼 크기 | ||
| */ | ||
| @Composable | ||
| fun PrezelRadio( | ||
| checked: Boolean, | ||
| onCheckedChange: (checked: Boolean) -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| size: PrezelRadioSize = PrezelRadioSize.REGULAR, | ||
| ) { | ||
| PrezelRadioIcon( | ||
| checked = checked, | ||
| size = size, | ||
| modifier = modifier | ||
| .toggleable( | ||
| value = checked, | ||
| onValueChange = onCheckedChange, | ||
| role = Role.RadioButton, | ||
| indication = null, | ||
| interactionSource = null, | ||
| ), | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * 텍스트와 함께 표시되는 라디오 버튼. | ||
| * | ||
| * @param text 라디오 버튼 라벨 텍스트 | ||
| * @param checked 현재 선택 여부 | ||
| * @param onCheckedChange 선택 상태 변경 콜백 | ||
| * @param size 라디오 버튼 크기 | ||
| */ | ||
| @Composable | ||
| fun PrezelRadio( | ||
| text: String, | ||
| checked: Boolean, | ||
| onCheckedChange: (checked: Boolean) -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| size: PrezelRadioSize = PrezelRadioSize.REGULAR, | ||
| textStyle: TextStyle = PrezelTheme.typography.body2Medium, | ||
| textColor: Color = PrezelTheme.colors.textLarge, | ||
| ) { | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| modifier = modifier | ||
| .fillMaxWidth() | ||
| .clip(PrezelTheme.shapes.V6) | ||
| .toggleable( | ||
| value = checked, | ||
| onValueChange = onCheckedChange, | ||
| role = Role.RadioButton, | ||
| indication = ripple(), | ||
| interactionSource = null, | ||
| ), | ||
| ) { | ||
| PrezelRadioIcon(checked = checked, size = size) | ||
| Spacer(modifier = Modifier.width(PrezelTheme.spacing.V4)) | ||
| Text(text = text, style = textStyle, color = textColor) | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun PrezelRadioIcon( | ||
| checked: Boolean, | ||
| modifier: Modifier = Modifier, | ||
| size: PrezelRadioSize = PrezelRadioSize.REGULAR, | ||
| ) { | ||
| val tintColor = if (checked) PrezelTheme.colors.interactiveRegular else PrezelTheme.colors.iconDisabled | ||
| val icon = if (checked) PrezelIcons.RadioCircleFilled else PrezelIcons.RadioCircleOutlined | ||
|
|
||
| Icon( | ||
| painter = painterResource(icon), | ||
| contentDescription = null, | ||
| tint = tintColor, | ||
| modifier = Modifier | ||
| .size(size.value) | ||
| .then(modifier) | ||
| .padding(PrezelTheme.spacing.V8), | ||
| ) | ||
| } | ||
|
|
||
| @ThemePreview | ||
| @Composable | ||
| private fun PrezelRadioPreview() { | ||
| var checked by remember { mutableStateOf(false) } | ||
|
|
||
| PrezelTheme { | ||
| PreviewScaffold { | ||
| SectionTitle("PrezelRadioSize.REGULAR") | ||
| Text("Checked: true") | ||
| PrezelRadio(checked = true, onCheckedChange = {}, size = PrezelRadioSize.REGULAR) | ||
| Text("Checked: false") | ||
| PrezelRadio(checked = false, onCheckedChange = {}, size = PrezelRadioSize.REGULAR) | ||
| Text("PrezelRadio with text") | ||
| PrezelRadio(checked = checked, onCheckedChange = { checked = it }, text = "텍스트", size = PrezelRadioSize.REGULAR) | ||
|
|
||
| Spacer(modifier = Modifier.height(20.dp)) | ||
|
|
||
| SectionTitle("PrezelRadioSize.LARGE") | ||
| Text("Checked: true") | ||
| PrezelRadio(checked = true, onCheckedChange = {}, size = PrezelRadioSize.LARGE) | ||
| Text("Checked: false") | ||
| PrezelRadio(checked = false, onCheckedChange = {}, size = PrezelRadioSize.LARGE) | ||
| Text("PrezelRadio with text") | ||
| PrezelRadio(checked = checked, onCheckedChange = { checked = it }, text = "텍스트", size = PrezelRadioSize.LARGE) | ||
| } | ||
| } | ||
| } | ||
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
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.