feat(InstallScreen): prevent autoclosing if interacted with
This commit is contained in:
parent
1b1316d4dc
commit
0d8a04af62
3 changed files with 50 additions and 17 deletions
|
|
@ -31,6 +31,7 @@ class InstallModel(
|
|||
) : StateScreenModel<InstallScreenState>(InstallScreenState.Pending) {
|
||||
private lateinit var startTime: Date
|
||||
private var installJob: Job? = null
|
||||
private var autocloseCancelled: Boolean = false
|
||||
|
||||
var installSteps by mutableStateOf<ImmutableMap<StepGroup, ImmutableList<Step>>?>(null)
|
||||
private set
|
||||
|
|
@ -63,6 +64,13 @@ class InstallModel(
|
|||
application.showToast(R.string.action_cleared_cache)
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the screen auto-close once installation was completed
|
||||
*/
|
||||
fun cancelAutoclose() {
|
||||
autocloseCancelled = true
|
||||
}
|
||||
|
||||
fun restart() {
|
||||
installJob?.cancel("Manual cancellation")
|
||||
installSteps = null
|
||||
|
|
@ -92,10 +100,13 @@ class InstallModel(
|
|||
// At this point, the installation has successfully completed
|
||||
else {
|
||||
mutableState.value = InstallScreenState.Success
|
||||
autocloseCancelled = false
|
||||
|
||||
// Wait 20s before returning to Home
|
||||
// Wait 5s before returning to Home if screen hasn't been clicked
|
||||
delay(5000)
|
||||
mutableState.value = InstallScreenState.CloseScreen
|
||||
if (!autocloseCancelled) {
|
||||
mutableState.value = InstallScreenState.CloseScreen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ package com.aliucord.manager.ui.screens.install
|
|||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
|
|
@ -15,7 +16,6 @@ import androidx.compose.runtime.*
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
|
@ -28,6 +28,7 @@ import com.aliucord.manager.installer.steps.StepGroup
|
|||
import com.aliucord.manager.ui.components.Wakelock
|
||||
import com.aliucord.manager.ui.components.back
|
||||
import com.aliucord.manager.ui.components.dialogs.InstallerAbortDialog
|
||||
import com.aliucord.manager.ui.screens.install.components.InstallAppBar
|
||||
import com.aliucord.manager.ui.screens.install.components.StepGroupCard
|
||||
import com.aliucord.manager.ui.screens.installopts.InstallOptions
|
||||
import org.koin.core.parameter.parametersOf
|
||||
|
|
@ -76,19 +77,13 @@ class InstallScreen(private val data: InstallOptions) : Screen {
|
|||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.installer)) },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onTryExit) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_back),
|
||||
contentDescription = stringResource(R.string.navigation_back),
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
topBar = { InstallAppBar(onTryExit) },
|
||||
modifier = Modifier
|
||||
.clickable(
|
||||
indication = null,
|
||||
onClick = model::cancelAutoclose,
|
||||
interactionSource = remember(::MutableInteractionSource),
|
||||
),
|
||||
) { paddingValues ->
|
||||
Column(Modifier.padding(paddingValues)) {
|
||||
if (state.value is InstallScreenState.Working) {
|
||||
|
|
@ -121,7 +116,10 @@ class InstallScreen(private val data: InstallOptions) : Screen {
|
|||
name = stringResource(group.localizedName),
|
||||
subSteps = steps,
|
||||
isExpanded = expandedGroup == group,
|
||||
onExpand = { expandedGroup = group },
|
||||
onExpand = {
|
||||
model.cancelAutoclose()
|
||||
expandedGroup = group
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.aliucord.manager.ui.screens.install.components
|
||||
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.aliucord.manager.R
|
||||
|
||||
@Composable
|
||||
fun InstallAppBar(
|
||||
onTryExit: () -> Unit,
|
||||
) {
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.installer)) },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onTryExit) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_back),
|
||||
contentDescription = stringResource(R.string.navigation_back),
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue