-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Chip 구현완료 * text 매개변수로 입력가능하게 변경 * 리뷰 반영 * modifier 추가 * text 기본값 제거 * 구현 Clickable Surface -> Box * toggle에 Modifier 추가
- Loading branch information
1 parent
01ab778
commit af144c4
Showing
3 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
compose/src/main/java/com/yourssu/design/system/compose/atom/Chip.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,100 @@ | ||
package com.yourssu.design.system.compose.atom | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
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.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.yourssu.design.system.compose.YdsTheme | ||
import com.yourssu.design.system.compose.base.YdsText | ||
|
||
@Composable | ||
fun Chip( | ||
modifier: Modifier = Modifier, | ||
text: String, | ||
isSelected: Boolean = false, | ||
isDisabled: Boolean = false, | ||
onSelectedChange: (Boolean) -> Unit, | ||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, | ||
) { | ||
val contentColor = if (isSelected) { | ||
YdsTheme.colors.textBright | ||
} else { | ||
YdsTheme.colors.textTertiary | ||
} | ||
|
||
val backgroundColor = if (isSelected) { | ||
YdsTheme.colors.buttonPoint | ||
} else { | ||
YdsTheme.colors.buttonDisabledBG | ||
} | ||
|
||
Box( | ||
modifier = modifier | ||
.height(24.dp) | ||
.clip(RoundedCornerShape(12.dp)) | ||
.background(backgroundColor) | ||
.clickable( | ||
interactionSource = interactionSource, | ||
indication = null, | ||
enabled = isDisabled.not(), | ||
onClick = { onSelectedChange(!isSelected) } | ||
), | ||
contentAlignment = Alignment.Center, | ||
) { | ||
YdsText( | ||
text = text, | ||
modifier = Modifier.padding(horizontal = 8.dp), | ||
color = contentColor, | ||
style = YdsTheme.typography.caption1 | ||
) | ||
} | ||
} | ||
|
||
|
||
@Preview(name = "Chip") | ||
@Composable | ||
private fun PreviewChip() { | ||
var checked1 by remember { mutableStateOf(true) } | ||
var checked2 by remember { mutableStateOf(false) } | ||
val onSelectedChange: (Boolean) -> Unit = { it -> checked1 = it } | ||
|
||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(YdsTheme.colors.bgNormal), | ||
verticalArrangement = Arrangement.Top, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Spacer(modifier = Modifier.height(8.dp)) | ||
Chip( | ||
text = "IT대학", | ||
isSelected = checked1, | ||
isDisabled = false, | ||
onSelectedChange = onSelectedChange | ||
) | ||
Spacer(modifier = Modifier.height(8.dp)) | ||
Chip( | ||
text = "IT대학", | ||
isSelected = checked2, | ||
isDisabled = true, | ||
onSelectedChange = onSelectedChange | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
versionName=2.3.0 | ||
versionName=2.3.1 | ||
#자동 배포를 위해서 버전은 여기 한 군데에서 관리하면 된다 |