Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Use scrollToItem instead of animateScrollToItem
Browse files Browse the repository at this point in the history
  • Loading branch information
SanmerDev committed Jul 2, 2024
1 parent c79acc5 commit 7288761
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions app/src/main/kotlin/dev/sanmer/mrepo/ui/activity/InstallScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
Expand Down Expand Up @@ -91,19 +90,13 @@ fun InstallScreen(
scope.launch {
viewModel.writeLogsTo(context, uri)
.onSuccess {
val message = context.getString(R.string.install_logs_saved)
snackbarHostState.showSnackbar(
message = message,
duration = SnackbarDuration.Short
message = context.getString(R.string.install_logs_saved)
)
}.onFailure {
val message = context.getString(
R.string.install_logs_save_failed,
it.message ?: context.getString(R.string.unknown_error)
)
val message = it.message ?: context.getString(R.string.unknown_error)
snackbarHostState.showSnackbar(
message = message,
duration = SnackbarDuration.Short
message = context.getString(R.string.install_logs_save_failed, message)
)
}
}
Expand All @@ -115,6 +108,7 @@ fun InstallScreen(
when (it.key) {
Key.VolumeUp,
Key.VolumeDown -> viewModel.event.isInstalling

else -> false
}
}
Expand Down Expand Up @@ -164,10 +158,6 @@ private fun Console(
state: LazyListState,
modifier: Modifier = Modifier,
) {
LaunchedEffect(list.size) {
state.animateScrollToItem(list.size)
}

LazyColumn(
state = state,
modifier = modifier
Expand All @@ -183,6 +173,10 @@ private fun Console(
)
}
}

LaunchedEffect(list.size) {
state.scrollToItem(list.size)
}
}

@Composable
Expand Down

0 comments on commit 7288761

Please sign in to comment.