-
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.
Add a customizable circular progress to the UI
This commit adds a flexible circular progress option to the UI that supports both small and large size variants. The base theme has been updated to provide styling to both variants, and new SVG files have been added to provide dynamic views of the circular progress. The circular progress can be incorporated in the UI using the CircularProgress and CircularProgressBig components. This addition provides a more visually engaging way to show progress in the UI.
- Loading branch information
Showing
42 changed files
with
714 additions
and
47 deletions.
There are no files selected for viewing
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
17 changes: 5 additions & 12 deletions
17
core/src/main/kotlin/org/jetbrains/jewel/styling/CircularProgressStyle.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 |
---|---|---|
@@ -1,32 +1,25 @@ | ||
package org.jetbrains.jewel.styling | ||
|
||
import androidx.compose.runtime.Immutable | ||
import androidx.compose.runtime.State | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import androidx.compose.ui.graphics.painter.Painter | ||
import androidx.compose.ui.unit.DpSize | ||
import kotlin.time.Duration | ||
|
||
interface CircularProgressStyle { | ||
|
||
val frameIcons: CircularProgressIcons | ||
val metrics: CircularProgressMetrics | ||
val frameTime: Duration | ||
} | ||
|
||
@Immutable | ||
interface CircularProgressIcons { | ||
|
||
val frames: State<List<Painter>> | ||
val frames: List<PainterProvider<Unit>> | ||
} | ||
|
||
@Immutable | ||
interface CircularProgressMetrics { | ||
|
||
val animationDelay: Duration | ||
val frameTime: Duration | ||
val size: DpSize | ||
val LocalCircularProgressStyle = staticCompositionLocalOf<CircularProgressStyle> { | ||
error("No CircularProgressStyle provided") | ||
} | ||
|
||
val LocalCircularProgressStyle = staticCompositionLocalOf<CircularProgressStyle> { | ||
val LocalCircularProgressBigStyle = staticCompositionLocalOf<CircularProgressStyle> { | ||
error("No CircularProgressStyle provided") | ||
} |
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
97 changes: 97 additions & 0 deletions
97
...rc/main/kotlin/org/jetbrains/jewel/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,97 @@ | ||
package org.jetbrains.jewel.intui.standalone.styling | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.Stable | ||
import org.jetbrains.jewel.SvgLoader | ||
import org.jetbrains.jewel.styling.CircularProgressIcons | ||
import org.jetbrains.jewel.styling.CircularProgressStyle | ||
import org.jetbrains.jewel.styling.PainterProvider | ||
import org.jetbrains.jewel.styling.ResourcePainterProvider | ||
import kotlin.time.Duration | ||
import kotlin.time.Duration.Companion.milliseconds | ||
|
||
@Stable | ||
data class IntUiCircularProgressStyle( | ||
override val frameIcons: IntUiCircularProgressIcons, | ||
override val frameTime: Duration, | ||
) : CircularProgressStyle { | ||
|
||
object Small { | ||
|
||
@Composable | ||
fun dark( | ||
svgLoader: SvgLoader, | ||
frameTime: Duration = 125.milliseconds, | ||
frameIcons: IntUiCircularProgressIcons = intUiCircularProgressIcons(svgLoader), | ||
) = | ||
IntUiCircularProgressStyle(frameIcons, frameTime) | ||
|
||
@Composable | ||
fun light( | ||
svgLoader: SvgLoader, | ||
frameTime: Duration = 125.milliseconds, | ||
frameIcons: IntUiCircularProgressIcons = intUiCircularProgressIcons(svgLoader), | ||
) = | ||
IntUiCircularProgressStyle(frameIcons, frameTime) | ||
} | ||
|
||
object Big { | ||
|
||
@Composable | ||
fun dark( | ||
svgLoader: SvgLoader, | ||
frameTime: Duration = 125.milliseconds, | ||
frameIcons: IntUiCircularProgressIcons = intUiCircularProgressBigIcons(svgLoader), | ||
) = | ||
IntUiCircularProgressStyle(frameIcons, frameTime) | ||
|
||
@Composable | ||
fun light( | ||
svgLoader: SvgLoader, | ||
frameTime: Duration = 125.milliseconds, | ||
frameIcons: IntUiCircularProgressIcons = intUiCircularProgressBigIcons(svgLoader), | ||
) = | ||
IntUiCircularProgressStyle(frameIcons, frameTime) | ||
} | ||
} | ||
|
||
data class IntUiCircularProgressIcons( | ||
override val frames: List<PainterProvider<Unit>>, | ||
) : CircularProgressIcons { | ||
|
||
companion object { | ||
|
||
@Composable | ||
fun getFrames( | ||
svgLoader: SvgLoader, | ||
iconsPaths: List<String>, | ||
): List<PainterProvider<Unit>> = iconsPaths.map { | ||
ResourcePainterProvider.stateless(basePath = it, svgLoader = svgLoader) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun intUiCircularProgressIcons( | ||
svgLoader: SvgLoader, | ||
iconPrefix: String = "icons/intui/animated/smallSpinner/", | ||
iconsNames: List<String> = listOf( | ||
"spinner1.svg", | ||
"spinner2.svg", | ||
"spinner3.svg", | ||
"spinner4.svg", | ||
"spinner5.svg", | ||
"spinner6.svg", | ||
"spinner7.svg", | ||
"spinner8.svg", | ||
), | ||
) = IntUiCircularProgressIcons( | ||
IntUiCircularProgressIcons.getFrames( | ||
svgLoader, | ||
iconsNames.map { iconPrefix + it }, | ||
), | ||
) | ||
|
||
@Composable | ||
fun intUiCircularProgressBigIcons(svgLoader: SvgLoader) = | ||
intUiCircularProgressIcons(svgLoader = svgLoader, iconPrefix = "icons/intui/animated/bigSpinner/") |
Oops, something went wrong.