Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new UI variant for One Dark Theme #311

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'one-dark-theme-plugin'
id 'org.jetbrains.intellij' version '1.9.0'
id 'org.jetbrains.intellij' version '1.15.0'
id 'org.jetbrains.kotlin.jvm' version '1.7.10'
id 'org.jlleitschuh.gradle.ktlint' version '8.2.0'
id 'org.kordamp.gradle.markdown' version '2.2.0'
Expand All @@ -24,7 +24,7 @@ configurations {
}

intellij {
version.set('2021.3.1')
version.set('2022.3')
type.set('IU')
downloadSources.set(true)
updateSinceUntilBuild.set(true)
Expand Down
33 changes: 24 additions & 9 deletions buildSrc/src/main/kotlin/themes/ThemeConstructor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ open class ThemeConstructor : DefaultTask() {
private const val ITALIC = "One Dark Italic"
private const val VIVID = "One Dark Vivid"
private const val VIVID_ITALIC = "One Dark Vivid Italic"

// new UI
private const val REGULAR_NEW_UI = "One Dark New UI"
val THEMES = mapOf(
"1fa63ea1-a161-4d01-b488-d4a6b2d4c10e" to REGULAR_NEW_UI,
"f92a0fa7-1a98-47cd-b5cb-78ff67e6f4f3" to REGULAR,
"1a92aa6f-c2f1-4994-ae01-6a78e43eeb24" to ITALIC,
"4b6007f7-b596-4ee2-96f9-968d3d3eb392" to VIVID,
Expand All @@ -65,37 +69,44 @@ open class ThemeConstructor : DefaultTask() {
THEMES.entries.forEach {
constructNewTheme(getSettings(it.value), OneDarkThemeDefinition(
it.key,
it.value
it.value,
))
}
}

private fun getSettings(themeName: String): ThemeSettings {
return when (themeName) {
REGULAR -> ThemeSettings(
false,
false, false,
GroupStyling.REGULAR.value,
GroupStyling.REGULAR.value,
GroupStyling.REGULAR.value
)
ITALIC -> ThemeSettings(
false,
false, false,
GroupStyling.ITALIC.value,
GroupStyling.ITALIC.value,
GroupStyling.ITALIC.value
)
VIVID -> ThemeSettings(
true,
true, false,
GroupStyling.REGULAR.value,
GroupStyling.REGULAR.value,
GroupStyling.REGULAR.value
)
VIVID_ITALIC -> ThemeSettings(
true,
true, false,
GroupStyling.ITALIC.value,
GroupStyling.ITALIC.value,
GroupStyling.ITALIC.value
)

REGULAR_NEW_UI -> ThemeSettings(
false, true,
GroupStyling.REGULAR.value,
GroupStyling.REGULAR.value,
GroupStyling.REGULAR.value
)
else -> throw IllegalArgumentException("Bro, I don't know what theme is $themeName")
}
}
Expand All @@ -115,21 +126,25 @@ open class ThemeConstructor : DefaultTask() {
"${createFileName(themeDefinition.name)}.xml"
)
buildNewEditorScheme(themeSettings, newEditorSchemeFile, themeDefinition)
buildThemeJson(themeDefinition, Paths.get(
assetsDirectory.toAbsolutePath().toString(),
"${createFileName(themeDefinition.name)}.theme.json"))
buildThemeJson(
themeSettings,
themeDefinition, Paths.get(
assetsDirectory.toAbsolutePath().toString(),
"${createFileName(themeDefinition.name)}.theme.json"))
}

private fun buildThemeJson(
themeSettings: ThemeSettings,
themeDefinition: OneDarkThemeDefinition,
destinationFile: Path
) {
val templateFile = if (themeSettings.newUi) "oneDark-newUi.template.theme.json" else "oneDark.template.theme.json"
val themeJsonTemplate: MutableMap<String, Any> =
Files.newInputStream(Paths.get(
project.rootDir.absolutePath,
"buildSrc",
"templates",
"oneDark.template.theme.json"
templateFile
))
.use {
gson.fromJson<MutableMap<String, Any>>(JsonReader(it.reader()),
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/themes/ThemeSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package themes

data class ThemeSettings (
val isVivid: Boolean = false,
val newUi: Boolean = false,
val commentStyle: String = GroupStyling.REGULAR.value,
val keywordStyle: String = GroupStyling.REGULAR.value,
val attributesStyle: String = GroupStyling.REGULAR.value
Expand Down
Loading