From 7e744c1e0cad007b7db0e952558f07ce1c139cc9 Mon Sep 17 00:00:00 2001 From: fscarponi Date: Fri, 29 Sep 2023 11:04:09 +0200 Subject: [PATCH] Remove SvgLoader from CircularProgressStyle --- .../org/jetbrains/jewel/CircularProgressIndicator.kt | 11 ++++++++--- .../jetbrains/jewel/styling/CircularProgressStyle.kt | 2 -- .../standalone/styling/IntUiCircularProgressStyle.kt | 8 ++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/jewel/CircularProgressIndicator.kt b/core/src/main/kotlin/org/jetbrains/jewel/CircularProgressIndicator.kt index c9b174305b..47a78ccc62 100644 --- a/core/src/main/kotlin/org/jetbrains/jewel/CircularProgressIndicator.kt +++ b/core/src/main/kotlin/org/jetbrains/jewel/CircularProgressIndicator.kt @@ -19,26 +19,30 @@ import org.jetbrains.jewel.util.toHexString @Composable fun CircularProgressIndicator( + svgLoader: SvgLoader, modifier: Modifier = Modifier, style: CircularProgressStyle = IntelliJTheme.circularProgressStyle, ) { CircularProgressIndicatorImpl( modifier = modifier, - style = style, + svgLoader = svgLoader, iconSize = DpSize(16.dp, 16.dp), + style = style, frameRetriever = { color -> SpinnerProgressIconGenerator.Small.generateSvgFrames(color.toHexString()) } ) } @Composable fun CircularProgressIndicatorBig( + svgLoader: SvgLoader, modifier: Modifier = Modifier, style: CircularProgressStyle = IntelliJTheme.circularProgressStyle, ) { CircularProgressIndicatorImpl( modifier = modifier, - style = style, + svgLoader = svgLoader, iconSize = DpSize(32.dp, 32.dp), + style = style, frameRetriever = { color -> SpinnerProgressIconGenerator.Big.generateSvgFrames(color.toHexString()) } ) } @@ -46,6 +50,7 @@ fun CircularProgressIndicatorBig( @Composable private fun CircularProgressIndicatorImpl( modifier: Modifier = Modifier, + svgLoader: SvgLoader, iconSize: DpSize, style: CircularProgressStyle, frameRetriever: (Color) -> List, @@ -59,7 +64,7 @@ private fun CircularProgressIndicatorImpl( } else { Icon( modifier = modifier.size(iconSize), - painter = style.svgLoader.loadRawSvg( + painter = svgLoader.loadRawSvg( currentFrame.first, "circularProgressIndicator_frame_${currentFrame.second}" ), diff --git a/core/src/main/kotlin/org/jetbrains/jewel/styling/CircularProgressStyle.kt b/core/src/main/kotlin/org/jetbrains/jewel/styling/CircularProgressStyle.kt index a7022ea385..ae3d34d423 100644 --- a/core/src/main/kotlin/org/jetbrains/jewel/styling/CircularProgressStyle.kt +++ b/core/src/main/kotlin/org/jetbrains/jewel/styling/CircularProgressStyle.kt @@ -2,12 +2,10 @@ package org.jetbrains.jewel.styling import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Color -import org.jetbrains.jewel.SvgLoader import kotlin.time.Duration interface CircularProgressStyle { - val svgLoader: SvgLoader val frameTime: Duration val color: Color } diff --git a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiCircularProgressStyle.kt b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiCircularProgressStyle.kt index 9aad1e4529..20d99bb970 100644 --- a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiCircularProgressStyle.kt +++ b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiCircularProgressStyle.kt @@ -2,14 +2,12 @@ package org.jetbrains.jewel.intui.standalone.styling import androidx.compose.runtime.Stable import androidx.compose.ui.graphics.Color -import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.styling.CircularProgressStyle import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds @Stable data class IntUiCircularProgressStyle( - override val svgLoader: SvgLoader, override val frameTime: Duration, override val color: Color, ) : CircularProgressStyle { @@ -17,15 +15,13 @@ data class IntUiCircularProgressStyle( companion object { fun dark( - svgLoader: SvgLoader, frameTime: Duration = 125.milliseconds, color: Color = Color(0xFF6F737A), - ) = IntUiCircularProgressStyle(svgLoader, frameTime, color) + ) = IntUiCircularProgressStyle(frameTime, color) fun light( - svgLoader: SvgLoader, frameTime: Duration = 125.milliseconds, color: Color = Color(0xFFA8ADBD), - ) = IntUiCircularProgressStyle(svgLoader, frameTime, color) + ) = IntUiCircularProgressStyle(frameTime, color) } }