diff --git a/designsystem/src/main/java/com/apeun/gidaechi/designsystem/component/Dropdown.kt b/designsystem/src/main/java/com/apeun/gidaechi/designsystem/component/Dropdown.kt index 2170d30e..f2cebafe 100644 --- a/designsystem/src/main/java/com/apeun/gidaechi/designsystem/component/Dropdown.kt +++ b/designsystem/src/main/java/com/apeun/gidaechi/designsystem/component/Dropdown.kt @@ -1,7 +1,5 @@ package com.apeun.gidaechi.designsystem.component -import android.graphics.ColorMatrix -import android.util.Log import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable @@ -10,7 +8,6 @@ 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.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width @@ -26,9 +23,9 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.setValue 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 @@ -37,7 +34,6 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.times -import com.apeun.gidaechi.designsystem.component.modifier.DropShadowType import com.apeun.gidaechi.designsystem.theme.Black import com.apeun.gidaechi.designsystem.theme.Gray200 import com.apeun.gidaechi.designsystem.theme.Gray300 @@ -49,20 +45,14 @@ import com.apeun.gidaechi.designsystem.theme.White sealed class DropDownType( val textColor: Color, val backgroundColor: Color, - val iconColor: Color -){ + val iconColor: Color, +) { data object Disabled : DropDownType(Gray400, Gray200, Gray400) data object Typing : DropDownType(Black, Gray300, Gray500) - } @Composable -fun SeugiDropDown( - item: List, - title: String, - type: DropDownType -) { - +fun SeugiDropDown(item: List, title: String, type: DropDownType) { var isExpanded by remember { mutableStateOf(false) } @@ -78,19 +68,18 @@ fun SeugiDropDown( Icons.Filled.KeyboardArrowDown } - - val clickableModifier = if (type != DropDownType.Disabled){ + val clickableModifier = if (type != DropDownType.Disabled) { Modifier.clickable { isExpanded = !isExpanded } - }else{ + } else { Modifier } - SeugiTheme { - Column(modifier = Modifier - .padding(20.dp) - .clip(RoundedCornerShape(12.dp)) - .then(clickableModifier) + Column( + modifier = Modifier + .padding(20.dp) + .clip(RoundedCornerShape(12.dp)) + .then(clickableModifier), ) { Box( modifier = Modifier @@ -99,20 +88,20 @@ fun SeugiDropDown( .border(1.dp, type.backgroundColor, RoundedCornerShape(12.dp)) .background(White, RoundedCornerShape(12.dp)) .clip(RoundedCornerShape(12.dp)) - .padding(horizontal = 16.dp, vertical = 12.dp) + .padding(horizontal = 16.dp, vertical = 12.dp), ) { Text( text = selectedItem, modifier = Modifier.align(Alignment.CenterStart), style = MaterialTheme.typography.titleMedium, - color = if (selectedItem == title) Gray500 else Black + color = if (selectedItem == title) Gray500 else Black, ) Icon( imageVector = icon, contentDescription = null, modifier = Modifier.align(Alignment.CenterEnd), - tint = type.iconColor + tint = type.iconColor, ) } @@ -123,11 +112,9 @@ fun SeugiDropDown( .width(300.dp) .align(Alignment.CenterHorizontally) .height(calculateDropdownHeight(item.size)) - .background(White) - , - scrollState = scrollState + .background(White), + scrollState = scrollState, ) { - item.forEach { label -> DropdownMenuItem( onClick = { @@ -135,15 +122,15 @@ fun SeugiDropDown( isExpanded = false }, text = { - Text(text = label, + Text( + text = label, style = MaterialTheme.typography.titleMedium, - color = type.textColor) - }, - modifier = Modifier.background(White) + color = type.textColor, + ) + }, + modifier = Modifier.background(White), ) } - - } } } @@ -158,27 +145,22 @@ fun calculateDropdownHeight(itemCount: Int): Dp { return calculatedHeight } - @Composable @Preview(showBackground = true) fun PreviewSeugiDropdown() { - val dummyList = listOf("1", "2","1", "2","1", "2","1", "2","1", "2","1", "2") + val dummyList = listOf("1", "2", "1", "2", "1", "2", "1", "2", "1", "2", "1", "2") SeugiTheme { - Column( modifier = Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center + verticalArrangement = Arrangement.Center, ) { - - SeugiDropDown(dummyList, "비밀번호 선택", DropDownType.Disabled) Spacer(modifier = Modifier.padding(horizontal = 20.dp)) SeugiDropDown(dummyList, "비밀번호 선택", DropDownType.Typing) - } } -} \ No newline at end of file +}