Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarponi committed Sep 13, 2023
1 parent 1316950 commit 5d61223
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 26 deletions.
2 changes: 2 additions & 0 deletions .idea/detekt.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jetbrains.jewel

import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -10,6 +11,7 @@ import androidx.compose.ui.Modifier
import kotlinx.coroutines.delay
import org.jetbrains.jewel.styling.CircularProgressStyle

@Composable
fun CircularProgress(
modifier: Modifier,
style: CircularProgressStyle = IntelliJTheme.circularProgressStyle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,7 @@ import androidx.compose.runtime.State
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.unit.DpSize
import java.time.Duration

data class IntUiCircularProgressStyle(
override val frameIcons: CircularProgressIcons,
override val metrics: CircularProgressMetrics,
) : CircularProgressStyle {

companion object {
// todo
// @Composable
// fun light(
// svgLoader: SvgLoader,
// metrics: IntUiLazyTreeMetrics = IntUiLazyTreeMetrics(),
// frameIcons: CircularProgressIcons: IntUiLazyTreeIcons = intUiLazyTreeIcons(svgLoader),
// ) = IntUiLazyTreeStyle(colors, metrics, icons)
//
// @Composable
// fun dark(
// svgLoader: SvgLoader,
// colors: IntUiLazyTreeColors = IntUiLazyTreeColors.dark(),
// metrics: IntUiLazyTreeMetrics = IntUiLazyTreeMetrics(),
// icons: IntUiLazyTreeIcons = intUiLazyTreeIcons(svgLoader),
// ) = IntUiLazyTreeStyle(colors, metrics, icons)
}
}
import kotlin.time.Duration

interface CircularProgressStyle {

Expand Down
1 change: 0 additions & 1 deletion ide-laf-bridge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ plugins {
dependencies {
api(projects.themes.intUi.intUiStandalone)
compileOnly(libs.bundles.idea)

testImplementation(compose.desktop.uiTestJUnit4)
}
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)
}
}
}

0 comments on commit 5d61223

Please sign in to comment.