mirror of
https://github.com/KRTirtho/spotube.git
synced 2026-08-09 05:39:26 +00:00
Compare commits
1 Commits
e6ddd0d960
...
ee708329d4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee708329d4 |
@ -269,7 +269,21 @@ fun <T> AutocompleteTextField(
|
|||||||
BorderStroke(resolvedBorder.width, resolvedBorder.color),
|
BorderStroke(resolvedBorder.width, resolvedBorder.color),
|
||||||
fieldState.shape
|
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),
|
.padding(resolvedTextFieldTheme.padding),
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
@ -89,29 +89,9 @@ private fun resolveButtonState(
|
|||||||
isHovered: Boolean,
|
isHovered: Boolean,
|
||||||
): ResolvedButtonState {
|
): ResolvedButtonState {
|
||||||
return when {
|
return when {
|
||||||
isPressed -> ResolvedButtonState(
|
isPressed -> ResolvedButtonState(style.colors.pressed, style.shape.pressed, style.shadow.pressed, style.border.pressed, style.padding.pressed)
|
||||||
style.colors.pressed,
|
isHovered -> ResolvedButtonState(style.colors.hovered, style.shape.hovered, style.shadow.hovered, style.border.hovered, style.padding.hovered)
|
||||||
style.shape.pressed,
|
else -> ResolvedButtonState(style.colors.focused, style.shape.focused, style.shadow.focused, style.border.focused, style.padding.focused)
|
||||||
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)
|
.hoverable(interactionSource = interactionSource, enabled = enabled)
|
||||||
.graphicsLayer { translationY = lift.toPx() }
|
.graphicsLayer { translationY = lift.toPx() }
|
||||||
.then(
|
.then(
|
||||||
if (hoverOnly && !isHovered) Modifier else Modifier.applyShadow(
|
if (hoverOnly && !isHovered) Modifier else Modifier.applyShadow(state.shadow, state.shape)
|
||||||
state.shadow,
|
|
||||||
state.shape
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.clip(state.shape)
|
.clip(state.shape)
|
||||||
.then(
|
.then(
|
||||||
if (hoverOnly && !isHovered) Modifier else Modifier.background(
|
if (hoverOnly && !isHovered) Modifier else Modifier.background(state.colors.background, state.shape)
|
||||||
state.colors.background,
|
|
||||||
state.shape
|
|
||||||
)
|
|
||||||
.border(BorderStroke(state.border.width, state.border.color), state.shape)
|
.border(BorderStroke(state.border.width, state.border.color), state.shape)
|
||||||
)
|
)
|
||||||
.clickable(
|
.clickable(
|
||||||
@ -173,7 +147,21 @@ fun OutlineButton(
|
|||||||
indication = ripple(),
|
indication = ripple(),
|
||||||
onClick = onClick,
|
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),
|
.padding(state.padding),
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
) {
|
) {
|
||||||
@ -220,7 +208,21 @@ fun PrimaryButton(
|
|||||||
indication = ripple(),
|
indication = ripple(),
|
||||||
onClick = onClick,
|
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),
|
.padding(state.padding),
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
) {
|
) {
|
||||||
@ -265,7 +267,21 @@ fun SecondaryButton(
|
|||||||
indication = ripple(),
|
indication = ripple(),
|
||||||
onClick = onClick,
|
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),
|
.padding(state.padding),
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@ -145,7 +145,21 @@ fun CheckBox(
|
|||||||
.clip(resolved.shape)
|
.clip(resolved.shape)
|
||||||
.background(resolved.colors.background, resolved.shape)
|
.background(resolved.colors.background, resolved.shape)
|
||||||
.border(BorderStroke(0.5.dp, borderColor), 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(
|
.then(
|
||||||
if (onClick != null) {
|
if (onClick != null) {
|
||||||
Modifier
|
Modifier
|
||||||
|
|||||||
@ -121,7 +121,21 @@ fun ChipTab(
|
|||||||
indication = ripple(),
|
indication = ripple(),
|
||||||
onClick = onClick,
|
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),
|
.padding(state.padding),
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@ -152,7 +152,21 @@ fun TextField(
|
|||||||
.clip(state.shape)
|
.clip(state.shape)
|
||||||
.background(state.background, state.shape)
|
.background(state.background, state.shape)
|
||||||
.border(BorderStroke(resolvedBorder.width, resolvedBorder.color), 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),
|
.padding(textFieldTheme.padding),
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
@ -23,8 +23,6 @@ import androidx.compose.material3.MaterialTheme
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import androidx.compose.runtime.staticCompositionLocalOf
|
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.Brush
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
@ -653,30 +651,15 @@ fun rememberBaseUITheme(): BaseUITheme {
|
|||||||
shape = RoundedCornerShape(16.dp),
|
shape = RoundedCornerShape(16.dp),
|
||||||
border = BaseUITheme.Border(border, 0.5.dp),
|
border = BaseUITheme.Border(border, 0.5.dp),
|
||||||
padding = PaddingValues(0.dp),
|
padding = PaddingValues(0.dp),
|
||||||
shadow = BaseUITheme.Shadow(
|
shadow = BaseUITheme.Shadow(6.dp, true, shadowColor.copy(alpha = 0.15f), shadowColor.copy(alpha = 0.18f)),
|
||||||
6.dp,
|
|
||||||
true,
|
|
||||||
shadowColor.copy(alpha = 0.15f),
|
|
||||||
shadowColor.copy(alpha = 0.18f)
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
listRowTile = BaseUITheme.ListRowTheme(
|
listRowTile = BaseUITheme.ListRowTheme(
|
||||||
background = BaseUITheme.AdvancedInteractionState(
|
background = BaseUITheme.AdvancedInteractionState(
|
||||||
hovered = Brush.verticalGradient(listOf(containerLighter, containerDarker)),
|
hovered = Brush.verticalGradient(listOf(containerLighter, containerDarker)),
|
||||||
pressed = Brush.verticalGradient(listOf(containerPressed, containerPressed)),
|
pressed = Brush.verticalGradient(listOf(containerPressed, containerPressed)),
|
||||||
focused = Brush.verticalGradient(listOf(containerLighter, containerDarker)),
|
focused = Brush.verticalGradient(listOf(containerLighter, containerDarker)),
|
||||||
selected = Brush.verticalGradient(
|
selected = Brush.verticalGradient(listOf(scheme.primaryContainer.copy(alpha = 0.3f), scheme.primaryContainer.copy(alpha = 0.3f))),
|
||||||
listOf(
|
disabled = Brush.verticalGradient(listOf(containerLighter.copy(alpha = 0.5f), containerDarker.copy(alpha = 0.5f))),
|
||||||
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(
|
shape = BaseUITheme.AdvancedInteractionState(
|
||||||
hovered = RoundedCornerShape(8.dp),
|
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),
|
highlight = if (isLight) Color.White.copy(alpha = 0.15f) else Color.White.copy(alpha = 0.08f),
|
||||||
)
|
)
|
||||||
val pressedColors = BaseUITheme.ButtonColors(
|
val pressedColors = BaseUITheme.ButtonColors(
|
||||||
background = Brush.verticalGradient(
|
background = Brush.verticalGradient(listOf(scheme.onSurfaceVariant, scheme.onSurfaceVariant)),
|
||||||
listOf(
|
|
||||||
scheme.onSurfaceVariant,
|
|
||||||
scheme.onSurfaceVariant
|
|
||||||
)
|
|
||||||
),
|
|
||||||
foreground = scheme.surface,
|
foreground = scheme.surface,
|
||||||
highlight = if (isLight) Color.White.copy(alpha = 0.1f) else Color.White.copy(alpha = 0.05f),
|
highlight = if (isLight) Color.White.copy(alpha = 0.1f) else Color.White.copy(alpha = 0.05f),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -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,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -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.GroupIconButton
|
||||||
import dev.krtirtho.spotube.core.ui.base.LocalBaseUITheme
|
import dev.krtirtho.spotube.core.ui.base.LocalBaseUITheme
|
||||||
import dev.krtirtho.spotube.core.ui.base.TextField
|
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.SkeletonTree
|
||||||
import dev.krtirtho.spotube.core.ui.misc.TextWithShimmer
|
import dev.krtirtho.spotube.core.ui.misc.TextWithShimmer
|
||||||
import dev.krtirtho.spotube.core.ui.misc.shimmerApply
|
import dev.krtirtho.spotube.core.ui.misc.shimmerApply
|
||||||
@ -540,13 +539,23 @@ private fun TrackListRow(
|
|||||||
onLongClick = onLongClick,
|
onLongClick = onLongClick,
|
||||||
)
|
)
|
||||||
.background(rowBackgroundColor)
|
.background(rowBackgroundColor)
|
||||||
.then(
|
.drawWithCache {
|
||||||
if (isRowHovered || isSelected || (isCurrentTrack && isCurrentTrackPlaying)) {
|
val highlightBrush = Brush.verticalGradient(
|
||||||
Modifier.highlight(highlightColor)
|
colors = listOf(highlightColor, Color.Transparent),
|
||||||
} else {
|
startY = 0f,
|
||||||
Modifier
|
endY = size.height * 0.5f,
|
||||||
|
)
|
||||||
|
onDrawWithContent {
|
||||||
|
drawContent()
|
||||||
|
if (isRowHovered || isSelected || (isCurrentTrack && isCurrentTrackPlaying)) {
|
||||||
|
drawRect(
|
||||||
|
brush = highlightBrush,
|
||||||
|
topLeft = Offset.Zero,
|
||||||
|
size = size,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
.clip(MaterialTheme.shapes.small)
|
.clip(MaterialTheme.shapes.small)
|
||||||
.padding(horizontal = 8.dp, vertical = 6.dp)
|
.padding(horizontal = 8.dp, vertical = 6.dp)
|
||||||
.padding(end = 6.dp),
|
.padding(end = 6.dp),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user