Skip to content

Commit

Permalink
Merge pull request #83 from marcauberer/master
Browse files Browse the repository at this point in the history
Add getButton function
  • Loading branch information
javiersantos authored May 16, 2020
2 parents 268c35c + 7e5764c commit 7414b6d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ And add the library to your module **build.gradle**:

```gradle
dependencies {
implementation 'com.github.javiersantos:MaterialStyledDialogs:3.0'
implementation 'com.github.javiersantos:MaterialStyledDialogs:3.0.1'
}
```

Expand Down Expand Up @@ -381,6 +381,18 @@ new MaterialStyledDialog.Builder(this)

</details><br>

### Get the buttons of the dialog
If you need to access the buttons of your dialog, you can achieve it like this:
```kotlin
val dialog = MaterialStyledDialog.Builder(this)
.setTitle("Awesome!")
.setDescription("This is a sample description.")
.show()

dialog.positiveButton().text = "Positive"
dialog.negativeButton().text = "Negative"
```

## License
Copyright 2016-2020 Javier Santos

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.github.javiersantos.materialstyleddialogs.demo"
minSdkVersion 16
targetSdkVersion 29
versionCode 300
versionName "3.0.0"
versionCode 301
versionName "3.0.1"
}
buildTypes {
release {
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 300
versionName "3.0.0"
versionCode 301
versionName "3.0.1"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import androidx.appcompat.widget.AppCompatImageView
import androidx.core.content.res.ResourcesCompat
import com.afollestad.materialdialogs.DialogCallback
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.WhichButton
import com.afollestad.materialdialogs.actions.getActionButton
import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.internal.button.DialogActionButton
import com.github.javiersantos.materialstyleddialogs.UtilsAnimation.startAnimation
import com.github.javiersantos.materialstyleddialogs.UtilsLibrary.dpToPixels
import com.github.javiersantos.materialstyleddialogs.UtilsLibrary.getColor
Expand Down Expand Up @@ -167,6 +170,11 @@ class MaterialStyledDialog(
return contentView
}

fun positiveButton() = builder.dialog?.getActionButton(WhichButton.POSITIVE)
fun negativeButton() = builder.dialog?.getActionButton(WhichButton.NEGATIVE)
@Deprecated("Neutral button is deprecated in the parent library: https://github.com/afollestad/material-dialogs")
fun neutralButton() = builder.dialog?.getActionButton(WhichButton.NEUTRAL)

class Builder(var context: Context) : IBuilder {

var dialog: MaterialDialog? = null
Expand Down

0 comments on commit 7414b6d

Please sign in to comment.