diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 38f86db..239101a 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -35,6 +35,7 @@ kotlin { implementation(compose.material) @OptIn(ExperimentalComposeLibrary::class) implementation(compose.components.resources) + implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5") } } val androidMain by getting { diff --git a/lib/src/commonMain/kotlin/StackedSnakbarHostState.kt b/lib/src/commonMain/kotlin/StackedSnakbarHostState.kt index 881fcbd..069c9a5 100644 --- a/lib/src/commonMain/kotlin/StackedSnakbarHostState.kt +++ b/lib/src/commonMain/kotlin/StackedSnakbarHostState.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.Modifier import internal.StackedSnackbar import internal.StackedSnackbarData import internal.Type +import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow @@ -41,7 +42,7 @@ fun StackedSnackbarHost( } if (hostState.currentSnackbarData.isNotEmpty()) { StackedSnackbar( - snackbarData = hostState.currentSnackbarData, + snackbarData = hostState.currentSnackbarData.toImmutableList(), onSnackbarRemoved = { hostState.newSnackbarHosted.value = false coroutineScope.launch { diff --git a/lib/src/commonMain/kotlin/internal/StackedSnackbar.kt b/lib/src/commonMain/kotlin/internal/StackedSnackbar.kt index 58cdf64..c79b347 100644 --- a/lib/src/commonMain/kotlin/internal/StackedSnackbar.kt +++ b/lib/src/commonMain/kotlin/internal/StackedSnackbar.kt @@ -48,6 +48,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp +import kotlinx.collections.immutable.ImmutableList import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.painterResource import kotlin.math.abs @@ -56,7 +57,7 @@ import kotlin.math.roundToInt @Composable internal fun StackedSnackbar( - snackbarData: List, + snackbarData: ImmutableList, maxStack: Int, animation: StackedSnackbarAnimation, onSnackbarRemoved: () -> Unit,