Created
June 21, 2021 16:36
-
-
Save sergenes/7ee58007bc7269dab4bed4b21c587aa2 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 HomeListLazy( | |
| editMode: Boolean, | |
| itemsSource: SnapshotStateList<ListFile>, | |
| clickItemHandler: (Int) -> Unit, | |
| deleteItemHandler: (Int) -> Unit | |
| ) { | |
| LazyColumn { | |
| when (itemsSource.size) { | |
| 1 -> itemsSource.first().let { | |
| item { | |
| HomeListItem( | |
| it.fileName, it.created, RowType.SINGLE, editMode, | |
| { clickItemHandler(0) }, | |
| { deleteItemHandler(0) } | |
| ) | |
| } | |
| } | |
| else -> { | |
| itemsIndexed(itemsSource) { index, item -> | |
| val rowType = when (index) { | |
| 0 -> RowType.TOP | |
| itemsSource.lastIndex -> RowType.BOTTOM | |
| else -> RowType.MIDDLE | |
| } | |
| HomeListItem( | |
| item.fileName, item.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