Skip to content

Commit

Permalink
Update dialog-list.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MFlisar authored Oct 24, 2024
1 parent 50ff476 commit e557188
Showing 1 changed file with 2 additions and 50 deletions.
52 changes: 2 additions & 50 deletions readmes/dialog-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,8 @@ This shows a dialog with a list of items. Rendering, selection mode and more is

Here you can create a dialog based on static list data like following:

```kotlin
fun <T> DialogList(
state: DialogState,
// Custom - Required
items: List<T>,
itemIdProvider: (item: T) -> Int,
itemContents: DialogList.ItemContents<T>,
selectionMode: DialogList.SelectionMode<T>,
// Custom - Optional
divider: Boolean = false,
description: String = "",
filter: DialogList.Filter<T>? = null,
// Base Dialog - Optional
title: String? = null,
icon: (@Composable () -> Unit)? = null,
style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(),
buttons: DialogButtons = DialogDefaults.buttons(),
options: Options = Options(),
specialOptions: SpecialOptions = DialogDefaults.specialOptions(),
onEvent: (event: DialogEvent) -> Unit = {}
)
```
https://github.com/MFlisar/ComposeDialogs/blob/50ff476087bfe675cb85a609bb8d1eebe72f0bca/library/modules/list/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/list/DialogList.kt#L64-L83

But you can also create list with an asynchronous loader function like following:

```kotlin
fun <T> DialogList(
state: DialogState,
// Custom - Required
itemsLoader: suspend () -> List<T>,
itemIdProvider: (item: T) -> Int,
itemContents: DialogList.ItemContents<T>,
selectionMode: DialogList.SelectionMode<T>,
// Custom - Optional
itemSaver: Saver<MutableState<List<T>>, out Any>? = null,
loadingIndicator: @Composable () -> Unit = {
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
CircularProgressIndicator()
}
},
divider: Boolean = false,
description: String = "",
filter: DialogList.Filter<T>? = null,
// Base Dialog - Optional
title: String? = null,
icon: (@Composable () -> Unit)? = null,
style: ComposeDialogStyle = DialogDefaults.defaultDialogStyle(),
buttons: DialogButtons = DialogDefaults.buttons(),
options: Options = Options(),
specialOptions: SpecialOptions = DialogDefaults.specialOptions(),
onEvent: (event: DialogEvent) -> Unit = {}
)
```
https://github.com/MFlisar/ComposeDialogs/blob/50ff476087bfe675cb85a609bb8d1eebe72f0bca/library/modules/list/src/commonMain/kotlin/com/michaelflisar/composedialogs/dialogs/list/DialogList.kt#L123-L148

0 comments on commit e557188

Please sign in to comment.