
This theme is mainly geared towards e-Ink displays with limited/no colour capabilities. Previous themes like Yin & Yang would make heavy use of greyscale colours which could look off on some devices. This theme is probably not conformant to Material Design 3 colour scheme guidelines, but it does boast some amazing WebAIM contrast ratios (#FFFFFF text on #000000 background gets a ratio of 21:1, vice versa too). Initially, this was intended as a purely black and white theme but some contrast issues arose, such as the download badges (tertiary background, onTertiary text colour) having the same colour as unread badges (primary/onPrimary), or the step indicators (stops) not being visible on sliders (since they use the colours of the opposite state track (active region stops are the colour of the inactive region track and vice versa). To mitigate this, each variant (dark/light) of the theme has one additional grey mixed in for their tertiary and secondaryContainer colours each. For the dark variant, this is a #A0A0A0 background for #000000 text (8.03:1 contrast ratio) and for the light variant, it is a #505050 background for #FFFFFF text (8.06:1 contrast ratio). This results in distinct unread vs download badges and visible steps in the sliders. --------- Co-authored-by: Sunspark-007 <73711243+Sunspark-007@users.noreply.github.com> Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> (cherry picked from commit 8b48d1016b851b425e4f66d44bca098220585c37) # Conflicts: # CHANGELOG.md
92 lines
3.2 KiB
Kotlin
92 lines
3.2 KiB
Kotlin
package eu.kanade.presentation.theme
|
|
|
|
import androidx.compose.foundation.isSystemInDarkTheme
|
|
import androidx.compose.material3.ColorScheme
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.ReadOnlyComposable
|
|
import androidx.compose.ui.platform.LocalContext
|
|
import eu.kanade.domain.ui.UiPreferences
|
|
import eu.kanade.domain.ui.model.AppTheme
|
|
import eu.kanade.presentation.theme.colorscheme.BaseColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.GreenAppleColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.LavenderColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.MidnightDuskColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.MonetColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.MonochromeColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.NordColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.StrawberryColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.TachiyomiColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.TakoColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.TealTurqoiseColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.TidalWaveColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.YinYangColorScheme
|
|
import eu.kanade.presentation.theme.colorscheme.YotsubaColorScheme
|
|
import uy.kohesive.injekt.Injekt
|
|
import uy.kohesive.injekt.api.get
|
|
|
|
@Composable
|
|
fun TachiyomiTheme(
|
|
appTheme: AppTheme? = null,
|
|
amoled: Boolean? = null,
|
|
content: @Composable () -> Unit,
|
|
) {
|
|
val uiPreferences = Injekt.get<UiPreferences>()
|
|
BaseTachiyomiTheme(
|
|
appTheme = appTheme ?: uiPreferences.appTheme().get(),
|
|
isAmoled = amoled ?: uiPreferences.themeDarkAmoled().get(),
|
|
content = content,
|
|
)
|
|
}
|
|
|
|
@Composable
|
|
fun TachiyomiPreviewTheme(
|
|
appTheme: AppTheme = AppTheme.DEFAULT,
|
|
isAmoled: Boolean = false,
|
|
content: @Composable () -> Unit,
|
|
) = BaseTachiyomiTheme(appTheme, isAmoled, content)
|
|
|
|
@Composable
|
|
private fun BaseTachiyomiTheme(
|
|
appTheme: AppTheme,
|
|
isAmoled: Boolean,
|
|
content: @Composable () -> Unit,
|
|
) {
|
|
MaterialTheme(
|
|
colorScheme = getThemeColorScheme(appTheme, isAmoled),
|
|
content = content,
|
|
)
|
|
}
|
|
|
|
@Composable
|
|
@ReadOnlyComposable
|
|
private fun getThemeColorScheme(
|
|
appTheme: AppTheme,
|
|
isAmoled: Boolean,
|
|
): ColorScheme {
|
|
val colorScheme = if (appTheme == AppTheme.MONET) {
|
|
MonetColorScheme(LocalContext.current)
|
|
} else {
|
|
colorSchemes.getOrDefault(appTheme, TachiyomiColorScheme)
|
|
}
|
|
return colorScheme.getColorScheme(
|
|
isSystemInDarkTheme(),
|
|
isAmoled,
|
|
)
|
|
}
|
|
|
|
private val colorSchemes: Map<AppTheme, BaseColorScheme> = mapOf(
|
|
AppTheme.DEFAULT to TachiyomiColorScheme,
|
|
AppTheme.GREEN_APPLE to GreenAppleColorScheme,
|
|
AppTheme.LAVENDER to LavenderColorScheme,
|
|
AppTheme.MIDNIGHT_DUSK to MidnightDuskColorScheme,
|
|
AppTheme.MONOCHROME to MonochromeColorScheme,
|
|
AppTheme.NORD to NordColorScheme,
|
|
AppTheme.STRAWBERRY_DAIQUIRI to StrawberryColorScheme,
|
|
AppTheme.TAKO to TakoColorScheme,
|
|
AppTheme.TEALTURQUOISE to TealTurqoiseColorScheme,
|
|
AppTheme.TIDAL_WAVE to TidalWaveColorScheme,
|
|
AppTheme.YINYANG to YinYangColorScheme,
|
|
AppTheme.YOTSUBA to YotsubaColorScheme,
|
|
)
|