|
@@ -4,25 +4,27 @@ import androidx.compose.animation.core.AnimationSpec
|
|
|
import androidx.compose.animation.core.TweenSpec
|
|
import androidx.compose.animation.core.TweenSpec
|
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
|
|
|
+import androidx.compose.runtime.getValue
|
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.graphics.Color
|
|
import androidx.compose.ui.graphics.Color
|
|
|
import com.aay.compose.baseComponents.model.LegendPosition
|
|
import com.aay.compose.baseComponents.model.LegendPosition
|
|
|
import eu.mjdev.desktop.components.draggable.DraggableView
|
|
import eu.mjdev.desktop.components.draggable.DraggableView
|
|
|
-import eu.mjdev.desktop.extensions.Compose.DarkDarkGray
|
|
|
|
|
import eu.mjdev.desktop.extensions.Compose.rememberState
|
|
import eu.mjdev.desktop.extensions.Compose.rememberState
|
|
|
|
|
+import eu.mjdev.desktop.helpers.internal.Palette.Companion.rememberBackgroundColor
|
|
|
|
|
+import eu.mjdev.desktop.helpers.internal.Palette.Companion.rememberBorderColor
|
|
|
|
|
+import eu.mjdev.desktop.helpers.internal.Palette.Companion.rememberIconTintColor
|
|
|
|
|
+import eu.mjdev.desktop.helpers.internal.Palette.Companion.rememberTextColor
|
|
|
import eu.mjdev.desktop.helpers.system.MemInfo
|
|
import eu.mjdev.desktop.helpers.system.MemInfo
|
|
|
import eu.mjdev.desktop.helpers.system.MemInfo.Companion.toReadable
|
|
import eu.mjdev.desktop.helpers.system.MemInfo.Companion.toReadable
|
|
|
|
|
+import eu.mjdev.desktop.provider.DesktopProvider
|
|
|
|
|
+import eu.mjdev.desktop.provider.DesktopProvider.Companion.LocalDesktop
|
|
|
import kotlinx.coroutines.delay
|
|
import kotlinx.coroutines.delay
|
|
|
import kotlinx.coroutines.isActive
|
|
import kotlinx.coroutines.isActive
|
|
|
|
|
|
|
|
|
|
+@Suppress("FunctionName")
|
|
|
@Composable
|
|
@Composable
|
|
|
fun MemoryChart(
|
|
fun MemoryChart(
|
|
|
modifier: Modifier = Modifier,
|
|
modifier: Modifier = Modifier,
|
|
|
- textColor: Color = Color.White,
|
|
|
|
|
- outerCircularColor: Color = Color.White,
|
|
|
|
|
- innerCircularColor: Color = Color.White,
|
|
|
|
|
- totalColor: Color = Color.DarkDarkGray,
|
|
|
|
|
- currentColor: Color = Color.White,
|
|
|
|
|
ratioLineColor: Color = Color.Transparent,
|
|
ratioLineColor: Color = Color.Transparent,
|
|
|
mainTitle: String = "Memory",
|
|
mainTitle: String = "Memory",
|
|
|
usedTitle: String = "Used",
|
|
usedTitle: String = "Used",
|
|
@@ -30,21 +32,26 @@ fun MemoryChart(
|
|
|
animation: AnimationSpec<Float> = TweenSpec(durationMillis = 3000),
|
|
animation: AnimationSpec<Float> = TweenSpec(durationMillis = 3000),
|
|
|
legendPosition: LegendPosition = LegendPosition.BOTTOM,
|
|
legendPosition: LegendPosition = LegendPosition.BOTTOM,
|
|
|
updateTimeOut: Long = 10000,
|
|
updateTimeOut: Long = 10000,
|
|
|
- dragEnabled: Boolean = true
|
|
|
|
|
|
|
+ dragEnabled: Boolean = true,
|
|
|
|
|
+ api: DesktopProvider = LocalDesktop.current,
|
|
|
) = DraggableView(
|
|
) = DraggableView(
|
|
|
modifier = modifier,
|
|
modifier = modifier,
|
|
|
dragEnabled = dragEnabled
|
|
dragEnabled = dragEnabled
|
|
|
) {
|
|
) {
|
|
|
|
|
+ val backgroundColor by rememberBackgroundColor(api)
|
|
|
|
|
+ val textColor by rememberTextColor(api)
|
|
|
|
|
+ val borderColor by rememberBorderColor(api)
|
|
|
|
|
+ val iconsTintColor by rememberIconTintColor(api)
|
|
|
val memData = rememberState(MemInfo())
|
|
val memData = rememberState(MemInfo())
|
|
|
DualDonutChart(
|
|
DualDonutChart(
|
|
|
modifier = modifier,
|
|
modifier = modifier,
|
|
|
title = mainTitle,
|
|
title = mainTitle,
|
|
|
textColor = textColor,
|
|
textColor = textColor,
|
|
|
- outerCircularColor = outerCircularColor,
|
|
|
|
|
- innerCircularColor = innerCircularColor,
|
|
|
|
|
|
|
+ outerCircularColor = borderColor,
|
|
|
|
|
+ innerCircularColor = borderColor,
|
|
|
ratioLineColor = ratioLineColor,
|
|
ratioLineColor = ratioLineColor,
|
|
|
- secondColor = totalColor,
|
|
|
|
|
- firstColor = currentColor,
|
|
|
|
|
|
|
+ secondColor = backgroundColor,
|
|
|
|
|
+ firstColor = iconsTintColor,
|
|
|
secondValue = memData.value.free,
|
|
secondValue = memData.value.free,
|
|
|
firstValue = memData.value.used,
|
|
firstValue = memData.value.used,
|
|
|
secondTitle = freeTitle.plus(": ").plus(memData.value.free.toReadable()),
|
|
secondTitle = freeTitle.plus(": ").plus(memData.value.free.toReadable()),
|