mirror of https://github.com/Ashinch/ReadYou.git
Add amoled dark theme
This commit is contained in:
parent
7933aa4d11
commit
58da4c8f2d
|
@ -27,7 +27,7 @@ fun DynamicSVGImage(
|
|||
val useDarkTheme = LocalDarkTheme.current.isDarkTheme()
|
||||
val tonalPalettes = LocalTonalPalettes.current
|
||||
var size by remember { mutableStateOf(IntSize.Zero) }
|
||||
val pic by remember(tonalPalettes, size) {
|
||||
val pic by remember(useDarkTheme, tonalPalettes, size) {
|
||||
mutableStateOf(
|
||||
PictureDrawable(
|
||||
SVG.getFromString(svgImageString.parseDynamicColor(tonalPalettes, useDarkTheme))
|
||||
|
|
|
@ -2,7 +2,6 @@ package me.ash.reader.ui.page.home.read
|
|||
|
||||
import android.util.Log
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
|
@ -77,7 +76,7 @@ fun ReadPage(
|
|||
}
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier.background(MaterialTheme.colorScheme.surface),
|
||||
containerColor = MaterialTheme.colorScheme.surface,
|
||||
topBar = {},
|
||||
content = {
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
|
|
|
@ -19,6 +19,8 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import me.ash.reader.ui.theme.palette.LocalTonalPalettes
|
||||
import me.ash.reader.ui.theme.palette.onDark
|
||||
|
||||
@Composable
|
||||
fun SettingItem(
|
||||
|
@ -31,6 +33,8 @@ fun SettingItem(
|
|||
onClick: () -> Unit,
|
||||
action: (@Composable () -> Unit)? = null
|
||||
) {
|
||||
val tonalPalettes = LocalTonalPalettes.current
|
||||
|
||||
Surface(
|
||||
modifier = modifier
|
||||
.clickable { onClick() }
|
||||
|
@ -71,7 +75,8 @@ fun SettingItem(
|
|||
Divider(
|
||||
modifier = Modifier
|
||||
.padding(start = 16.dp)
|
||||
.size(1.dp, 32.dp)
|
||||
.size(1.dp, 32.dp),
|
||||
color = tonalPalettes neutralVariant 80 onDark (tonalPalettes neutralVariant 30),
|
||||
)
|
||||
}
|
||||
Box(Modifier.padding(start = 16.dp)) {
|
||||
|
|
|
@ -81,10 +81,10 @@ fun DarkTheme(
|
|||
}
|
||||
Subtitle(
|
||||
modifier = Modifier.padding(horizontal = 24.dp),
|
||||
text = "其他",
|
||||
text = stringResource(R.string.other),
|
||||
)
|
||||
SettingItem(
|
||||
title = "Amoled 的深色主题",
|
||||
title = stringResource(R.string.amoled_dark_theme),
|
||||
onClick = {
|
||||
(!amoledDarkTheme).put(context, scope)
|
||||
},
|
||||
|
|
|
@ -6,6 +6,7 @@ import androidx.compose.material3.darkColorScheme
|
|||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import me.ash.reader.data.preference.LocalAmoledDarkTheme
|
||||
import me.ash.reader.data.preference.LocalDarkTheme
|
||||
|
||||
@Composable
|
||||
|
@ -41,6 +42,8 @@ fun dynamicLightColorScheme(): ColorScheme {
|
|||
@Composable
|
||||
fun dynamicDarkColorScheme(): ColorScheme {
|
||||
val palettes = LocalTonalPalettes.current
|
||||
val amoledDarkTheme = LocalAmoledDarkTheme.current
|
||||
|
||||
return darkColorScheme(
|
||||
primary = palettes primary 80,
|
||||
onPrimary = palettes primary 20,
|
||||
|
@ -57,7 +60,7 @@ fun dynamicDarkColorScheme(): ColorScheme {
|
|||
onTertiaryContainer = palettes tertiary 90,
|
||||
background = palettes neutral 10,
|
||||
onBackground = palettes neutral 90,
|
||||
surface = palettes neutral 10,
|
||||
surface = palettes neutral if (amoledDarkTheme.value) 0 else 10,
|
||||
onSurface = palettes neutral 90,
|
||||
surfaceVariant = palettes neutralVariant 30,
|
||||
onSurfaceVariant = palettes neutralVariant 80,
|
||||
|
|
|
@ -102,6 +102,10 @@
|
|||
<string name="style">样式</string>
|
||||
<string name="dark_theme">深色主题</string>
|
||||
<string name="use_device_theme">跟随系统设置</string>
|
||||
<string name="on">开启</string>
|
||||
<string name="off">关闭</string>
|
||||
<string name="amoled_dark_theme">Amoled 深色主题</string>
|
||||
<string name="other">其他</string>
|
||||
<string name="tonal_elevation">色调海拔</string>
|
||||
<string name="fonts">字体</string>
|
||||
<string name="basic_fonts">基本字体</string>
|
||||
|
|
|
@ -103,6 +103,10 @@
|
|||
<string name="style">Style</string>
|
||||
<string name="dark_theme">Dark Theme</string>
|
||||
<string name="use_device_theme">Use Device Theme</string>
|
||||
<string name="on">On</string>
|
||||
<string name="off">Off</string>
|
||||
<string name="other">Other</string>
|
||||
<string name="amoled_dark_theme">Amoled Dark Theme</string>
|
||||
<string name="tonal_elevation">Tonal Elevation</string>
|
||||
<string name="fonts">Fonts</string>
|
||||
<string name="basic_fonts">Basic Fonts</string>
|
||||
|
|
Loading…
Reference in New Issue