mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Remove useless derivedStateOf
This commit is contained in:
+8
-13
@@ -15,7 +15,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.derivedStateOf
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@@ -51,27 +50,23 @@ fun LiveWaveformView(
|
|||||||
linePadding: Dp = 2.dp,
|
linePadding: Dp = 2.dp,
|
||||||
) {
|
) {
|
||||||
var canvasSize by remember { mutableStateOf(DpSize(0.dp, 0.dp)) }
|
var canvasSize by remember { mutableStateOf(DpSize(0.dp, 0.dp)) }
|
||||||
|
|
||||||
var parentWidth by remember { mutableIntStateOf(0) }
|
var parentWidth by remember { mutableIntStateOf(0) }
|
||||||
|
val waveformWidth = remember(levels.size, lineWidth, linePadding) {
|
||||||
val waveformWidth by remember(levels.size, lineWidth, linePadding) {
|
levels.size * (lineWidth.value + linePadding.value)
|
||||||
derivedStateOf {
|
|
||||||
levels.size * (lineWidth.value + linePadding.value)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
contentAlignment = Alignment.CenterEnd,
|
contentAlignment = Alignment.CenterEnd,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(waveFormHeight)
|
.height(waveFormHeight)
|
||||||
.onSizeChanged { parentWidth = it.width }
|
.onSizeChanged { parentWidth = it.width }
|
||||||
) {
|
) {
|
||||||
Canvas(
|
Canvas(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(Dp(waveformWidth))
|
.width(Dp(waveformWidth))
|
||||||
.graphicsLayer(alpha = DEFAULT_GRAPHICS_LAYER_ALPHA)
|
.graphicsLayer(alpha = DEFAULT_GRAPHICS_LAYER_ALPHA)
|
||||||
.then(modifier)
|
.then(modifier)
|
||||||
) {
|
) {
|
||||||
val width = min(waveformWidth, parentWidth.toFloat())
|
val width = min(waveformWidth, parentWidth.toFloat())
|
||||||
canvasSize = DpSize(width.dp, size.height.toDp())
|
canvasSize = DpSize(width.dp, size.height.toDp())
|
||||||
|
|||||||
Reference in New Issue
Block a user