-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
112 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
.../kotlin/org/jetbrains/jewel/themes/intui/standalone/styling/IntUiCircularProgressStyle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package org.jetbrains.jewel.themes.intui.standalone.styling | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.Immutable | ||
import androidx.compose.runtime.Stable | ||
import androidx.compose.ui.res.ResourceLoader | ||
import androidx.compose.ui.unit.DpSize | ||
import androidx.compose.ui.unit.dp | ||
import org.jetbrains.jewel.SvgLoader | ||
import org.jetbrains.jewel.painterResource | ||
import org.jetbrains.jewel.styling.CircularProgressIcons | ||
import org.jetbrains.jewel.styling.CircularProgressMetrics | ||
import org.jetbrains.jewel.styling.CircularProgressStyle | ||
import org.jetbrains.jewel.styling.ResourcePainterProvider | ||
import kotlin.time.Duration | ||
import kotlin.time.Duration.Companion.milliseconds | ||
|
||
data class IntUiCircularProgressStyle( | ||
override val metrics: CircularProgressMetrics, | ||
override val frameIcons: CircularProgressIcons, | ||
) : CircularProgressStyle { | ||
|
||
companion object { | ||
|
||
@Composable | ||
fun light( | ||
svgLoader: SvgLoader, | ||
metrics: CircularProgressMetrics = IntUiCircularProgressMetrics.light(), | ||
frameIcons: CircularProgressIcons = intUiLazyTreeIcons(svgLoader), | ||
) = IntUiCircularProgressStyle(colors, metrics, icons) | ||
|
||
@Composable | ||
fun dark( | ||
svgLoader: SvgLoader, | ||
metrics: CircularProgressMetrics = IntUiCircularProgressMetrics.dark(), | ||
frameIcons: CircularProgressIcons = intUiLazyTreeIcons(svgLoader), | ||
) = IntUiCircularProgressStyle(colors, metrics, icons) | ||
} | ||
} | ||
|
||
@Stable | ||
data class IntUiCircularProgressMetrics( | ||
override val animationDelay: Duration, | ||
override val frameTime: Duration, | ||
override val size: DpSize, | ||
) : CircularProgressMetrics { | ||
|
||
companion object { | ||
|
||
@Composable | ||
fun light( | ||
animationDelay: Duration = Duration.ZERO, | ||
frameTime: Duration = 80.milliseconds, | ||
size: DpSize = DpSize(24.dp, 24.dp), | ||
) = IntUiCircularProgressMetrics(animationDelay, frameTime, size) | ||
|
||
@Composable | ||
fun dark( | ||
animationDelay: Duration = Duration.ZERO, | ||
frameTime: Duration = 80.milliseconds, | ||
size: DpSize = DpSize(24.dp, 24.dp), | ||
) = IntUiCircularProgressMetrics(animationDelay, frameTime, size) | ||
} | ||
} | ||
|
||
@Immutable | ||
data class IntUiCircularProgressIcons( | ||
override val frames: List<ResourcePainterProvider<CircularProgressState>>, | ||
) : CircularProgressIcons { | ||
|
||
companion object { | ||
|
||
@Composable | ||
fun light( | ||
svgLoader: SvgLoader, | ||
resourceLoader: ResourceLoader, | ||
framesCount: Int, | ||
basePath: String = "icons/intui/circularProgressFrames/.svg", | ||
) { | ||
val extension = "." + basePath.substringAfterLast(".") | ||
val isSvg = extension.endsWith(".svg", ignoreCase = true) | ||
val frames = buildList { | ||
for (i in 0 until framesCount) { | ||
add( | ||
if (isSvg) { | ||
svgLoader.loadSvgResource(basePath, resourceLoader) { | ||
it.removeSuffix(".$extension").plus("_$i.$extension") | ||
} | ||
} else { | ||
painterResource(basePath.removeSuffix(".$extension").plus("_$i.$extension"), resourceLoader) | ||
} | ||
) | ||
} | ||
} | ||
IntUiCircularProgressIcons(frames) | ||
} | ||
|
||
@Composable | ||
fun dark( | ||
svgLoader: SvgLoader, | ||
framesCount: Int, | ||
basePath: String = "icons/intui/circularProgressFrames/.svg", | ||
) { | ||
IntUiCircularProgressIcons(frames) | ||
} | ||
} | ||
} |