-
Notifications
You must be signed in to change notification settings - Fork 0
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
Single select button 구현 방식에 대한 생각 #7
Labels
help wanted
Extra attention is needed
Comments
가독성이 얼마나 차이가 날까 Group 컴포넌트가 없는 경우 var selectedItem: String? by remember { mutableStateOf(null) }
val items = listOf("radio 1", "radio 2", "radio 3")
LaunchedEffect(selectedItem) {
println(selectedItem)
}
Column {
items.forEach { item ->
RadioButton(
label = item,
selected = (selectedItem == item),
onClick = { selectedItem = item }
)
}
} Group 컴포넌트가 있는 경우 val radioState = rememberSingleSelectButtonState()
val items = listOf("radio 1", "radio 2", "radio 3")
LaunchedEffect(radioState.selectedItem) {
println(radioState.selectedItem)
}
RadioGroup(state = radioState) {
items.forEach { item ->
RadioButton(label = item, radioId = item) // 선택된 버튼의 radioId가 selectedItem으로 지정됨
}
} 음.. 크게 차이나지 않는 것 같긴 하다 우선 Group 컴포넌트는 만들지 않고, 이후에 필요하면 추가하는 것으로 해야 할 것 같음 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Single select button이란
RadioGroup
,ChipGroup
처럼 group 컴포넌트를 제공하여 같은 그룹 내에서의 컴포넌트에 대해 정해진 효과를 부여하는 방식이 있음name
끼리를 그룹으로 취급하는 방식도 있을 것 같음.group 컴포넌트를 제공하지 않고 직접 구현하도록 두는 방식
(기존 compose material의 방식과 동일)
group 컴포넌트를 제공하는 방식
The text was updated successfully, but these errors were encountered: