Skip to content

Commit c8ec545

Browse files
committed
Replace path-based icon with key-based
1 parent 11b6486 commit c8ec545

File tree

1 file changed

+13
-36
lines changed
  • samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component

1 file changed

+13
-36
lines changed

samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/Tabs.kt

+13-36
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,13 @@ private fun DefaultTabShowcase() {
6464
content = { tabState ->
6565
val iconProvider = rememberResourcePainterProvider(AllIconsKeys.Actions.Find)
6666
val icon by iconProvider.getPainter(Stateful(tabState))
67-
SimpleTabContent(
68-
label = "Default Tab $id",
69-
state = tabState,
70-
icon = icon,
71-
)
67+
SimpleTabContent(label = "Default Tab $id", state = tabState, icon = icon)
7268
},
7369
onClose = {
7470
tabIds = tabIds.toMutableList().apply { removeAt(index) }
7571
if (selectedTabIndex >= index) {
7672
val maxPossibleIndex = max(0, tabIds.lastIndex)
77-
selectedTabIndex =
78-
(selectedTabIndex - 1)
79-
.coerceIn(0..maxPossibleIndex)
73+
selectedTabIndex = (selectedTabIndex - 1).coerceIn(0..maxPossibleIndex)
8074
}
8175
},
8276
onClick = { selectedTabIndex = index },
@@ -88,10 +82,7 @@ private fun DefaultTabShowcase() {
8882
val insertionIndex = (selectedTabIndex + 1).coerceIn(0..tabIds.size)
8983
val nextTabId = maxId + 1
9084

91-
tabIds =
92-
tabIds
93-
.toMutableList()
94-
.apply { add(insertionIndex, nextTabId) }
85+
tabIds = tabIds.toMutableList().apply { add(insertionIndex, nextTabId) }
9586
selectedTabIndex = insertionIndex
9687
}
9788
}
@@ -125,24 +116,20 @@ private fun EditorTabShowcase() {
125116
)
126117
Box(
127118
modifier =
128-
Modifier
129-
.size(12.dp)
130-
.thenIf(tabState.isHovered) {
131-
drawWithCache {
132-
onDrawBehind {
133-
drawCircle(color = Color.Magenta.copy(alpha = .4f), radius = 6.dp.toPx())
134-
}
119+
Modifier.size(12.dp).thenIf(tabState.isHovered) {
120+
drawWithCache {
121+
onDrawBehind {
122+
drawCircle(color = Color.Magenta.copy(alpha = .4f), radius = 6.dp.toPx())
135123
}
136-
},
124+
}
125+
},
137126
)
138127
},
139128
onClose = {
140129
tabIds = tabIds.toMutableList().apply { removeAt(index) }
141130
if (selectedTabIndex >= index) {
142131
val maxPossibleIndex = max(0, tabIds.lastIndex)
143-
selectedTabIndex =
144-
(selectedTabIndex - 1)
145-
.coerceIn(0..maxPossibleIndex)
132+
selectedTabIndex = (selectedTabIndex - 1).coerceIn(0..maxPossibleIndex)
146133
}
147134
},
148135
onClick = { selectedTabIndex = index },
@@ -154,10 +141,7 @@ private fun EditorTabShowcase() {
154141
val insertionIndex = (selectedTabIndex + 1).coerceIn(0..tabIds.size)
155142
val nextTabId = maxId + 1
156143

157-
tabIds =
158-
tabIds
159-
.toMutableList()
160-
.apply { add(insertionIndex, nextTabId) }
144+
tabIds = tabIds.toMutableList().apply { add(insertionIndex, nextTabId) }
161145
selectedTabIndex = insertionIndex
162146
}
163147
}
@@ -171,15 +155,8 @@ private fun TabStripWithAddButton(
171155
Row(verticalAlignment = Alignment.CenterVertically) {
172156
TabStrip(tabs, style, modifier = Modifier.weight(1f))
173157

174-
IconButton(
175-
onClick = onAddClick,
176-
modifier = Modifier.size(JewelTheme.defaultTabStyle.metrics.tabHeight),
177-
) {
178-
Icon(
179-
resource = "expui/general/add.svg",
180-
contentDescription = "Add a tab",
181-
StandaloneSampleIcons::class.java,
182-
)
158+
IconButton(onClick = onAddClick, modifier = Modifier.size(JewelTheme.defaultTabStyle.metrics.tabHeight)) {
159+
Icon(key = AllIconsKeys.General.Add, contentDescription = "Add a tab")
183160
}
184161
}
185162
}

0 commit comments

Comments
 (0)