Skip to content

Commit

Permalink
Passing textbutton to control color of buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
NelzkieLabs committed Nov 20, 2022
1 parent dc8280b commit 8cc2151
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.ButtonColors
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextButton
Expand Down Expand Up @@ -125,6 +127,7 @@ class MaterialDialogButtons(private val scope: MaterialDialogScope) {
text: String? = null,
textStyle: TextStyle = MaterialTheme.typography.button,
@StringRes res: Int? = null,
colors: ButtonColors = ButtonDefaults.textButtonColors(),
onClick: () -> Unit = {}
) {
val buttonText = getString(res, text).uppercase(Locale.ROOT)
Expand All @@ -134,7 +137,8 @@ class MaterialDialogButtons(private val scope: MaterialDialogScope) {
},
modifier = Modifier
.layoutId(MaterialDialogButtonTypes.Text)
.testTag(MaterialDialogButtonTypes.Text.testTag)
.testTag(MaterialDialogButtonTypes.Text.testTag),
colors = colors
) {
Text(text = buttonText, style = textStyle)
}
Expand All @@ -154,6 +158,7 @@ class MaterialDialogButtons(private val scope: MaterialDialogScope) {
text: String? = null,
textStyle: TextStyle = MaterialTheme.typography.button,
@StringRes res: Int? = null,
colors: ButtonColors = ButtonDefaults.textButtonColors(),
disableDismiss: Boolean = false,
onClick: () -> Unit = {}
) {
Expand All @@ -175,7 +180,8 @@ class MaterialDialogButtons(private val scope: MaterialDialogScope) {
},
modifier = Modifier.layoutId(MaterialDialogButtonTypes.Positive)
.testTag(MaterialDialogButtonTypes.Positive.testTag),
enabled = buttonEnabled
enabled = buttonEnabled,
colors = colors
) {
Text(text = buttonText, style = textStyle)
}
Expand All @@ -194,6 +200,7 @@ class MaterialDialogButtons(private val scope: MaterialDialogScope) {
text: String? = null,
textStyle: TextStyle = MaterialTheme.typography.button,
@StringRes res: Int? = null,
colors: ButtonColors = ButtonDefaults.textButtonColors(),
onClick: () -> Unit = {}
) {
val buttonText = getString(res, text).uppercase(Locale.ROOT)
Expand All @@ -207,7 +214,8 @@ class MaterialDialogButtons(private val scope: MaterialDialogScope) {
onClick()
},
modifier = Modifier.layoutId(MaterialDialogButtonTypes.Negative)
.testTag(MaterialDialogButtonTypes.Negative.testTag)
.testTag(MaterialDialogButtonTypes.Negative.testTag),
colors = colors
) {
Text(text = buttonText, style = textStyle)
}
Expand Down

0 comments on commit 8cc2151

Please sign in to comment.