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 |
package org.jetbrains.codeviewer.ui.common |
||||||
|
|
||||||
|
import androidx.compose.material.Colors |
||||||
import androidx.compose.material.darkColors |
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.graphics.Color |
||||||
import androidx.compose.ui.text.SpanStyle |
import androidx.compose.ui.text.SpanStyle |
||||||
|
|
||||||
object AppTheme { |
@Immutable |
||||||
val colors: Colors = Colors() |
data class Theme( |
||||||
|
val materialColors: Colors, |
||||||
val code: Code = Code() |
val colors: ExtendedColors, |
||||||
|
val code: CodeStyle |
||||||
|
) { |
||||||
|
@Immutable |
||||||
|
class ExtendedColors( |
||||||
|
val codeGuide: Color |
||||||
|
) |
||||||
|
|
||||||
class Colors( |
@Immutable |
||||||
val backgroundDark: Color = Color(0xFF2B2B2B), |
data class CodeStyle( |
||||||
val backgroundMedium: Color = Color(0xFF3C3F41), |
val simple: SpanStyle, |
||||||
val backgroundLight: Color = Color(0xFF4E5254), |
val value: SpanStyle, |
||||||
|
val keyword: SpanStyle, |
||||||
|
val punctuation: SpanStyle, |
||||||
|
val annotation: SpanStyle, |
||||||
|
val comment: SpanStyle |
||||||
|
) |
||||||
|
|
||||||
val material: androidx.compose.material.Colors = darkColors( |
companion object { |
||||||
background = backgroundDark, |
val dark = Theme( |
||||||
surface = backgroundMedium, |
materialColors = darkColors( |
||||||
primary = Color.White |
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)) |
||||||
|
) |
||||||
) |
) |
||||||
|
|
||||||
class Code( |
val light = Theme( |
||||||
val simple: SpanStyle = SpanStyle(Color(0xFFA9B7C6)), |
materialColors = lightColors( |
||||||
val value: SpanStyle = SpanStyle(Color(0xFF6897BB)), |
background = Color(0xFFF5F5F5), |
||||||
val keyword: SpanStyle = SpanStyle(Color(0xFFCC7832)), |
surface = Color(0xFFFFFFFF) |
||||||
val punctuation: SpanStyle = SpanStyle(Color(0xFFA1C17E)), |
), |
||||||
val annotation: SpanStyle = SpanStyle(Color(0xFFBBB529)), |
colors = ExtendedColors( |
||||||
val comment: SpanStyle = SpanStyle(Color(0xFF808080)) |
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