fix: proper exit flow from install screen
- Refresh install list when returning to home screen - Fix auto-exiting successful install screen
This commit is contained in:
parent
18ab148e67
commit
8ba070b23b
5 changed files with 19 additions and 6 deletions
|
|
@ -36,7 +36,7 @@ class HomeModel(
|
|||
private set
|
||||
|
||||
init {
|
||||
fetchInstallations()
|
||||
// fetchInstallations() is called from UI
|
||||
fetchSupportedVersion()
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +94,9 @@ class HomeModel(
|
|||
return dangerousMobileDataStates.contains(telephony.dataState)
|
||||
}
|
||||
|
||||
private fun fetchInstallations() = screenModelScope.launchBlock {
|
||||
fun fetchInstallations() = screenModelScope.launchBlock {
|
||||
installations = InstallsState.Fetching
|
||||
|
||||
try {
|
||||
val packageManager = application.packageManager
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import androidx.compose.ui.text.SpanStyle
|
|||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.withStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.LifecycleResumeEffect
|
||||
import cafe.adriel.voyager.core.screen.Screen
|
||||
import cafe.adriel.voyager.koin.getScreenModel
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
|
|
@ -43,12 +44,19 @@ class HomeScreen : Screen {
|
|||
val navigator = LocalNavigator.currentOrThrow
|
||||
val model = getScreenModel<HomeModel>()
|
||||
|
||||
// Refresh installations list when the screen changes or activity resumes
|
||||
LifecycleResumeEffect {
|
||||
model.fetchInstallations()
|
||||
|
||||
onPauseOrDispose {}
|
||||
}
|
||||
|
||||
var showNetworkWarningDialog by remember { mutableStateOf(false) }
|
||||
var showInstallerDialog by remember { mutableStateOf(false) }
|
||||
|
||||
val onClickInstall: () -> Unit = remember {
|
||||
{
|
||||
if ((model.installations as? InstallsState.Fetched)?.data?.isNotEmpty() == false) {
|
||||
if ((model.installations as? InstallsState.Fetched)?.data?.isNotEmpty() == true) {
|
||||
model.showMultiInstallToast()
|
||||
} else if (model.isNetworkDangerous()) {
|
||||
showNetworkWarningDialog = true
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class InstallModel(
|
|||
mutableState.value = InstallScreenState.Success
|
||||
|
||||
// Wait 20s before returning to Home
|
||||
delay(20_000)
|
||||
delay(5000)
|
||||
mutableState.value = InstallScreenState.CloseScreen
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ class InstallScreen : Screen {
|
|||
val model = getScreenModel<InstallModel>()
|
||||
val state = model.state.collectAsState()
|
||||
|
||||
LaunchedEffect(model.state) {
|
||||
if (model.state.value is InstallScreenState.CloseScreen)
|
||||
LaunchedEffect(state.value) {
|
||||
if (state.value is InstallScreenState.CloseScreen)
|
||||
navigator.back(currentActivity = null)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ agp = "8.2.1"
|
|||
androidx-activity = "1.8.2"
|
||||
androidx-core = "1.12.0"
|
||||
androidx-splashscreen = "1.0.1"
|
||||
androidx-lifecycle = "2.7.0"
|
||||
apksig = "7.4.2"
|
||||
axml = "1.0.1"
|
||||
bouncycastle = "1.70"
|
||||
|
|
@ -27,6 +28,7 @@ accompanist-systemUiController = { module = "com.google.accompanist:accompanist-
|
|||
|
||||
# AndroidX
|
||||
androidx-activity = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
|
||||
androidx-lifecycle = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
|
||||
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
|
||||
androidx-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "androidx-splashscreen" }
|
||||
|
||||
|
|
@ -77,6 +79,7 @@ accompanist = [
|
|||
androidx = [
|
||||
"androidx-core",
|
||||
"androidx-activity",
|
||||
"androidx-lifecycle",
|
||||
"androidx-splashscreen",
|
||||
]
|
||||
compose = [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue