mirror of
https://github.com/kalarina-bit/Fogwave.git
synced 2026-11-22 08:06:09 +00:00
Add color styles and a station-colored fog option; compact About with MingCute icons
Styles match Matewave: Fogwave (default), Lavender, Peach, Mint, Sky and Device (Material You, Android 12+). The fog and the disc ring follow the style and no longer change with the station unless 'Fog in station color' is switched on. About now has an Appearance section and grouped link rows.
This commit is contained in:
@@ -11,11 +11,13 @@ import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.ui.Modifier
|
||||
import cc.skysparkle.fogwave.ui.screens.HomeScreen
|
||||
import cc.skysparkle.fogwave.ui.theme.AppThemeState
|
||||
import cc.skysparkle.fogwave.ui.theme.FogwaveTheme
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
AppThemeState.load(this)
|
||||
enableEdgeToEdge(
|
||||
statusBarStyle = SystemBarStyle.dark(Color.TRANSPARENT),
|
||||
navigationBarStyle = SystemBarStyle.dark(Color.TRANSPARENT)
|
||||
|
||||
@@ -1,40 +1,52 @@
|
||||
package cc.skysparkle.fogwave.ui.components
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.selection.selectable
|
||||
import androidx.compose.foundation.selection.toggleable
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.SwitchDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import cc.skysparkle.fogwave.BuildConfig
|
||||
import cc.skysparkle.fogwave.R
|
||||
import cc.skysparkle.fogwave.ui.theme.AppStyle
|
||||
import cc.skysparkle.fogwave.ui.theme.AppThemeState
|
||||
import cc.skysparkle.fogwave.ui.theme.GeoColors
|
||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||
|
||||
private const val REPOSITORY_URL = "https://git.skysparkle.cc/kalarina/Fogwave"
|
||||
@@ -48,92 +60,47 @@ fun AboutPanel(modifier: Modifier = Modifier) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 20.dp, vertical = 12.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
.padding(horizontal = 20.dp, vertical = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.shadow(4.dp, RoundedCornerShape(24.dp))
|
||||
.clip(RoundedCornerShape(24.dp))
|
||||
.background(LocalGeoColors.current.surfaceContainer)
|
||||
.border(1.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(24.dp))
|
||||
.padding(20.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(64.dp)
|
||||
.clip(RoundedCornerShape(20.dp)),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
AppIcon(
|
||||
resId = R.drawable.ic_fogwave_logo,
|
||||
contentDescription = stringResource(R.string.fogwave_logo_content_desc),
|
||||
size = 52.dp
|
||||
)
|
||||
}
|
||||
AppHeader()
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.app_name),
|
||||
style = MaterialTheme.typography.titleLarge.copy(
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
fontSize = 22.sp,
|
||||
letterSpacing = (-0.5).sp,
|
||||
color = LocalGeoColors.current.deepPurple
|
||||
)
|
||||
)
|
||||
|
||||
// Comes straight from versionName in app/build.gradle.kts, so it can never drift.
|
||||
Text(
|
||||
text = stringResource(R.string.about_version, BuildConfig.VERSION_NAME),
|
||||
style = MaterialTheme.typography.labelMedium.copy(
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
color = LocalGeoColors.current.primary
|
||||
),
|
||||
modifier = Modifier.testTag("about_version")
|
||||
)
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.about_description),
|
||||
style = MaterialTheme.typography.bodyMedium.copy(
|
||||
fontSize = 13.5.sp,
|
||||
lineHeight = 20.sp,
|
||||
color = LocalGeoColors.current.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center
|
||||
),
|
||||
modifier = Modifier.padding(top = 4.dp)
|
||||
)
|
||||
SectionLabel(stringResource(R.string.about_appearance))
|
||||
GroupCard {
|
||||
StylePicker()
|
||||
CardDivider()
|
||||
StationFogRow()
|
||||
}
|
||||
|
||||
AboutLinkCard(
|
||||
iconRes = R.drawable.ic_repo,
|
||||
iconTint = null,
|
||||
title = stringResource(R.string.about_my_repository),
|
||||
subtitle = REPOSITORY_URL.removePrefix("https://git.skysparkle.cc/"),
|
||||
trailingIconRes = R.drawable.ic_open_in_new,
|
||||
onClick = { context.openUrl(REPOSITORY_URL) },
|
||||
modifier = Modifier.testTag("github_repo_card")
|
||||
)
|
||||
|
||||
AboutLinkCard(
|
||||
iconRes = R.drawable.ic_privacy,
|
||||
title = stringResource(R.string.privacy_title),
|
||||
subtitle = stringResource(R.string.privacy_subtitle),
|
||||
trailingIconRes = R.drawable.ic_open_in_new,
|
||||
onClick = { context.openUrl(PRIVACY_POLICY_URL) },
|
||||
modifier = Modifier.testTag("privacy_card")
|
||||
)
|
||||
|
||||
AboutLinkCard(
|
||||
iconRes = R.drawable.ic_copyright,
|
||||
title = stringResource(R.string.licenses_title),
|
||||
subtitle = stringResource(R.string.licenses_subtitle),
|
||||
trailingIconRes = R.drawable.ic_chevron_right,
|
||||
onClick = { showLicenses = true },
|
||||
modifier = Modifier.testTag("licenses_card")
|
||||
)
|
||||
SectionLabel(stringResource(R.string.about_more))
|
||||
GroupCard {
|
||||
LinkRow(
|
||||
iconRes = R.drawable.ic_mc_code,
|
||||
title = stringResource(R.string.about_my_repository),
|
||||
subtitle = REPOSITORY_URL.removePrefix("https://"),
|
||||
external = true,
|
||||
onClick = { context.openUrl(REPOSITORY_URL) },
|
||||
modifier = Modifier.testTag("github_repo_card")
|
||||
)
|
||||
CardDivider()
|
||||
LinkRow(
|
||||
iconRes = R.drawable.ic_mc_shield,
|
||||
title = stringResource(R.string.privacy_title),
|
||||
subtitle = stringResource(R.string.privacy_subtitle),
|
||||
external = true,
|
||||
onClick = { context.openUrl(PRIVACY_POLICY_URL) },
|
||||
modifier = Modifier.testTag("privacy_card")
|
||||
)
|
||||
CardDivider()
|
||||
LinkRow(
|
||||
iconRes = R.drawable.ic_mc_copyright,
|
||||
title = stringResource(R.string.licenses_title),
|
||||
subtitle = stringResource(R.string.licenses_subtitle),
|
||||
external = false,
|
||||
onClick = { showLicenses = true },
|
||||
modifier = Modifier.testTag("licenses_card")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (showLicenses) {
|
||||
@@ -141,86 +108,324 @@ fun AboutPanel(modifier: Modifier = Modifier) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Logo, name and version in one row, the description underneath. */
|
||||
@Composable
|
||||
private fun AboutLinkCard(
|
||||
@DrawableRes iconRes: Int,
|
||||
title: String,
|
||||
subtitle: String,
|
||||
@DrawableRes trailingIconRes: Int,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
iconTint: Color? = LocalGeoColors.current.deepPurple
|
||||
) {
|
||||
val opensBrowser = trailingIconRes == R.drawable.ic_open_in_new
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.shadow(4.dp, RoundedCornerShape(20.dp))
|
||||
.clip(RoundedCornerShape(20.dp))
|
||||
.background(LocalGeoColors.current.surfaceContainer)
|
||||
.border(1.2.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(20.dp))
|
||||
.clickable(
|
||||
onClickLabel = if (opensBrowser) stringResource(R.string.about_open_in_browser) else null,
|
||||
role = Role.Button,
|
||||
onClick = onClick
|
||||
)
|
||||
.padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp)
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(48.dp)
|
||||
.clip(RoundedCornerShape(14.dp))
|
||||
.background(LocalGeoColors.current.primaryContainer)
|
||||
.border(1.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(14.dp)),
|
||||
contentAlignment = Alignment.Center
|
||||
private fun AppHeader() {
|
||||
val colors = LocalGeoColors.current
|
||||
GroupCard(contentPadding = 16.dp) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp)
|
||||
) {
|
||||
AppIcon(
|
||||
resId = iconRes,
|
||||
tint = iconTint ?: Color.Unspecified,
|
||||
size = if (iconTint == null) 32.dp else 26.dp
|
||||
)
|
||||
}
|
||||
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleSmall.copy(
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 15.sp,
|
||||
color = LocalGeoColors.current.deepPurple
|
||||
)
|
||||
)
|
||||
Text(
|
||||
text = subtitle,
|
||||
style = MaterialTheme.typography.bodySmall.copy(
|
||||
fontSize = 12.sp,
|
||||
color = LocalGeoColors.current.primary
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (opensBrowser) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(36.dp)
|
||||
.clip(CircleShape)
|
||||
.background(LocalGeoColors.current.primaryContainer),
|
||||
.size(52.dp)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.background(colors.primaryContainer),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
AppIcon(
|
||||
resId = trailingIconRes,
|
||||
tint = LocalGeoColors.current.deepPurple,
|
||||
size = 18.dp
|
||||
resId = R.drawable.ic_fogwave_logo,
|
||||
contentDescription = stringResource(R.string.fogwave_logo_content_desc),
|
||||
size = 40.dp
|
||||
)
|
||||
}
|
||||
} else {
|
||||
AppIcon(
|
||||
resId = trailingIconRes,
|
||||
tint = LocalGeoColors.current.onSurfaceVariant,
|
||||
size = 18.dp
|
||||
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
Text(
|
||||
text = stringResource(R.string.app_name),
|
||||
style = MaterialTheme.typography.titleLarge.copy(
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
fontSize = 21.sp,
|
||||
letterSpacing = (-0.4).sp,
|
||||
color = colors.deepPurple
|
||||
)
|
||||
)
|
||||
// Comes straight from versionName in app/build.gradle.kts, so it can never drift.
|
||||
Text(
|
||||
text = stringResource(R.string.about_version, BuildConfig.VERSION_NAME),
|
||||
style = MaterialTheme.typography.labelSmall.copy(
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 11.sp,
|
||||
color = colors.primary
|
||||
),
|
||||
modifier = Modifier
|
||||
.clip(CircleShape)
|
||||
.background(colors.primaryContainer)
|
||||
.padding(horizontal = 9.dp, vertical = 3.dp)
|
||||
.testTag("about_version")
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
text = stringResource(R.string.about_description),
|
||||
style = MaterialTheme.typography.bodySmall.copy(
|
||||
fontSize = 13.sp,
|
||||
lineHeight = 19.sp,
|
||||
color = colors.onSurfaceVariant
|
||||
),
|
||||
modifier = Modifier.padding(top = 12.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun StylePicker() {
|
||||
val context = LocalContext.current
|
||||
val colors = LocalGeoColors.current
|
||||
val selected = AppThemeState.style
|
||||
val styles = remember { AppStyle.available }
|
||||
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
RowHeader(iconRes = R.drawable.ic_mc_palette, title = stringResource(R.string.app_style_title))
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 14.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
styles.forEach { style ->
|
||||
StyleSwatch(
|
||||
style = style,
|
||||
preview = remember(style) { AppThemeState.colorsFor(context, style) },
|
||||
selected = style == selected,
|
||||
onClick = { AppThemeState.select(context, style) },
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
}
|
||||
AnimatedVisibility(visible = selected == AppStyle.DEVICE) {
|
||||
Text(
|
||||
text = stringResource(R.string.app_style_device_hint),
|
||||
style = MaterialTheme.typography.bodySmall.copy(
|
||||
fontSize = 12.sp,
|
||||
lineHeight = 17.sp,
|
||||
color = colors.onSurfaceVariant
|
||||
),
|
||||
modifier = Modifier.padding(top = 12.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun StyleSwatch(
|
||||
style: AppStyle,
|
||||
preview: GeoColors,
|
||||
selected: Boolean,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val colors = LocalGeoColors.current
|
||||
val ring by animateColorAsState(if (selected) colors.deepPurple else Color.Transparent, label = "swatch_ring")
|
||||
|
||||
Column(
|
||||
modifier = modifier
|
||||
.clip(RoundedCornerShape(14.dp))
|
||||
.selectable(selected = selected, role = Role.RadioButton, onClick = onClick)
|
||||
.padding(vertical = 6.dp)
|
||||
.testTag("style_${style.name.lowercase()}"),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp)
|
||||
) {
|
||||
// The outer ring shows the selection; inside, the style's accent over its background
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(42.dp)
|
||||
.border(2.dp, ring, CircleShape)
|
||||
.padding(4.dp)
|
||||
.clip(CircleShape)
|
||||
.background(preview.surfaceContainerHigh),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(24.dp)
|
||||
.clip(CircleShape)
|
||||
.background(preview.accentLavender),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
if (selected) {
|
||||
AppIcon(resId = R.drawable.ic_mc_check, tint = preview.onAccentLavender, size = 15.dp)
|
||||
}
|
||||
}
|
||||
}
|
||||
Text(
|
||||
text = stringResource(style.titleRes),
|
||||
style = MaterialTheme.typography.labelSmall.copy(
|
||||
fontSize = 11.sp,
|
||||
fontWeight = if (selected) FontWeight.Bold else FontWeight.Medium,
|
||||
color = if (selected) colors.deepPurple else colors.onSurfaceVariant
|
||||
),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun StationFogRow() {
|
||||
val context = LocalContext.current
|
||||
val colors = LocalGeoColors.current
|
||||
val checked = AppThemeState.stationFog
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.toggleable(
|
||||
value = checked,
|
||||
role = Role.Switch,
|
||||
onValueChange = { AppThemeState.setStationFog(context, it) }
|
||||
)
|
||||
.padding(16.dp)
|
||||
.testTag("station_fog_toggle"),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
RowIcon(R.drawable.ic_mc_fog)
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
RowTitle(stringResource(R.string.station_fog_title))
|
||||
RowSubtitle(stringResource(R.string.station_fog_subtitle), maxLines = 3)
|
||||
}
|
||||
// The row handles the tap, so the switch itself only shows the state
|
||||
Switch(
|
||||
checked = checked,
|
||||
onCheckedChange = null,
|
||||
colors = SwitchDefaults.colors(
|
||||
checkedThumbColor = colors.onAccentLavender,
|
||||
checkedTrackColor = colors.accentLavender,
|
||||
checkedBorderColor = colors.accentLavender,
|
||||
uncheckedThumbColor = colors.onSurfaceVariant,
|
||||
uncheckedTrackColor = colors.surfaceContainerHigh,
|
||||
uncheckedBorderColor = colors.outline
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LinkRow(
|
||||
@DrawableRes iconRes: Int,
|
||||
title: String,
|
||||
subtitle: String,
|
||||
external: Boolean,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(
|
||||
onClickLabel = if (external) stringResource(R.string.about_open_in_browser) else null,
|
||||
role = Role.Button,
|
||||
onClick = onClick
|
||||
)
|
||||
.padding(horizontal = 16.dp, vertical = 13.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
RowIcon(iconRes)
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
RowTitle(title)
|
||||
RowSubtitle(subtitle)
|
||||
}
|
||||
AppIcon(
|
||||
resId = if (external) R.drawable.ic_mc_external else R.drawable.ic_mc_right,
|
||||
tint = LocalGeoColors.current.onSurfaceVariant,
|
||||
size = 18.dp
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RowHeader(@DrawableRes iconRes: Int, title: String) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
RowIcon(iconRes)
|
||||
RowTitle(title)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RowIcon(@DrawableRes iconRes: Int) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(36.dp)
|
||||
.clip(RoundedCornerShape(11.dp))
|
||||
.background(LocalGeoColors.current.primaryContainer),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
AppIcon(resId = iconRes, tint = LocalGeoColors.current.primary, size = 20.dp)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RowTitle(text: String) {
|
||||
Text(
|
||||
text = text,
|
||||
style = MaterialTheme.typography.titleSmall.copy(
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 14.5.sp,
|
||||
color = LocalGeoColors.current.deepPurple
|
||||
),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RowSubtitle(text: String, maxLines: Int = 1) {
|
||||
Text(
|
||||
text = text,
|
||||
style = MaterialTheme.typography.bodySmall.copy(
|
||||
fontSize = 12.sp,
|
||||
lineHeight = 16.sp,
|
||||
color = LocalGeoColors.current.onSurfaceVariant
|
||||
),
|
||||
maxLines = maxLines,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SectionLabel(text: String) {
|
||||
Text(
|
||||
text = text.uppercase(),
|
||||
style = MaterialTheme.typography.labelSmall.copy(
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 11.sp,
|
||||
letterSpacing = 1.2.sp,
|
||||
color = LocalGeoColors.current.onSurfaceVariant
|
||||
),
|
||||
modifier = Modifier.padding(start = 6.dp, top = 8.dp)
|
||||
)
|
||||
}
|
||||
|
||||
/** Rows grouped on one rounded card, like a settings list. */
|
||||
@Composable
|
||||
private fun GroupCard(
|
||||
contentPadding: Dp = 0.dp,
|
||||
content: @Composable ColumnScope.() -> Unit
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(22.dp))
|
||||
.background(LocalGeoColors.current.surfaceContainer)
|
||||
.border(1.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(22.dp))
|
||||
.padding(contentPadding),
|
||||
content = content
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CardDivider() {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 64.dp)
|
||||
.height(1.dp)
|
||||
.background(LocalGeoColors.current.outlineVariant)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ import cc.skysparkle.fogwave.data.model.ExtraPlayerTab
|
||||
import cc.skysparkle.fogwave.data.model.RadioStation
|
||||
import cc.skysparkle.fogwave.player.AudioEffectsState
|
||||
import cc.skysparkle.fogwave.player.PlayerState
|
||||
import cc.skysparkle.fogwave.ui.theme.AppThemeState
|
||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@@ -120,7 +121,7 @@ fun NowPlayingSheet(
|
||||
)
|
||||
}
|
||||
val accent by animateColorAsState(
|
||||
targetValue = rememberStationArt(station).accentOr(colors.accentLavender),
|
||||
targetValue = rememberStationArt(station).takeIf { AppThemeState.stationFog }.accentOr(colors.accentLavender),
|
||||
animationSpec = tween(700),
|
||||
label = "page_accent"
|
||||
)
|
||||
|
||||
@@ -32,6 +32,7 @@ import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import cc.skysparkle.fogwave.data.model.RadioStation
|
||||
import cc.skysparkle.fogwave.ui.theme.AppThemeState
|
||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.min
|
||||
@@ -56,7 +57,7 @@ fun StationDisc(
|
||||
val colors = LocalGeoColors.current
|
||||
val art = rememberStationArt(station)
|
||||
val accent by animateColorAsState(
|
||||
targetValue = art.accentOr(colors.primary),
|
||||
targetValue = art.takeIf { AppThemeState.stationFog }.accentOr(colors.primary),
|
||||
animationSpec = tween(600),
|
||||
label = "disc_accent"
|
||||
)
|
||||
|
||||
@@ -73,6 +73,7 @@ import cc.skysparkle.fogwave.ui.components.TopBrandBar
|
||||
import cc.skysparkle.fogwave.ui.components.accentOr
|
||||
import cc.skysparkle.fogwave.ui.components.rememberStationArt
|
||||
import cc.skysparkle.fogwave.ui.components.stationDescription
|
||||
import cc.skysparkle.fogwave.ui.theme.AppThemeState
|
||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||
import cc.skysparkle.fogwave.ui.viewmodel.RadioViewModel
|
||||
|
||||
@@ -116,7 +117,10 @@ fun HomeScreen(
|
||||
|
||||
val radioListState = rememberLazyListState()
|
||||
val accent by animateColorAsState(
|
||||
targetValue = uiState.currentStation?.let { rememberStationArt(it) }.accentOr(LocalGeoColors.current.accentLavender),
|
||||
// The style's colour unless the user asked for each station's own
|
||||
targetValue = uiState.currentStation?.let { rememberStationArt(it) }
|
||||
.takeIf { AppThemeState.stationFog }
|
||||
.accentOr(LocalGeoColors.current.accentLavender),
|
||||
animationSpec = tween(700),
|
||||
label = "home_accent"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
package cc.skysparkle.fogwave.ui.theme
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.lerp
|
||||
import cc.skysparkle.fogwave.R
|
||||
|
||||
/** Colour styles, the same set as in Matewave. Every style is dark. */
|
||||
enum class AppStyle(@param:StringRes val titleRes: Int) {
|
||||
FOGWAVE(R.string.app_style_fogwave),
|
||||
LAVENDER(R.string.app_style_lavender),
|
||||
PEACH(R.string.app_style_peach),
|
||||
MINT(R.string.app_style_mint),
|
||||
SKY(R.string.app_style_sky),
|
||||
DEVICE(R.string.app_style_device);
|
||||
|
||||
companion object {
|
||||
/** Wallpaper colours exist from Android 12. */
|
||||
val deviceSupported: Boolean get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||
|
||||
val available: List<AppStyle> get() = entries.filter { it != DEVICE || deviceSupported }
|
||||
}
|
||||
}
|
||||
|
||||
/** The selected style, kept in compose state so every screen recolours at once. */
|
||||
object AppThemeState {
|
||||
private const val PREFS = "app_theme"
|
||||
private const val KEY_STYLE = "style"
|
||||
private const val KEY_STATION_FOG = "station_fog"
|
||||
|
||||
var style by mutableStateOf(AppStyle.FOGWAVE)
|
||||
private set
|
||||
|
||||
var colors by mutableStateOf(DarkGeoColors)
|
||||
private set
|
||||
|
||||
/** Fog and the disc ring take the playing station's colour instead of the style's. */
|
||||
var stationFog by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
/** Reads the saved settings; call before the first frame. */
|
||||
fun load(context: Context) {
|
||||
val prefs = prefs(context)
|
||||
val saved = prefs.getString(KEY_STYLE, null)
|
||||
stationFog = prefs.getBoolean(KEY_STATION_FOG, false)
|
||||
apply(context, AppStyle.entries.firstOrNull { it.name == saved } ?: AppStyle.FOGWAVE)
|
||||
}
|
||||
|
||||
fun select(context: Context, style: AppStyle) {
|
||||
prefs(context).edit().putString(KEY_STYLE, style.name).apply()
|
||||
apply(context, style)
|
||||
}
|
||||
|
||||
fun setStationFog(context: Context, enabled: Boolean) {
|
||||
prefs(context).edit().putBoolean(KEY_STATION_FOG, enabled).apply()
|
||||
stationFog = enabled
|
||||
}
|
||||
|
||||
/** Colours of a style, also used for the previews in the picker. */
|
||||
fun colorsFor(context: Context, style: AppStyle): GeoColors = when (style) {
|
||||
AppStyle.FOGWAVE -> DarkGeoColors
|
||||
AppStyle.LAVENDER -> styleColors(Color(0xFFC8B6FF), Color(0xFF1E1630), Color(0xFF0F0E14), Color(0xFF1A1822), Color(0xFF25222F))
|
||||
AppStyle.PEACH -> styleColors(Color(0xFFFFB59E), Color(0xFF2A1710), Color(0xFF12100E), Color(0xFF1D1A17), Color(0xFF28231F))
|
||||
AppStyle.MINT -> styleColors(Color(0xFF9EE7C8), Color(0xFF0F231B), Color(0xFF0D110F), Color(0xFF171C1A), Color(0xFF202724))
|
||||
AppStyle.SKY -> styleColors(Color(0xFFA5CBFF), Color(0xFF0F1A2A), Color(0xFF0D1014), Color(0xFF171B21), Color(0xFF20252D))
|
||||
AppStyle.DEVICE -> deviceColors(context)
|
||||
}
|
||||
|
||||
private fun apply(context: Context, requested: AppStyle) {
|
||||
val style = if (requested == AppStyle.DEVICE && !AppStyle.deviceSupported) AppStyle.FOGWAVE else requested
|
||||
this.style = style
|
||||
colors = colorsFor(context, style)
|
||||
}
|
||||
|
||||
private fun deviceColors(context: Context): GeoColors {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return DarkGeoColors
|
||||
val scheme = dynamicDarkColorScheme(context)
|
||||
return styleColors(
|
||||
accent = scheme.primary,
|
||||
onAccent = scheme.onPrimary,
|
||||
background = scheme.background,
|
||||
surface1 = scheme.surfaceContainer,
|
||||
surface2 = scheme.surfaceContainerHigh
|
||||
)
|
||||
}
|
||||
|
||||
private fun prefs(context: Context) =
|
||||
context.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the full set from a style's few colours. Pastel styles use their accent for buttons too,
|
||||
* with dark text on top, like in Matewave. The live dot and the favourite heart keep their own red.
|
||||
*/
|
||||
private fun styleColors(
|
||||
accent: Color,
|
||||
onAccent: Color,
|
||||
background: Color,
|
||||
surface1: Color,
|
||||
surface2: Color
|
||||
): GeoColors = DarkGeoColors.copy(
|
||||
background = background,
|
||||
surface = background,
|
||||
surfaceContainer = surface1,
|
||||
surfaceContainerHigh = surface2,
|
||||
onSurfaceVariant = lerp(Color(0xFF9AA0AA), accent, 0.12f),
|
||||
outline = lerp(surface2, Color.White, 0.3f),
|
||||
outlineVariant = lerp(surface2, Color.White, 0.06f),
|
||||
primary = accent,
|
||||
onPrimary = onAccent,
|
||||
primaryContainer = lerp(background, accent, 0.22f),
|
||||
onPrimaryContainer = lerp(accent, Color.White, 0.75f),
|
||||
secondary = lerp(accent, Color.White, 0.4f),
|
||||
onSecondary = onAccent,
|
||||
secondaryContainer = lerp(surface2, accent, 0.18f),
|
||||
onSecondaryContainer = lerp(accent, Color.White, 0.75f),
|
||||
accentLavender = accent,
|
||||
onAccentLavender = onAccent,
|
||||
deepPurple = lerp(Color.White, accent, 0.06f)
|
||||
)
|
||||
@@ -1,33 +1,36 @@
|
||||
package cc.skysparkle.fogwave.ui.theme
|
||||
|
||||
import androidx.compose.material3.ColorScheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.remember
|
||||
|
||||
private val DarkColorScheme = with(DarkGeoColors) {
|
||||
darkColorScheme(
|
||||
primary = primary,
|
||||
onPrimary = onPrimary,
|
||||
primaryContainer = primaryContainer,
|
||||
onPrimaryContainer = onPrimaryContainer,
|
||||
secondary = secondary,
|
||||
onSecondary = onSecondary,
|
||||
secondaryContainer = secondaryContainer,
|
||||
onSecondaryContainer = onSecondaryContainer,
|
||||
background = background,
|
||||
onBackground = onBackground,
|
||||
surface = surface,
|
||||
onSurface = onSurface,
|
||||
surfaceVariant = outlineVariant,
|
||||
onSurfaceVariant = onSurfaceVariant,
|
||||
outline = outline
|
||||
)
|
||||
}
|
||||
private fun GeoColors.toColorScheme(): ColorScheme = darkColorScheme(
|
||||
primary = primary,
|
||||
onPrimary = onPrimary,
|
||||
primaryContainer = primaryContainer,
|
||||
onPrimaryContainer = onPrimaryContainer,
|
||||
secondary = secondary,
|
||||
onSecondary = onSecondary,
|
||||
secondaryContainer = secondaryContainer,
|
||||
onSecondaryContainer = onSecondaryContainer,
|
||||
background = background,
|
||||
onBackground = onBackground,
|
||||
surface = surface,
|
||||
onSurface = onSurface,
|
||||
surfaceVariant = outlineVariant,
|
||||
onSurfaceVariant = onSurfaceVariant,
|
||||
outline = outline
|
||||
)
|
||||
|
||||
/** Always dark; the colours follow the style picked in About (see [AppThemeState]). */
|
||||
@Composable
|
||||
fun FogwaveTheme(content: @Composable () -> Unit) {
|
||||
CompositionLocalProvider(LocalGeoColors provides DarkGeoColors) {
|
||||
MaterialTheme(colorScheme = DarkColorScheme, typography = Typography, content = content)
|
||||
val colors = AppThemeState.colors
|
||||
val scheme = remember(colors) { colors.toColorScheme() }
|
||||
CompositionLocalProvider(LocalGeoColors provides colors) {
|
||||
MaterialTheme(colorScheme = scheme, typography = Typography, content = content)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user