Skip to content

Commit

Permalink
chore: use kotlin immutable list
Browse files Browse the repository at this point in the history
  • Loading branch information
Rizki Maulana committed Jan 5, 2024
1 parent 73b3617 commit 2eaaa63
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion lib/src/commonMain/kotlin/StackedSnakbarHostState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion lib/src/commonMain/kotlin/internal/StackedSnackbar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -56,7 +57,7 @@ import kotlin.math.roundToInt

@Composable
internal fun StackedSnackbar(
snackbarData: List<StackedSnackbarData>,
snackbarData: ImmutableList<StackedSnackbarData>,
maxStack: Int,
animation: StackedSnackbarAnimation,
onSnackbarRemoved: () -> Unit,
Expand Down

0 comments on commit 2eaaa63

Please sign in to comment.