Compare commits

..

1 Commits

Author SHA1 Message Date
Kingkor Roy Tirtho
ee708329d4
Merge dadc302ef0 into 80626ba4b5 2026-07-05 13:27:56 +00:00
8 changed files with 130 additions and 94 deletions

View File

@ -269,7 +269,21 @@ fun <T> AutocompleteTextField(
BorderStroke(resolvedBorder.width, resolvedBorder.color),
fieldState.shape
)
.highlight(fieldState.highlight)
.drawWithCache {
val highlightBrush = Brush.verticalGradient(
colors = listOf(fieldState.highlight, Color.Transparent),
startY = 0f,
endY = size.height * 0.5f,
)
onDrawWithContent {
drawContent()
drawRect(
brush = highlightBrush,
topLeft = androidx.compose.ui.geometry.Offset.Zero,
size = size,
)
}
}
.padding(resolvedTextFieldTheme.padding),
) {
Row(

View File

@ -89,29 +89,9 @@ private fun resolveButtonState(
isHovered: Boolean,
): ResolvedButtonState {
return when {
isPressed -> ResolvedButtonState(
style.colors.pressed,
style.shape.pressed,
style.shadow.pressed,
style.border.pressed,
style.padding.pressed
)
isHovered -> ResolvedButtonState(
style.colors.hovered,
style.shape.hovered,
style.shadow.hovered,
style.border.hovered,
style.padding.hovered
)
else -> ResolvedButtonState(
style.colors.focused,
style.shape.focused,
style.shadow.focused,
style.border.focused,
style.padding.focused
)
isPressed -> ResolvedButtonState(style.colors.pressed, style.shape.pressed, style.shadow.pressed, style.border.pressed, style.padding.pressed)
isHovered -> ResolvedButtonState(style.colors.hovered, style.shape.hovered, style.shadow.hovered, style.border.hovered, style.padding.hovered)
else -> ResolvedButtonState(style.colors.focused, style.shape.focused, style.shadow.focused, style.border.focused, style.padding.focused)
}
}
@ -154,17 +134,11 @@ fun OutlineButton(
.hoverable(interactionSource = interactionSource, enabled = enabled)
.graphicsLayer { translationY = lift.toPx() }
.then(
if (hoverOnly && !isHovered) Modifier else Modifier.applyShadow(
state.shadow,
state.shape
)
if (hoverOnly && !isHovered) Modifier else Modifier.applyShadow(state.shadow, state.shape)
)
.clip(state.shape)
.then(
if (hoverOnly && !isHovered) Modifier else Modifier.background(
state.colors.background,
state.shape
)
if (hoverOnly && !isHovered) Modifier else Modifier.background(state.colors.background, state.shape)
.border(BorderStroke(state.border.width, state.border.color), state.shape)
)
.clickable(
@ -173,7 +147,21 @@ fun OutlineButton(
indication = ripple(),
onClick = onClick,
)
.then(if (hoverOnly && !isHovered) Modifier else Modifier.highlight(state.colors.highlight))
.then(if (hoverOnly && !isHovered) Modifier else Modifier.drawWithCache {
val highlightBrush = Brush.verticalGradient(
colors = listOf(state.colors.highlight, Color.Transparent),
startY = 0f,
endY = size.height * 0.5f,
)
onDrawWithContent {
drawContent()
drawRect(
brush = highlightBrush,
topLeft = androidx.compose.ui.geometry.Offset.Zero,
size = size,
)
}
})
.padding(state.padding),
contentAlignment = Alignment.Center,
) {
@ -220,7 +208,21 @@ fun PrimaryButton(
indication = ripple(),
onClick = onClick,
)
.highlight(state.colors.highlight)
.drawWithCache {
val highlightBrush = Brush.verticalGradient(
colors = listOf(state.colors.highlight, Color.Transparent),
startY = 0f,
endY = size.height * 0.5f,
)
onDrawWithContent {
drawContent()
drawRect(
brush = highlightBrush,
topLeft = androidx.compose.ui.geometry.Offset.Zero,
size = size,
)
}
}
.padding(state.padding),
contentAlignment = Alignment.Center,
) {
@ -265,7 +267,21 @@ fun SecondaryButton(
indication = ripple(),
onClick = onClick,
)
.highlight(state.colors.highlight)
.drawWithCache {
val highlightBrush = Brush.verticalGradient(
colors = listOf(state.colors.highlight, Color.Transparent),
startY = 0f,
endY = size.height * 0.5f,
)
onDrawWithContent {
drawContent()
drawRect(
brush = highlightBrush,
topLeft = androidx.compose.ui.geometry.Offset.Zero,
size = size,
)
}
}
.padding(state.padding),
contentAlignment = Alignment.Center,
) {

View File

@ -145,7 +145,21 @@ fun CheckBox(
.clip(resolved.shape)
.background(resolved.colors.background, resolved.shape)
.border(BorderStroke(0.5.dp, borderColor), resolved.shape)
.highlight(resolved.colors.highlight)
.drawWithCache {
val highlightBrush = Brush.verticalGradient(
colors = listOf(resolved.colors.highlight, Color.Transparent),
startY = 0f,
endY = size.height * 0.5f,
)
onDrawWithContent {
drawContent()
drawRect(
brush = highlightBrush,
topLeft = Offset.Zero,
size = size,
)
}
}
.then(
if (onClick != null) {
Modifier

View File

@ -121,7 +121,21 @@ fun ChipTab(
indication = ripple(),
onClick = onClick,
)
.highlight(state.colors.highlight)
.drawWithCache {
val highlightBrush = Brush.verticalGradient(
colors = listOf(state.colors.highlight, Color.Transparent),
startY = 0f,
endY = size.height * 0.5f,
)
onDrawWithContent {
drawContent()
drawRect(
brush = highlightBrush,
topLeft = androidx.compose.ui.geometry.Offset.Zero,
size = size,
)
}
}
.padding(state.padding),
contentAlignment = Alignment.Center,
) {

View File

@ -152,7 +152,21 @@ fun TextField(
.clip(state.shape)
.background(state.background, state.shape)
.border(BorderStroke(resolvedBorder.width, resolvedBorder.color), state.shape)
.highlight(state.highlight)
.drawWithCache {
val highlightBrush = Brush.verticalGradient(
colors = listOf(state.highlight, Color.Transparent),
startY = 0f,
endY = size.height * 0.5f,
)
onDrawWithContent {
drawContent()
drawRect(
brush = highlightBrush,
topLeft = androidx.compose.ui.geometry.Offset.Zero,
size = size,
)
}
}
.padding(textFieldTheme.padding),
) {
Row(

View File

@ -23,8 +23,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
@ -653,30 +651,15 @@ fun rememberBaseUITheme(): BaseUITheme {
shape = RoundedCornerShape(16.dp),
border = BaseUITheme.Border(border, 0.5.dp),
padding = PaddingValues(0.dp),
shadow = BaseUITheme.Shadow(
6.dp,
true,
shadowColor.copy(alpha = 0.15f),
shadowColor.copy(alpha = 0.18f)
),
shadow = BaseUITheme.Shadow(6.dp, true, shadowColor.copy(alpha = 0.15f), shadowColor.copy(alpha = 0.18f)),
),
listRowTile = BaseUITheme.ListRowTheme(
background = BaseUITheme.AdvancedInteractionState(
hovered = Brush.verticalGradient(listOf(containerLighter, containerDarker)),
pressed = Brush.verticalGradient(listOf(containerPressed, containerPressed)),
focused = Brush.verticalGradient(listOf(containerLighter, containerDarker)),
selected = Brush.verticalGradient(
listOf(
scheme.primaryContainer.copy(alpha = 0.3f),
scheme.primaryContainer.copy(alpha = 0.3f)
)
),
disabled = Brush.verticalGradient(
listOf(
containerLighter.copy(alpha = 0.5f),
containerDarker.copy(alpha = 0.5f)
)
),
selected = Brush.verticalGradient(listOf(scheme.primaryContainer.copy(alpha = 0.3f), scheme.primaryContainer.copy(alpha = 0.3f))),
disabled = Brush.verticalGradient(listOf(containerLighter.copy(alpha = 0.5f), containerDarker.copy(alpha = 0.5f))),
),
shape = BaseUITheme.AdvancedInteractionState(
hovered = RoundedCornerShape(8.dp),
@ -747,12 +730,7 @@ fun invertedButtonStyle(): BaseUITheme.ButtonStyle {
highlight = if (isLight) Color.White.copy(alpha = 0.15f) else Color.White.copy(alpha = 0.08f),
)
val pressedColors = BaseUITheme.ButtonColors(
background = Brush.verticalGradient(
listOf(
scheme.onSurfaceVariant,
scheme.onSurfaceVariant
)
),
background = Brush.verticalGradient(listOf(scheme.onSurfaceVariant, scheme.onSurfaceVariant)),
foreground = scheme.surface,
highlight = if (isLight) Color.White.copy(alpha = 0.1f) else Color.White.copy(alpha = 0.05f),
)

View File

@ -1,23 +0,0 @@
package dev.krtirtho.spotube.core.ui.base
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
fun Modifier.highlight(color: Color): Modifier =
drawWithCache {
val highlightBrush = Brush.verticalGradient(
colors = listOf(color, Color.Transparent),
startY = 0f,
endY = size.height * 0.5f,
)
onDrawWithContent {
drawContent()
drawRect(
brush = highlightBrush,
topLeft = androidx.compose.ui.geometry.Offset.Zero,
size = size,
)
}
}

View File

@ -91,7 +91,6 @@ import dev.krtirtho.spotube.core.ui.base.GhostIconButton
import dev.krtirtho.spotube.core.ui.base.GroupIconButton
import dev.krtirtho.spotube.core.ui.base.LocalBaseUITheme
import dev.krtirtho.spotube.core.ui.base.TextField
import dev.krtirtho.spotube.core.ui.base.highlight
import dev.krtirtho.spotube.core.ui.misc.SkeletonTree
import dev.krtirtho.spotube.core.ui.misc.TextWithShimmer
import dev.krtirtho.spotube.core.ui.misc.shimmerApply
@ -540,13 +539,23 @@ private fun TrackListRow(
onLongClick = onLongClick,
)
.background(rowBackgroundColor)
.then(
if (isRowHovered || isSelected || (isCurrentTrack && isCurrentTrackPlaying)) {
Modifier.highlight(highlightColor)
} else {
Modifier
.drawWithCache {
val highlightBrush = Brush.verticalGradient(
colors = listOf(highlightColor, Color.Transparent),
startY = 0f,
endY = size.height * 0.5f,
)
onDrawWithContent {
drawContent()
if (isRowHovered || isSelected || (isCurrentTrack && isCurrentTrackPlaying)) {
drawRect(
brush = highlightBrush,
topLeft = Offset.Zero,
size = size,
)
}
}
)
}
.clip(MaterialTheme.shapes.small)
.padding(horizontal = 8.dp, vertical = 6.dp)
.padding(end = 6.dp),