[优化] 优化书籍详情界面
This commit is contained in:
7 files changed
+20
-22
No files matched your search
@@ -11,6 +11,7 @@ data class BookInfoUiState(
|
|||||||
val webFiles: List<BookInfoWebFile> = emptyList(),
|
val webFiles: List<BookInfoWebFile> = emptyList(),
|
||||||
val kindLabels: List<String> = emptyList(),
|
val kindLabels: List<String> = emptyList(),
|
||||||
val groupNames: String? = null,
|
val groupNames: String? = null,
|
||||||
|
val hasCustomGroup: Boolean = false,
|
||||||
val inBookshelf: Boolean = false,
|
val inBookshelf: Boolean = false,
|
||||||
val bookSource: BookSource? = null,
|
val bookSource: BookSource? = null,
|
||||||
val isTocLoading: Boolean = true,
|
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.filled.Star
|
||||||
import androidx.compose.material.icons.outlined.Book
|
import androidx.compose.material.icons.outlined.Book
|
||||||
import androidx.compose.material.icons.outlined.Bookmark
|
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.CollectionsBookmark
|
||||||
import androidx.compose.material.icons.outlined.FolderZip
|
import androidx.compose.material.icons.outlined.FolderZip
|
||||||
import androidx.compose.material.icons.outlined.Image
|
import androidx.compose.material.icons.outlined.Image
|
||||||
@@ -264,7 +265,7 @@ private fun BookInfoScreenContent(
|
|||||||
.padding(bottom = 24.dp)
|
.padding(bottom = 24.dp)
|
||||||
) {
|
) {
|
||||||
BookInfoActions(
|
BookInfoActions(
|
||||||
book = book,
|
hasCustomGroup = state.hasCustomGroup,
|
||||||
inBookshelf = state.inBookshelf,
|
inBookshelf = state.inBookshelf,
|
||||||
onShelfClick = { onIntent(BookInfoIntent.ShelfClick) },
|
onShelfClick = { onIntent(BookInfoIntent.ShelfClick) },
|
||||||
onTocClick = { onIntent(BookInfoIntent.TocClick) },
|
onTocClick = { onIntent(BookInfoIntent.TocClick) },
|
||||||
@@ -735,7 +736,7 @@ private fun BookInfoHeader(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun BookInfoActions(
|
private fun BookInfoActions(
|
||||||
book: Book,
|
hasCustomGroup: Boolean,
|
||||||
inBookshelf: Boolean,
|
inBookshelf: Boolean,
|
||||||
onShelfClick: () -> Unit,
|
onShelfClick: () -> Unit,
|
||||||
onTocClick: () -> Unit,
|
onTocClick: () -> Unit,
|
||||||
@@ -791,7 +792,7 @@ private fun BookInfoActions(
|
|||||||
)
|
)
|
||||||
BookInfoActionCard(
|
BookInfoActionCard(
|
||||||
modifier = Modifier.weight(1f),
|
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),
|
label = stringResource(R.string.change_group),
|
||||||
onClick = onGroupClick
|
onClick = onGroupClick
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ fun GroupSelectSheet(
|
|||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.fillMaxWidth()) {
|
Column(modifier = Modifier.fillMaxWidth()) {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.heightIn(max = 600.dp),
|
modifier = Modifier.heightIn(max = 560.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
) {
|
) {
|
||||||
items(groups, key = { it.groupId }) { group ->
|
items(groups, key = { it.groupId }) { group ->
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ class BookInfoViewModel(
|
|||||||
private var currentWebFiles: List<BookInfoWebFile> = emptyList()
|
private var currentWebFiles: List<BookInfoWebFile> = emptyList()
|
||||||
private var currentKindLabels: List<String> = emptyList()
|
private var currentKindLabels: List<String> = emptyList()
|
||||||
private var currentGroupNames: String? = null
|
private var currentGroupNames: String? = null
|
||||||
|
private var currentHasCustomGroup = false
|
||||||
private var chapterChanged = false
|
private var chapterChanged = false
|
||||||
|
|
||||||
var inBookshelf = false
|
var inBookshelf = false
|
||||||
@@ -602,6 +603,7 @@ class BookInfoViewModel(
|
|||||||
currentBook = it
|
currentBook = it
|
||||||
currentChapterList = toc
|
currentChapterList = toc
|
||||||
currentGroupNames = null
|
currentGroupNames = null
|
||||||
|
currentHasCustomGroup = false
|
||||||
currentKindLabels = emptyList()
|
currentKindLabels = emptyList()
|
||||||
syncUiState(isTocLoading = false)
|
syncUiState(isTocLoading = false)
|
||||||
refreshMeta(it)
|
refreshMeta(it)
|
||||||
@@ -616,6 +618,7 @@ class BookInfoViewModel(
|
|||||||
currentWebFiles = emptyList()
|
currentWebFiles = emptyList()
|
||||||
currentKindLabels = emptyList()
|
currentKindLabels = emptyList()
|
||||||
currentGroupNames = null
|
currentGroupNames = null
|
||||||
|
currentHasCustomGroup = false
|
||||||
syncUiState(isTocLoading = true)
|
syncUiState(isTocLoading = true)
|
||||||
refreshMeta(book)
|
refreshMeta(book)
|
||||||
upCoverByRule(book)
|
upCoverByRule(book)
|
||||||
@@ -668,11 +671,16 @@ class BookInfoViewModel(
|
|||||||
kinds.add(ConvertUtils.formatFileSize(size))
|
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(",")
|
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 {
|
}.onSuccess {
|
||||||
currentKindLabels = it.first
|
currentKindLabels = it.first
|
||||||
currentGroupNames = it.second
|
currentGroupNames = it.second
|
||||||
|
currentHasCustomGroup = it.third
|
||||||
syncUiState()
|
syncUiState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -803,6 +811,7 @@ class BookInfoViewModel(
|
|||||||
currentBook?.let { book ->
|
currentBook?.let { book ->
|
||||||
book.group = groupId
|
book.group = groupId
|
||||||
currentGroupNames = null
|
currentGroupNames = null
|
||||||
|
currentHasCustomGroup = false
|
||||||
refreshMeta(book)
|
refreshMeta(book)
|
||||||
if (inBookshelf) {
|
if (inBookshelf) {
|
||||||
saveBook(book)
|
saveBook(book)
|
||||||
@@ -1100,6 +1109,7 @@ class BookInfoViewModel(
|
|||||||
webFiles = currentWebFiles,
|
webFiles = currentWebFiles,
|
||||||
kindLabels = currentKindLabels,
|
kindLabels = currentKindLabels,
|
||||||
groupNames = currentGroupNames,
|
groupNames = currentGroupNames,
|
||||||
|
hasCustomGroup = currentHasCustomGroup,
|
||||||
inBookshelf = inBookshelf,
|
inBookshelf = inBookshelf,
|
||||||
bookSource = bookSource,
|
bookSource = bookSource,
|
||||||
isTocLoading = isTocLoading,
|
isTocLoading = isTocLoading,
|
||||||
|
|||||||
@@ -226,7 +226,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
android:text="@string/follow_background" />
|
android:text="@string/follow_read_background" />
|
||||||
|
|
||||||
<com.google.android.material.chip.Chip
|
<com.google.android.material.chip.Chip
|
||||||
android:id="@+id/bottom_mode3"
|
android:id="@+id/bottom_mode3"
|
||||||
|
|||||||
@@ -1434,4 +1434,5 @@
|
|||||||
<string name="subtitle_scale">次行缩放</string>
|
<string name="subtitle_scale">次行缩放</string>
|
||||||
<string name="subtitle_margin">次行距离</string>
|
<string name="subtitle_margin">次行距离</string>
|
||||||
<string name="heading_spacing">标题段距</string>
|
<string name="heading_spacing">标题段距</string>
|
||||||
|
<string name="follow_read_background">跟随阅读背景</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1388,21 +1388,6 @@
|
|||||||
<string name="read_change_all_s">Otherwise, Only Change Single-Chapter Source.</string>
|
<string name="read_change_all_s">Otherwise, Only Change Single-Chapter Source.</string>
|
||||||
<string name="show_tip">显示书籍类型</string>
|
<string name="show_tip">显示书籍类型</string>
|
||||||
<string name="show_book_count">显示分组书籍数量</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_reading">Reading</string>
|
||||||
<string name="is_unread">Unread</string>
|
<string name="is_unread">Unread</string>
|
||||||
<string name="is_read_finished">Finished</string>
|
<string name="is_read_finished">Finished</string>
|
||||||
@@ -1453,5 +1438,5 @@
|
|||||||
<string name="subtitle_scale">Subtitle scale</string>
|
<string name="subtitle_scale">Subtitle scale</string>
|
||||||
<string name="subtitle_margin">Subtitle margin</string>
|
<string name="subtitle_margin">Subtitle margin</string>
|
||||||
<string name="heading_spacing">Heading spacing</string>
|
<string name="heading_spacing">Heading spacing</string>
|
||||||
<string name="follow_background">Follow Background</string>
|
<string name="follow_read_background">Follow Background</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in new issue
Block a user