Created
June 21, 2021 16:35
-
-
Save sergenes/2a0077c06fd9002a2f9ac5aeb6d0b61e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 HomeList( | |
editMode: Boolean, | |
items: SnapshotStateList<ListFile>, | |
clickItemHandler: (Int) -> Unit, | |
deleteItemHandler: (Int) -> Unit | |
) { | |
Column { | |
when (items.size) { | |
1 -> items.first().let { | |
HomeListItem( | |
it.fileName, it.created, RowType.SINGLE, editMode, | |
{ clickItemHandler(0) }, | |
{ deleteItemHandler(0) } | |
) | |
} | |
else -> { | |
items.forEachIndexed { index, data -> | |
val rowType = when (index) { | |
0 -> RowType.TOP | |
items.lastIndex -> RowType.BOTTOM | |
else -> RowType.MIDDLE | |
} | |
HomeListItem( | |
data.fileName, data.created, rowType, editMode, | |
{ clickItemHandler(index) }, | |
{ deleteItemHandler(index) } | |
) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment