diff --git a/core/src/main/kotlin/org/jetbrains/jewel/IconMapper.kt b/core/src/main/kotlin/org/jetbrains/jewel/IconMapper.kt new file mode 100644 index 000000000..605c3f4a0 --- /dev/null +++ b/core/src/main/kotlin/org/jetbrains/jewel/IconMapper.kt @@ -0,0 +1,30 @@ +package org.jetbrains.jewel + +import androidx.compose.ui.res.ResourceLoader +import java.util.logging.Level +import java.util.logging.Logger + +interface IconMapper { + + fun mapPath(originalPath: String, iconData: IntelliJThemeIconData, resourceLoader: ResourceLoader): String +} + +object IntelliJIconMapper : IconMapper { + + private val verbose = true + + override fun mapPath( + originalPath: String, + iconData: IntelliJThemeIconData, + resourceLoader: ResourceLoader, + ): String { + val normalized = "/${originalPath.trimStart('/')}" + val overriddenPath = iconData.iconOverrides[normalized] ?: normalized + + if (overriddenPath != normalized) { + if (verbose) println("Found theme icon override: '$originalPath' -> '$overriddenPath'") + } + + return overriddenPath + } +} diff --git a/core/src/main/kotlin/org/jetbrains/jewel/styling/ResourcePainterProvider.kt b/core/src/main/kotlin/org/jetbrains/jewel/styling/ResourcePainterProvider.kt index 0ba415ec1..21cef2559 100644 --- a/core/src/main/kotlin/org/jetbrains/jewel/styling/ResourcePainterProvider.kt +++ b/core/src/main/kotlin/org/jetbrains/jewel/styling/ResourcePainterProvider.kt @@ -2,17 +2,24 @@ package org.jetbrains.jewel.styling import androidx.compose.runtime.Composable import androidx.compose.runtime.State +import androidx.compose.runtime.remember import androidx.compose.runtime.rememberUpdatedState import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.res.ResourceLoader +import org.jetbrains.jewel.IconMapper +import org.jetbrains.jewel.IntelliJIconMapper +import org.jetbrains.jewel.IntelliJThemeIconData import org.jetbrains.jewel.InteractiveComponentState import org.jetbrains.jewel.InternalJewelApi +import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.painterResource open class ResourcePainterProvider @InternalJewelApi constructor( private val basePath: String, private val svgLoader: SvgLoader, + private val iconMapper: IconMapper, + private val iconData: IntelliJThemeIconData, private val pathPatcher: ResourcePathPatcher, ) : PainterProvider { @@ -38,7 +45,8 @@ open class ResourcePainterProvider @InternalJewelApi constructor( extraData: T?, ): String { val patched = pathPatcher.patchVariant(basePath, resourceLoader, extraData) - return pathPatcher.patchTheme(patched, resourceLoader) + val override = iconMapper.mapPath(patched, iconData, resourceLoader) + return pathPatcher.patchTheme(override, resourceLoader) } override fun equals(other: Any?): Boolean { @@ -49,32 +57,63 @@ open class ResourcePainterProvider @InternalJewelApi constructor( if (basePath != other.basePath) return false if (svgLoader != other.svgLoader) return false + if (iconMapper != other.iconMapper) return false + if (iconData != other.iconData) return false if (pathPatcher != other.pathPatcher) return false + return true } override fun hashCode(): Int { var result = basePath.hashCode() result = 31 * result + svgLoader.hashCode() + result = 31 * result + iconMapper.hashCode() + result = 31 * result + iconData.hashCode() result = 31 * result + pathPatcher.hashCode() return result } override fun toString(): String = - "ResourcePainterProvider(basePath='$basePath', svgLoader=$svgLoader, pathPatcher=$pathPatcher)" + "ResourcePainterProvider(basePath='$basePath', svgLoader=$svgLoader, iconMapper=$iconMapper, iconData=$iconData, pathPatcher=$pathPatcher)" @OptIn(InternalJewelApi::class) // These are the public constructors companion object Factory { - fun stateless(basePath: String, svgLoader: SvgLoader) = - ResourcePainterProvider(basePath, svgLoader, SimpleResourcePathPatcher()) + fun stateless(basePath: String, svgLoader: SvgLoader, iconData: IntelliJThemeIconData) = + ResourcePainterProvider( + basePath, + svgLoader, + IntelliJIconMapper, + iconData, + SimpleResourcePathPatcher() + ) fun stateful( basePath: String, svgLoader: SvgLoader, - pathPatcher: ResourcePathPatcher = StatefulResourcePathPatcher(), + iconData: IntelliJThemeIconData, + pathPatcher: ResourcePathPatcher = StatefulResourcePathPatcher() ) = - ResourcePainterProvider(basePath, svgLoader, pathPatcher) + ResourcePainterProvider(basePath, svgLoader, IntelliJIconMapper, iconData, pathPatcher) } } + +@Composable +fun rememberStatelessPainterProvider( + basePath: String, + svgLoader: SvgLoader, + iconData: IntelliJThemeIconData = LocalIconData.current +): ResourcePainterProvider = remember(basePath, iconData) { + ResourcePainterProvider.stateless(basePath, svgLoader, iconData) +} + +@Composable +fun rememberStatefulPainterProvider( + basePath: String, + svgLoader: SvgLoader, + pathPatcher: ResourcePathPatcher = StatefulResourcePathPatcher(), + iconData: IntelliJThemeIconData = LocalIconData.current +): ResourcePainterProvider = remember(basePath, iconData, pathPatcher) { + ResourcePainterProvider.stateful(basePath, svgLoader, iconData, pathPatcher) +} \ No newline at end of file diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeIconMapper.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeIconMapper.kt index 8201a9a1c..d7f3cbbe0 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeIconMapper.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeIconMapper.kt @@ -4,6 +4,7 @@ import androidx.compose.ui.res.ResourceLoader import com.intellij.openapi.diagnostic.thisLogger import com.intellij.util.ui.DirProvider import org.jetbrains.jewel.ClassLoaderProvider +import org.jetbrains.jewel.IconMapper import org.jetbrains.jewel.IntelliJThemeIconData import org.jetbrains.jewel.InternalJewelApi diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeResourcePainterProvider.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeResourcePainterProvider.kt index 973a42404..cdbb3de33 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeResourcePainterProvider.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeResourcePainterProvider.kt @@ -1,7 +1,6 @@ package org.jetbrains.jewel.bridge -import androidx.compose.runtime.Composable -import androidx.compose.ui.res.ResourceLoader +import org.jetbrains.jewel.IconMapper import org.jetbrains.jewel.IntelliJThemeIconData import org.jetbrains.jewel.InteractiveComponentState import org.jetbrains.jewel.InternalJewelApi @@ -15,21 +14,10 @@ import org.jetbrains.jewel.styling.StatefulResourcePathPatcher internal class BridgeResourcePainterProvider @InternalJewelApi constructor( basePath: String, svgLoader: SvgLoader, - private val pathPatcher: ResourcePathPatcher, - private val iconMapper: IconMapper, - private val iconData: IntelliJThemeIconData, -) : ResourcePainterProvider(basePath, svgLoader, pathPatcher) { - - @Composable - override fun patchPath( - basePath: String, - resourceLoader: ResourceLoader, - extraData: T?, - ): String { - val patched = pathPatcher.patchVariant(basePath, resourceLoader, extraData) - val override = iconMapper.mapPath(patched, iconData, resourceLoader) - return pathPatcher.patchTheme(override, resourceLoader) - } + pathPatcher: ResourcePathPatcher, + iconMapper: IconMapper, + iconData: IntelliJThemeIconData, +) : ResourcePainterProvider(basePath, svgLoader, iconMapper, iconData, pathPatcher) { companion object Factory { diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IconMapper.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IconMapper.kt deleted file mode 100644 index da88ea8f6..000000000 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IconMapper.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.jetbrains.jewel.bridge - -import androidx.compose.ui.res.ResourceLoader -import org.jetbrains.jewel.IntelliJThemeIconData - -interface IconMapper { - - fun mapPath(originalPath: String, iconData: IntelliJThemeIconData, resourceLoader: ResourceLoader): String -} diff --git a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiCheckboxStyling.kt b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiCheckboxStyling.kt index d6a5776be..abc74235b 100644 --- a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiCheckboxStyling.kt +++ b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiCheckboxStyling.kt @@ -10,6 +10,7 @@ import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp import org.jetbrains.jewel.CheckboxState +import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme import org.jetbrains.jewel.intui.core.theme.IntUiLightTheme @@ -104,19 +105,22 @@ import org.jetbrains.jewel.styling.StatefulResourcePathPatcher companion object { + @Composable fun checkbox( svgLoader: SvgLoader, basePath: String = "com/intellij/ide/ui/laf/icons/intellij/checkBox.svg", ): PainterProvider = ResourcePainterProvider.stateful( basePath, svgLoader, + LocalIconData.current, pathPatcher = StatefulResourcePathPatcher( prefixTokensProvider = { state: CheckboxState -> if (state.toggleableState == ToggleableState.Indeterminate) "Indeterminate" else "" }, - ), + ) ) + @Composable fun light( svgLoader: SvgLoader, checkbox: PainterProvider = checkbox( @@ -125,6 +129,7 @@ import org.jetbrains.jewel.styling.StatefulResourcePathPatcher ), ) = IntUiCheckboxIcons(checkbox) + @Composable fun dark( svgLoader: SvgLoader, checkbox: PainterProvider = checkbox( diff --git a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiDropdownStyling.kt b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiDropdownStyling.kt index e99bbabf8..1ce35fb14 100644 --- a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiDropdownStyling.kt +++ b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiDropdownStyling.kt @@ -11,6 +11,7 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp import org.jetbrains.jewel.DropdownState +import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme import org.jetbrains.jewel.intui.core.theme.IntUiLightTheme @@ -195,7 +196,7 @@ data class IntUiDropdownIcons( svgLoader: SvgLoader, basePath: String = "expui/general/chevronDown.svg", ): PainterProvider = - ResourcePainterProvider.stateful(basePath, svgLoader) + ResourcePainterProvider.stateful(basePath, svgLoader, LocalIconData.current) } } diff --git a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiLazyTreeStyling.kt b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiLazyTreeStyling.kt index 09c06d72c..dec1abdf9 100644 --- a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiLazyTreeStyling.kt +++ b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiLazyTreeStyling.kt @@ -8,6 +8,7 @@ import androidx.compose.runtime.Stable import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme import org.jetbrains.jewel.intui.core.theme.IntUiLightTheme @@ -123,14 +124,14 @@ data class IntUiLazyTreeIcons( svgLoader: SvgLoader, basePath: String = "expui/general/chevronRight.svg", ): PainterProvider = - ResourcePainterProvider.stateless(basePath, svgLoader) + ResourcePainterProvider.stateless(basePath, svgLoader, LocalIconData.current) @Composable fun chevronExpanded( svgLoader: SvgLoader, basePath: String = "expui/general/chevronDown.svg", ): PainterProvider = - ResourcePainterProvider.stateless(basePath, svgLoader) + ResourcePainterProvider.stateless(basePath, svgLoader, LocalIconData.current) } } diff --git a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiLinkStyling.kt b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiLinkStyling.kt index 9083caa85..74af02e39 100644 --- a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiLinkStyling.kt +++ b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiLinkStyling.kt @@ -10,6 +10,7 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp import org.jetbrains.jewel.LinkState +import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme import org.jetbrains.jewel.intui.core.theme.IntUiLightTheme @@ -120,14 +121,14 @@ data class IntUiLinkIcons( svgLoader: SvgLoader, basePath: String = "expui/general/chevronDown.svg", ): PainterProvider = - ResourcePainterProvider.stateful(basePath, svgLoader) + ResourcePainterProvider.stateful(basePath, svgLoader, LocalIconData.current) @Composable fun externalLink( svgLoader: SvgLoader, basePath: String = "expui/ide/externalLink.svg", ): PainterProvider = - ResourcePainterProvider.stateful(basePath, svgLoader) + ResourcePainterProvider.stateful(basePath, svgLoader, LocalIconData.current) } } diff --git a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiMenuStyling.kt b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiMenuStyling.kt index 3cf8ce536..670784e6c 100644 --- a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiMenuStyling.kt +++ b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiMenuStyling.kt @@ -9,6 +9,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.dp +import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.MenuItemState import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme @@ -214,7 +215,7 @@ data class IntUiMenuIcons( svgLoader: SvgLoader, basePath: String = "expui/general/chevronRight.svg", ): PainterProvider = - ResourcePainterProvider.stateful(basePath, svgLoader) + ResourcePainterProvider.stateful(basePath, svgLoader, LocalIconData.current) } } diff --git a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiRadioButtonStyling.kt b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiRadioButtonStyling.kt index b185a091f..3622b9361 100644 --- a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiRadioButtonStyling.kt +++ b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiRadioButtonStyling.kt @@ -6,6 +6,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp +import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.RadioButtonState import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme @@ -105,12 +106,14 @@ data class IntUiRadioButtonIcons( companion object { + @Composable fun radioButton( svgLoader: SvgLoader, basePath: String = "com/intellij/ide/ui/laf/icons/intellij/radio.svg", ): PainterProvider = - ResourcePainterProvider.stateful(basePath, svgLoader) + ResourcePainterProvider.stateful(basePath, svgLoader, LocalIconData.current) + @Composable fun light( svgLoader: SvgLoader, radioButton: PainterProvider = radioButton( @@ -119,6 +122,7 @@ data class IntUiRadioButtonIcons( ), ) = IntUiRadioButtonIcons(radioButton) + @Composable fun dark( svgLoader: SvgLoader, radioButton: PainterProvider = radioButton( diff --git a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTabStyling.kt b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTabStyling.kt index df1d9f8bd..f75dce47f 100644 --- a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTabStyling.kt +++ b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTabStyling.kt @@ -7,6 +7,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import org.jetbrains.jewel.ButtonState +import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme import org.jetbrains.jewel.intui.core.theme.IntUiLightTheme @@ -355,7 +356,7 @@ data class IntUiTabIcons( svgLoader: SvgLoader, basePath: String = "expui/general/closeSmall.svg", ): PainterProvider = - ResourcePainterProvider.stateful(basePath, svgLoader) + ResourcePainterProvider.stateful(basePath, svgLoader, LocalIconData.current) } } diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Buttons.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Buttons.kt index 36277b54c..dad044b8f 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Buttons.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Buttons.kt @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.ResourceLoader @@ -15,9 +14,10 @@ import org.jetbrains.jewel.GroupHeader import org.jetbrains.jewel.Icon import org.jetbrains.jewel.IconButton import org.jetbrains.jewel.JewelSvgLoader +import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.OutlinedButton import org.jetbrains.jewel.Text -import org.jetbrains.jewel.styling.ResourcePainterProvider +import org.jetbrains.jewel.styling.rememberStatelessPainterProvider @Composable fun Buttons(svgLoader: JewelSvgLoader, resourceLoader: ResourceLoader) { @@ -44,7 +44,7 @@ fun Buttons(svgLoader: JewelSvgLoader, resourceLoader: ResourceLoader) { } IconButton(onClick = {}) { - val iconProvider = remember { ResourcePainterProvider.stateless("icons/close.svg", svgLoader) } + val iconProvider = rememberStatelessPainterProvider("icons/close.svg", svgLoader) val iconPainter by iconProvider.getPainter(resourceLoader) Icon( painter = iconPainter, diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Icons.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Icons.kt index 2e6a9c743..71c494d84 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Icons.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Icons.kt @@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.BlendMode import androidx.compose.ui.graphics.Color @@ -17,7 +16,7 @@ import androidx.compose.ui.unit.dp import org.jetbrains.jewel.GroupHeader import org.jetbrains.jewel.Icon import org.jetbrains.jewel.SvgLoader -import org.jetbrains.jewel.styling.ResourcePainterProvider +import org.jetbrains.jewel.styling.rememberStatelessPainterProvider @Composable internal fun Icons(svgLoader: SvgLoader, resourceLoader: ResourceLoader) { @@ -27,7 +26,7 @@ internal fun Icons(svgLoader: SvgLoader, resourceLoader: ResourceLoader) { modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(16.dp), ) { - val jewelLogoProvider = remember { ResourcePainterProvider.stateless("icons/jewel-logo.svg", svgLoader) } + val jewelLogoProvider = rememberStatelessPainterProvider("icons/jewel-logo.svg", svgLoader) val jewelLogo by jewelLogoProvider.getPainter(resourceLoader) Icon(jewelLogo, "Jewel Logo", Modifier.size(16.dp)) diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Tabs.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Tabs.kt index 851a4952f..1eed2c231 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Tabs.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Tabs.kt @@ -28,13 +28,14 @@ import androidx.compose.ui.unit.dp import org.jetbrains.jewel.GroupHeader import org.jetbrains.jewel.Icon import org.jetbrains.jewel.IntelliJTheme +import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.NoIndication import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.TabData import org.jetbrains.jewel.TabStrip import org.jetbrains.jewel.Text import org.jetbrains.jewel.intui.standalone.IntUiTheme -import org.jetbrains.jewel.styling.ResourcePainterProvider +import org.jetbrains.jewel.styling.rememberStatelessPainterProvider import kotlin.math.max @Composable @@ -170,7 +171,7 @@ private fun TabStripWithAddButton( .background(backgroundColor), contentAlignment = Alignment.Center, ) { - val addIconProvider = remember { ResourcePainterProvider.stateless("expui/general/add.svg", svgLoader) } + val addIconProvider = rememberStatelessPainterProvider("expui/general/add.svg", svgLoader) val addIcon by addIconProvider.getPainter(resourceLoader) Icon(addIcon, contentDescription = "Add a tab") diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/TextFields.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/TextFields.kt index 0fbe47a73..83af58ef1 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/TextFields.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/TextFields.kt @@ -15,11 +15,12 @@ import androidx.compose.ui.unit.dp import org.jetbrains.jewel.GroupHeader import org.jetbrains.jewel.Icon import org.jetbrains.jewel.LabelledTextField +import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.Outline import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.Text import org.jetbrains.jewel.TextField -import org.jetbrains.jewel.styling.ResourcePainterProvider +import org.jetbrains.jewel.styling.rememberStatelessPainterProvider @Composable fun TextFields(svgLoader: SvgLoader, resourceLoader: ResourceLoader) { @@ -71,9 +72,11 @@ fun TextFields(svgLoader: SvgLoader, resourceLoader: ResourceLoader) { ) { var text by remember { mutableStateOf("With leading icon") } TextField(text, { text = it }, enabled = true, leadingIcon = { - val searchIcon by remember { ResourcePainterProvider.stateless("icons/search.svg", svgLoader) }.getPainter( - resourceLoader, - ) + val iconData = LocalIconData.current + val searchIcon by rememberStatelessPainterProvider("icons/search.svg", svgLoader, iconData) + .getPainter( + resourceLoader, + ) Icon(searchIcon, "SearchIcon", Modifier.size(16.dp)) }) }