[优化] 添加未开启模糊时的顶栏与底栏透明度选项
This commit is contained in:
@@ -186,6 +186,8 @@ object PreferKey {
|
|||||||
const val materialVersion = "materialVersion"
|
const val materialVersion = "materialVersion"
|
||||||
const val composeEngine = "composeEngine"
|
const val composeEngine = "composeEngine"
|
||||||
const val containerOpacity = "containerOpacity"
|
const val containerOpacity = "containerOpacity"
|
||||||
|
const val topBarOpacity = "topBarOpacity"
|
||||||
|
const val bottomBarOpacity = "bottomBarOpacity"
|
||||||
const val enableBlur = "enableBlur"
|
const val enableBlur = "enableBlur"
|
||||||
const val enableProgressiveBlur = "enableProgressiveBlur"
|
const val enableProgressiveBlur = "enableProgressiveBlur"
|
||||||
const val useFlexibleTopAppBar = "useFlexibleTopAppBar"
|
const val useFlexibleTopAppBar = "useFlexibleTopAppBar"
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ object ThemeConfig {
|
|||||||
|
|
||||||
var containerOpacity by prefDelegate(PreferKey.containerOpacity, 100)
|
var containerOpacity by prefDelegate(PreferKey.containerOpacity, 100)
|
||||||
|
|
||||||
|
var topBarOpacity by prefDelegate(PreferKey.topBarOpacity, 100)
|
||||||
|
|
||||||
|
var bottomBarOpacity by prefDelegate(PreferKey.bottomBarOpacity, 100)
|
||||||
|
|
||||||
var enableBlur by prefDelegate(PreferKey.enableBlur, false)
|
var enableBlur by prefDelegate(PreferKey.enableBlur, false)
|
||||||
|
|
||||||
var enableProgressiveBlur by prefDelegate(PreferKey.enableProgressiveBlur, true)
|
var enableProgressiveBlur by prefDelegate(PreferKey.enableProgressiveBlur, true)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.core.animateDpAsState
|
import androidx.compose.animation.core.animateDpAsState
|
||||||
import androidx.compose.foundation.BorderStroke
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.Canvas
|
import androidx.compose.foundation.Canvas
|
||||||
@@ -365,6 +366,51 @@ fun ThemeConfigScreen(
|
|||||||
checked = ThemeConfig.useFlexibleTopAppBar,
|
checked = ThemeConfig.useFlexibleTopAppBar,
|
||||||
onCheckedChange = { ThemeConfig.useFlexibleTopAppBar = it }
|
onCheckedChange = { ThemeConfig.useFlexibleTopAppBar = it }
|
||||||
)
|
)
|
||||||
|
SwitchSettingItem(
|
||||||
|
title = stringResource(R.string.is_blur_enable),
|
||||||
|
checked = ThemeConfig.enableBlur,
|
||||||
|
onCheckedChange = {
|
||||||
|
ThemeConfig.enableBlur = it
|
||||||
|
if (!it) ThemeConfig.enableProgressiveBlur = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
AnimatedVisibility(visible = ThemeConfig.enableBlur) {
|
||||||
|
SwitchSettingItem(
|
||||||
|
title = stringResource(R.string.is_blur_progressive_enable),
|
||||||
|
checked = ThemeConfig.enableProgressiveBlur,
|
||||||
|
onCheckedChange = { ThemeConfig.enableProgressiveBlur = it }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
AnimatedVisibility(visible = !ThemeConfig.enableBlur) {
|
||||||
|
Column(
|
||||||
|
verticalArrangement = Arrangement.spacedBy(2.dp)
|
||||||
|
) {
|
||||||
|
SliderSettingItem(
|
||||||
|
title = stringResource(R.string.top_bar_opacity),
|
||||||
|
description = stringResource(
|
||||||
|
R.string.top_bar_opacity_summary,
|
||||||
|
ThemeConfig.topBarOpacity
|
||||||
|
),
|
||||||
|
value = ThemeConfig.topBarOpacity.toFloat(),
|
||||||
|
defaultValue = 100f,
|
||||||
|
valueRange = 0f..100f,
|
||||||
|
steps = 99,
|
||||||
|
onValueChange = { ThemeConfig.topBarOpacity = it.toInt() }
|
||||||
|
)
|
||||||
|
SliderSettingItem(
|
||||||
|
title = stringResource(R.string.bottom_bar_opacity),
|
||||||
|
description = stringResource(
|
||||||
|
R.string.bottom_bar_opacity_summary,
|
||||||
|
ThemeConfig.bottomBarOpacity
|
||||||
|
),
|
||||||
|
value = ThemeConfig.bottomBarOpacity.toFloat(),
|
||||||
|
defaultValue = 100f,
|
||||||
|
valueRange = 0f..100f,
|
||||||
|
steps = 99,
|
||||||
|
onValueChange = { ThemeConfig.bottomBarOpacity = it.toInt() }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
SliderSettingItem(
|
SliderSettingItem(
|
||||||
title = stringResource(R.string.container_opacity),
|
title = stringResource(R.string.container_opacity),
|
||||||
description = stringResource(
|
description = stringResource(
|
||||||
@@ -377,18 +423,6 @@ fun ThemeConfigScreen(
|
|||||||
steps = 99,
|
steps = 99,
|
||||||
onValueChange = { ThemeConfig.containerOpacity = it.toInt() }
|
onValueChange = { ThemeConfig.containerOpacity = it.toInt() }
|
||||||
)
|
)
|
||||||
SwitchSettingItem(
|
|
||||||
title = stringResource(R.string.is_blur_enable),
|
|
||||||
checked = ThemeConfig.enableBlur,
|
|
||||||
onCheckedChange = { ThemeConfig.enableBlur = it }
|
|
||||||
)
|
|
||||||
if (ThemeConfig.enableBlur) {
|
|
||||||
SwitchSettingItem(
|
|
||||||
title = stringResource(R.string.is_blur_progressive_enable),
|
|
||||||
checked = ThemeConfig.enableProgressiveBlur,
|
|
||||||
onCheckedChange = { ThemeConfig.enableProgressiveBlur = it }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SplicedColumnGroup(title = stringResource(R.string.day)) {
|
SplicedColumnGroup(title = stringResource(R.string.day)) {
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ import io.legado.app.R
|
|||||||
import io.legado.app.ui.book.info.BookInfoActivity
|
import io.legado.app.ui.book.info.BookInfoActivity
|
||||||
import io.legado.app.ui.book.search.SearchActivity
|
import io.legado.app.ui.book.search.SearchActivity
|
||||||
import io.legado.app.ui.config.mainConfig.MainConfig
|
import io.legado.app.ui.config.mainConfig.MainConfig
|
||||||
|
import io.legado.app.ui.config.themeConfig.ThemeConfig
|
||||||
import io.legado.app.ui.main.bookshelf.BookshelfScreen
|
import io.legado.app.ui.main.bookshelf.BookshelfScreen
|
||||||
import io.legado.app.ui.main.bookshelf.BookshelfViewModel
|
import io.legado.app.ui.main.bookshelf.BookshelfViewModel
|
||||||
import io.legado.app.ui.main.explore.ExploreScreen
|
import io.legado.app.ui.main.explore.ExploreScreen
|
||||||
@@ -243,7 +244,10 @@ fun MainScreen(
|
|||||||
containerColor = GlassDefaults.glassColor(
|
containerColor = GlassDefaults.glassColor(
|
||||||
noBlurColor = BottomAppBarDefaults.containerColor,
|
noBlurColor = BottomAppBarDefaults.containerColor,
|
||||||
blurAlpha = GlassDefaults.DefaultBlurAlpha
|
blurAlpha = GlassDefaults.DefaultBlurAlpha
|
||||||
)
|
).let { baseColor ->
|
||||||
|
val opacity = (ThemeConfig.bottomBarOpacity.coerceIn(0, 100)) / 100f
|
||||||
|
baseColor.copy(alpha = (baseColor.alpha * opacity).coerceIn(0f, 1f))
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
val alwaysShowLabel = when (labelVisibilityMode) {
|
val alwaysShowLabel = when (labelVisibilityMode) {
|
||||||
"labeled" -> true
|
"labeled" -> true
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.legado.app.ui.main.bookshelf
|
package io.legado.app.ui.main.bookshelf
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.animateContentSize
|
import androidx.compose.animation.animateContentSize
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
@@ -95,7 +96,9 @@ fun BookshelfConfigSheet(
|
|||||||
|
|
||||||
// Layout Mode
|
// Layout Mode
|
||||||
val layoutMode =
|
val layoutMode =
|
||||||
if (isLandscape) BookshelfConfig.bookshelfLayoutModeLandscape else BookshelfConfig.bookshelfLayoutModePortrait
|
if (isLandscape) BookshelfConfig.bookshelfLayoutModeLandscape
|
||||||
|
else BookshelfConfig.bookshelfLayoutModePortrait
|
||||||
|
|
||||||
CompactDropdownSettingItem(
|
CompactDropdownSettingItem(
|
||||||
title = "布局模式",
|
title = "布局模式",
|
||||||
description = stringResource(if (isLandscape) R.string.screen_landscape else R.string.screen_portrait),
|
description = stringResource(if (isLandscape) R.string.screen_landscape else R.string.screen_portrait),
|
||||||
@@ -109,59 +112,61 @@ fun BookshelfConfigSheet(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (layoutMode == 1) {
|
AnimatedVisibility(
|
||||||
CompactDropdownSettingItem(
|
visible = layoutMode == 1
|
||||||
title = "网格样式",
|
) {
|
||||||
selectedValue = BookshelfConfig.bookshelfGridLayout.toString(),
|
Column(
|
||||||
displayEntries = stringArrayResource(R.array.bookshelf_grid_layout),
|
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
entryValues = Array(stringArrayResource(R.array.bookshelf_grid_layout).size) { it.toString() },
|
) {
|
||||||
imageVector = Icons.Default.ViewCompact,
|
CompactDropdownSettingItem(
|
||||||
onValueChange = { BookshelfConfig.bookshelfGridLayout = it.toInt() }
|
title = "网格样式",
|
||||||
)
|
selectedValue = BookshelfConfig.bookshelfGridLayout.toString(),
|
||||||
CompactSwitchSettingItem(
|
displayEntries = stringArrayResource(R.array.bookshelf_grid_layout),
|
||||||
title = "标题小字体",
|
entryValues = Array(stringArrayResource(R.array.bookshelf_grid_layout).size) { it.toString() },
|
||||||
checked = BookshelfConfig.bookshelfTitleSmallFont,
|
imageVector = Icons.Default.ViewCompact,
|
||||||
imageVector = Icons.Default.TextFormat,
|
onValueChange = { BookshelfConfig.bookshelfGridLayout = it.toInt() }
|
||||||
color = MaterialTheme.colorScheme.surface,
|
)
|
||||||
onCheckedChange = { BookshelfConfig.bookshelfTitleSmallFont = it }
|
|
||||||
)
|
|
||||||
|
|
||||||
CompactSwitchSettingItem(
|
CompactSwitchSettingItem(
|
||||||
title = "标题居中",
|
title = "标题小字体",
|
||||||
checked = BookshelfConfig.bookshelfTitleCenter,
|
checked = BookshelfConfig.bookshelfTitleSmallFont,
|
||||||
color = MaterialTheme.colorScheme.surface,
|
imageVector = Icons.Default.TextFormat,
|
||||||
onCheckedChange = { BookshelfConfig.bookshelfTitleCenter = it }
|
color = MaterialTheme.colorScheme.surface,
|
||||||
)
|
onCheckedChange = { BookshelfConfig.bookshelfTitleSmallFont = it }
|
||||||
} else {
|
)
|
||||||
CompactSwitchSettingItem(
|
|
||||||
title = "紧凑模式",
|
CompactSwitchSettingItem(
|
||||||
checked = BookshelfConfig.bookshelfLayoutCompact,
|
title = "标题居中",
|
||||||
imageVector = Icons.Default.ViewCompact,
|
checked = BookshelfConfig.bookshelfTitleCenter,
|
||||||
color = MaterialTheme.colorScheme.surface,
|
color = MaterialTheme.colorScheme.surface,
|
||||||
onCheckedChange = { BookshelfConfig.bookshelfLayoutCompact = it }
|
onCheckedChange = { BookshelfConfig.bookshelfTitleCenter = it }
|
||||||
)
|
)
|
||||||
CompactSwitchSettingItem(
|
}
|
||||||
title = "显示分隔线",
|
|
||||||
checked = BookshelfConfig.bookshelfShowDivider,
|
|
||||||
imageVector = Icons.Default.ViewCompact,
|
|
||||||
color = MaterialTheme.colorScheme.surface,
|
|
||||||
onCheckedChange = { BookshelfConfig.bookshelfShowDivider = it }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grid Count
|
AnimatedVisibility(
|
||||||
val gridCount =
|
visible = layoutMode != 1
|
||||||
if (isLandscape) BookshelfConfig.bookshelfLayoutGridLandscape else BookshelfConfig.bookshelfLayoutGridPortrait
|
) {
|
||||||
CompactSliderSettingItem(
|
Column(
|
||||||
title = stringResource(R.string.number_rows_columns),
|
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
value = gridCount.toFloat(),
|
) {
|
||||||
valueRange = 1f..15f,
|
CompactSwitchSettingItem(
|
||||||
steps = 14,
|
title = "紧凑模式",
|
||||||
onValueChange = {
|
checked = BookshelfConfig.bookshelfLayoutCompact,
|
||||||
if (isLandscape) BookshelfConfig.bookshelfLayoutGridLandscape = it.toInt()
|
imageVector = Icons.Default.ViewCompact,
|
||||||
else BookshelfConfig.bookshelfLayoutGridPortrait = it.toInt()
|
color = MaterialTheme.colorScheme.surface,
|
||||||
|
onCheckedChange = { BookshelfConfig.bookshelfLayoutCompact = it }
|
||||||
|
)
|
||||||
|
|
||||||
|
CompactSwitchSettingItem(
|
||||||
|
title = "显示分隔线",
|
||||||
|
checked = BookshelfConfig.bookshelfShowDivider,
|
||||||
|
imageVector = Icons.Default.ViewCompact,
|
||||||
|
color = MaterialTheme.colorScheme.surface,
|
||||||
|
onCheckedChange = { BookshelfConfig.bookshelfShowDivider = it }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
|
||||||
CompactSliderSettingItem(
|
CompactSliderSettingItem(
|
||||||
title = "标题最大行数",
|
title = "标题最大行数",
|
||||||
|
|||||||
+13
-5
@@ -74,32 +74,40 @@ object GlassTopAppBarDefaults {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return TopAppBarDefaults.topAppBarColors(
|
return TopAppBarDefaults.topAppBarColors(
|
||||||
containerColor = containerColor,
|
containerColor = applyTopBarOpacity(containerColor),
|
||||||
scrolledContainerColor = scrolledContainerColor
|
scrolledContainerColor = applyTopBarOpacity(scrolledContainerColor)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun containerColor(): Color {
|
fun containerColor(): Color {
|
||||||
return GlassDefaults.glassColor(
|
val baseColor = GlassDefaults.glassColor(
|
||||||
noBlurColor = MaterialTheme.colorScheme.surface,
|
noBlurColor = MaterialTheme.colorScheme.surface,
|
||||||
blurAlpha = GlassDefaults.TransparentAlpha
|
blurAlpha = GlassDefaults.TransparentAlpha
|
||||||
)
|
)
|
||||||
|
return applyTopBarOpacity(baseColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun scrolledContainerColor(): Color {
|
fun scrolledContainerColor(): Color {
|
||||||
return GlassDefaults.glassColor(
|
val baseColor = GlassDefaults.glassColor(
|
||||||
noBlurColor = MaterialTheme.colorScheme.surfaceContainer,
|
noBlurColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||||
blurAlpha = GlassDefaults.TransparentAlpha
|
blurAlpha = GlassDefaults.TransparentAlpha
|
||||||
)
|
)
|
||||||
|
return applyTopBarOpacity(baseColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun controlContainerColor(): Color {
|
fun controlContainerColor(): Color {
|
||||||
return GlassDefaults.glassColor(
|
val baseColor = GlassDefaults.glassColor(
|
||||||
noBlurColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
noBlurColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
||||||
blurAlpha = GlassDefaults.DefaultBlurAlpha
|
blurAlpha = GlassDefaults.DefaultBlurAlpha
|
||||||
)
|
)
|
||||||
|
return applyTopBarOpacity(baseColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun applyTopBarOpacity(color: Color): Color {
|
||||||
|
val opacity = (ThemeConfig.topBarOpacity.coerceIn(0, 100)) / 100f
|
||||||
|
return color.copy(alpha = (color.alpha * opacity).coerceIn(0f, 1f))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ fun SplicedColumnGroup(
|
|||||||
Card(
|
Card(
|
||||||
shape = RoundedCornerShape(16.dp),
|
shape = RoundedCornerShape(16.dp),
|
||||||
colors = CardDefaults.cardColors(containerColor = Color.Transparent),
|
colors = CardDefaults.cardColors(containerColor = Color.Transparent),
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.animateContentSize()
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
|
||||||
.animateContentSize(),
|
|
||||||
verticalArrangement = Arrangement.spacedBy(2.dp)
|
verticalArrangement = Arrangement.spacedBy(2.dp)
|
||||||
) {
|
) {
|
||||||
content()
|
content()
|
||||||
|
|||||||
@@ -1397,6 +1397,10 @@
|
|||||||
<string name="compose_engine">主题风格</string>
|
<string name="compose_engine">主题风格</string>
|
||||||
<string name="container_opacity">容器背景不透明度</string>
|
<string name="container_opacity">容器背景不透明度</string>
|
||||||
<string name="container_opacity_summary">%d</string>
|
<string name="container_opacity_summary">%d</string>
|
||||||
|
<string name="top_bar_opacity">顶栏不透明度</string>
|
||||||
|
<string name="top_bar_opacity_summary">%d</string>
|
||||||
|
<string name="bottom_bar_opacity">底栏不透明度</string>
|
||||||
|
<string name="bottom_bar_opacity_summary">%d</string>
|
||||||
<string name="web_service_auto_start">启动应用时打开Web服务</string>
|
<string name="web_service_auto_start">启动应用时打开Web服务</string>
|
||||||
<string name="read_aloud_preload">听书预加载数量</string>
|
<string name="read_aloud_preload">听书预加载数量</string>
|
||||||
<string name="read_aloud_preload_summary">%d</string>
|
<string name="read_aloud_preload_summary">%d</string>
|
||||||
|
|||||||
@@ -1216,4 +1216,8 @@
|
|||||||
<string name="auto_check_new_backup_s">打开软件时检查是否有新备份,有新备份时提示是否更新</string>
|
<string name="auto_check_new_backup_s">打开软件时检查是否有新备份,有新备份时提示是否更新</string>
|
||||||
<string name="welcome_book_folder_tip">设置本地书籍保存目录,后续也可在设置中修改。</string>
|
<string name="welcome_book_folder_tip">设置本地书籍保存目录,后续也可在设置中修改。</string>
|
||||||
<string name="welcome_book_folder_not_selected">未选择文件夹</string>
|
<string name="welcome_book_folder_not_selected">未选择文件夹</string>
|
||||||
|
<string name="top_bar_opacity">頂欄不透明度</string>
|
||||||
|
<string name="top_bar_opacity_summary">%d</string>
|
||||||
|
<string name="bottom_bar_opacity">底欄不透明度</string>
|
||||||
|
<string name="bottom_bar_opacity_summary">%d</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1218,4 +1218,8 @@
|
|||||||
<string name="auto_check_new_backup_s">打开软件时检查是否有新备份,有新备份时提示是否更新</string>
|
<string name="auto_check_new_backup_s">打开软件时检查是否有新备份,有新备份时提示是否更新</string>
|
||||||
<string name="welcome_book_folder_tip">设置本地书籍保存目录,后续也可在设置中修改。</string>
|
<string name="welcome_book_folder_tip">设置本地书籍保存目录,后续也可在设置中修改。</string>
|
||||||
<string name="welcome_book_folder_not_selected">未选择文件夹</string>
|
<string name="welcome_book_folder_not_selected">未选择文件夹</string>
|
||||||
|
<string name="top_bar_opacity">頂欄不透明度</string>
|
||||||
|
<string name="top_bar_opacity_summary">%d</string>
|
||||||
|
<string name="bottom_bar_opacity">底欄不透明度</string>
|
||||||
|
<string name="bottom_bar_opacity_summary">%d</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1401,6 +1401,10 @@
|
|||||||
<string name="compose_engine">主题风格</string>
|
<string name="compose_engine">主题风格</string>
|
||||||
<string name="container_opacity">容器背景不透明度</string>
|
<string name="container_opacity">容器背景不透明度</string>
|
||||||
<string name="container_opacity_summary">%d</string>
|
<string name="container_opacity_summary">%d</string>
|
||||||
|
<string name="top_bar_opacity">顶栏不透明度</string>
|
||||||
|
<string name="top_bar_opacity_summary">%d</string>
|
||||||
|
<string name="bottom_bar_opacity">底栏不透明度</string>
|
||||||
|
<string name="bottom_bar_opacity_summary">%d</string>
|
||||||
<string name="web_service_auto_start">启动应用时打开Web服务</string>
|
<string name="web_service_auto_start">启动应用时打开Web服务</string>
|
||||||
<string name="read_aloud_preload">听书预加载数量</string>
|
<string name="read_aloud_preload">听书预加载数量</string>
|
||||||
<string name="read_aloud_preload_summary">%d</string>
|
<string name="read_aloud_preload_summary">%d</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user