Skip to content

Commit

Permalink
Update documentation and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
PranavMaganti committed Sep 10, 2021
1 parent 3589706 commit b0b866d
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 51 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

### 0.6.0 - 2021-09-10

- [BREAKING CHANGE] Replace MaterialDialog class structure with composable function with state. See [docs](https://vanpra.github.io/compose-material-dialogs) and the [sample app](https://github.com/vanpra/compose-material-dialogs/tree/main/app/src/main/java/com/vanpra/composematerialdialogdemos/demos) for examples
- Update compose to 1.1.0-alpha03
- Update kotlin to 1.5.30
- Fix bug which caused the year picker to fill the whole dialog

### 0.5.1 - 2021-07-29

- Update compose to 1.0.0
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:core:0.5.1"
implementation "io.github.vanpra.compose-material-dialogs:core:0.6.0"
...
}
```
Expand All @@ -35,7 +35,7 @@ dependencies {
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:datetime:0.5.1"
implementation "io.github.vanpra.compose-material-dialogs:datetime:0.6.0"
...
}
```
Expand All @@ -51,7 +51,7 @@ dependencies {
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:color:0.5.1"
implementation "io.github.vanpra.compose-material-dialogs:color:0.6.0"
...
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import kotlin.math.min
import java.util.concurrent.atomic.AtomicInteger
import kotlin.math.min

/**
* Interface defining values and functions which are available to any code
Expand Down
11 changes: 5 additions & 6 deletions docs/ColorPicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
Here is an example of how to add a color picker to a dialog:

``` kotlin
val dialog = remember { MaterialDialog() }

dialog.build {
val dialogState = rememberMaterialDialogState()
MaterialDialog(dialogState = dialogState) {
...
colorPicker(colors = ColorPalette.Primary)
...
}

/* This should be called in an onClick or an Effect */
dialog.show()
dialogState.show()
```

`ColorPalette.Primary` is a predefined list of colors and can be replaced with a list of custom colors.
Expand All @@ -26,7 +25,7 @@ dialog.show()
Here is an example of how to add a color picker with sub colors to a dialog:

``` kotlin
dialog.build {
MaterialDialog(dialogState = dialogState) {
...
colorPicker(colors = ColorPalette.Primary, subColors = ColorPalette.PrimarySub)
...
Expand All @@ -40,7 +39,7 @@ The `subColors` parameter is passed in a list of list of colors which are show t
Here is an example of how to add a color picker with custom argb selector to a dialog:

``` kotlin
dialog.build {
MaterialDialog(dialogState = dialogState) {
...
colorPicker(colors = ColorPalette.Primary, allowCustomArgb = true)
...
Expand Down
47 changes: 19 additions & 28 deletions docs/Core.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
Here is an example to make a basic dialog with a title and text:

```kotlin
val dialog = remember { MaterialDialog() }

dialog.build {
val dialogState = rememberMaterialDialogState()
MaterialDialog(dialogState = dialogState) {
title(text = "Use Location Services?")
message(res = R.string.location_dialog_message)
}
Expand All @@ -20,26 +19,16 @@ dialog.show()

The dialog is shown when the `dialog.show()` is called. The hard coded strings for all the components in the example above can be replaced with a string resource id.

If the `autoDismiss` parameter of a `MaterialDialog` is set to false then the dialog will not close when the positive or negative buttons are clicked, allowing for flexibility in custom views.

The `MaterialDialog` class also has a `onCancelRequest` parameter which is a callback which is used when the user clicks outside the dialog area. By default this parameter is set to hide the dialog.

Buttons can be added to the dialog by adding the `buttons` parameter:

```kotlin
dialog.build(buttons = {
positiveButton("Ok", onClick = {
//Do Something
})

button("Later", onClick = {
//Do Something
})

negativeButton("Cancel", onClick = {
//Do Something
})
}) {
MaterialDialog(
dialogState = dialogState,
buttons = {
positiveButton("Ok")
negativeButton("Cancel")
}
) {
...
}
```
Expand All @@ -51,7 +40,7 @@ If the text of the buttons is too long to fit in one row the buttons will be aut
<img src="https://raw.githubusercontent.com/vanpra/compose-material-dialogs/main/imgs/input.jpg" width="300" height="600" />

```kotlin
dialog.build(buttons = { ... }) {
MaterialDialog(dialogState = dialogState, buttons = { ... }) {
...
input(label = "Name", hint = "Jon Smith") { inputString ->
/* Do something */
Expand All @@ -69,7 +58,7 @@ In the code snippet above creates the dialog seen in the image (without the titl
Below is an example of a plain list dialog:

```kotlin
dialog.build {
MaterialDialog(dialogState = dialogState) {
...
listItems(listOf("Item 1", "Item 2", "Item 3"), onClick { index, item ->
//Do Something
Expand All @@ -88,7 +77,9 @@ val items = listOf(
TextIcon("Item 3", imageFromResource(R.drawable.item_three))
)

dialog.build {
...

MaterialDialog(dialogState = dialogState) {
...
listItems(items, onClick { index, item ->
//Do Something
Expand All @@ -109,7 +100,7 @@ dialog.build {
![](https://raw.githubusercontent.com/vanpra/compose-material-dialogs/main/imgs/single_selection.png)

```kotlin
dialog.build {
MaterialDialog(dialogState = dialogState, buttons = { ... }) {
listItemsSingleChoice(
list = listOf("Item 1", "Item 2", "Item 3"),
disabledIndices = listOf(1),
Expand All @@ -127,7 +118,7 @@ As seen in the code snippet above you can pass in a list of indices of items whi
![](https://raw.githubusercontent.com/vanpra/compose-material-dialogs/main/imgs/multi_selection.png)

```kotlin
dialog.build {
MaterialDialog(dialogState = dialogState, buttons = { ... }) {
listItemsSingleChoice(
list = listOf("Item 1", "Item 2", "Item 3"),
disabledIndices = listOf(1),
Expand All @@ -143,7 +134,7 @@ As seen in the code snippet above you can select which items will be disabled (i
### Custom View

```kotlin
dialog.build {
MaterialDialog(dialogState = dialogState, buttons = { ... }) {
customView {
//Define your view here
}
Expand All @@ -157,10 +148,10 @@ The custom view provides a box with the appropriate material design padding's a
The background colour of the dialog can be changed by using the `backgroundColor` parameter of the build function:

```kotlin
dialog.build(backgroundColor = Color.Red) {
MaterialDialog(dialogState = dialogState, buttons = { ... }, backgroundColor = Color.Red) {
title(text = "Use Location Services?")
message(res = R.string.location_dialog_message)
}
```

The shape of the dialog is dictated by the `MaterialTheme.shapes.medium` parameter.
The shape of the dialog is defaulted to the `MaterialTheme.shapes.medium` property but can also be set using the `shape` parameter in `MaterialDialog` .
25 changes: 16 additions & 9 deletions docs/DateTimePicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ Note, this only has to be done if you intend to target an Android API level < 26
![](https://raw.githubusercontent.com/vanpra/compose-material-dialogs/main/imgs/date.png)

```kotlin
val dialog = remember { MaterialDialog() }
dialog.build(buttons = {
positiveButton("Ok")
negativeButton("Cancel")
}) {
val dialogState = rememberMaterialDialogState()
MaterialDialog(
dialogState = dialogState,
buttons = {
positiveButton("Ok")
negativeButton("Cancel")
}
) {
...
datepicker { date ->
// Do stuff with java.time.LocalDate object which is passed in
Expand All @@ -53,10 +56,14 @@ dialog.show()
![](https://raw.githubusercontent.com/vanpra/compose-material-dialogs/main/imgs/time.png)

```kotlin
dialog.build(buttons = {
positiveButton("Ok")
negativeButton("Cancel")
}) {
val dialogState = rememberMaterialDialogState()
MaterialDialog(
dialogState = dialogState,
buttons = {
positiveButton("Ok")
negativeButton("Cancel")
}
) {
...
timepicker { time ->
// Do stuff with java.time.LocalTime object which is passed in
Expand Down
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:core:0.5.1"
implementation "io.github.vanpra.compose-material-dialogs:core:0.5.2"
...
}
```
Expand All @@ -27,7 +27,7 @@ dependencies {
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:datetime:0.5.1"
implementation "io.github.vanpra.compose-material-dialogs:datetime:0.5.2"
...
}
```
Expand All @@ -43,7 +43,7 @@ dependencies {
```gradle
dependencies {
...
implementation "io.github.vanpra.compose-material-dialogs:color:0.5.1"
implementation "io.github.vanpra.compose-material-dialogs:color:0.5.2"
...
}
```
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android.enableJetifier=false
kotlin.code.style=official

GROUP=io.github.vanpra.compose-material-dialogs
VERSION_NAME=0.5.2
VERSION_NAME=0.6.0

POM_DESCRIPTION=A Material Dialog Builder for Jetpack Compose
POM_INCEPTION_YEAR=2020
Expand Down

0 comments on commit b0b866d

Please sign in to comment.