feat(Zinnia): allow setting static text colours
This commit is contained in:
parent
9113ee5b24
commit
d62186f50b
2 changed files with 38 additions and 1 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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<T : Enum<T>>(
|
||||
|
|
@ -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<CheckedSetting>()
|
||||
|
||||
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<CheckedSetting>()
|
||||
val roleDotSettings = mutableListOf<CheckedSetting>()
|
||||
|
||||
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")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue