Add HotDog theme, tune some color choices

This commit is contained in:
Aleksandras Kostarevas 2024-08-01 10:15:38 +03:00
parent cef7e286cd
commit 049e2c288d
6 changed files with 141 additions and 26 deletions

View File

@ -36,6 +36,7 @@
<string name="steel_gray_theme_name">Steel Gray</string>
<string name="sunflower_theme_name">Sunflower</string>
<string name="cotton_candy_theme_name">Cotton Candy</string>
<string name="hot_dog_theme_name">Hot Dog</string>
<string name="dynamic_system_theme_name">Dynamic Auto</string>
<string name="dynamic_light_theme_name">Dynamic Light</string>

View File

@ -409,6 +409,7 @@ fun LazyItemScope.ActionItem(idx: Int, action: Action, onSelect: (Action) -> Uni
@Composable
fun ActionItemSmall(action: Action, onSelect: (Action) -> Unit, onLongSelect: (Action) -> Unit) {
val bgCol = LocalKeyboardScheme.current.backgroundContainer
val fgCol = LocalKeyboardScheme.current.onBackgroundContainer
val circleRadius = with(LocalDensity.current) {
16.dp.toPx()
@ -430,11 +431,12 @@ fun ActionItemSmall(action: Action, onSelect: (Action) -> Unit, onLongSelect: (A
action
)
},
contentAlignment = Alignment.Center) {
contentAlignment = Center
) {
Icon(
painter = painterResource(id = action.icon),
contentDescription = stringResource(action.name),
tint = contentColorFor(backgroundColor = bgCol),
tint = fgCol,
modifier = Modifier.size(16.dp)
)
}
@ -539,8 +541,7 @@ fun ActionItems(onSelect: (Action) -> Unit, onLongSelect: (Action) -> Unit) {
@Composable
fun ExpandActionsButton(isActionsOpen: Boolean, onClick: () -> Unit) {
val bgCol = LocalKeyboardScheme.current.backgroundContainer
val actionsContent = MaterialTheme.colorScheme.onSurface
val fgCol = LocalKeyboardScheme.current.onBackgroundContainer
val circleRadius = with(LocalDensity.current) {
16.dp.toPx()
@ -566,7 +567,7 @@ fun ExpandActionsButton(isActionsOpen: Boolean, onClick: () -> Unit) {
)
},
colors = IconButtonDefaults.iconButtonColors(contentColor = actionsContent)
colors = IconButtonDefaults.iconButtonColors(contentColor = fgCol)
) {
Icon(
painter = painterResource(id = R.drawable.chevron_right),

View File

@ -182,7 +182,6 @@ class BasicThemeProvider(val context: Context, val colorScheme: KeyboardColorSch
colorScheme.surface.toArgb()
}
val ratio = 1.5f
val keyColor = if(keyBorders) {
colorScheme.backgroundContainer.toArgb()
} else {
@ -197,29 +196,38 @@ class BasicThemeProvider(val context: Context, val colorScheme: KeyboardColorSch
transparent
}
val onKeyColor = if(keyBorders) {
colorScheme.onBackgroundContainer.toArgb()
} else {
onBackground
}
val onKeyColorHalf = Color(onKeyColor).copy(alpha = 0.5f).toArgb()
val onKeyColorThird = Color(onKeyColor).copy(alpha = 0.33f).toArgb()
val enterKeyBackground = if(expertMode) { functionalKeyColor } else { primary }
val enterKeyForeground = if(expertMode) { onBackgroundThird } else { onPrimary }
colors[R.styleable.Keyboard_Key_keyTextColor] = onBackground
colors[R.styleable.Keyboard_Key_keyTextInactivatedColor] = onBackgroundHalf
colors[R.styleable.Keyboard_Key_keyTextColor] = onKeyColor
colors[R.styleable.Keyboard_Key_keyTextInactivatedColor] = onKeyColorHalf
colors[R.styleable.Keyboard_Key_keyPressedTextColor] = onPrimary
colors[R.styleable.Keyboard_Key_keyTextShadowColor] = 0
colors[R.styleable.Keyboard_Key_actionKeyTextColor] = enterKeyForeground
colors[R.styleable.Keyboard_Key_functionalTextColor] = onBackground
colors[R.styleable.Keyboard_Key_keyHintLetterColor] = onBackgroundHalf
colors[R.styleable.Keyboard_Key_keyHintLabelColor] = onBackgroundHalf
colors[R.styleable.Keyboard_Key_keyShiftedLetterHintInactivatedColor] = onBackgroundHalf
colors[R.styleable.Keyboard_Key_keyShiftedLetterHintActivatedColor] = onBackgroundHalf
colors[R.styleable.Keyboard_Key_functionalTextColor] = onKeyColor
colors[R.styleable.Keyboard_Key_keyHintLetterColor] = onKeyColorHalf
colors[R.styleable.Keyboard_Key_keyHintLabelColor] = onKeyColorHalf
colors[R.styleable.Keyboard_Key_keyShiftedLetterHintInactivatedColor] = onKeyColorHalf
colors[R.styleable.Keyboard_Key_keyShiftedLetterHintActivatedColor] = onKeyColorHalf
colors[R.styleable.Keyboard_Key_keyPreviewTextColor] = onSecondary
colors[R.styleable.MainKeyboardView_languageOnSpacebarTextColor] = onBackgroundHalf
colors[R.styleable.MainKeyboardView_languageOnSpacebarTextColor] = onKeyColorHalf
colors[R.styleable.MainKeyboardView_gestureTrailColor] = primary
colors[R.styleable.MainKeyboardView_slidingKeyInputPreviewColor] = primary
addIcon(KeyboardIconsSet.NAME_SHIFT_KEY, R.drawable.shift, onBackground)
addIcon(KeyboardIconsSet.NAME_SHIFT_KEY_SHIFTED, R.drawable.shiftshifted, onBackground)
addIcon(KeyboardIconsSet.NAME_DELETE_KEY, R.drawable.delete, onBackground)
addIcon(KeyboardIconsSet.NAME_SETTINGS_KEY, R.drawable.settings, onBackground)
addIcon(KeyboardIconsSet.NAME_SPACE_KEY, null, onBackground)
addIcon(KeyboardIconsSet.NAME_SHIFT_KEY, R.drawable.shift, onKeyColor)
addIcon(KeyboardIconsSet.NAME_SHIFT_KEY_SHIFTED, R.drawable.shiftshifted, onKeyColor)
addIcon(KeyboardIconsSet.NAME_DELETE_KEY, R.drawable.delete, onKeyColor)
addIcon(KeyboardIconsSet.NAME_SETTINGS_KEY, R.drawable.settings, onKeyColor)
addIcon(KeyboardIconsSet.NAME_SPACE_KEY, null, onKeyColor)
addIcon(KeyboardIconsSet.NAME_ENTER_KEY, R.drawable.sym_keyboard_return_lxx_light, enterKeyForeground)
addIcon(KeyboardIconsSet.NAME_GO_KEY, R.drawable.sym_keyboard_go_lxx_light, enterKeyForeground)
addIcon(KeyboardIconsSet.NAME_SEARCH_KEY, R.drawable.sym_keyboard_search_lxx_light, enterKeyForeground)
@ -227,21 +235,21 @@ class BasicThemeProvider(val context: Context, val colorScheme: KeyboardColorSch
addIcon(KeyboardIconsSet.NAME_NEXT_KEY, R.drawable.sym_keyboard_next_lxx_light, enterKeyForeground)
addIcon(KeyboardIconsSet.NAME_DONE_KEY, R.drawable.sym_keyboard_done_lxx_light, enterKeyForeground)
addIcon(KeyboardIconsSet.NAME_PREVIOUS_KEY, R.drawable.sym_keyboard_previous_lxx_light, enterKeyForeground)
addIcon(KeyboardIconsSet.NAME_TAB_KEY, R.drawable.sym_keyboard_tab_holo_dark, onBackground) // TODO: Correct tint
addIcon(KeyboardIconsSet.NAME_ZWNJ_KEY, R.drawable.sym_keyboard_zwnj_lxx_dark, onBackground)
addIcon(KeyboardIconsSet.NAME_TAB_KEY, R.drawable.sym_keyboard_tab_holo_dark, onKeyColor) // TODO: Correct tint
addIcon(KeyboardIconsSet.NAME_ZWNJ_KEY, R.drawable.sym_keyboard_zwnj_lxx_dark, onKeyColor)
addIcon(KeyboardIconsSet.NAME_ZWJ_KEY, R.drawable.sym_keyboard_zwj_lxx_dark, onPrimary)
addIcon(KeyboardIconsSet.NAME_EMOJI_ACTION_KEY, R.drawable.smile, onPrimary)
addIcon(KeyboardIconsSet.NAME_EMOJI_NORMAL_KEY, R.drawable.smile, onBackground)
addIcon(KeyboardIconsSet.NAME_EMOJI_NORMAL_KEY, R.drawable.smile, onKeyColor)
// Add by name (action_emoji)
AllActionsMap.forEach { (i, it) ->
addIcon("action_${i}", it.icon, onBackground)
addIcon("action_${i}", it.icon, onKeyColor)
}
// Add by id (action_0)
AllActions.forEachIndexed { i, it ->
addIcon("action_${i}", it.icon, onBackground)
addIcon("action_${i}", it.icon, onKeyColor)
}
if(!showKeyHints) {
@ -257,7 +265,7 @@ class BasicThemeProvider(val context: Context, val colorScheme: KeyboardColorSch
// Note: We don't fully hide some things, but fade them away as they may be important landmarks
colors[R.styleable.Keyboard_Key_functionalTextColor] = onBackgroundThird
colors[R.styleable.Keyboard_Key_functionalTextColor] = onKeyColorThird
}
keyboardBackground = coloredRectangle(primaryKeyboardColor)

View File

@ -11,7 +11,7 @@ val LocalKeyboardScheme = staticCompositionLocalOf {
wrapColorScheme(lightColorScheme())
}
class ExtraColors(
data class ExtraColors(
val backgroundContainer: Color,
val backgroundContainerDim: Color,
val onBackgroundContainer: Color,

View File

@ -13,6 +13,7 @@ import org.futo.inputmethod.latin.uix.theme.presets.DynamicDarkTheme
import org.futo.inputmethod.latin.uix.theme.presets.DynamicLightTheme
import org.futo.inputmethod.latin.uix.theme.presets.DynamicSystemTheme
import org.futo.inputmethod.latin.uix.theme.presets.Emerald
import org.futo.inputmethod.latin.uix.theme.presets.HotDog
import org.futo.inputmethod.latin.uix.theme.presets.Snowfall
import org.futo.inputmethod.latin.uix.theme.presets.SteelGray
import org.futo.inputmethod.latin.uix.theme.presets.Sunflower
@ -46,6 +47,7 @@ val ThemeOptions = mapOf(
DeepSeaLight.key to DeepSeaLight,
DeepSeaDark.key to DeepSeaDark,
HotDog.key to HotDog
)
val ThemeOptionKeys = ThemeOptions.keys

View File

@ -0,0 +1,103 @@
package org.futo.inputmethod.latin.uix.theme.presets
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import org.futo.inputmethod.latin.R
import org.futo.inputmethod.latin.uix.theme.ThemeOption
import org.futo.inputmethod.latin.uix.theme.selector.ThemePreview
import org.futo.inputmethod.latin.uix.wrapColorScheme
private val primaryLight = Color(0xFFC4FF00)
private val onPrimaryLight = Color(0xFF000000)
private val primaryContainerLight = Color(0xFFC0C016)
private val onPrimaryContainerLight = Color(0xFF1A3300)
private val secondaryLight = primaryLight
private val onSecondaryLight = onPrimaryLight
private val secondaryContainerLight = primaryContainerLight
private val onSecondaryContainerLight = onPrimaryContainerLight
private val tertiaryLight = primaryLight
private val onTertiaryLight = onPrimaryLight
private val tertiaryContainerLight = primaryContainerLight
private val onTertiaryContainerLight = onPrimaryContainerLight
private val errorLight = Color(0xFFFF0000)
private val onErrorLight = Color(0xFFFFFFFF)
private val errorContainerLight = Color(0xFFFFDAD6)
private val onErrorContainerLight = Color(0xFF410002)
private val backgroundLight = Color(0xFFFF0000)
private val onBackgroundLight = Color(0xFFFFFFFF)
private val surfaceLight = backgroundLight
private val onSurfaceLight = onBackgroundLight
private val surfaceVariantLight = surfaceLight
private val onSurfaceVariantLight = onSurfaceLight
private val outlineLight = Color(0xFFFFFF00)
private val outlineVariantLight = Color(0xFFFFFF00)
private val scrimLight = Color(0xFF000000)
private val inverseSurfaceLight = Color(0xFF000000)
private val inverseOnSurfaceLight = Color(0xFFFFFFFF)
private val inversePrimaryLight = Color(0xFFFFFFFF)
private val backgroundContainerLight = Color(0xFFFFEB3B)
private val backgroundContainerDimLight = Color(0xFFFFC107)
private val onBackgroundContainerLight = Color(0xFF000000)
private val lightScheme = lightColorScheme(
primary = primaryLight,
onPrimary = onPrimaryLight,
primaryContainer = primaryContainerLight,
onPrimaryContainer = onPrimaryContainerLight,
secondary = secondaryLight,
onSecondary = onSecondaryLight,
secondaryContainer = secondaryContainerLight,
onSecondaryContainer = onSecondaryContainerLight,
tertiary = tertiaryLight,
onTertiary = onTertiaryLight,
tertiaryContainer = tertiaryContainerLight,
onTertiaryContainer = onTertiaryContainerLight,
error = errorLight,
onError = onErrorLight,
errorContainer = errorContainerLight,
onErrorContainer = onErrorContainerLight,
background = backgroundLight,
onBackground = onBackgroundLight,
surface = surfaceLight,
onSurface = onSurfaceLight,
surfaceVariant = surfaceVariantLight,
onSurfaceVariant = onSurfaceVariantLight,
outline = outlineLight,
outlineVariant = outlineVariantLight,
scrim = scrimLight,
inverseSurface = inverseSurfaceLight,
inverseOnSurface = inverseOnSurfaceLight,
inversePrimary = inversePrimaryLight,
)
val HotDog = ThemeOption(
dynamic = false,
key = "HotDog",
name = R.string.hot_dog_theme_name,
available = { true }
) {
wrapColorScheme(lightScheme).let {
it.copy(
base = it.base,
extended = it.extended.copy(
backgroundContainer = backgroundContainerLight,
backgroundContainerDim = backgroundContainerDimLight,
onBackgroundContainer = onBackgroundContainerLight
)
)
}
}
@Composable
@Preview
private fun PreviewThemeLight() {
ThemePreview(HotDog)
}