Fixed icon color in compact secondary button
This commit is contained in:
parent
35d7b23913
commit
61151e8571
@ -8,7 +8,6 @@ import androidx.compose.animation.fadeIn
|
|||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.focusable
|
|
||||||
import androidx.compose.foundation.hoverable
|
import androidx.compose.foundation.hoverable
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.interaction.collectIsHoveredAsState
|
import androidx.compose.foundation.interaction.collectIsHoveredAsState
|
||||||
@ -25,7 +24,6 @@ import androidx.compose.ui.ExperimentalComposeUiApi
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
import androidx.compose.ui.focus.focusRequester
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.input.key.onPreviewKeyEvent
|
import androidx.compose.ui.input.key.onPreviewKeyEvent
|
||||||
@ -652,7 +650,7 @@ private fun EntriesList(
|
|||||||
icon = actionIcon,
|
icon = actionIcon,
|
||||||
isParentHovered = isHeaderHovered,
|
isParentHovered = isHeaderHovered,
|
||||||
backgroundButton = actionColor,
|
backgroundButton = actionColor,
|
||||||
textColor = actionTextColor,
|
onBackgroundColor = actionTextColor,
|
||||||
onClick = onAllAction,
|
onClick = onAllAction,
|
||||||
modifier = Modifier.padding(start = 4.dp, end = 16.dp),
|
modifier = Modifier.padding(start = 4.dp, end = 16.dp),
|
||||||
)
|
)
|
||||||
|
@ -55,7 +55,7 @@ fun SecondaryButtonCompactable(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
icon: String,
|
icon: String,
|
||||||
text: String,
|
text: String,
|
||||||
textColor: Color = MaterialTheme.colors.onPrimary,
|
onBackgroundColor: Color = MaterialTheme.colors.onPrimary,
|
||||||
backgroundButton: Color,
|
backgroundButton: Color,
|
||||||
maxLines: Int = 1,
|
maxLines: Int = 1,
|
||||||
isParentHovered: Boolean,
|
isParentHovered: Boolean,
|
||||||
@ -74,23 +74,27 @@ fun SecondaryButtonCompactable(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val targetBackground: Color
|
val targetBackground: Color
|
||||||
|
val iconColor: Color
|
||||||
val iconPadding: Float
|
val iconPadding: Float
|
||||||
|
|
||||||
if (isExpanded) {
|
if (isExpanded) {
|
||||||
targetBackground = backgroundButton
|
targetBackground = backgroundButton
|
||||||
|
iconColor = onBackgroundColor
|
||||||
iconPadding = 12f
|
iconPadding = 12f
|
||||||
} else {
|
} else {
|
||||||
targetBackground = MaterialTheme.colors.tertiarySurface
|
targetBackground = MaterialTheme.colors.tertiarySurface
|
||||||
|
iconColor = MaterialTheme.colors.onBackground
|
||||||
iconPadding = 0f
|
iconPadding = 0f
|
||||||
}
|
}
|
||||||
|
|
||||||
val color by animateColorAsState(targetBackground)
|
val backgroundColorState by animateColorAsState(targetBackground)
|
||||||
|
val iconColorState by animateColorAsState(iconColor)
|
||||||
val iconPaddingState by animateFloatAsState(iconPadding)
|
val iconPaddingState by animateFloatAsState(iconPadding)
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.clip(RoundedCornerShape(4.dp))
|
.clip(RoundedCornerShape(4.dp))
|
||||||
.background(color)
|
.background(backgroundColorState)
|
||||||
.hoverable(hoverInteraction)
|
.hoverable(hoverInteraction)
|
||||||
.handMouseClickable { onClick() }
|
.handMouseClickable { onClick() }
|
||||||
.padding(horizontal = 4.dp),
|
.padding(horizontal = 4.dp),
|
||||||
@ -99,7 +103,7 @@ fun SecondaryButtonCompactable(
|
|||||||
Icon(
|
Icon(
|
||||||
painterResource(icon),
|
painterResource(icon),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
tint = MaterialTheme.colors.onBackground,
|
tint = iconColorState,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(start = iconPaddingState.dp, end = 8.dp)
|
.padding(start = iconPaddingState.dp, end = 8.dp)
|
||||||
.size(18.dp)
|
.size(18.dp)
|
||||||
@ -111,7 +115,7 @@ fun SecondaryButtonCompactable(
|
|||||||
Text(
|
Text(
|
||||||
text = text,
|
text = text,
|
||||||
style = MaterialTheme.typography.body2,
|
style = MaterialTheme.typography.body2,
|
||||||
color = textColor,
|
color = onBackgroundColor,
|
||||||
maxLines = maxLines,
|
maxLines = maxLines,
|
||||||
modifier = Modifier.padding(top = 4.dp, bottom = 4.dp, end = 12.dp)
|
modifier = Modifier.padding(top = 4.dp, bottom = 4.dp, end = 12.dp)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user