[优化] 修复列数封面等问题
This commit is contained in:
@@ -35,7 +35,6 @@ android {
|
|||||||
kotlin {
|
kotlin {
|
||||||
jvmToolchain {
|
jvmToolchain {
|
||||||
languageVersion.set(JavaLanguageVersion.of(21))
|
languageVersion.set(JavaLanguageVersion.of(21))
|
||||||
vendor.set(JvmVendorSpec.ADOPTIUM)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,6 +231,8 @@ object PreferKey {
|
|||||||
const val sharedElementEnterTransitionEnable = "sharedElementEnterTransitionEnable"
|
const val sharedElementEnterTransitionEnable = "sharedElementEnterTransitionEnable"
|
||||||
const val bookshelfLayoutGridLandscape = "bookshelfLayoutGridLandscape"
|
const val bookshelfLayoutGridLandscape = "bookshelfLayoutGridLandscape"
|
||||||
const val bookshelfLayoutGridPortrait = "bookshelfLayoutGridPortrait"
|
const val bookshelfLayoutGridPortrait = "bookshelfLayoutGridPortrait"
|
||||||
|
const val bookshelfLayoutListLandscape = "bookshelfLayoutListLandscape"
|
||||||
|
const val bookshelfLayoutListPortrait = "bookshelfLayoutListPortrait"
|
||||||
const val bookshelfTitleSmallFont = "bookshelfTitleSmallFont"
|
const val bookshelfTitleSmallFont = "bookshelfTitleSmallFont"
|
||||||
const val bookshelfTitleCenter = "bookshelfTitleCenter"
|
const val bookshelfTitleCenter = "bookshelfTitleCenter"
|
||||||
const val bookshelfTitleMaxLines = "bookshelfTitleMaxLines"
|
const val bookshelfTitleMaxLines = "bookshelfTitleMaxLines"
|
||||||
|
|||||||
@@ -88,6 +88,16 @@ object BookshelfConfig {
|
|||||||
*/
|
*/
|
||||||
var bookshelfLayoutGridLandscape by prefDelegate(PreferKey.bookshelfLayoutGridLandscape, 7)
|
var bookshelfLayoutGridLandscape by prefDelegate(PreferKey.bookshelfLayoutGridLandscape, 7)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 竖屏书架列表列数
|
||||||
|
*/
|
||||||
|
var bookshelfLayoutListPortrait by prefDelegate(PreferKey.bookshelfLayoutListPortrait, 1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 横屏书架列表列数
|
||||||
|
*/
|
||||||
|
var bookshelfLayoutListLandscape by prefDelegate(PreferKey.bookshelfLayoutListLandscape, 1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网格模式布局样式: 0:标准, 1:紧凑, 2:仅封面
|
* 网格模式布局样式: 0:标准, 1:紧凑, 2:仅封面
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import androidx.compose.foundation.layout.Spacer
|
|||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.Checkbox
|
import androidx.compose.material3.Checkbox
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
@@ -57,6 +59,7 @@ fun CoverRuleConfigSheet(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(16.dp)
|
.padding(16.dp)
|
||||||
|
.verticalScroll(rememberScrollState())
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.cover_rule),
|
text = stringResource(R.string.cover_rule),
|
||||||
|
|||||||
@@ -127,6 +127,20 @@ fun BookshelfConfigSheet(
|
|||||||
onValueChange = { BookshelfConfig.bookshelfGridLayout = it.toInt() }
|
onValueChange = { BookshelfConfig.bookshelfGridLayout = it.toInt() }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val gridCount =
|
||||||
|
if (isLandscape) BookshelfConfig.bookshelfLayoutGridLandscape else BookshelfConfig.bookshelfLayoutGridPortrait
|
||||||
|
CompactSliderSettingItem(
|
||||||
|
title = stringResource(R.string.number_rows_columns),
|
||||||
|
value = gridCount.toFloat(),
|
||||||
|
valueRange = 1f..15f,
|
||||||
|
steps = 14,
|
||||||
|
onValueChange = {
|
||||||
|
if (isLandscape) BookshelfConfig.bookshelfLayoutGridLandscape =
|
||||||
|
it.toInt()
|
||||||
|
else BookshelfConfig.bookshelfLayoutGridPortrait = it.toInt()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
CompactSwitchSettingItem(
|
CompactSwitchSettingItem(
|
||||||
title = "标题小字体",
|
title = "标题小字体",
|
||||||
checked = BookshelfConfig.bookshelfTitleSmallFont,
|
checked = BookshelfConfig.bookshelfTitleSmallFont,
|
||||||
@@ -165,6 +179,20 @@ fun BookshelfConfigSheet(
|
|||||||
color = MaterialTheme.colorScheme.surface,
|
color = MaterialTheme.colorScheme.surface,
|
||||||
onCheckedChange = { BookshelfConfig.bookshelfShowDivider = it }
|
onCheckedChange = { BookshelfConfig.bookshelfShowDivider = it }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val listColCount =
|
||||||
|
if (isLandscape) BookshelfConfig.bookshelfLayoutListLandscape else BookshelfConfig.bookshelfLayoutListPortrait
|
||||||
|
CompactSliderSettingItem(
|
||||||
|
title = stringResource(R.string.number_rows_columns),
|
||||||
|
value = listColCount.toFloat(),
|
||||||
|
valueRange = 1f..5f,
|
||||||
|
steps = 4,
|
||||||
|
onValueChange = {
|
||||||
|
if (isLandscape) BookshelfConfig.bookshelfLayoutListLandscape =
|
||||||
|
it.toInt()
|
||||||
|
else BookshelfConfig.bookshelfLayoutListPortrait = it.toInt()
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -226,6 +226,8 @@ fun BookshelfScreen(
|
|||||||
if (isLandscape) BookshelfConfig.bookshelfLayoutModeLandscape else BookshelfConfig.bookshelfLayoutModePortrait
|
if (isLandscape) BookshelfConfig.bookshelfLayoutModeLandscape else BookshelfConfig.bookshelfLayoutModePortrait
|
||||||
val bookshelfLayoutGrid =
|
val bookshelfLayoutGrid =
|
||||||
if (isLandscape) BookshelfConfig.bookshelfLayoutGridLandscape else BookshelfConfig.bookshelfLayoutGridPortrait
|
if (isLandscape) BookshelfConfig.bookshelfLayoutGridLandscape else BookshelfConfig.bookshelfLayoutGridPortrait
|
||||||
|
val bookshelfLayoutList =
|
||||||
|
if (isLandscape) BookshelfConfig.bookshelfLayoutListLandscape else BookshelfConfig.bookshelfLayoutListPortrait
|
||||||
|
|
||||||
ListScaffold(
|
ListScaffold(
|
||||||
title = title,
|
title = title,
|
||||||
@@ -481,6 +483,7 @@ fun BookshelfScreen(
|
|||||||
uiState = uiState,
|
uiState = uiState,
|
||||||
bookshelfLayoutMode = bookshelfLayoutMode,
|
bookshelfLayoutMode = bookshelfLayoutMode,
|
||||||
bookshelfLayoutGrid = bookshelfLayoutGrid,
|
bookshelfLayoutGrid = bookshelfLayoutGrid,
|
||||||
|
bookshelfLayoutList = bookshelfLayoutList,
|
||||||
onBookClick = onBookClick,
|
onBookClick = onBookClick,
|
||||||
onBookLongClick = onBookLongClick
|
onBookLongClick = onBookLongClick
|
||||||
)
|
)
|
||||||
@@ -584,11 +587,13 @@ fun BookshelfPage(
|
|||||||
uiState: BookshelfUiState,
|
uiState: BookshelfUiState,
|
||||||
bookshelfLayoutMode: Int,
|
bookshelfLayoutMode: Int,
|
||||||
bookshelfLayoutGrid: Int,
|
bookshelfLayoutGrid: Int,
|
||||||
|
bookshelfLayoutList: Int,
|
||||||
onBookClick: (BookShelfItem) -> Unit,
|
onBookClick: (BookShelfItem) -> Unit,
|
||||||
onBookLongClick: (BookShelfItem) -> Unit
|
onBookLongClick: (BookShelfItem) -> Unit
|
||||||
) {
|
) {
|
||||||
|
val columns = if (bookshelfLayoutMode == 0) bookshelfLayoutList else bookshelfLayoutGrid
|
||||||
FastScrollLazyVerticalGrid(
|
FastScrollLazyVerticalGrid(
|
||||||
columns = GridCells.Fixed(bookshelfLayoutGrid.coerceAtLeast(1)),
|
columns = GridCells.Fixed(columns.coerceAtLeast(1)),
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
contentPadding = PaddingValues(
|
contentPadding = PaddingValues(
|
||||||
top = paddingValues.calculateTopPadding(),
|
top = paddingValues.calculateTopPadding(),
|
||||||
|
|||||||
@@ -74,8 +74,10 @@ fun BookCover(
|
|||||||
val hasCustomDefault = !randomPath.isNullOrBlank()
|
val hasCustomDefault = !randomPath.isNullOrBlank()
|
||||||
|
|
||||||
var isOnlineCoverLoaded by remember(path) { mutableStateOf(false) }
|
var isOnlineCoverLoaded by remember(path) { mutableStateOf(false) }
|
||||||
|
var isFinalPathLoaded by remember(path) { mutableStateOf(false) }
|
||||||
LaunchedEffect(finalPath) {
|
LaunchedEffect(finalPath) {
|
||||||
isOnlineCoverLoaded = false
|
isOnlineCoverLoaded = false
|
||||||
|
isFinalPathLoaded = false
|
||||||
}
|
}
|
||||||
|
|
||||||
BoxWithConstraints(
|
BoxWithConstraints(
|
||||||
@@ -98,7 +100,7 @@ fun BookCover(
|
|||||||
(minOf(maxWidth, maxHeight).toPx() / 3f).toDp()
|
(minOf(maxWidth, maxHeight).toPx() / 3f).toDp()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasCustomDefault) {
|
if (hasCustomDefault && !isFinalPathLoaded) {
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = ImageRequest.Builder(context)
|
model = ImageRequest.Builder(context)
|
||||||
.data(randomPath)
|
.data(randomPath)
|
||||||
@@ -125,6 +127,7 @@ fun BookCover(
|
|||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
onSuccess = {
|
onSuccess = {
|
||||||
isOnlineCoverLoaded = true
|
isOnlineCoverLoaded = true
|
||||||
|
isFinalPathLoaded = true
|
||||||
onLoadFinish?.invoke()
|
onLoadFinish?.invoke()
|
||||||
},
|
},
|
||||||
onError = {
|
onError = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
VERSION_MAJOR=3
|
VERSION_MAJOR=3
|
||||||
VERSION_MINOR=26
|
VERSION_MINOR=26
|
||||||
VERSION_PATCH=9
|
VERSION_PATCH=10
|
||||||
VERSION_SUFFIX=0
|
VERSION_SUFFIX=0
|
||||||
# 1 = Pre, 0 = Release
|
# 1 = Pre, 0 = Release
|
||||||
@@ -9,7 +9,6 @@ android {
|
|||||||
kotlin {
|
kotlin {
|
||||||
jvmToolchain {
|
jvmToolchain {
|
||||||
languageVersion.set(JavaLanguageVersion.of(21))
|
languageVersion.set(JavaLanguageVersion.of(21))
|
||||||
vendor.set(JvmVendorSpec.ADOPTIUM)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ android {
|
|||||||
kotlin {
|
kotlin {
|
||||||
jvmToolchain {
|
jvmToolchain {
|
||||||
languageVersion.set(JavaLanguageVersion.of(21))
|
languageVersion.set(JavaLanguageVersion.of(21))
|
||||||
vendor.set(JvmVendorSpec.ADOPTIUM)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
|
|||||||
Reference in New Issue
Block a user