|
@@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.Column
|
|
|
import androidx.compose.foundation.layout.FlowRow
|
|
import androidx.compose.foundation.layout.FlowRow
|
|
|
import androidx.compose.foundation.layout.Row
|
|
import androidx.compose.foundation.layout.Row
|
|
|
import androidx.compose.foundation.layout.RowScope
|
|
import androidx.compose.foundation.layout.RowScope
|
|
|
|
|
+import androidx.compose.foundation.layout.Spacer
|
|
|
import androidx.compose.foundation.layout.aspectRatio
|
|
import androidx.compose.foundation.layout.aspectRatio
|
|
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
@@ -20,6 +21,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
import androidx.compose.foundation.layout.padding
|
|
import androidx.compose.foundation.layout.padding
|
|
|
import androidx.compose.foundation.layout.width
|
|
import androidx.compose.foundation.layout.width
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
|
+import androidx.compose.material.icons.Icons
|
|
|
|
|
+import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
|
|
|
import androidx.compose.material3.HorizontalDivider
|
|
import androidx.compose.material3.HorizontalDivider
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.Composable
|
|
@@ -55,6 +58,8 @@ import io.legado.app.ui.widget.components.card.NormalCard
|
|
|
import io.legado.app.ui.widget.components.card.TextCard
|
|
import io.legado.app.ui.widget.components.card.TextCard
|
|
|
import io.legado.app.ui.widget.components.cover.CoilBookCover
|
|
import io.legado.app.ui.widget.components.cover.CoilBookCover
|
|
|
import io.legado.app.ui.widget.components.cover.BookshelfCover
|
|
import io.legado.app.ui.widget.components.cover.BookshelfCover
|
|
|
|
|
+import io.legado.app.ui.widget.components.icon.AppIcon
|
|
|
|
|
+import io.legado.app.ui.widget.components.icon.AppIcons
|
|
|
import io.legado.app.ui.widget.components.text.AppText
|
|
import io.legado.app.ui.widget.components.text.AppText
|
|
|
import io.legado.app.utils.splitNotBlank
|
|
import io.legado.app.utils.splitNotBlank
|
|
|
import io.legado.app.utils.toTimeAgo
|
|
import io.legado.app.utils.toTimeAgo
|
|
@@ -134,6 +139,7 @@ fun BookshelfItem(
|
|
|
if (isGrid) {
|
|
if (isGrid) {
|
|
|
Box(
|
|
Box(
|
|
|
modifier = modifier
|
|
modifier = modifier
|
|
|
|
|
+ .clip(RoundedCornerShape(4.dp))
|
|
|
.combinedClickable(
|
|
.combinedClickable(
|
|
|
onClick = onClick,
|
|
onClick = onClick,
|
|
|
onLongClick = onLongClick
|
|
onLongClick = onLongClick
|
|
@@ -450,16 +456,27 @@ fun BookGroupItemGrid(
|
|
|
fun BookGroupItemList(
|
|
fun BookGroupItemList(
|
|
|
group: BookGroupUi,
|
|
group: BookGroupUi,
|
|
|
previewBooks: List<BookShelfItem>,
|
|
previewBooks: List<BookShelfItem>,
|
|
|
|
|
+ onClick: () -> Unit,
|
|
|
|
|
+ modifier: Modifier = Modifier,
|
|
|
countText: String? = null,
|
|
countText: String? = null,
|
|
|
isCompact: Boolean = false,
|
|
isCompact: Boolean = false,
|
|
|
titleSmallFont: Boolean = false,
|
|
titleSmallFont: Boolean = false,
|
|
|
titleCenter: Boolean = true,
|
|
titleCenter: Boolean = true,
|
|
|
titleMaxLines: Int = 2,
|
|
titleMaxLines: Int = 2,
|
|
|
coverShadow: Boolean = false,
|
|
coverShadow: Boolean = false,
|
|
|
- modifier: Modifier = Modifier,
|
|
|
|
|
- onClick: () -> Unit,
|
|
|
|
|
- onLongClick: (() -> Unit)?
|
|
|
|
|
|
|
+ onLongClick: (() -> Unit)? = null
|
|
|
) {
|
|
) {
|
|
|
|
|
+ if (BookshelfConfig.bookshelfGroupListStyle == 2) {
|
|
|
|
|
+ BookGroupItemHorizontalCovers(
|
|
|
|
|
+ group = group,
|
|
|
|
|
+ previewBooks = previewBooks,
|
|
|
|
|
+ onClick = onClick,
|
|
|
|
|
+ modifier = modifier,
|
|
|
|
|
+ countText = countText,
|
|
|
|
|
+ onLongClick = onLongClick
|
|
|
|
|
+ )
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
val firstBookName = previewBooks.firstOrNull()?.name
|
|
val firstBookName = previewBooks.firstOrNull()?.name
|
|
|
val primaryColor = MaterialTheme.colorScheme.primary
|
|
val primaryColor = MaterialTheme.colorScheme.primary
|
|
|
val descAnnotated = if (firstBookName != null) {
|
|
val descAnnotated = if (firstBookName != null) {
|
|
@@ -475,7 +492,7 @@ fun BookGroupItemList(
|
|
|
BookshelfItem(
|
|
BookshelfItem(
|
|
|
isGrid = false,
|
|
isGrid = false,
|
|
|
gridStyle = 0,
|
|
gridStyle = 0,
|
|
|
- isCompact = isCompact,
|
|
|
|
|
|
|
+ isCompact = BookshelfConfig.bookshelfGroupListStyle == 1 || isCompact,
|
|
|
cover = { BookGroupCover(books = previewBooks, coverPath = group.cover, modifier = it) },
|
|
cover = { BookGroupCover(books = previewBooks, coverPath = group.cover, modifier = it) },
|
|
|
title = group.groupName,
|
|
title = group.groupName,
|
|
|
titleColor = primaryColor,
|
|
titleColor = primaryColor,
|
|
@@ -491,6 +508,99 @@ fun BookGroupItemList(
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+@Composable
|
|
|
|
|
+fun BookGroupItemHorizontalCovers(
|
|
|
|
|
+ group: BookGroupUi,
|
|
|
|
|
+ previewBooks: List<BookShelfItem>,
|
|
|
|
|
+ onClick: () -> Unit,
|
|
|
|
|
+ modifier: Modifier = Modifier,
|
|
|
|
|
+ countText: String? = null,
|
|
|
|
|
+ onLongClick: (() -> Unit)? = null
|
|
|
|
|
+) {
|
|
|
|
|
+ Column {
|
|
|
|
|
+ NormalCard(
|
|
|
|
|
+ modifier = modifier
|
|
|
|
|
+ .fillMaxWidth()
|
|
|
|
|
+ .padding(all = 4.dp),
|
|
|
|
|
+ cornerRadius = 12.dp,
|
|
|
|
|
+ containerColor = if (BookshelfConfig.bookshelfCardColor != 0) {
|
|
|
|
|
+ Color(BookshelfConfig.bookshelfCardColor)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ LegadoTheme.colorScheme.cardContainer
|
|
|
|
|
+ },
|
|
|
|
|
+ onClick = onClick,
|
|
|
|
|
+ onLongClick = onLongClick
|
|
|
|
|
+ ) {
|
|
|
|
|
+ Column(
|
|
|
|
|
+ modifier = Modifier
|
|
|
|
|
+ .padding(vertical = 12.dp),
|
|
|
|
|
+ verticalArrangement = Arrangement.spacedBy(8.dp)
|
|
|
|
|
+ ) {
|
|
|
|
|
+ Row(
|
|
|
|
|
+ modifier = Modifier
|
|
|
|
|
+ .fillMaxWidth()
|
|
|
|
|
+ .padding(start = 12.dp, top = 4.dp, bottom = 4.dp),
|
|
|
|
|
+ horizontalArrangement = Arrangement.SpaceBetween,
|
|
|
|
|
+ verticalAlignment = Alignment.CenterVertically
|
|
|
|
|
+ ) {
|
|
|
|
|
+ AppText(
|
|
|
|
|
+ text = group.groupName,
|
|
|
|
|
+ style = LegadoTheme.typography.titleMediumEmphasized,
|
|
|
|
|
+ maxLines = 1,
|
|
|
|
|
+ overflow = TextOverflow.Ellipsis,
|
|
|
|
|
+ modifier = Modifier.weight(1f)
|
|
|
|
|
+ )
|
|
|
|
|
+ if (countText != null) {
|
|
|
|
|
+ AppText(
|
|
|
|
|
+ text = countText,
|
|
|
|
|
+ style = LegadoTheme.typography.labelSmallEmphasized,
|
|
|
|
|
+ color = LegadoTheme.colorScheme.onSurfaceVariant
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ AppIcon(
|
|
|
|
|
+ modifier = Modifier.padding(end = 6.dp),
|
|
|
|
|
+ imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight,
|
|
|
|
|
+ contentDescription = "",
|
|
|
|
|
+ tint = LegadoTheme.colorScheme.onSurfaceVariant
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ Row(
|
|
|
|
|
+ modifier = Modifier
|
|
|
|
|
+ .fillMaxWidth()
|
|
|
|
|
+ .padding(horizontal = 12.dp),
|
|
|
|
|
+ horizontalArrangement = Arrangement.spacedBy(8.dp)
|
|
|
|
|
+ ) {
|
|
|
|
|
+ val coverCount = BookshelfConfig.bookshelfGroupCoverCount
|
|
|
|
|
+ previewBooks.take(coverCount).forEach { book ->
|
|
|
|
|
+ Box(
|
|
|
|
|
+ modifier = Modifier
|
|
|
|
|
+ .weight(1f)
|
|
|
|
|
+ .aspectRatio(5f / 7f)
|
|
|
|
|
+ .clip(RoundedCornerShape(4.dp))
|
|
|
|
|
+ ) {
|
|
|
|
|
+ CoilBookCover(
|
|
|
|
|
+ name = book.name,
|
|
|
|
|
+ author = book.author,
|
|
|
|
|
+ path = book.getDisplayCover(),
|
|
|
|
|
+ modifier = Modifier.fillMaxSize()
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ repeat(maxOf(0, coverCount - previewBooks.size)) {
|
|
|
|
|
+ Spacer(modifier = Modifier.weight(1f))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (BookshelfConfig.bookshelfShowDivider)
|
|
|
|
|
+ HorizontalDivider(
|
|
|
|
|
+ modifier = Modifier.padding(horizontal = 16.dp),
|
|
|
|
|
+ thickness = 0.5.dp,
|
|
|
|
|
+ color = LegadoTheme.colorScheme.outlineVariant.copy(alpha = 0.5f)
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
@OptIn(ExperimentalSharedTransitionApi::class)
|
|
@OptIn(ExperimentalSharedTransitionApi::class)
|
|
|
@Composable
|
|
@Composable
|
|
|
fun BookItem(
|
|
fun BookItem(
|
|
@@ -582,7 +692,7 @@ fun BookItem(
|
|
|
val kindList = book.kind?.splitNotBlank(",", "\n")?.filter { it.isNotBlank() }
|
|
val kindList = book.kind?.splitNotBlank(",", "\n")?.filter { it.isNotBlank() }
|
|
|
val intro = book.intro?.takeIf { it.isNotBlank() }
|
|
val intro = book.intro?.takeIf { it.isNotBlank() }
|
|
|
val customTagColors = if (ThemeConfig.enableCustomTagColors) ThemeConfig.getCustomTagColors() else emptyList()
|
|
val customTagColors = if (ThemeConfig.enableCustomTagColors) ThemeConfig.getCustomTagColors() else emptyList()
|
|
|
- if (!kindList.isNullOrEmpty()) {
|
|
|
|
|
|
|
+ if (BookshelfConfig.bookshelfShowTag && !kindList.isNullOrEmpty()) {
|
|
|
FlowRow(
|
|
FlowRow(
|
|
|
modifier = Modifier
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|
|
.fillMaxWidth()
|
|
@@ -608,7 +718,7 @@ fun BookItem(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (intro != null) {
|
|
|
|
|
|
|
+ if (BookshelfConfig.bookshelfShowIntro && intro != null) {
|
|
|
val maxLines = if (BookshelfConfig.bookshelfIntroMaxLines == 0) Int.MAX_VALUE else BookshelfConfig.bookshelfIntroMaxLines
|
|
val maxLines = if (BookshelfConfig.bookshelfIntroMaxLines == 0) Int.MAX_VALUE else BookshelfConfig.bookshelfIntroMaxLines
|
|
|
AppText(
|
|
AppText(
|
|
|
text = intro,
|
|
text = intro,
|