From 4c94b0dc63b60376d5ee35cbf890cf02ef5b77e9 Mon Sep 17 00:00:00 2001 From: Noah Bond Date: Tue, 1 Nov 2022 10:16:34 -0700 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/27485 - Add optional overrides for the colors in `Button` Composables --- .../mozilla/fenix/compose/button/Button.kt | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/compose/button/Button.kt b/app/src/main/java/org/mozilla/fenix/compose/button/Button.kt index 22c4a5255..d344fb681 100644 --- a/app/src/main/java/org/mozilla/fenix/compose/button/Button.kt +++ b/app/src/main/java/org/mozilla/fenix/compose/button/Button.kt @@ -38,7 +38,7 @@ import org.mozilla.fenix.theme.Theme * @param onClick Invoked when the user clicks on the button. */ @Composable -fun Button( +private fun Button( text: String, textColor: Color, backgroundColor: Color, @@ -79,19 +79,23 @@ fun Button( * Primary button. * * @param text The button text to be displayed. + * @param textColor [Color] to apply to the button text. + * @param backgroundColor The background [Color] of the button. * @param icon Optional [Painter] used to display an [Icon] before the button text. * @param onClick Invoked when the user clicks on the button. */ @Composable fun PrimaryButton( text: String, + textColor: Color = FirefoxTheme.colors.textActionPrimary, + backgroundColor: Color = FirefoxTheme.colors.actionPrimary, icon: Painter? = null, onClick: () -> Unit, ) { Button( text = text, - textColor = FirefoxTheme.colors.textActionPrimary, - backgroundColor = FirefoxTheme.colors.actionPrimary, + textColor = textColor, + backgroundColor = backgroundColor, icon = icon, tint = FirefoxTheme.colors.iconActionPrimary, onClick = onClick, @@ -129,19 +133,23 @@ fun SecondaryButton( * Tertiary button. * * @param text The button text to be displayed. + * @param textColor [Color] to apply to the button text. + * @param backgroundColor The background [Color] of the button. * @param icon Optional [Painter] used to display an [Icon] before the button text. * @param onClick Invoked when the user clicks on the button. */ @Composable fun TertiaryButton( text: String, + textColor: Color = FirefoxTheme.colors.textActionTertiary, + backgroundColor: Color = FirefoxTheme.colors.actionTertiary, icon: Painter? = null, onClick: () -> Unit, ) { Button( text = text, - textColor = FirefoxTheme.colors.textActionTertiary, - backgroundColor = FirefoxTheme.colors.actionTertiary, + textColor = textColor, + backgroundColor = backgroundColor, icon = icon, tint = FirefoxTheme.colors.iconActionTertiary, onClick = onClick, @@ -152,19 +160,23 @@ fun TertiaryButton( * Destructive button. * * @param text The button text to be displayed. + * @param textColor [Color] to apply to the button text. + * @param backgroundColor The background [Color] of the button. * @param icon Optional [Painter] used to display an [Icon] before the button text. * @param onClick Invoked when the user clicks on the button. */ @Composable fun DestructiveButton( text: String, + textColor: Color = FirefoxTheme.colors.textWarningButton, + backgroundColor: Color = FirefoxTheme.colors.actionSecondary, icon: Painter? = null, onClick: () -> Unit, ) { Button( text = text, - textColor = FirefoxTheme.colors.textWarningButton, - backgroundColor = FirefoxTheme.colors.actionSecondary, + textColor = textColor, + backgroundColor = backgroundColor, icon = icon, tint = FirefoxTheme.colors.iconWarningButton, onClick = onClick,