diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/SwingBridgeService.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/SwingBridgeService.kt index 3460289a3..a2f1fef89 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/SwingBridgeService.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/SwingBridgeService.kt @@ -40,8 +40,8 @@ class SwingBridgeService : Disposable { .mapLatest { tryGettingThemeData() } .stateIn(coroutineScope, SharingStarted.Eagerly, BridgeThemeData.DEFAULT) - @get:Composable val svgLoader: SvgLoader + @Composable get() { val data by currentBridgeThemeData.collectAsState() return data.svgLoader diff --git a/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/JewelDemoToolWindow.kt b/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/JewelDemoToolWindow.kt index 2e9d2a1a9..062763cd8 100644 --- a/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/JewelDemoToolWindow.kt +++ b/samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/JewelDemoToolWindow.kt @@ -1,6 +1,7 @@ package org.jetbrains.jewel.samples.ideplugin import androidx.compose.foundation.background +import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -20,8 +21,10 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.ResourceLoader import androidx.compose.ui.unit.dp +import com.intellij.openapi.components.service import com.intellij.openapi.project.DumbAware import com.intellij.openapi.project.Project import com.intellij.openapi.wm.ToolWindow @@ -31,14 +34,17 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import org.jetbrains.jewel.CheckboxRow import org.jetbrains.jewel.DefaultButton import org.jetbrains.jewel.ExperimentalJewelApi +import org.jetbrains.jewel.Icon import org.jetbrains.jewel.LazyTree import org.jetbrains.jewel.LocalResourceLoader import org.jetbrains.jewel.OutlinedButton import org.jetbrains.jewel.RadioButtonRow import org.jetbrains.jewel.Text import org.jetbrains.jewel.TextField +import org.jetbrains.jewel.bridge.SwingBridgeService import org.jetbrains.jewel.bridge.SwingBridgeTheme import org.jetbrains.jewel.bridge.addComposeTab +import org.jetbrains.jewel.bridge.retrieveStatelessIcon import org.jetbrains.jewel.bridge.toComposeColor import org.jetbrains.jewel.foundation.tree.buildTree import org.jetbrains.jewel.themes.intui.standalone.IntUiTheme @@ -70,8 +76,9 @@ internal class JewelDemoToolWindow : ToolWindowFactory, DumbAware { } @Composable - private fun ColumnOne(resourceLoader: ResourceLoader) { + private fun RowScope.ColumnOne(resourceLoader: ResourceLoader) { Column( + Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(16.dp), ) { Text("Here is a selection of our finest components:") @@ -123,63 +130,12 @@ internal class JewelDemoToolWindow : ToolWindowFactory, DumbAware { Text("Sad second") } } - } - } - - @Composable - private fun RowScope.ColumnOne(resourceLoader: ResourceLoader) { - Column( - Modifier.weight(1f), - verticalArrangement = Arrangement.spacedBy(16.dp), - ) { - Text("Here is a selection of our finest components:") - - Row( - horizontalArrangement = Arrangement.spacedBy(16.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - var clicks1 by remember { mutableStateOf(0) } - OutlinedButton({ clicks1++ }) { - Text("Outlined: $clicks1") - } - OutlinedButton({ }, enabled = false) { - Text("Outlined") - } - - var clicks2 by remember { mutableStateOf(0) } - DefaultButton({ clicks2++ }) { - Text("Default: $clicks2") - } - DefaultButton({ }, enabled = false) { - Text("Default") - } - } - - var textFieldValue by remember { mutableStateOf("") } - TextField( - value = textFieldValue, - onValueChange = { textFieldValue = it }, - placeholder = { Text("Write something...") }, - modifier = Modifier.width(200.dp), - ) - - var checked by remember { mutableStateOf(false) } - CheckboxRow( - checked = checked, - onCheckedChange = { checked = it }, - resourceLoader = resourceLoader, - ) { - Text("Hello, I am a themed checkbox") - } Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) { - var index by remember { mutableStateOf(0) } - RadioButtonRow(selected = index == 0, resourceLoader, onClick = { index = 0 }) { - Text("I am number one") - } - RadioButtonRow(selected = index == 1, resourceLoader, onClick = { index = 1 }) { - Text("Sad second") - } + val svgLoader = service().svgLoader + val painterProvider = retrieveStatelessIcon("actions/close.svg", svgLoader, IntUiTheme.iconData) + val painter by painterProvider.getPainter(resourceLoader) + Icon(painter = painter, modifier = Modifier.border(1.dp, Color.Magenta), contentDescription = "An icon") } } }