Skip to content

Commit

Permalink
Add API to access SVGLoader in bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
rock3r committed Sep 19, 2023
1 parent 3476af6 commit 60cb501
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.jetbrains.jewel.bridge

import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.text.TextStyle
import com.intellij.openapi.Disposable
import com.intellij.openapi.components.Service
Expand Down Expand Up @@ -34,10 +37,17 @@ class SwingBridgeService : Disposable {
// TODO we shouldn't assume it's Int UI, but we only have that for now
internal val currentBridgeThemeData: StateFlow<BridgeThemeData> =
IntelliJApplication.lookAndFeelChangedFlow(coroutineScope)
.mapLatest { getThemeData() }
.mapLatest { tryGettingThemeData() }
.stateIn(coroutineScope, SharingStarted.Eagerly, BridgeThemeData.DEFAULT)

private suspend fun getThemeData(): BridgeThemeData {
@get:Composable
val svgLoader: SvgLoader
get() {
val data by currentBridgeThemeData.collectAsState()
return data.svgLoader
}

private suspend fun tryGettingThemeData(): BridgeThemeData {
var counter = 0
while (counter < 20) {
delay(20.milliseconds)
Expand Down

0 comments on commit 60cb501

Please sign in to comment.