-
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
[UI/#57] 색상 팔레트 #58
Changes from 3 commits
fab26cf
2778b76
363c9ed
4d08fca
d13c019
4103230
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.terning.core.designsystem.component.item | ||
|
||
import android.util.Log | ||
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.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.Check | ||
import androidx.compose.material3.Icon | ||
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.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
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:() -> 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 -> | ||
Log.d("CalendarScreen","color: ${colorList.indexOf(color)}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 로그있음도! |
||
}, | ||
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) { | ||
Icon( | ||
imageVector = Icons.Outlined.Check, | ||
tint = Color.White, | ||
contentDescription = "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Icons.Outlined.Check 지우고 피그마에 있는 아이콘으로 바꿔주세욤! |
||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun ColorPalettePreview() { | ||
ColorPalette() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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 | ||
//.padding(horizontal = 42.dp) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기 주석처리는 오 ㅐ하신건가여? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 실수임다! |
||
) { | ||
items(options) { option -> | ||
buttonComposable( | ||
option, | ||
(selectedOption == option), | ||
) { | ||
selectedOption = option | ||
onOptionSelected(option) | ||
} | ||
} | ||
} | ||
} | ||
|
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.
이건 나중에 아린이가 다이얼로그 만들 때 유동적으로 수정하면 될 거 같아요!