|
|
@ -21,6 +21,7 @@ import androidx.compose.material3.ColorScheme
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.dynamicDarkColorScheme
|
|
|
|
import androidx.compose.material3.dynamicDarkColorScheme
|
|
|
|
import androidx.compose.material3.dynamicLightColorScheme
|
|
|
|
import androidx.compose.material3.dynamicLightColorScheme
|
|
|
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
import androidx.compose.ui.test.junit4.createComposeRule
|
|
|
|
import androidx.compose.ui.test.junit4.createComposeRule
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
@ -62,16 +63,9 @@ class ThemeTest {
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
val colorScheme = LightDefaultColorScheme
|
|
|
|
val colorScheme = LightDefaultColorScheme
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
val gradientColors = GradientColors(
|
|
|
|
val gradientColors = defaultGradientColors(colorScheme)
|
|
|
|
top = colorScheme.inverseOnSurface,
|
|
|
|
|
|
|
|
bottom = colorScheme.primaryContainer,
|
|
|
|
|
|
|
|
container = colorScheme.surface
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
val backgroundTheme = BackgroundTheme(
|
|
|
|
val backgroundTheme = defaultBackgroundTheme(colorScheme)
|
|
|
|
color = colorScheme.surface,
|
|
|
|
|
|
|
|
tonalElevation = 2.dp
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -87,16 +81,9 @@ class ThemeTest {
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
val colorScheme = DarkDefaultColorScheme
|
|
|
|
val colorScheme = DarkDefaultColorScheme
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
val gradientColors = GradientColors(
|
|
|
|
val gradientColors = defaultGradientColors(colorScheme)
|
|
|
|
top = colorScheme.inverseOnSurface,
|
|
|
|
|
|
|
|
bottom = colorScheme.primaryContainer,
|
|
|
|
|
|
|
|
container = colorScheme.surface
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
val backgroundTheme = BackgroundTheme(
|
|
|
|
val backgroundTheme = defaultBackgroundTheme(colorScheme)
|
|
|
|
color = colorScheme.surface,
|
|
|
|
|
|
|
|
tonalElevation = 2.dp
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -109,26 +96,11 @@ class ThemeTest {
|
|
|
|
darkTheme = false,
|
|
|
|
darkTheme = false,
|
|
|
|
androidTheme = false
|
|
|
|
androidTheme = false
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
val colorScheme = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
|
|
val colorScheme = dynamicLightColorSchemeWithFallback()
|
|
|
|
dynamicLightColorScheme(LocalContext.current)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
LightDefaultColorScheme
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
val gradientColors = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
|
|
val gradientColors = dynamicGradientColorsWithFallback(colorScheme)
|
|
|
|
GradientColors()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
GradientColors(
|
|
|
|
|
|
|
|
top = colorScheme.inverseOnSurface,
|
|
|
|
|
|
|
|
bottom = colorScheme.primaryContainer,
|
|
|
|
|
|
|
|
container = colorScheme.surface
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
val backgroundTheme = BackgroundTheme(
|
|
|
|
val backgroundTheme = defaultBackgroundTheme(colorScheme)
|
|
|
|
color = colorScheme.surface,
|
|
|
|
|
|
|
|
tonalElevation = 2.dp
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -141,26 +113,11 @@ class ThemeTest {
|
|
|
|
darkTheme = true,
|
|
|
|
darkTheme = true,
|
|
|
|
androidTheme = false
|
|
|
|
androidTheme = false
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
val colorScheme = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
|
|
val colorScheme = dynamicDarkColorSchemeWithFallback()
|
|
|
|
dynamicDarkColorScheme(LocalContext.current)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
DarkDefaultColorScheme
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
val gradientColors = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
|
|
val gradientColors = dynamicGradientColorsWithFallback(colorScheme)
|
|
|
|
GradientColors()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
GradientColors(
|
|
|
|
|
|
|
|
top = colorScheme.inverseOnSurface,
|
|
|
|
|
|
|
|
bottom = colorScheme.primaryContainer,
|
|
|
|
|
|
|
|
container = colorScheme.surface
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
val backgroundTheme = BackgroundTheme(
|
|
|
|
val backgroundTheme = defaultBackgroundTheme(colorScheme)
|
|
|
|
color = colorScheme.surface,
|
|
|
|
|
|
|
|
tonalElevation = 2.dp
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -176,7 +133,7 @@ class ThemeTest {
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
val colorScheme = LightAndroidColorScheme
|
|
|
|
val colorScheme = LightAndroidColorScheme
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
val gradientColors = GradientColors()
|
|
|
|
val gradientColors = emptyGradientColors
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
val backgroundTheme = LightAndroidBackgroundTheme
|
|
|
|
val backgroundTheme = LightAndroidBackgroundTheme
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
@ -194,7 +151,7 @@ class ThemeTest {
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
val colorScheme = DarkAndroidColorScheme
|
|
|
|
val colorScheme = DarkAndroidColorScheme
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
val gradientColors = GradientColors()
|
|
|
|
val gradientColors = emptyGradientColors
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
val backgroundTheme = DarkAndroidBackgroundTheme
|
|
|
|
val backgroundTheme = DarkAndroidBackgroundTheme
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
@ -209,23 +166,11 @@ class ThemeTest {
|
|
|
|
darkTheme = false,
|
|
|
|
darkTheme = false,
|
|
|
|
androidTheme = true
|
|
|
|
androidTheme = true
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
val colorScheme = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
|
|
val colorScheme = dynamicLightColorSchemeWithFallback()
|
|
|
|
dynamicLightColorScheme(LocalContext.current)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
LightDefaultColorScheme
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
val gradientColors = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
|
|
val gradientColors = dynamicGradientColorsWithFallback(colorScheme)
|
|
|
|
GradientColors()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
GradientColors(
|
|
|
|
|
|
|
|
top = colorScheme.inverseOnSurface,
|
|
|
|
|
|
|
|
bottom = colorScheme.primaryContainer,
|
|
|
|
|
|
|
|
container = colorScheme.surface
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
val backgroundTheme = LightAndroidBackgroundTheme
|
|
|
|
val backgroundTheme = defaultBackgroundTheme(colorScheme)
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -238,28 +183,59 @@ class ThemeTest {
|
|
|
|
darkTheme = true,
|
|
|
|
darkTheme = true,
|
|
|
|
androidTheme = true
|
|
|
|
androidTheme = true
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
val colorScheme = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
|
|
val colorScheme = dynamicDarkColorSchemeWithFallback()
|
|
|
|
dynamicDarkColorScheme(LocalContext.current)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
DarkDefaultColorScheme
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
assertColorSchemesEqual(colorScheme, MaterialTheme.colorScheme)
|
|
|
|
val gradientColors = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
|
|
val gradientColors = dynamicGradientColorsWithFallback(colorScheme)
|
|
|
|
GradientColors()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
GradientColors(
|
|
|
|
|
|
|
|
top = colorScheme.inverseOnSurface,
|
|
|
|
|
|
|
|
bottom = colorScheme.primaryContainer,
|
|
|
|
|
|
|
|
container = colorScheme.surface
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
assertEquals(gradientColors, LocalGradientColors.current)
|
|
|
|
val backgroundTheme = DarkAndroidBackgroundTheme
|
|
|
|
val backgroundTheme = defaultBackgroundTheme(colorScheme)
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
assertEquals(backgroundTheme, LocalBackgroundTheme.current)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
|
|
|
private fun dynamicLightColorSchemeWithFallback(): ColorScheme {
|
|
|
|
|
|
|
|
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
|
|
|
|
|
|
dynamicLightColorScheme(LocalContext.current)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
LightDefaultColorScheme
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
|
|
|
private fun dynamicDarkColorSchemeWithFallback(): ColorScheme {
|
|
|
|
|
|
|
|
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
|
|
|
|
|
|
dynamicDarkColorScheme(LocalContext.current)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
DarkDefaultColorScheme
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val emptyGradientColors = GradientColors()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun defaultGradientColors(colorScheme: ColorScheme): GradientColors {
|
|
|
|
|
|
|
|
return GradientColors(
|
|
|
|
|
|
|
|
top = colorScheme.inverseOnSurface,
|
|
|
|
|
|
|
|
bottom = colorScheme.primaryContainer,
|
|
|
|
|
|
|
|
container = colorScheme.surface
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun dynamicGradientColorsWithFallback(colorScheme: ColorScheme): GradientColors {
|
|
|
|
|
|
|
|
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
|
|
|
|
|
|
emptyGradientColors
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
defaultGradientColors(colorScheme)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun defaultBackgroundTheme(colorScheme: ColorScheme): BackgroundTheme {
|
|
|
|
|
|
|
|
return BackgroundTheme(
|
|
|
|
|
|
|
|
color = colorScheme.surface,
|
|
|
|
|
|
|
|
tonalElevation = 2.dp
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Workaround for the fact that the NiA design system specify all color scheme values.
|
|
|
|
* Workaround for the fact that the NiA design system specify all color scheme values.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|