Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MFlisarWork committed Jan 15, 2025
1 parent 40e738d commit 6bed8ea
Showing 1 changed file with 1 addition and 64 deletions.
65 changes: 1 addition & 64 deletions documentation/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,4 @@
icon: material/keyboard
---

#### Basic examples

```kotlin
// create and remember a state
val state = rememberDialogState()

// Create a dialog composable
if (state.visible) {
DialogInfo(
state = state,
info = "Some "
)
}

// show the dialog inside a button press event or similar
Button(onClick = { state.show() }) {
Text("Show Dialog")
}
```

Alternatively you can hold any `saveable` state inside dialog state. If the dialog state holds any data, it will consider itself as visible.

```kotlin
// create and remember a state (e.g. selected list index as in this example)
val state = rememberDialogState<Int>(data = null)

// show a dialog if necessary
if (state.showing)
{
val data = state.requireData() // in this example the data is the list index
DialogInfo(
state = state,
info = "Data = $data"
)
}

// a list that uses the dialog
val items = 1..100
LazyColumn {
items.forEach {
item(key = it) {
Button(onClick = { state.show(it) }) {
Text("Item $it")
}
}
}
}
```

#### Dialog styling/customisation and events

All dialog (also custom ones) do support styling like:

* optional icon (including style like `CenterTop` and `Begin`)
* dialog style (dialog, bottom sheet, fullscreen)
* custom buttons (zero, one or two) with custom texts
* a options variable to set up features like `dismissOnButtonClick`, `dismissOnBackPress` and `dismissOnClickOutside`
* a event callback for the close event and button click event

Check out the advanced region on the side for more details.

#### Dialogs

Check out all the modules to find out more about the available implementations.
#### TODO

0 comments on commit 6bed8ea

Please sign in to comment.