From 61151e8571477f1d2866b5b9de15bc4e58f172c2 Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Tue, 25 Apr 2023 22:34:13 +0200 Subject: [PATCH] Fixed icon color in compact secondary button --- .../jetpackduba/gitnuro/ui/UncommitedChanges.kt | 4 +--- .../gitnuro/ui/components/SecondaryButton.kt | 14 +++++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/UncommitedChanges.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/UncommitedChanges.kt index 0bf8846..058c719 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/UncommitedChanges.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/UncommitedChanges.kt @@ -8,7 +8,6 @@ import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background -import androidx.compose.foundation.focusable import androidx.compose.foundation.hoverable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.collectIsHoveredAsState @@ -25,7 +24,6 @@ import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.focus.FocusRequester -import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape import androidx.compose.ui.input.key.onPreviewKeyEvent @@ -652,7 +650,7 @@ private fun EntriesList( icon = actionIcon, isParentHovered = isHeaderHovered, backgroundButton = actionColor, - textColor = actionTextColor, + onBackgroundColor = actionTextColor, onClick = onAllAction, modifier = Modifier.padding(start = 4.dp, end = 16.dp), ) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/SecondaryButton.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/SecondaryButton.kt index e7d614e..63a8e48 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/SecondaryButton.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/components/SecondaryButton.kt @@ -55,7 +55,7 @@ fun SecondaryButtonCompactable( modifier: Modifier = Modifier, icon: String, text: String, - textColor: Color = MaterialTheme.colors.onPrimary, + onBackgroundColor: Color = MaterialTheme.colors.onPrimary, backgroundButton: Color, maxLines: Int = 1, isParentHovered: Boolean, @@ -74,23 +74,27 @@ fun SecondaryButtonCompactable( } val targetBackground: Color + val iconColor: Color val iconPadding: Float if (isExpanded) { targetBackground = backgroundButton + iconColor = onBackgroundColor iconPadding = 12f } else { targetBackground = MaterialTheme.colors.tertiarySurface + iconColor = MaterialTheme.colors.onBackground iconPadding = 0f } - val color by animateColorAsState(targetBackground) + val backgroundColorState by animateColorAsState(targetBackground) + val iconColorState by animateColorAsState(iconColor) val iconPaddingState by animateFloatAsState(iconPadding) Row( modifier = modifier .clip(RoundedCornerShape(4.dp)) - .background(color) + .background(backgroundColorState) .hoverable(hoverInteraction) .handMouseClickable { onClick() } .padding(horizontal = 4.dp), @@ -99,7 +103,7 @@ fun SecondaryButtonCompactable( Icon( painterResource(icon), contentDescription = null, - tint = MaterialTheme.colors.onBackground, + tint = iconColorState, modifier = Modifier .padding(start = iconPaddingState.dp, end = 8.dp) .size(18.dp) @@ -111,7 +115,7 @@ fun SecondaryButtonCompactable( Text( text = text, style = MaterialTheme.typography.body2, - color = textColor, + color = onBackgroundColor, maxLines = maxLines, modifier = Modifier.padding(top = 4.dp, bottom = 4.dp, end = 12.dp) )