Fix scrollability in theme switcher

This commit is contained in:
Aleksandras Kostarevas 2023-08-22 15:52:49 +03:00
parent f91a626955
commit 226fea5d46
2 changed files with 230 additions and 151 deletions

View File

@ -262,8 +262,8 @@ fun RowScope.SuggestionItems(words: SuggestedWords, onClick: (i: Int) -> Unit) {
@Composable @Composable
fun ActionItem(action: Action, onSelect: (Action) -> Unit) { fun ActionItem(action: Action, onSelect: (Action) -> Unit) {
val col = MaterialTheme.colorScheme.secondary val col = MaterialTheme.colorScheme.secondaryContainer
val contentCol = MaterialTheme.colorScheme.onSecondary val contentCol = MaterialTheme.colorScheme.onSecondaryContainer
IconButton(onClick = { onSelect(action) }, modifier = Modifier IconButton(onClick = { onSelect(action) }, modifier = Modifier
.drawBehind { .drawBehind {
val radius = size.height / 4.0f val radius = size.height / 4.0f

View File

@ -7,6 +7,9 @@ import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.scrollable import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -18,6 +21,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import org.futo.inputmethod.latin.R import org.futo.inputmethod.latin.R
import org.futo.inputmethod.latin.uix.theme.DarkColorScheme import org.futo.inputmethod.latin.uix.theme.DarkColorScheme
@ -46,164 +50,239 @@ val ThemeAction = Action(
@Composable @Composable
override fun WindowContents(manager: KeyboardManagerForAction) { override fun WindowContents(manager: KeyboardManagerForAction) {
val context = LocalContext.current val context = LocalContext.current
Column(modifier = Modifier.fillMaxSize().scrollable(rememberScrollState(), Orientation.Vertical)) { LazyColumn(modifier = Modifier.padding(8.dp, 0.dp).fillMaxWidth()) {
Button(onClick = { item {
manager.updateTheme(DarkColorScheme)
}) {
Text("Default voice input theme")
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
Button(onClick = { Button(onClick = {
manager.updateTheme(dynamicLightColorScheme(context)) manager.updateTheme(DarkColorScheme)
}) { }) {
Text("Dynamic light color scheme") Text("Default voice input theme")
}
Button(onClick = {
manager.updateTheme(dynamicDarkColorScheme(context))
}) {
Text("Dynamic dark color scheme")
} }
} }
item {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
Button(onClick = {
manager.updateTheme(dynamicLightColorScheme(context))
}) {
Text("Dynamic light color scheme")
}
Button(onClick = { Button(onClick = {
val md_theme_light_primary = Color(0xFF6750A4) manager.updateTheme(dynamicDarkColorScheme(context))
val md_theme_light_onPrimary = Color(0xFFFFFFFF) }) {
val md_theme_light_primaryContainer = Color(0xFFEADDFF) Text("Dynamic dark color scheme")
val md_theme_light_onPrimaryContainer = Color(0xFF21005D) }
val md_theme_light_secondary = Color(0xFF625B71) }
val md_theme_light_onSecondary = Color(0xFFFFFFFF)
val md_theme_light_secondaryContainer = Color(0xFFE8DEF8)
val md_theme_light_onSecondaryContainer = Color(0xFF1D192B)
val md_theme_light_tertiary = Color(0xFF7D5260)
val md_theme_light_onTertiary = Color(0xFFFFFFFF)
val md_theme_light_tertiaryContainer = Color(0xFFFFD8E4)
val md_theme_light_onTertiaryContainer = Color(0xFF31111D)
val md_theme_light_error = Color(0xFFB3261E)
val md_theme_light_onError = Color(0xFFFFFFFF)
val md_theme_light_errorContainer = Color(0xFFF9DEDC)
val md_theme_light_onErrorContainer = Color(0xFF410E0B)
val md_theme_light_outline = Color(0xFF79747E)
val md_theme_light_background = Color(0xFFFFFBFE)
val md_theme_light_onBackground = Color(0xFF1C1B1F)
val md_theme_light_surface = Color(0xFFFFFBFE)
val md_theme_light_onSurface = Color(0xFF1C1B1F)
val md_theme_light_surfaceVariant = Color(0xFFE7E0EC)
val md_theme_light_onSurfaceVariant = Color(0xFF49454F)
val md_theme_light_inverseSurface = Color(0xFF313033)
val md_theme_light_inverseOnSurface = Color(0xFFF4EFF4)
val md_theme_light_inversePrimary = Color(0xFFD0BCFF)
val md_theme_light_shadow = Color(0xFF000000)
val md_theme_light_surfaceTint = Color(0xFF6750A4)
val md_theme_light_outlineVariant = Color(0xFFCAC4D0)
val md_theme_light_scrim = Color(0xFF000000)
manager.updateTheme(
lightColorScheme(
primary = md_theme_light_primary,
onPrimary = md_theme_light_onPrimary,
primaryContainer = md_theme_light_primaryContainer,
onPrimaryContainer = md_theme_light_onPrimaryContainer,
secondary = md_theme_light_secondary,
onSecondary = md_theme_light_onSecondary,
secondaryContainer = md_theme_light_secondaryContainer,
onSecondaryContainer = md_theme_light_onSecondaryContainer,
tertiary = md_theme_light_tertiary,
onTertiary = md_theme_light_onTertiary,
tertiaryContainer = md_theme_light_tertiaryContainer,
onTertiaryContainer = md_theme_light_onTertiaryContainer,
error = md_theme_light_error,
onError = md_theme_light_onError,
errorContainer = md_theme_light_errorContainer,
onErrorContainer = md_theme_light_onErrorContainer,
outline = md_theme_light_outline,
background = md_theme_light_background,
onBackground = md_theme_light_onBackground,
surface = md_theme_light_surface,
onSurface = md_theme_light_onSurface,
surfaceVariant = md_theme_light_surfaceVariant,
onSurfaceVariant = md_theme_light_onSurfaceVariant,
inverseSurface = md_theme_light_inverseSurface,
inverseOnSurface = md_theme_light_inverseOnSurface,
inversePrimary = md_theme_light_inversePrimary,
surfaceTint = md_theme_light_surfaceTint,
outlineVariant = md_theme_light_outlineVariant,
scrim = md_theme_light_scrim,
)
)
}) {
Text("Some random light theme")
} }
Button(onClick = { item {
val md_theme_dark_primary = Color(0xFFD0BCFF) Button(onClick = {
val md_theme_dark_onPrimary = Color(0xFF381E72) val md_theme_light_primary = Color(0xFF6750A4)
val md_theme_dark_primaryContainer = Color(0xFF4F378B) val md_theme_light_onPrimary = Color(0xFFFFFFFF)
val md_theme_dark_onPrimaryContainer = Color(0xFFEADDFF) val md_theme_light_primaryContainer = Color(0xFFEADDFF)
val md_theme_dark_secondary = Color(0xFFCCC2DC) val md_theme_light_onPrimaryContainer = Color(0xFF21005D)
val md_theme_dark_onSecondary = Color(0xFF332D41) val md_theme_light_secondary = Color(0xFF625B71)
val md_theme_dark_secondaryContainer = Color(0xFF4A4458) val md_theme_light_onSecondary = Color(0xFFFFFFFF)
val md_theme_dark_onSecondaryContainer = Color(0xFFE8DEF8) val md_theme_light_secondaryContainer = Color(0xFFE8DEF8)
val md_theme_dark_tertiary = Color(0xFFEFB8C8) val md_theme_light_onSecondaryContainer = Color(0xFF1D192B)
val md_theme_dark_onTertiary = Color(0xFF492532) val md_theme_light_tertiary = Color(0xFF7D5260)
val md_theme_dark_tertiaryContainer = Color(0xFF633B48) val md_theme_light_onTertiary = Color(0xFFFFFFFF)
val md_theme_dark_onTertiaryContainer = Color(0xFFFFD8E4) val md_theme_light_tertiaryContainer = Color(0xFFFFD8E4)
val md_theme_dark_error = Color(0xFFF2B8B5) val md_theme_light_onTertiaryContainer = Color(0xFF31111D)
val md_theme_dark_onError = Color(0xFF601410) val md_theme_light_error = Color(0xFFB3261E)
val md_theme_dark_errorContainer = Color(0xFF8C1D18) val md_theme_light_onError = Color(0xFFFFFFFF)
val md_theme_dark_onErrorContainer = Color(0xFFF9DEDC) val md_theme_light_errorContainer = Color(0xFFF9DEDC)
val md_theme_dark_outline = Color(0xFF938F99) val md_theme_light_onErrorContainer = Color(0xFF410E0B)
val md_theme_dark_background = Color(0xFF1C1B1F) val md_theme_light_outline = Color(0xFF79747E)
val md_theme_dark_onBackground = Color(0xFFE6E1E5) val md_theme_light_background = Color(0xFFFFFBFE)
val md_theme_dark_surface = Color(0xFF1C1B1F) val md_theme_light_onBackground = Color(0xFF1C1B1F)
val md_theme_dark_onSurface = Color(0xFFE6E1E5) val md_theme_light_surface = Color(0xFFFFFBFE)
val md_theme_dark_surfaceVariant = Color(0xFF49454F) val md_theme_light_onSurface = Color(0xFF1C1B1F)
val md_theme_dark_onSurfaceVariant = Color(0xFFCAC4D0) val md_theme_light_surfaceVariant = Color(0xFFE7E0EC)
val md_theme_dark_inverseSurface = Color(0xFFE6E1E5) val md_theme_light_onSurfaceVariant = Color(0xFF49454F)
val md_theme_dark_inverseOnSurface = Color(0xFF313033) val md_theme_light_inverseSurface = Color(0xFF313033)
val md_theme_dark_inversePrimary = Color(0xFF6750A4) val md_theme_light_inverseOnSurface = Color(0xFFF4EFF4)
val md_theme_dark_shadow = Color(0xFF000000) val md_theme_light_inversePrimary = Color(0xFFD0BCFF)
val md_theme_dark_surfaceTint = Color(0xFFD0BCFF) val md_theme_light_shadow = Color(0xFF000000)
val md_theme_dark_outlineVariant = Color(0xFF49454F) val md_theme_light_surfaceTint = Color(0xFF6750A4)
val md_theme_dark_scrim = Color(0xFF000000) val md_theme_light_outlineVariant = Color(0xFFCAC4D0)
val md_theme_light_scrim = Color(0xFF000000)
manager.updateTheme( manager.updateTheme(
darkColorScheme( lightColorScheme(
primary = md_theme_dark_primary, primary = md_theme_light_primary,
onPrimary = md_theme_dark_onPrimary, onPrimary = md_theme_light_onPrimary,
primaryContainer = md_theme_dark_primaryContainer, primaryContainer = md_theme_light_primaryContainer,
onPrimaryContainer = md_theme_dark_onPrimaryContainer, onPrimaryContainer = md_theme_light_onPrimaryContainer,
secondary = md_theme_dark_secondary, secondary = md_theme_light_secondary,
onSecondary = md_theme_dark_onSecondary, onSecondary = md_theme_light_onSecondary,
secondaryContainer = md_theme_dark_secondaryContainer, secondaryContainer = md_theme_light_secondaryContainer,
onSecondaryContainer = md_theme_dark_onSecondaryContainer, onSecondaryContainer = md_theme_light_onSecondaryContainer,
tertiary = md_theme_dark_tertiary, tertiary = md_theme_light_tertiary,
onTertiary = md_theme_dark_onTertiary, onTertiary = md_theme_light_onTertiary,
tertiaryContainer = md_theme_dark_tertiaryContainer, tertiaryContainer = md_theme_light_tertiaryContainer,
onTertiaryContainer = md_theme_dark_onTertiaryContainer, onTertiaryContainer = md_theme_light_onTertiaryContainer,
error = md_theme_dark_error, error = md_theme_light_error,
onError = md_theme_dark_onError, onError = md_theme_light_onError,
errorContainer = md_theme_dark_errorContainer, errorContainer = md_theme_light_errorContainer,
onErrorContainer = md_theme_dark_onErrorContainer, onErrorContainer = md_theme_light_onErrorContainer,
outline = md_theme_dark_outline, outline = md_theme_light_outline,
background = md_theme_dark_background, background = md_theme_light_background,
onBackground = md_theme_dark_onBackground, onBackground = md_theme_light_onBackground,
surface = md_theme_dark_surface, surface = md_theme_light_surface,
onSurface = md_theme_dark_onSurface, onSurface = md_theme_light_onSurface,
surfaceVariant = md_theme_dark_surfaceVariant, surfaceVariant = md_theme_light_surfaceVariant,
onSurfaceVariant = md_theme_dark_onSurfaceVariant, onSurfaceVariant = md_theme_light_onSurfaceVariant,
inverseSurface = md_theme_dark_inverseSurface, inverseSurface = md_theme_light_inverseSurface,
inverseOnSurface = md_theme_dark_inverseOnSurface, inverseOnSurface = md_theme_light_inverseOnSurface,
inversePrimary = md_theme_dark_inversePrimary, inversePrimary = md_theme_light_inversePrimary,
surfaceTint = md_theme_dark_surfaceTint, surfaceTint = md_theme_light_surfaceTint,
outlineVariant = md_theme_dark_outlineVariant, outlineVariant = md_theme_light_outlineVariant,
scrim = md_theme_dark_scrim, scrim = md_theme_light_scrim,
) )
) )
}) { }) {
Text("Some random dark theme") Text("Some random light theme")
}
Button(onClick = {
val md_theme_dark_primary = Color(0xFFD0BCFF)
val md_theme_dark_onPrimary = Color(0xFF381E72)
val md_theme_dark_primaryContainer = Color(0xFF4F378B)
val md_theme_dark_onPrimaryContainer = Color(0xFFEADDFF)
val md_theme_dark_secondary = Color(0xFFCCC2DC)
val md_theme_dark_onSecondary = Color(0xFF332D41)
val md_theme_dark_secondaryContainer = Color(0xFF4A4458)
val md_theme_dark_onSecondaryContainer = Color(0xFFE8DEF8)
val md_theme_dark_tertiary = Color(0xFFEFB8C8)
val md_theme_dark_onTertiary = Color(0xFF492532)
val md_theme_dark_tertiaryContainer = Color(0xFF633B48)
val md_theme_dark_onTertiaryContainer = Color(0xFFFFD8E4)
val md_theme_dark_error = Color(0xFFF2B8B5)
val md_theme_dark_onError = Color(0xFF601410)
val md_theme_dark_errorContainer = Color(0xFF8C1D18)
val md_theme_dark_onErrorContainer = Color(0xFFF9DEDC)
val md_theme_dark_outline = Color(0xFF938F99)
val md_theme_dark_background = Color(0xFF1C1B1F)
val md_theme_dark_onBackground = Color(0xFFE6E1E5)
val md_theme_dark_surface = Color(0xFF1C1B1F)
val md_theme_dark_onSurface = Color(0xFFE6E1E5)
val md_theme_dark_surfaceVariant = Color(0xFF49454F)
val md_theme_dark_onSurfaceVariant = Color(0xFFCAC4D0)
val md_theme_dark_inverseSurface = Color(0xFFE6E1E5)
val md_theme_dark_inverseOnSurface = Color(0xFF313033)
val md_theme_dark_inversePrimary = Color(0xFF6750A4)
val md_theme_dark_shadow = Color(0xFF000000)
val md_theme_dark_surfaceTint = Color(0xFFD0BCFF)
val md_theme_dark_outlineVariant = Color(0xFF49454F)
val md_theme_dark_scrim = Color(0xFF000000)
manager.updateTheme(
darkColorScheme(
primary = md_theme_dark_primary,
onPrimary = md_theme_dark_onPrimary,
primaryContainer = md_theme_dark_primaryContainer,
onPrimaryContainer = md_theme_dark_onPrimaryContainer,
secondary = md_theme_dark_secondary,
onSecondary = md_theme_dark_onSecondary,
secondaryContainer = md_theme_dark_secondaryContainer,
onSecondaryContainer = md_theme_dark_onSecondaryContainer,
tertiary = md_theme_dark_tertiary,
onTertiary = md_theme_dark_onTertiary,
tertiaryContainer = md_theme_dark_tertiaryContainer,
onTertiaryContainer = md_theme_dark_onTertiaryContainer,
error = md_theme_dark_error,
onError = md_theme_dark_onError,
errorContainer = md_theme_dark_errorContainer,
onErrorContainer = md_theme_dark_onErrorContainer,
outline = md_theme_dark_outline,
background = md_theme_dark_background,
onBackground = md_theme_dark_onBackground,
surface = md_theme_dark_surface,
onSurface = md_theme_dark_onSurface,
surfaceVariant = md_theme_dark_surfaceVariant,
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
inverseSurface = md_theme_dark_inverseSurface,
inverseOnSurface = md_theme_dark_inverseOnSurface,
inversePrimary = md_theme_dark_inversePrimary,
surfaceTint = md_theme_dark_surfaceTint,
outlineVariant = md_theme_dark_outlineVariant,
scrim = md_theme_dark_scrim,
)
)
}) {
Text("Some random dark theme")
}
Button(onClick = {
val md_theme_dark_primary = Color(0xFFD0BCFF)
val md_theme_dark_onPrimary = Color(0xFF381E72)
val md_theme_dark_primaryContainer = Color(0xFF4F378B)
val md_theme_dark_onPrimaryContainer = Color(0xFFEADDFF)
val md_theme_dark_secondary = Color(0xFFCCC2DC)
val md_theme_dark_onSecondary = Color(0xFF332D41)
val md_theme_dark_secondaryContainer = Color(0xFF4A4458)
val md_theme_dark_onSecondaryContainer = Color(0xFFE8DEF8)
val md_theme_dark_tertiary = Color(0xFFEFB8C8)
val md_theme_dark_onTertiary = Color(0xFF492532)
val md_theme_dark_tertiaryContainer = Color(0xFF633B48)
val md_theme_dark_onTertiaryContainer = Color(0xFFFFD8E4)
val md_theme_dark_error = Color(0xFFF2B8B5)
val md_theme_dark_onError = Color(0xFF601410)
val md_theme_dark_errorContainer = Color(0xFF8C1D18)
val md_theme_dark_onErrorContainer = Color(0xFFF9DEDC)
val md_theme_dark_outline = Color(0xFF938F99)
val md_theme_dark_background = Color(0xFF000000)
val md_theme_dark_onBackground = Color(0xFFE6E1E5)
val md_theme_dark_surface = Color(0xFF000000)
val md_theme_dark_onSurface = Color(0xFFE6E1E5)
val md_theme_dark_surfaceVariant = Color(0xFF49454F)
val md_theme_dark_onSurfaceVariant = Color(0xFFCAC4D0)
val md_theme_dark_inverseSurface = Color(0xFFE6E1E5)
val md_theme_dark_inverseOnSurface = Color(0xFF313033)
val md_theme_dark_inversePrimary = Color(0xFF6750A4)
val md_theme_dark_shadow = Color(0xFF000000)
val md_theme_dark_surfaceTint = Color(0xFFD0BCFF)
val md_theme_dark_outlineVariant = Color(0xFF49454F)
val md_theme_dark_scrim = Color(0xFF000000)
manager.updateTheme(
darkColorScheme(
primary = md_theme_dark_primary,
onPrimary = md_theme_dark_onPrimary,
primaryContainer = md_theme_dark_primaryContainer,
onPrimaryContainer = md_theme_dark_onPrimaryContainer,
secondary = md_theme_dark_secondary,
onSecondary = md_theme_dark_onSecondary,
secondaryContainer = md_theme_dark_secondaryContainer,
onSecondaryContainer = md_theme_dark_onSecondaryContainer,
tertiary = md_theme_dark_tertiary,
onTertiary = md_theme_dark_onTertiary,
tertiaryContainer = md_theme_dark_tertiaryContainer,
onTertiaryContainer = md_theme_dark_onTertiaryContainer,
error = md_theme_dark_error,
onError = md_theme_dark_onError,
errorContainer = md_theme_dark_errorContainer,
onErrorContainer = md_theme_dark_onErrorContainer,
outline = md_theme_dark_outline,
background = md_theme_dark_background,
onBackground = md_theme_dark_onBackground,
surface = md_theme_dark_surface,
onSurface = md_theme_dark_onSurface,
surfaceVariant = md_theme_dark_surfaceVariant,
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
inverseSurface = md_theme_dark_inverseSurface,
inverseOnSurface = md_theme_dark_inverseOnSurface,
inversePrimary = md_theme_dark_inversePrimary,
surfaceTint = md_theme_dark_surfaceTint,
outlineVariant = md_theme_dark_outlineVariant,
scrim = md_theme_dark_scrim,
)
)
}) {
Text("AMOLED dark")
}
} }
} }
} }