refactor(ui): отступы через Spacing, доп. цвета сводятся к тону схемы
This commit is contained in:
1 parent
6e8cbc952f
commit
f6257cb141
14 files changed
+126
-36
No files matched your search
@@ -52,7 +52,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
FreeTurnTheme(dynamicColor = dynamicTheme) {
|
FreeTurnTheme(dynamicColor = dynamicTheme) {
|
||||||
Surface(
|
Surface(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
color = MaterialTheme.colorScheme.background
|
color = MaterialTheme.colorScheme.surface
|
||||||
) {
|
) {
|
||||||
AppNavigation()
|
AppNavigation()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ fun EmptyState(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(Spacing.lg))
|
||||||
title?.let {
|
title?.let {
|
||||||
Text(it, style = MaterialTheme.typography.titleLarge, textAlign = TextAlign.Center)
|
Text(it, style = MaterialTheme.typography.titleLarge, textAlign = TextAlign.Center)
|
||||||
Spacer(Modifier.height(8.dp))
|
Spacer(Modifier.height(Spacing.sm))
|
||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
desc,
|
desc,
|
||||||
@@ -69,7 +69,7 @@ fun EmptyState(
|
|||||||
textAlign = TextAlign.Center
|
textAlign = TextAlign.Center
|
||||||
)
|
)
|
||||||
if (actionLabel != null && onAction != null) {
|
if (actionLabel != null && onAction != null) {
|
||||||
Spacer(Modifier.height(24.dp))
|
Spacer(Modifier.height(Spacing.xxl))
|
||||||
Button(shapes = ButtonDefaults.shapes(), onClick = onAction) { Text(actionLabel) }
|
Button(shapes = ButtonDefaults.shapes(), onClick = onAction) { Text(actionLabel) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,32 +4,27 @@ import androidx.compose.foundation.layout.Arrangement
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.shape.CornerSize
|
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import com.freeturn.app.ui.theme.Spacing
|
import com.freeturn.app.ui.theme.Spacing
|
||||||
|
|
||||||
// Сегментированная группа строк (M3 expressive, как в системных настройках Android 16):
|
// Сегментированная группа строк (M3 expressive, как в системных настройках Android 16):
|
||||||
// наружные углы группы большие, внутренние - маленькие, между элементами микро-зазор.
|
// наружные углы группы большие, внутренние - маленькие, между элементами микро-зазор.
|
||||||
|
|
||||||
// Внутренний радиус сегментированной группы (между элементами). Внешний - shapes.large,
|
|
||||||
// чтобы группа из одного элемента визуально совпадала с SettingsCard.
|
|
||||||
private val GroupInnerCorner = CornerSize(5.dp)
|
|
||||||
|
|
||||||
/** Форма элемента сегментированной группы по позиции (см. [SettingsGroup]). */
|
/** Форма элемента сегментированной группы по позиции (см. [SettingsGroup]). */
|
||||||
@Composable
|
@Composable
|
||||||
fun settingsItemShape(index: Int, count: Int): Shape {
|
fun settingsItemShape(index: Int, count: Int): Shape {
|
||||||
val outer = MaterialTheme.shapes.large.topStart
|
val outer = MaterialTheme.shapes.large.topStart
|
||||||
|
val inner = MaterialTheme.shapes.extraSmall.topStart
|
||||||
return RoundedCornerShape(
|
return RoundedCornerShape(
|
||||||
topStart = if (index == 0) outer else GroupInnerCorner,
|
topStart = if (index == 0) outer else inner,
|
||||||
topEnd = if (index == 0) outer else GroupInnerCorner,
|
topEnd = if (index == 0) outer else inner,
|
||||||
bottomStart = if (index == count - 1) outer else GroupInnerCorner,
|
bottomStart = if (index == count - 1) outer else inner,
|
||||||
bottomEnd = if (index == count - 1) outer else GroupInnerCorner
|
bottomEnd = if (index == count - 1) outer else inner
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
import com.freeturn.app.data.share.FreeturnLink
|
import com.freeturn.app.data.share.FreeturnLink
|
||||||
import com.freeturn.app.domain.share.LinkImportBus
|
import com.freeturn.app.domain.share.LinkImportBus
|
||||||
@@ -133,10 +132,10 @@ fun AddServerScreen(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(Modifier.height(24.dp))
|
Spacer(Modifier.height(Spacing.xxl))
|
||||||
|
|
||||||
SectionLabel(stringResource(R.string.add_methods_section))
|
SectionLabel(stringResource(R.string.add_methods_section))
|
||||||
Spacer(Modifier.height(8.dp))
|
Spacer(Modifier.height(Spacing.sm))
|
||||||
SettingsGroup {
|
SettingsGroup {
|
||||||
SettingsGroupItem(0, 4) {
|
SettingsGroupItem(0, 4) {
|
||||||
SettingsEntryRow(
|
SettingsEntryRow(
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
import com.freeturn.app.data.config.ClientConfig
|
import com.freeturn.app.data.config.ClientConfig
|
||||||
@@ -233,7 +232,7 @@ fun ClientSetupScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(Modifier.height(24.dp))
|
Spacer(Modifier.height(Spacing.xxl))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,11 +100,11 @@ internal fun ConnectionHero(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(Modifier.height(20.dp))
|
Spacer(Modifier.height(Spacing.xl))
|
||||||
|
|
||||||
StatusLabel(status = status, reducedMotion = reducedMotion)
|
StatusLabel(status = status, reducedMotion = reducedMotion)
|
||||||
|
|
||||||
Spacer(Modifier.height(10.dp))
|
Spacer(Modifier.height(Spacing.md))
|
||||||
|
|
||||||
StatsPill(status = status, kind = kind, uptimeText = uptimeText, showStreams = showStreams)
|
StatsPill(status = status, kind = kind, uptimeText = uptimeText, showStreams = showStreams)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,20 +82,20 @@ internal fun HomeEmptyState(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer(Modifier.height(24.dp))
|
Spacer(Modifier.height(Spacing.xxl))
|
||||||
Text(
|
Text(
|
||||||
stringResource(R.string.home_empty_title),
|
stringResource(R.string.home_empty_title),
|
||||||
style = MaterialTheme.typography.titleLarge,
|
style = MaterialTheme.typography.titleLarge,
|
||||||
textAlign = TextAlign.Center
|
textAlign = TextAlign.Center
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(8.dp))
|
Spacer(Modifier.height(Spacing.sm))
|
||||||
Text(
|
Text(
|
||||||
stringResource(R.string.home_empty_desc),
|
stringResource(R.string.home_empty_desc),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
textAlign = TextAlign.Center
|
textAlign = TextAlign.Center
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(24.dp))
|
Spacer(Modifier.height(Spacing.xxl))
|
||||||
Button(
|
Button(
|
||||||
shapes = ButtonDefaults.shapes(),
|
shapes = ButtonDefaults.shapes(),
|
||||||
onClick = onAddServer,
|
onClick = onAddServer,
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ internal fun ServersSheetContent(
|
|||||||
(it.client.serverAddress.takeIf { a -> a.isNotBlank() }
|
(it.client.serverAddress.takeIf { a -> a.isNotBlank() }
|
||||||
?: it.ssh.ip.takeIf { a -> a.isNotBlank() })?.redact(privacyMode)
|
?: it.ssh.ip.takeIf { a -> a.isNotBlank() })?.redact(privacyMode)
|
||||||
}
|
}
|
||||||
Spacer(Modifier.height(4.dp))
|
Spacer(Modifier.height(Spacing.xs))
|
||||||
Text(
|
Text(
|
||||||
sub.orEmpty(),
|
sub.orEmpty(),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
@@ -133,7 +133,7 @@ internal fun ServersSheetContent(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(Spacing.lg))
|
||||||
|
|
||||||
ProviderPicker(
|
ProviderPicker(
|
||||||
current = active?.client?.provider ?: Provider.RELAY,
|
current = active?.client?.provider ?: Provider.RELAY,
|
||||||
@@ -145,7 +145,7 @@ internal fun ServersSheetContent(
|
|||||||
modifier = Modifier.padding(horizontal = Spacing.lg)
|
modifier = Modifier.padding(horizontal = Spacing.lg)
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(Modifier.height(20.dp))
|
Spacer(Modifier.height(Spacing.xl))
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
stringResource(R.string.servers_sheet_title),
|
stringResource(R.string.servers_sheet_title),
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
import com.freeturn.app.ui.util.HapticUtil
|
import com.freeturn.app.ui.util.HapticUtil
|
||||||
import com.freeturn.app.domain.UpdateState
|
import com.freeturn.app.domain.UpdateState
|
||||||
import com.freeturn.app.ui.components.BusyProgressIndicator
|
import com.freeturn.app.ui.components.BusyProgressIndicator
|
||||||
|
import com.freeturn.app.ui.theme.Spacing
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Диалоги цикла обновления приложения: доступно -> качается -> готово к установке.
|
* Диалоги цикла обновления приложения: доступно -> качается -> готово к установке.
|
||||||
@@ -69,7 +69,7 @@ internal fun UpdateDialogs(
|
|||||||
text = {
|
text = {
|
||||||
Column {
|
Column {
|
||||||
Text(stringResource(R.string.update_downloading, state.progress))
|
Text(stringResource(R.string.update_downloading, state.progress))
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(Spacing.md))
|
||||||
BusyProgressIndicator(progress = { state.progress / 100f })
|
BusyProgressIndicator(progress = { state.progress / 100f })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
import com.freeturn.app.data.config.Provider
|
import com.freeturn.app.data.config.Provider
|
||||||
import com.freeturn.app.ui.util.HapticUtil
|
import com.freeturn.app.ui.util.HapticUtil
|
||||||
import com.freeturn.app.domain.SshConnectionState
|
import com.freeturn.app.domain.SshConnectionState
|
||||||
|
import com.freeturn.app.ui.components.FabClearance
|
||||||
import com.freeturn.app.ui.components.SectionLabel
|
import com.freeturn.app.ui.components.SectionLabel
|
||||||
import com.freeturn.app.ui.components.SettingsBackButton
|
import com.freeturn.app.ui.components.SettingsBackButton
|
||||||
import com.freeturn.app.ui.components.SettingsCard
|
import com.freeturn.app.ui.components.SettingsCard
|
||||||
@@ -296,7 +296,7 @@ fun ServerDetailScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(Modifier.height(88.dp))
|
Spacer(Modifier.height(FabClearance))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,12 +149,12 @@ private fun AboutHero(appVersion: String) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(Spacing.lg))
|
||||||
Text(
|
Text(
|
||||||
stringResource(R.string.turn_proxy_title),
|
stringResource(R.string.turn_proxy_title),
|
||||||
style = MaterialTheme.typography.headlineSmall
|
style = MaterialTheme.typography.headlineSmall
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(8.dp))
|
Spacer(Modifier.height(Spacing.sm))
|
||||||
Surface(
|
Surface(
|
||||||
shape = CircleShape,
|
shape = CircleShape,
|
||||||
color = MaterialTheme.colorScheme.secondaryContainer
|
color = MaterialTheme.colorScheme.secondaryContainer
|
||||||
@@ -166,7 +166,7 @@ private fun AboutHero(appVersion: String) {
|
|||||||
modifier = Modifier.padding(horizontal = Spacing.md, vertical = Spacing.xs)
|
modifier = Modifier.padding(horizontal = Spacing.md, vertical = Spacing.xs)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(Spacing.lg))
|
||||||
Text(
|
Text(
|
||||||
stringResource(R.string.about_description),
|
stringResource(R.string.about_description),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.freeturn.app.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import kotlin.math.atan2
|
||||||
|
import kotlin.math.cbrt
|
||||||
|
import kotlin.math.cos
|
||||||
|
import kotlin.math.hypot
|
||||||
|
import kotlin.math.pow
|
||||||
|
import kotlin.math.sin
|
||||||
|
|
||||||
|
internal fun Color.harmonizeWith(source: Color, maxShiftDegrees: Float = 15f): Color {
|
||||||
|
val (l, a, b) = toOklab()
|
||||||
|
val chroma = hypot(a, b)
|
||||||
|
if (chroma < NEUTRAL_CHROMA) return this
|
||||||
|
|
||||||
|
val (_, sourceA, sourceB) = source.toOklab()
|
||||||
|
if (hypot(sourceA, sourceB) < NEUTRAL_CHROMA) return this
|
||||||
|
|
||||||
|
val hue = atan2(b, a)
|
||||||
|
val maxShift = maxShiftDegrees * DEG_TO_RAD
|
||||||
|
val shift = shortestAngle(atan2(sourceB, sourceA) - hue).coerceIn(-maxShift, maxShift)
|
||||||
|
val shifted = hue + shift
|
||||||
|
|
||||||
|
return oklabToColor(l, chroma * cos(shifted), chroma * sin(shifted), alpha)
|
||||||
|
}
|
||||||
|
|
||||||
|
private const val NEUTRAL_CHROMA = 1e-4f
|
||||||
|
private const val DEG_TO_RAD = (Math.PI / 180.0).toFloat()
|
||||||
|
private const val TWO_PI = (2.0 * Math.PI).toFloat()
|
||||||
|
|
||||||
|
/** Разница тонов по короткой дуге: 350° -> 10° это +20°, а не -340°. */
|
||||||
|
private fun shortestAngle(radians: Float): Float {
|
||||||
|
var d = radians % TWO_PI
|
||||||
|
if (d > TWO_PI / 2f) d -= TWO_PI
|
||||||
|
if (d < -TWO_PI / 2f) d += TWO_PI
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Color.toOklab(): Triple<Float, Float, Float> {
|
||||||
|
val r = srgbToLinear(red)
|
||||||
|
val g = srgbToLinear(green)
|
||||||
|
val b = srgbToLinear(blue)
|
||||||
|
|
||||||
|
val lCone = cbrt(0.4122214708f * r + 0.5363325363f * g + 0.0514459929f * b)
|
||||||
|
val mCone = cbrt(0.2119034982f * r + 0.6806995451f * g + 0.1073969566f * b)
|
||||||
|
val sCone = cbrt(0.0883024619f * r + 0.2817188376f * g + 0.6299787005f * b)
|
||||||
|
|
||||||
|
return Triple(
|
||||||
|
0.2104542553f * lCone + 0.7936177850f * mCone - 0.0040720468f * sCone,
|
||||||
|
1.9779984951f * lCone - 2.4285922050f * mCone + 0.4505937099f * sCone,
|
||||||
|
0.0259040371f * lCone + 0.7827717662f * mCone - 0.8086757660f * sCone
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun oklabToColor(l: Float, a: Float, b: Float, alpha: Float): Color {
|
||||||
|
val lCone = (l + 0.3963377774f * a + 0.2158037573f * b).let { it * it * it }
|
||||||
|
val mCone = (l - 0.1055613458f * a - 0.0638541728f * b).let { it * it * it }
|
||||||
|
val sCone = (l - 0.0894841775f * a - 1.2914855480f * b).let { it * it * it }
|
||||||
|
|
||||||
|
// Сдвинутый тон может выпасть за sRGB - обрезаем по каналам.
|
||||||
|
return Color(
|
||||||
|
red = linearToSrgb(4.0767416621f * lCone - 3.3077115913f * mCone + 0.2309699292f * sCone),
|
||||||
|
green = linearToSrgb(-1.2684380046f * lCone + 2.6097574011f * mCone - 0.3413193965f * sCone),
|
||||||
|
blue = linearToSrgb(-0.0041960863f * lCone - 0.7034186147f * mCone + 1.7076147010f * sCone),
|
||||||
|
alpha = alpha
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun srgbToLinear(c: Float): Float =
|
||||||
|
if (c <= 0.04045f) c / 12.92f else ((c + 0.055f) / 1.055f).pow(2.4f)
|
||||||
|
|
||||||
|
private fun linearToSrgb(c: Float): Float {
|
||||||
|
// Обрезаем до гаммы: pow от отрицательного - NaN.
|
||||||
|
val v = c.coerceIn(0f, 1f)
|
||||||
|
return if (v <= 0.0031308f) v * 12.92f else 1.055f * v.pow(1f / 2.4f) - 0.055f
|
||||||
|
}
|
||||||
@@ -11,7 +11,9 @@ import androidx.compose.ui.graphics.Color
|
|||||||
* Дополнительная цветовая схема для ролей, которых нет в MaterialTheme.colorScheme:
|
* Дополнительная цветовая схема для ролей, которых нет в MaterialTheme.colorScheme:
|
||||||
* success / warning / info. Значения сгенерированы через Material Theme Builder
|
* success / warning / info. Значения сгенерированы через Material Theme Builder
|
||||||
* (seed: success #4CAF50, warning #E67E22, info #2196F3) и держат полный набор
|
* (seed: success #4CAF50, warning #E67E22, info #2196F3) и держат полный набор
|
||||||
* тональных пар, чтобы корректно пройти контраст 4.5:1 в light/dark.
|
* тональных пар, чтобы корректно пройти контраст 4.5:1 в light/dark. Тон сводится
|
||||||
|
* к colorScheme.primary в FreeTurnTheme ([harmonizedWith]) - сдвиг тона контраст пар
|
||||||
|
* не трогает.
|
||||||
*/
|
*/
|
||||||
@Immutable
|
@Immutable
|
||||||
data class ExtendedColorScheme(
|
data class ExtendedColorScheme(
|
||||||
@@ -62,6 +64,22 @@ private val extendedDark = ExtendedColorScheme(
|
|||||||
internal fun extendedColorSchemeFor(darkTheme: Boolean): ExtendedColorScheme =
|
internal fun extendedColorSchemeFor(darkTheme: Boolean): ExtendedColorScheme =
|
||||||
if (darkTheme) extendedDark else extendedLight
|
if (darkTheme) extendedDark else extendedLight
|
||||||
|
|
||||||
|
/** Схема, сведённая к тону [source] (обычно colorScheme.primary) - см. [harmonizeWith]. */
|
||||||
|
internal fun ExtendedColorScheme.harmonizedWith(source: Color) = ExtendedColorScheme(
|
||||||
|
success = success.harmonizeWith(source),
|
||||||
|
onSuccess = onSuccess.harmonizeWith(source),
|
||||||
|
successContainer = successContainer.harmonizeWith(source),
|
||||||
|
onSuccessContainer = onSuccessContainer.harmonizeWith(source),
|
||||||
|
warning = warning.harmonizeWith(source),
|
||||||
|
onWarning = onWarning.harmonizeWith(source),
|
||||||
|
warningContainer = warningContainer.harmonizeWith(source),
|
||||||
|
onWarningContainer = onWarningContainer.harmonizeWith(source),
|
||||||
|
info = info.harmonizeWith(source),
|
||||||
|
onInfo = onInfo.harmonizeWith(source),
|
||||||
|
infoContainer = infoContainer.harmonizeWith(source),
|
||||||
|
onInfoContainer = onInfoContainer.harmonizeWith(source),
|
||||||
|
)
|
||||||
|
|
||||||
internal val LocalExtendedColorScheme = staticCompositionLocalOf { extendedLight }
|
internal val LocalExtendedColorScheme = staticCompositionLocalOf { extendedLight }
|
||||||
|
|
||||||
@Suppress("UnusedReceiverParameter")
|
@Suppress("UnusedReceiverParameter")
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ fun FreeTurnTheme(
|
|||||||
else -> lightScheme
|
else -> lightScheme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val extendedScheme = remember(colorScheme.primary, darkTheme) {
|
||||||
|
extendedColorSchemeFor(darkTheme).harmonizedWith(colorScheme.primary)
|
||||||
|
}
|
||||||
val motionScheme = remember { MotionScheme.expressive() }
|
val motionScheme = remember { MotionScheme.expressive() }
|
||||||
|
|
||||||
val view = LocalView.current
|
val view = LocalView.current
|
||||||
@@ -140,7 +143,7 @@ fun FreeTurnTheme(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
LocalExtendedColorScheme provides extendedColorSchemeFor(darkTheme),
|
LocalExtendedColorScheme provides extendedScheme,
|
||||||
LocalReducedMotion provides reduceMotion
|
LocalReducedMotion provides reduceMotion
|
||||||
) {
|
) {
|
||||||
MaterialExpressiveTheme(
|
MaterialExpressiveTheme(
|
||||||
|
|||||||
Reference in new issue
Block a user