Orhan Tozan
02/20/2021, 1:23 PMShakil Karim
02/20/2021, 1:42 PMzoha131
02/20/2021, 1:48 PMSe7eN
02/20/2021, 1:54 PMdarkmoon_uk
02/20/2021, 2:33 PMAdam Powell
02/20/2021, 3:36 PMAdam Powell
02/20/2021, 3:40 PMAdam Powell
02/20/2021, 3:41 PMAdam Powell
02/20/2021, 3:43 PMAdam Powell
02/20/2021, 3:44 PMAdam Powell
02/20/2021, 3:46 PMAdam Powell
02/20/2021, 3:49 PMAdam Powell
02/20/2021, 3:50 PMAdam Powell
02/20/2021, 3:52 PMShakil Karim
02/20/2021, 3:59 PM@Composable
fun TeamItem(club: Club,
selectedClubs: List<Club> = emptyList(),
onItemClicked: (Club) -> Unit) {
val isSelected = selectedClubs.contains(club)
val color: Color by animateColorAsState(
if (isSelected) MaterialTheme.colors.primary else MaterialTheme.colors.onBackground
)
val transition = updateTransition(
targetState = if (isSelected) SelectionState.Selected else SelectionState.Unselected
)
val selectedAlpha by transition.animateFloat { state ->
when (state) {
SelectionState.Unselected -> 0f
SelectionState.Selected -> 1f
}
}
val checkScale by transition.animateFloat { state ->
when (state) {
SelectionState.Unselected -> 0f
SelectionState.Selected -> 1f
}
}
Column(horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.padding(Padding8dp)
.clickable(onClick = {
club.isSelected.value = !club.isSelected.value
onItemClicked(club)
})
) {
Box {
Image(
painterResource(id = club.teamLogoDrawable),
contentScale = ContentScale.Fit,
modifier = Modifier.preferredSize(80.dp),
contentDescription = null
)
Surface(
color = MaterialTheme.colors.primary,
shape = CircleShape,
elevation = 4.dp,
modifier = Modifier.size(25.dp)
.align(Alignment.CenterEnd)
.offset(x = 5.dp)
.scale(checkScale)
) {
Icon(
imageVector = Icons.Filled.Done,
contentDescription = null,
tint = MaterialTheme.colors.onPrimary.copy(alpha = selectedAlpha),
modifier = Modifier.padding(4.dp)
)
}
}
VerticleSpace(Padding4dp)
Text(
text = club.name,
maxLines = 2,
style = facrNormal16BodyText().copy(color = color)
)
}
}
Shakil Karim
02/20/2021, 4:00 PMLazyVerticalGrid(
modifier = Modifier.fillMaxSize(),
cells = GridCells.Fixed(column),
// contentPadding = PaddingValues(top = Constants.Padding8dp)
) {
itemsGridIndexed(items) { _, item ->
item?.let {
itemContent(it)
}
}
}
Adam Powell
02/20/2021, 4:05 PMAdam Powell
02/20/2021, 4:23 PMShakil Karim
02/20/2021, 4:36 PMAdam Powell
02/20/2021, 4:38 PM