From d62186f50b2ce6b138a748313e0d01704e60b5e1 Mon Sep 17 00:00:00 2001 From: Cilly Leang Date: Wed, 8 Oct 2025 17:30:43 +1100 Subject: [PATCH] feat(Zinnia): allow setting static text colours --- .../kotlin/moe/lava/awoocord/zinnia/Zinnia.kt | 12 ++++++++- .../lava/awoocord/zinnia/ZinniaSettings.kt | 27 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/plugins/Zinnia/src/main/kotlin/moe/lava/awoocord/zinnia/Zinnia.kt b/plugins/Zinnia/src/main/kotlin/moe/lava/awoocord/zinnia/Zinnia.kt index fb0e334..e0d6b6c 100644 --- a/plugins/Zinnia/src/main/kotlin/moe/lava/awoocord/zinnia/Zinnia.kt +++ b/plugins/Zinnia/src/main/kotlin/moe/lava/awoocord/zinnia/Zinnia.kt @@ -82,11 +82,17 @@ class Zinnia : Plugin() { } view.setPadding(4.dp, 0, 4.dp, 0) - val (preferred, other) = if (isLight) { + var (preferred, other) = if (isLight) { Color.WHITE to Color.BLACK } else { Color.BLACK to Color.WHITE } + when (localSettings.blockMode) { + BlockMode.InvertedThemeOnly -> preferred = other + BlockMode.WhiteOnly -> preferred = Color.WHITE + BlockMode.BlackOnly -> preferred = Color.BLACK + else -> {} + } val colours = if (!localSettings.blockInverted) { Colours( @@ -109,6 +115,10 @@ class Zinnia : Plugin() { BlockMode.WcagOnly -> isWcag(colours) BlockMode.ApcaLightWcagDark -> if (isLight) isApca(colours) else isWcag(colours) BlockMode.WcagLightApcaDark -> if (isLight) isWcag(colours) else isApca(colours) + BlockMode.ThemeOnly, + BlockMode.InvertedThemeOnly, + BlockMode.WhiteOnly, + BlockMode.BlackOnly -> true } if (usePreferred) { diff --git a/plugins/Zinnia/src/main/kotlin/moe/lava/awoocord/zinnia/ZinniaSettings.kt b/plugins/Zinnia/src/main/kotlin/moe/lava/awoocord/zinnia/ZinniaSettings.kt index 3d44b19..45d750c 100644 --- a/plugins/Zinnia/src/main/kotlin/moe/lava/awoocord/zinnia/ZinniaSettings.kt +++ b/plugins/Zinnia/src/main/kotlin/moe/lava/awoocord/zinnia/ZinniaSettings.kt @@ -7,6 +7,7 @@ import com.aliucord.api.SettingsAPI import com.aliucord.fragments.SettingsPage import com.aliucord.settings.delegate import com.discord.views.CheckedSetting +import com.discord.views.RadioManager import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty @@ -20,6 +21,10 @@ enum class BlockMode { WcagLightApcaDark, ApcaOnly, WcagOnly, + ThemeOnly, + InvertedThemeOnly, + WhiteOnly, + BlackOnly, } class SettingsDelegateEnum>( @@ -59,9 +64,24 @@ object ZinniaSettings { @Suppress("MISSING_DEPENDENCY_CLASS", "MISSING_DEPENDENCY_SUPERCLASS") class Page : SettingsPage() { + private lateinit var manager: RadioManager private lateinit var mRoleDot: CheckedSetting private lateinit var mBlock: CheckedSetting + private val checks = mutableListOf() + + private fun createRadio(newMode: BlockMode, text: String, subtext: String? = null): CheckedSetting { + return Utils.createCheckedSetting(requireContext(), CheckedSetting.ViewType.RADIO, text, subtext).addTo(linearLayout) { + isChecked = blockMode == newMode + setOnCheckedListener { + for (check in checks) check.isChecked = false + blockMode = newMode + isChecked = true + } + checks.add(this) + } + } + override fun onViewBound(view: View) { super.onViewBound(view) setActionBarTitle(Zinnia.NAME) @@ -72,6 +92,13 @@ object ZinniaSettings { val blockSettings = mutableListOf() val roleDotSettings = mutableListOf() + addHeader(ctx, "Text colour") + createRadio(BlockMode.ApcaLightWcagDark, "Automatic", "Adjusts text colour based on role colour") + createRadio(BlockMode.ThemeOnly, "By theme", "Adjusts text colour based on theme") + createRadio(BlockMode.InvertedThemeOnly, "By theme (inverted)", "Same as above, but inverted") + createRadio(BlockMode.WhiteOnly, "White", "Force text colour to be white") + createRadio(BlockMode.BlackOnly, "Black", "Force text colour to be black") + /* addHeader(ctx, "Mode")