Skip to content

Commit

Permalink
[feature] Add a theme color
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyD666 committed Jan 5, 2025
1 parent 47c6488 commit 4bba342
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 49 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {
minSdk = 24
targetSdk = 35
versionCode = 25
versionName = "2.1-rc06"
versionName = "2.1-rc07"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ object ThemePreference : BasePreference<String> {
const val RED = "Red"
const val GREEN = "Green"
const val PURPLE = "Purple"
const val MAHIRO = "Mahiro"

val basicValues = arrayOf(BLUE, PINK, YELLOW, RED, GREEN, PURPLE)
val basicValues = arrayOf(BLUE, PINK, YELLOW, RED, GREEN, PURPLE, MAHIRO)

val values: Array<String>
get() {
Expand Down Expand Up @@ -65,6 +66,7 @@ object ThemePreference : BasePreference<String> {
RED -> context.getString(R.string.theme_red)
GREEN -> context.getString(R.string.theme_green)
PURPLE -> context.getString(R.string.theme_purple)
MAHIRO -> context.getString(R.string.theme_mahiro)
else -> context.getString(R.string.unknown)
}

Expand All @@ -76,8 +78,9 @@ object ThemePreference : BasePreference<String> {
PINK -> Color(0xFFFF7AA3)
YELLOW -> Color(0xFFFABE03)
RED -> Color(0xFFB90037)
GREEN -> Color(0xFF406836)
PURPLE -> Color(0xFF65558F)
GREEN -> Color(0xFF3F975B)
PURPLE -> Color(0xFF7E6195)
MAHIRO -> Color(0xFFEAD4CE)
else -> Color(0xFF006EBE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ import androidx.compose.material.icons.outlined.Colorize
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.PlainTooltip
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SegmentedButton
import androidx.compose.material3.SegmentedButtonDefaults
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TooltipBox
import androidx.compose.material3.TooltipDefaults
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTooltipState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -61,11 +65,11 @@ import com.skyd.anivu.model.preference.appearance.DateStylePreference
import com.skyd.anivu.model.preference.appearance.NavigationBarLabelPreference
import com.skyd.anivu.model.preference.appearance.TextFieldStylePreference
import com.skyd.anivu.model.preference.appearance.ThemePreference
import com.skyd.anivu.ui.component.PodAuraTopBar
import com.skyd.anivu.ui.component.PodAuraTopBarStyle
import com.skyd.anivu.ui.component.BaseSettingsItem
import com.skyd.anivu.ui.component.CategorySettingsItem
import com.skyd.anivu.ui.component.CheckableListMenu
import com.skyd.anivu.ui.component.PodAuraTopBar
import com.skyd.anivu.ui.component.PodAuraTopBarStyle
import com.skyd.anivu.ui.component.SwitchSettingsItem
import com.skyd.anivu.ui.local.LocalAmoledDarkMode
import com.skyd.anivu.ui.local.LocalDarkMode
Expand Down Expand Up @@ -341,6 +345,7 @@ fun Palettes(
context.activity.recreate()
}
},
contentDescription = { ThemePreference.toDisplayName(context, t) },
accents = remember(u) {
listOf(
TonalPalette.from(u.primary),
Expand All @@ -358,56 +363,68 @@ fun SelectableMiniPalette(
modifier: Modifier = Modifier,
selected: Boolean,
onClick: () -> Unit,
contentDescription: () -> String,
accents: List<TonalPalette>,
) {
Surface(
modifier = modifier,
shape = RoundedCornerShape(16.dp),
color = MaterialTheme.colorScheme.inverseOnSurface,
) {
Surface(
modifier = Modifier
.clickable { onClick() }
.padding(12.dp)
.size(50.dp),
shape = CircleShape,
color = Color(accents[0].tone(60)),
TooltipBox(
modifier = modifier,
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(),
tooltip = {
PlainTooltip {
Text(contentDescription())
}
},
state = rememberTooltipState()
) {
Box {
Surface(
modifier = Modifier
.size(50.dp)
.offset((-25).dp, 25.dp),
color = Color(accents[1].tone(85)),
) {}
Surface(
modifier = Modifier
.size(50.dp)
.offset(25.dp, 25.dp),
color = Color(accents[2].tone(75)),
) {}
val animationSpec = spring<Float>(stiffness = Spring.StiffnessMedium)
AnimatedVisibility(
visible = selected,
enter = scaleIn(animationSpec) + fadeIn(animationSpec),
exit = scaleOut(animationSpec) + fadeOut(animationSpec),
) {
Box(
Surface(
modifier = Modifier
.clickable(onClick = onClick)
.padding(12.dp)
.size(50.dp),
shape = CircleShape,
color = Color(accents[0].tone(60)),
) {
Box {
Surface(
modifier = Modifier
.size(50.dp)
.offset((-25).dp, 25.dp),
color = Color(accents[1].tone(85)),
) {}
Surface(
modifier = Modifier
.padding(10.dp)
.fillMaxSize()
.clip(CircleShape)
.background(MaterialTheme.colorScheme.primary),
contentAlignment = Alignment.Center
.size(50.dp)
.offset(25.dp, 25.dp),
color = Color(accents[2].tone(75)),
) {}
val animationSpec = spring<Float>(stiffness = Spring.StiffnessMedium)
AnimatedVisibility(
visible = selected,
enter = scaleIn(animationSpec) + fadeIn(animationSpec),
exit = scaleOut(animationSpec) + fadeOut(animationSpec),
) {
Icon(
imageVector = Icons.Outlined.Check,
contentDescription = "Checked",
Box(
modifier = Modifier
.padding(8.dp)
.size(16.dp),
tint = MaterialTheme.colorScheme.surface
)
.padding(10.dp)
.fillMaxSize()
.clip(CircleShape)
.background(MaterialTheme.colorScheme.primary),
contentAlignment = Alignment.Center
) {
Icon(
imageVector = Icons.Outlined.Check,
contentDescription = "Checked",
modifier = Modifier
.padding(8.dp)
.size(16.dp),
tint = MaterialTheme.colorScheme.surface
)
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/values-ja-rJP/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="theme_pink">後藤ひとり</string>
<string name="theme_green">古明地 こいし</string>
<string name="theme_blue">山田リョウ</string>
<string name="theme_yellow">伊地知虹夏</string>
<string name="theme_red">喜多郁代</string>
<string name="theme_purple">刻晴</string>
<string name="theme_mahiro">緒山まひろ</string>
</resources>
5 changes: 3 additions & 2 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@
<string name="appearance_screen_description">配置主题、外观等</string>
<string name="theme_dynamic">动态主题</string>
<string name="theme_pink">波奇</string>
<string name="theme_green">绿帽绿</string>
<string name="theme_green">古明地恋</string>
<string name="theme_blue">山田凉</string>
<string name="theme_yellow">虹夏</string>
<string name="theme_red">喜多</string>
<string name="theme_purple">基佬紫</string>
<string name="theme_purple">刻晴</string>
<string name="theme_mahiro">真寻</string>
<string name="player_config_screen_appearance_category">外观</string>
<string name="player_config_screen_show_85s_button">+85s 按钮</string>
<string name="player_config_screen_show_85s_button_description">在播放进度条上方显示 +85s 按钮</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@
<string name="appearance_screen_description">Configure theme, appearance</string>
<string name="theme_dynamic">Dynamic</string>
<string name="theme_pink">Bocchi</string>
<string name="theme_green">Green</string>
<string name="theme_green">Komeiji Koishi</string>
<string name="theme_blue">Ryo</string>
<string name="theme_yellow">Nijika</string>
<string name="theme_red">Kita</string>
<string name="theme_purple">Purple</string>
<string name="theme_purple">Keqing</string>
<string name="theme_mahiro">Mahiro</string>
<string name="player_forward_85s" translatable="false">+85s</string>
<string name="player_config_screen_appearance_category">Appearance</string>
<string name="player_config_screen_show_85s_button">+85s button</string>
Expand Down

0 comments on commit 4bba342

Please sign in to comment.