Skip to content

Instantly share code, notes, and snippets.

@cicerohellmann
Created May 11, 2021 10:58
Show Gist options
  • Save cicerohellmann/809f5f687838a334b4236f5ef0363594 to your computer and use it in GitHub Desktop.
Save cicerohellmann/809f5f687838a334b4236f5ef0363594 to your computer and use it in GitHub Desktop.
A simple selectable
@Composable
fun SelectableItem(
modifier: Modifier = Modifier,
text: String,
selected: Boolean = false,
onClick: (() -> Unit)? = null,
) {
Button(
onClick = { onClick?.invoke() },
modifier = modifier
.fillMaxWidth(),
elevation = ButtonDefaults.elevation(Elevation),
border = if (selected) BorderStroke(SelectableItemBorderStroke, AppColor.SelectableItemBorder) else null,
colors = ButtonDefaults.buttonColors(backgroundColor = AppColor.SelectableItemBackground),
) {
Text(
modifier = Modifier.padding(gu1),
text = text,
style = SelectiableItem(),
fontStyle = null,
fontWeight = null,
fontFamily = null,
textDecoration = null,
textAlign = TextAlign.Center,
overflow = TextOverflow.Ellipsis,
softWrap = true,
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment