-
Notifications
You must be signed in to change notification settings - Fork 1
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
[UI/#57] 색상 팔레트 #58
Merged
+154
−2
Merged
[UI/#57] 색상 팔레트 #58
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fab26cf
[UI/#57] 라디오버튼 그룹 컴포넌트 구현
boiledEgg-s 2778b76
[UI/#57] 컬러 팔레트 구현
boiledEgg-s 363c9ed
[MOD/#57] 컬러 팔레트 코드 수정
boiledEgg-s 4d08fca
[REFACTOR/#57] 리뷰 기반 코드 수정
boiledEgg-s d13c019
[CHORE/#57] 색상 코드 수정
boiledEgg-s 4103230
[REFACTOR/#57] 임포트 정리
boiledEgg-s 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
98 changes: 98 additions & 0 deletions
98
core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt
This file contains 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,98 @@ | ||
package com.terning.core.designsystem.component.item | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
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.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.terning.core.R | ||
import com.terning.core.designsystem.theme.CalBlue1 | ||
import com.terning.core.designsystem.theme.CalBlue2 | ||
import com.terning.core.designsystem.theme.CalGreen1 | ||
import com.terning.core.designsystem.theme.CalGreen2 | ||
import com.terning.core.designsystem.theme.CalOrange1 | ||
import com.terning.core.designsystem.theme.CalOrange2 | ||
import com.terning.core.designsystem.theme.CalPink | ||
import com.terning.core.designsystem.theme.CalPurple | ||
import com.terning.core.designsystem.theme.CalRed | ||
import com.terning.core.designsystem.theme.CalYellow | ||
import com.terning.core.extension.noRippleClickable | ||
|
||
@Composable | ||
fun ColorPalette( | ||
modifier: Modifier = Modifier, | ||
onColorSelected:(Color) -> Unit = {} | ||
) { | ||
val colorList = listOf( | ||
CalRed, | ||
CalOrange2, | ||
CalGreen1, | ||
CalBlue1, | ||
CalPurple, | ||
CalOrange1, | ||
CalYellow, | ||
CalGreen2, | ||
CalBlue2, | ||
CalPink | ||
) | ||
|
||
RadioButtonGroups( | ||
modifier = modifier.size(251.dp, 84.dp), | ||
options = colorList, | ||
gridCellCount = 5, | ||
onOptionSelected = { color -> | ||
onColorSelected(color) | ||
}, | ||
buttonComposable = { | ||
color, isSelected, onOptionSelected -> | ||
ColorButton( | ||
color = color, | ||
isSelected = isSelected, | ||
onColorSelected = onOptionSelected) | ||
}, | ||
verticalArrangementSpace = 6.dp, | ||
horizontalArrangementSpace = 14.dp, | ||
) | ||
} | ||
|
||
@Composable | ||
internal fun ColorButton( | ||
modifier: Modifier = Modifier, | ||
color: Color, | ||
isSelected: Boolean, | ||
onColorSelected: (Color) -> Unit | ||
) { | ||
Box(modifier = modifier.size(39.dp)) { | ||
Box( | ||
modifier = Modifier | ||
.size(39.dp) | ||
.background(shape = CircleShape, color = color) | ||
.noRippleClickable { | ||
onColorSelected(color) | ||
}, | ||
contentAlignment = Alignment.Center | ||
) { | ||
if (isSelected) { | ||
Image( | ||
painter = painterResource(id = R.drawable.ic_color_check), | ||
contentDescription = "" | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun ColorPalettePreview() { | ||
ColorPalette() | ||
} | ||
|
45 changes: 45 additions & 0 deletions
45
core/src/main/java/com/terning/core/designsystem/component/item/RadioButtonGroups.kt
This file contains 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,45 @@ | ||
package com.terning.core.designsystem.component.item | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.lazy.grid.GridCells | ||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
import androidx.compose.foundation.lazy.grid.items | ||
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.Modifier | ||
import androidx.compose.ui.unit.Dp | ||
|
||
@Composable | ||
fun <T> RadioButtonGroups( | ||
options: List<T>, | ||
buttonComposable: @Composable (T, Boolean, (T) -> Unit) -> Unit, | ||
gridCellCount: Int, | ||
verticalArrangementSpace: Dp, | ||
horizontalArrangementSpace: Dp, | ||
modifier: Modifier = Modifier, | ||
onOptionSelected: (T) -> Unit = {}, | ||
|
||
) { | ||
var selectedOption by remember { mutableStateOf(options[0]) } | ||
|
||
LazyVerticalGrid( | ||
columns = GridCells.Fixed(gridCellCount), | ||
verticalArrangement = Arrangement.spacedBy(verticalArrangementSpace), | ||
horizontalArrangement = Arrangement.spacedBy(horizontalArrangementSpace), | ||
modifier = modifier | ||
) { | ||
items(options) { option -> | ||
buttonComposable( | ||
option, | ||
(selectedOption == option), | ||
) { | ||
selectedOption = option | ||
onOptionSelected(option) | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains 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 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,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="16dp" | ||
android:height="13dp" | ||
android:viewportWidth="16" | ||
android:viewportHeight="13"> | ||
<path | ||
android:pathData="M14.698,0.197C14.448,0.247 14.202,0.381 14.049,0.608L7.196,10.743C6.994,11.041 6.732,11.046 6.475,10.793L2.671,7.047C2.282,6.665 1.63,6.667 1.239,7.052C0.849,7.437 0.846,8.079 1.235,8.461L5.039,12.208C6.184,13.334 7.94,13.155 8.845,11.821L15.734,1.711C16.04,1.258 15.913,0.627 15.457,0.326C15.228,0.176 14.949,0.147 14.698,0.197Z" | ||
android:fillColor="#ffffff"/> | ||
</vector> |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
named argument!! 해주세용
그리구 251은,,어디서 쓰이는 걸까여,,,?!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 나중에 아린이가 다이얼로그 만들 때 유동적으로 수정하면 될 거 같아요!