[优化] 优化书籍详情界面
This commit is contained in:
@@ -11,6 +11,7 @@ data class BookInfoUiState(
|
||||
val webFiles: List<BookInfoWebFile> = emptyList(),
|
||||
val kindLabels: List<String> = emptyList(),
|
||||
val groupNames: String? = null,
|
||||
val hasCustomGroup: Boolean = false,
|
||||
val inBookshelf: Boolean = false,
|
||||
val bookSource: BookSource? = null,
|
||||
val isTocLoading: Boolean = true,
|
||||
|
||||
@@ -43,6 +43,7 @@ import androidx.compose.material.icons.filled.Share
|
||||
import androidx.compose.material.icons.filled.Star
|
||||
import androidx.compose.material.icons.outlined.Book
|
||||
import androidx.compose.material.icons.outlined.Bookmark
|
||||
import androidx.compose.material.icons.outlined.BookmarkBorder
|
||||
import androidx.compose.material.icons.outlined.CollectionsBookmark
|
||||
import androidx.compose.material.icons.outlined.FolderZip
|
||||
import androidx.compose.material.icons.outlined.Image
|
||||
@@ -264,7 +265,7 @@ private fun BookInfoScreenContent(
|
||||
.padding(bottom = 24.dp)
|
||||
) {
|
||||
BookInfoActions(
|
||||
book = book,
|
||||
hasCustomGroup = state.hasCustomGroup,
|
||||
inBookshelf = state.inBookshelf,
|
||||
onShelfClick = { onIntent(BookInfoIntent.ShelfClick) },
|
||||
onTocClick = { onIntent(BookInfoIntent.TocClick) },
|
||||
@@ -735,7 +736,7 @@ private fun BookInfoHeader(
|
||||
|
||||
@Composable
|
||||
private fun BookInfoActions(
|
||||
book: Book,
|
||||
hasCustomGroup: Boolean,
|
||||
inBookshelf: Boolean,
|
||||
onShelfClick: () -> Unit,
|
||||
onTocClick: () -> Unit,
|
||||
@@ -791,7 +792,7 @@ private fun BookInfoActions(
|
||||
)
|
||||
BookInfoActionCard(
|
||||
modifier = Modifier.weight(1f),
|
||||
icon = if (book.group > 0) Icons.Default.Bookmark else Icons.Outlined.Bookmark,
|
||||
icon = if (hasCustomGroup) Icons.Default.Bookmark else Icons.Outlined.BookmarkBorder,
|
||||
label = stringResource(R.string.change_group),
|
||||
onClick = onGroupClick
|
||||
)
|
||||
|
||||
@@ -138,7 +138,7 @@ fun GroupSelectSheet(
|
||||
) {
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
LazyColumn(
|
||||
modifier = Modifier.heightIn(max = 600.dp),
|
||||
modifier = Modifier.heightIn(max = 560.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
items(groups, key = { it.groupId }) { group ->
|
||||
|
||||
@@ -70,6 +70,7 @@ class BookInfoViewModel(
|
||||
private var currentWebFiles: List<BookInfoWebFile> = emptyList()
|
||||
private var currentKindLabels: List<String> = emptyList()
|
||||
private var currentGroupNames: String? = null
|
||||
private var currentHasCustomGroup = false
|
||||
private var chapterChanged = false
|
||||
|
||||
var inBookshelf = false
|
||||
@@ -602,6 +603,7 @@ class BookInfoViewModel(
|
||||
currentBook = it
|
||||
currentChapterList = toc
|
||||
currentGroupNames = null
|
||||
currentHasCustomGroup = false
|
||||
currentKindLabels = emptyList()
|
||||
syncUiState(isTocLoading = false)
|
||||
refreshMeta(it)
|
||||
@@ -616,6 +618,7 @@ class BookInfoViewModel(
|
||||
currentWebFiles = emptyList()
|
||||
currentKindLabels = emptyList()
|
||||
currentGroupNames = null
|
||||
currentHasCustomGroup = false
|
||||
syncUiState(isTocLoading = true)
|
||||
refreshMeta(book)
|
||||
upCoverByRule(book)
|
||||
@@ -668,11 +671,16 @@ class BookInfoViewModel(
|
||||
kinds.add(ConvertUtils.formatFileSize(size))
|
||||
}
|
||||
}
|
||||
val userGroupIds = appDb.bookGroupDao.idsSum
|
||||
val groupAnd = userGroupIds and book.group
|
||||
val hasCustomGroup = book.group > 0L && groupAnd != 0L
|
||||
val groupNames = appDb.bookGroupDao.getGroupNames(book.group).joinToString(",")
|
||||
kinds.toList() to groupNames.ifBlank { null }
|
||||
val normalizedGroupNames = groupNames.ifBlank { null }
|
||||
Triple(kinds.toList(), normalizedGroupNames, hasCustomGroup)
|
||||
}.onSuccess {
|
||||
currentKindLabels = it.first
|
||||
currentGroupNames = it.second
|
||||
currentHasCustomGroup = it.third
|
||||
syncUiState()
|
||||
}
|
||||
}
|
||||
@@ -803,6 +811,7 @@ class BookInfoViewModel(
|
||||
currentBook?.let { book ->
|
||||
book.group = groupId
|
||||
currentGroupNames = null
|
||||
currentHasCustomGroup = false
|
||||
refreshMeta(book)
|
||||
if (inBookshelf) {
|
||||
saveBook(book)
|
||||
@@ -1100,6 +1109,7 @@ class BookInfoViewModel(
|
||||
webFiles = currentWebFiles,
|
||||
kindLabels = currentKindLabels,
|
||||
groupNames = currentGroupNames,
|
||||
hasCustomGroup = currentHasCustomGroup,
|
||||
inBookshelf = inBookshelf,
|
||||
bookSource = bookSource,
|
||||
isTocLoading = isTocLoading,
|
||||
|
||||
@@ -226,7 +226,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checkable="true"
|
||||
android:text="@string/follow_background" />
|
||||
android:text="@string/follow_read_background" />
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/bottom_mode3"
|
||||
|
||||
@@ -1434,4 +1434,5 @@
|
||||
<string name="subtitle_scale">次行缩放</string>
|
||||
<string name="subtitle_margin">次行距离</string>
|
||||
<string name="heading_spacing">标题段距</string>
|
||||
<string name="follow_read_background">跟随阅读背景</string>
|
||||
</resources>
|
||||
|
||||
@@ -1388,21 +1388,6 @@
|
||||
<string name="read_change_all_s">Otherwise, Only Change Single-Chapter Source.</string>
|
||||
<string name="show_tip">显示书籍类型</string>
|
||||
<string name="show_book_count">显示分组书籍数量</string>
|
||||
<string name="is_reading">在读</string>
|
||||
<string name="is_unread">未读</string>
|
||||
<string name="is_read_finished">已读</string>
|
||||
<string name="manga">漫画</string>
|
||||
<string name="noval">小说</string>
|
||||
<string name="cover_show_shadow">显示字体阴影</string>
|
||||
<string name="cover_show_stroke">显示字体描边</string>
|
||||
<string name="default_color">使用默认字体颜色</string>
|
||||
<string name="enable_slider_vibrator">滑动进度条时震动</string>
|
||||
<string name="edit_remark">编辑备注</string>
|
||||
<string name="book_remark">书籍备注</string>
|
||||
<string name="save_to_local">保存至本地</string>
|
||||
<string name="select_operation">选择操作</string>
|
||||
<string name="text_accent_color">强调</string>
|
||||
<string name="read_color">颜色样式</string>
|
||||
<string name="is_reading">Reading</string>
|
||||
<string name="is_unread">Unread</string>
|
||||
<string name="is_read_finished">Finished</string>
|
||||
@@ -1453,5 +1438,5 @@
|
||||
<string name="subtitle_scale">Subtitle scale</string>
|
||||
<string name="subtitle_margin">Subtitle margin</string>
|
||||
<string name="heading_spacing">Heading spacing</string>
|
||||
<string name="follow_background">Follow Background</string>
|
||||
<string name="follow_read_background">Follow Background</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user