|
@@ -1,7 +1,6 @@
|
|
|
package io.legado.app.ui.widget.components.card
|
|
package io.legado.app.ui.widget.components.card
|
|
|
|
|
|
|
|
import androidx.compose.foundation.BorderStroke
|
|
import androidx.compose.foundation.BorderStroke
|
|
|
-import androidx.compose.foundation.border
|
|
|
|
|
import androidx.compose.foundation.combinedClickable
|
|
import androidx.compose.foundation.combinedClickable
|
|
|
import androidx.compose.foundation.layout.Box
|
|
import androidx.compose.foundation.layout.Box
|
|
|
import androidx.compose.foundation.layout.Column
|
|
import androidx.compose.foundation.layout.Column
|
|
@@ -9,7 +8,6 @@ import androidx.compose.foundation.layout.ColumnScope
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
import androidx.compose.material.ExperimentalMaterialApi
|
|
import androidx.compose.material.ExperimentalMaterialApi
|
|
|
-import androidx.compose.material3.CardDefaults
|
|
|
|
|
import androidx.compose.material3.Surface
|
|
import androidx.compose.material3.Surface
|
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.Modifier
|
|
@@ -18,13 +16,10 @@ import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.graphics.Shape
|
|
import androidx.compose.ui.graphics.Shape
|
|
|
import androidx.compose.ui.unit.Dp
|
|
import androidx.compose.ui.unit.Dp
|
|
|
import androidx.compose.ui.unit.dp
|
|
import androidx.compose.ui.unit.dp
|
|
|
-import io.legado.app.ui.theme.LocalAppUiConfiguration
|
|
|
|
|
import io.legado.app.ui.theme.LegadoTheme
|
|
import io.legado.app.ui.theme.LegadoTheme
|
|
|
-import io.legado.app.ui.theme.ThemeResolver
|
|
|
|
|
|
|
+import io.legado.app.ui.theme.LocalAppUiConfiguration
|
|
|
import io.legado.app.ui.widget.components.AppContainerBackgroundType
|
|
import io.legado.app.ui.widget.components.AppContainerBackgroundType
|
|
|
import io.legado.app.ui.widget.components.appContainerBackground
|
|
import io.legado.app.ui.widget.components.appContainerBackground
|
|
|
-import top.yukonga.miuix.kmp.utils.PressFeedbackType
|
|
|
|
|
-import top.yukonga.miuix.kmp.basic.Card as MiuixCard
|
|
|
|
|
import top.yukonga.miuix.kmp.basic.CardDefaults as MiuixCardDefaults
|
|
import top.yukonga.miuix.kmp.basic.CardDefaults as MiuixCardDefaults
|
|
|
|
|
|
|
|
@Composable
|
|
@Composable
|
|
@@ -57,7 +52,6 @@ private fun BaseCard(
|
|
|
onClick: (() -> Unit)? = null,
|
|
onClick: (() -> Unit)? = null,
|
|
|
onLongClick: (() -> Unit)? = null,
|
|
onLongClick: (() -> Unit)? = null,
|
|
|
cornerRadius: Dp = MiuixCardDefaults.CornerRadius,
|
|
cornerRadius: Dp = MiuixCardDefaults.CornerRadius,
|
|
|
- pressFeedbackType: PressFeedbackType = PressFeedbackType.None,
|
|
|
|
|
containerColor: Color? = null,
|
|
containerColor: Color? = null,
|
|
|
contentColor: Color? = null,
|
|
contentColor: Color? = null,
|
|
|
elevation: Dp = 0.dp,
|
|
elevation: Dp = 0.dp,
|
|
@@ -90,99 +84,30 @@ private fun BaseCard(
|
|
|
border
|
|
border
|
|
|
}
|
|
}
|
|
|
val resolvedShape = RoundedCornerShape(resolvedCornerRadius)
|
|
val resolvedShape = RoundedCornerShape(resolvedCornerRadius)
|
|
|
- val decoratedModifier = modifier.then(
|
|
|
|
|
- if (themeSettings.overrideBaseCardBorder && resolvedBorder != null) {
|
|
|
|
|
- Modifier.border(resolvedBorder, resolvedShape)
|
|
|
|
|
- } else {
|
|
|
|
|
- Modifier
|
|
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- if (isTransparent) {
|
|
|
|
|
- val clickableModifier = if (onClick != null || onLongClick != null) {
|
|
|
|
|
- decoratedModifier
|
|
|
|
|
- .clip(resolvedShape)
|
|
|
|
|
- .combinedClickable(
|
|
|
|
|
- onClick = { onClick?.invoke() },
|
|
|
|
|
- onLongClick = onLongClick
|
|
|
|
|
- )
|
|
|
|
|
- } else {
|
|
|
|
|
- decoratedModifier.clip(resolvedShape)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ val clickableModifier = if (onClick != null || onLongClick != null) {
|
|
|
|
|
+ modifier
|
|
|
|
|
+ .clip(resolvedShape)
|
|
|
|
|
+ .combinedClickable(
|
|
|
|
|
+ onClick = { onClick?.invoke() },
|
|
|
|
|
+ onLongClick = onLongClick
|
|
|
|
|
+ )
|
|
|
|
|
+ } else {
|
|
|
|
|
+ modifier
|
|
|
|
|
+ }
|
|
|
|
|
+ Surface(
|
|
|
|
|
+ modifier = clickableModifier,
|
|
|
|
|
+ shape = resolvedShape,
|
|
|
|
|
+ color = if (isTransparent) Color.Transparent else resolvedContainerColor,
|
|
|
|
|
+ contentColor = contentColor ?: LegadoTheme.colorScheme.onSurface,
|
|
|
|
|
+ tonalElevation = 0.dp,
|
|
|
|
|
+ shadowElevation = elevation,
|
|
|
|
|
+ border = resolvedBorder
|
|
|
|
|
+ ) {
|
|
|
BaseCardContent(
|
|
BaseCardContent(
|
|
|
- modifier = clickableModifier,
|
|
|
|
|
shape = resolvedShape,
|
|
shape = resolvedShape,
|
|
|
useItemBackground = useItemBackground,
|
|
useItemBackground = useItemBackground,
|
|
|
content = content,
|
|
content = content,
|
|
|
)
|
|
)
|
|
|
- } else if (ThemeResolver.isMiuixEngine(LegadoTheme.composeEngine)) {
|
|
|
|
|
- val colors = MiuixCardDefaults.defaultColors(
|
|
|
|
|
- color = resolvedContainerColor,
|
|
|
|
|
- contentColor = contentColor ?: LegadoTheme.colorScheme.onSurface
|
|
|
|
|
- )
|
|
|
|
|
- if (onClick != null) {
|
|
|
|
|
- MiuixCard(
|
|
|
|
|
- modifier = decoratedModifier,
|
|
|
|
|
- cornerRadius = resolvedCornerRadius,
|
|
|
|
|
- pressFeedbackType = pressFeedbackType,
|
|
|
|
|
- showIndication = true,
|
|
|
|
|
- onClick = onClick,
|
|
|
|
|
- onLongPress = onLongClick,
|
|
|
|
|
- content = {
|
|
|
|
|
- BaseCardContent(
|
|
|
|
|
- shape = resolvedShape,
|
|
|
|
|
- useItemBackground = useItemBackground,
|
|
|
|
|
- content = content,
|
|
|
|
|
- )
|
|
|
|
|
- },
|
|
|
|
|
- colors = colors
|
|
|
|
|
- )
|
|
|
|
|
- } else {
|
|
|
|
|
- MiuixCard(
|
|
|
|
|
- modifier = decoratedModifier,
|
|
|
|
|
- cornerRadius = resolvedCornerRadius,
|
|
|
|
|
- content = {
|
|
|
|
|
- BaseCardContent(
|
|
|
|
|
- shape = resolvedShape,
|
|
|
|
|
- useItemBackground = useItemBackground,
|
|
|
|
|
- content = content,
|
|
|
|
|
- )
|
|
|
|
|
- },
|
|
|
|
|
- colors = colors
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- val colors = CardDefaults.cardColors(
|
|
|
|
|
- containerColor = resolvedContainerColor,
|
|
|
|
|
- contentColor = contentColor ?: LegadoTheme.colorScheme.onSecondaryContainer,
|
|
|
|
|
- disabledContainerColor = LegadoTheme.colorScheme.onSecondaryContainer.copy(alpha = alpha * 0.38f),
|
|
|
|
|
- disabledContentColor = LegadoTheme.colorScheme.onSecondaryContainer.copy(alpha = alpha * 0.38f)
|
|
|
|
|
- )
|
|
|
|
|
- val clickableModifier = if (onClick != null || onLongClick != null) {
|
|
|
|
|
- modifier
|
|
|
|
|
- .clip(resolvedShape)
|
|
|
|
|
- .combinedClickable(
|
|
|
|
|
- onClick = { onClick?.invoke() },
|
|
|
|
|
- onLongClick = onLongClick
|
|
|
|
|
- )
|
|
|
|
|
- } else {
|
|
|
|
|
- modifier
|
|
|
|
|
- }
|
|
|
|
|
- Surface(
|
|
|
|
|
- modifier = clickableModifier,
|
|
|
|
|
- shape = resolvedShape,
|
|
|
|
|
- color = colors.containerColor,
|
|
|
|
|
- contentColor = colors.contentColor,
|
|
|
|
|
- tonalElevation = 0.dp,
|
|
|
|
|
- shadowElevation = elevation,
|
|
|
|
|
- border = resolvedBorder
|
|
|
|
|
- ) {
|
|
|
|
|
- BaseCardContent(
|
|
|
|
|
- shape = resolvedShape,
|
|
|
|
|
- useItemBackground = useItemBackground,
|
|
|
|
|
- content = content,
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -193,7 +118,6 @@ fun GlassCard(
|
|
|
onClick: (() -> Unit)? = null,
|
|
onClick: (() -> Unit)? = null,
|
|
|
onLongClick: (() -> Unit)? = null,
|
|
onLongClick: (() -> Unit)? = null,
|
|
|
cornerRadius: Dp = MiuixCardDefaults.CornerRadius,
|
|
cornerRadius: Dp = MiuixCardDefaults.CornerRadius,
|
|
|
- pressFeedbackType: PressFeedbackType = PressFeedbackType.None,
|
|
|
|
|
containerColor: Color? = null,
|
|
containerColor: Color? = null,
|
|
|
contentColor: Color? = null,
|
|
contentColor: Color? = null,
|
|
|
elevation: Dp = 0.dp,
|
|
elevation: Dp = 0.dp,
|
|
@@ -205,7 +129,6 @@ fun GlassCard(
|
|
|
onClick = onClick,
|
|
onClick = onClick,
|
|
|
onLongClick = onLongClick,
|
|
onLongClick = onLongClick,
|
|
|
cornerRadius = cornerRadius,
|
|
cornerRadius = cornerRadius,
|
|
|
- pressFeedbackType = pressFeedbackType,
|
|
|
|
|
containerColor = containerColor,
|
|
containerColor = containerColor,
|
|
|
contentColor = contentColor,
|
|
contentColor = contentColor,
|
|
|
elevation = elevation,
|
|
elevation = elevation,
|
|
@@ -223,7 +146,6 @@ fun NormalCard(
|
|
|
onClick: (() -> Unit)? = null,
|
|
onClick: (() -> Unit)? = null,
|
|
|
onLongClick: (() -> Unit)? = null,
|
|
onLongClick: (() -> Unit)? = null,
|
|
|
cornerRadius: Dp = MiuixCardDefaults.CornerRadius,
|
|
cornerRadius: Dp = MiuixCardDefaults.CornerRadius,
|
|
|
- pressFeedbackType: PressFeedbackType = PressFeedbackType.None,
|
|
|
|
|
containerColor: Color? = null,
|
|
containerColor: Color? = null,
|
|
|
contentColor: Color? = null,
|
|
contentColor: Color? = null,
|
|
|
elevation: Dp = 0.dp,
|
|
elevation: Dp = 0.dp,
|
|
@@ -235,7 +157,6 @@ fun NormalCard(
|
|
|
onClick = onClick,
|
|
onClick = onClick,
|
|
|
onLongClick = onLongClick,
|
|
onLongClick = onLongClick,
|
|
|
cornerRadius = cornerRadius,
|
|
cornerRadius = cornerRadius,
|
|
|
- pressFeedbackType = pressFeedbackType,
|
|
|
|
|
containerColor = containerColor,
|
|
containerColor = containerColor,
|
|
|
contentColor = contentColor,
|
|
contentColor = contentColor,
|
|
|
elevation = elevation,
|
|
elevation = elevation,
|