Browse Source
https://youtrack.jetbrains.com/issue/COMPOSE-356/Add-Dark-theme-to-codeviewer-examples The MR does the following: - Enables dark theme for iOS, Android and Desktop platforms - Expands compose view to fullscreen and uses window padding to adjust content location - Adjusts toolbar clock style to application theme on mobile platformspull/3864/head
Andrei Salavei
1 year ago
committed by
GitHub
14 changed files with 175 additions and 70 deletions
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<style name="Theme.Application" parent="Theme.General"> |
||||
<item name="android:windowLightStatusBar">false</item> |
||||
</style> |
||||
</resources> |
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<style name="Theme.General" parent="Theme.AppCompat.Light.NoActionBar"> |
||||
<item name="android:statusBarColor">@android:color/transparent</item> |
||||
<item name="android:navigationBarColor">@android:color/transparent</item> |
||||
</style> |
||||
|
||||
<style name="Theme.Application" parent="Theme.General"> |
||||
<item name="android:windowLightStatusBar">true</item> |
||||
</style> |
||||
</resources> |
@ -1,32 +1,76 @@
|
||||
package org.jetbrains.codeviewer.ui.common |
||||
|
||||
import androidx.compose.material.Colors |
||||
import androidx.compose.material.darkColors |
||||
import androidx.compose.material.lightColors |
||||
import androidx.compose.runtime.Composable |
||||
import androidx.compose.runtime.Immutable |
||||
import androidx.compose.runtime.staticCompositionLocalOf |
||||
import androidx.compose.ui.graphics.Color |
||||
import androidx.compose.ui.text.SpanStyle |
||||
|
||||
object AppTheme { |
||||
val colors: Colors = Colors() |
||||
|
||||
val code: Code = Code() |
||||
|
||||
class Colors( |
||||
val backgroundDark: Color = Color(0xFF2B2B2B), |
||||
val backgroundMedium: Color = Color(0xFF3C3F41), |
||||
val backgroundLight: Color = Color(0xFF4E5254), |
||||
|
||||
val material: androidx.compose.material.Colors = darkColors( |
||||
background = backgroundDark, |
||||
surface = backgroundMedium, |
||||
primary = Color.White |
||||
), |
||||
@Immutable |
||||
data class Theme( |
||||
val materialColors: Colors, |
||||
val colors: ExtendedColors, |
||||
val code: CodeStyle |
||||
) { |
||||
@Immutable |
||||
class ExtendedColors( |
||||
val codeGuide: Color |
||||
) |
||||
|
||||
class Code( |
||||
val simple: SpanStyle = SpanStyle(Color(0xFFA9B7C6)), |
||||
val value: SpanStyle = SpanStyle(Color(0xFF6897BB)), |
||||
val keyword: SpanStyle = SpanStyle(Color(0xFFCC7832)), |
||||
val punctuation: SpanStyle = SpanStyle(Color(0xFFA1C17E)), |
||||
val annotation: SpanStyle = SpanStyle(Color(0xFFBBB529)), |
||||
val comment: SpanStyle = SpanStyle(Color(0xFF808080)) |
||||
@Immutable |
||||
data class CodeStyle( |
||||
val simple: SpanStyle, |
||||
val value: SpanStyle, |
||||
val keyword: SpanStyle, |
||||
val punctuation: SpanStyle, |
||||
val annotation: SpanStyle, |
||||
val comment: SpanStyle |
||||
) |
||||
|
||||
companion object { |
||||
val dark = Theme( |
||||
materialColors = darkColors( |
||||
background = Color(0xFF2B2B2B), |
||||
surface = Color(0xFF3C3F41) |
||||
), |
||||
colors = ExtendedColors( |
||||
codeGuide = Color(0xFF4E5254) |
||||
), |
||||
code = CodeStyle( |
||||
simple = SpanStyle(Color(0xFFA9B7C6)), |
||||
value = SpanStyle(Color(0xFF6897BB)), |
||||
keyword = SpanStyle(Color(0xFFCC7832)), |
||||
punctuation = SpanStyle(Color(0xFFA1C17E)), |
||||
annotation = SpanStyle(Color(0xFFBBB529)), |
||||
comment = SpanStyle(Color(0xFF808080)) |
||||
) |
||||
) |
||||
|
||||
val light = Theme( |
||||
materialColors = lightColors( |
||||
background = Color(0xFFF5F5F5), |
||||
surface = Color(0xFFFFFFFF) |
||||
), |
||||
colors = ExtendedColors( |
||||
codeGuide = Color(0xFF8E9294) |
||||
), |
||||
code = CodeStyle( |
||||
simple = SpanStyle(Color(0xFF000000)), |
||||
value = SpanStyle(Color(0xFF4A86E8)), |
||||
keyword = SpanStyle(Color(0xFF000080)), |
||||
punctuation = SpanStyle(Color(0xFFA1A1A1)), |
||||
annotation = SpanStyle(Color(0xFFBBB529)), |
||||
comment = SpanStyle(Color(0xFF808080)) |
||||
) |
||||
) |
||||
} |
||||
} |
||||
|
||||
val LocalTheme = staticCompositionLocalOf { Theme.dark } |
||||
|
||||
val AppTheme |
||||
@Composable |
||||
get() = LocalTheme.current |
||||
|
Loading…
Reference in new issue