impl VBoxUpdateFetcher
This commit is contained in:
+10
-8
@@ -18,11 +18,11 @@ import androidx.compose.animation.AnimatedContent
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -38,6 +38,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.arkivanov.decompose.extensions.compose.subscribeAsState
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import ru.shadowsparky.ui.components.Loading
|
||||
import ru.shadowsparky.updater.domain.UpdateState
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@@ -54,11 +55,15 @@ fun UpdateBottomSheet(
|
||||
val isVisible = remember(state) { state !is UpdateState.Idle && state !is UpdateState.UpToDate }
|
||||
|
||||
if (isVisible) {
|
||||
ModalBottomSheet(onDismissRequest = {}, sheetState = sheetState, modifier = modifier) {
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = { component.reset() },
|
||||
sheetState = sheetState,
|
||||
modifier = modifier
|
||||
) {
|
||||
AnimatedContent(
|
||||
targetState = state,
|
||||
label = "UpdateStateAnimation",
|
||||
modifier = Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, bottom = 32.dp)
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp)
|
||||
) { currentState ->
|
||||
when (currentState) {
|
||||
is UpdateState.Checking -> UpdateCheckingContent()
|
||||
@@ -90,11 +95,8 @@ fun UpdateBottomSheet(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun UpdateCheckingContent(modifier: Modifier = Modifier) {
|
||||
Column(
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) { CircularProgressIndicator() }
|
||||
private fun UpdateCheckingContent() {
|
||||
Loading(Modifier.fillMaxSize())
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
+4
@@ -65,6 +65,10 @@ class UpdateComponent(
|
||||
fun installApk(path: String) {
|
||||
scope.launch { interactor.installApk(path) }
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
_state.value = UpdateState.Idle
|
||||
}
|
||||
}
|
||||
|
||||
@Factory
|
||||
|
||||
Reference in New Issue
Block a user