Skip to content

Commit 38bcbba

Browse files
committed
impl: icon support for light & dark theme
- LAF support in Toolbox is quite primitive, it turns out icon support for light and dark themes is enabled by a masked flag on the icons - the mask flag controls whether the svg colors are inverted in light&dark themes.
1 parent 7559cbb commit 38bcbba

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
### Added
66

77
- initial support for JetBrains Toolbox 2.6.0.38311 with the possibility to manage the workspaces - i.e. start, stop,
8-
update and delete actions and also quick shortcuts to templates, web terminal and dashboard.
8+
update and delete actions and also quick shortcuts to templates, web terminal and dashboard.
9+
- support for light & dark themes

src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt

+9-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.coder.toolbox.views.NewEnvironmentPage
1717
import com.coder.toolbox.views.SignInPage
1818
import com.coder.toolbox.views.TokenPage
1919
import com.jetbrains.toolbox.api.core.ui.icons.SvgIcon
20+
import com.jetbrains.toolbox.api.core.ui.icons.SvgIcon.IconType
2021
import com.jetbrains.toolbox.api.core.util.LoadableState
2122
import com.jetbrains.toolbox.api.remoteDev.ProviderVisibilityState
2223
import com.jetbrains.toolbox.api.remoteDev.RemoteProvider
@@ -181,10 +182,16 @@ class CoderRemoteProvider(
181182
}
182183

183184
override val svgIcon: SvgIcon =
184-
SvgIcon(this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf())
185+
SvgIcon(
186+
this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf(),
187+
type = IconType.Masked
188+
)
185189

186190
override val noEnvironmentsSvgIcon: SvgIcon? =
187-
SvgIcon(this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf())
191+
SvgIcon(
192+
this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf(),
193+
type = IconType.Masked
194+
)
188195

189196
/**
190197
* TODO@JB: It would be nice to show "loading workspaces" at first but it

src/main/kotlin/com/coder/toolbox/views/CoderPage.kt

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.coder.toolbox.views
22

33
import com.coder.toolbox.CoderToolboxContext
44
import com.jetbrains.toolbox.api.core.ui.icons.SvgIcon
5+
import com.jetbrains.toolbox.api.core.ui.icons.SvgIcon.IconType
56
import com.jetbrains.toolbox.api.localization.LocalizableString
67
import com.jetbrains.toolbox.api.ui.actions.RunnableActionDescription
78
import com.jetbrains.toolbox.api.ui.components.UiField
@@ -46,9 +47,12 @@ abstract class CoderPage(
4647
* This seems to only work on the first page.
4748
*/
4849
override val svgIcon: SvgIcon? = if (showIcon) {
49-
SvgIcon(this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf())
50+
SvgIcon(
51+
this::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf(),
52+
type = IconType.Masked
53+
)
5054
} else {
51-
SvgIcon(byteArrayOf())
55+
SvgIcon(byteArrayOf(), type = IconType.Masked)
5256
}
5357

5458
/**

0 commit comments

Comments
 (0)