Created
June 27, 2022 16:51
-
-
Save aqua30/eed091807bbb3a2abe61fe7b674eb8eb to your computer and use it in GitHub Desktop.
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
@Composable | |
fun ListItem( | |
item: AppItem, | |
background: Color, | |
onItemClick: (Int) -> Unit | |
) { | |
Row( | |
modifier = Modifier | |
.fillMaxWidth() | |
.height(60.dp) | |
.background(background) | |
.clickable { | |
onItemClick(item.id) | |
}, | |
horizontalArrangement = Arrangement.Start, | |
verticalAlignment = Alignment.CenterVertically, | |
) { | |
Text( | |
modifier = Modifier.weight(1f).padding(horizontal = 16.dp), | |
text = item.text, | |
style = TextStyle( | |
fontSize = 20.sp, | |
fontWeight = FontWeight.SemiBold | |
) | |
) | |
Box( | |
modifier = Modifier.size(60.dp), | |
contentAlignment = Alignment.Center | |
) { | |
/** show indicator only for loading state */ | |
if (item.taskStatus == TaskStatus.IN_PROGRESS) | |
CircularProgressIndicator( | |
modifier = Modifier.size(30.dp), | |
strokeWidth = 3.dp, | |
color = Color.Magenta, | |
) | |
else | |
Icon( | |
if (item.taskStatus == TaskStatus.NOT_STARTED) | |
Icons.Default.PlayArrow | |
else Icons.Default.Check, | |
"action icon", | |
tint = if (item.taskStatus == TaskStatus.NOT_STARTED) | |
Color.Gray | |
else | |
Color.Blue, | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment