feat: don't show network warning dialog more than once per launch
Fixes #80
This commit is contained in:
parent
db66f26f67
commit
95ff30684d
2 changed files with 15 additions and 5 deletions
|
|
@ -49,6 +49,15 @@ class PatchOptionsModel(
|
|||
debuggable = value
|
||||
}
|
||||
|
||||
// ---------- Other ----------
|
||||
var showNetworkWarningDialog by mutableStateOf(!alreadyShownNetworkWarning && isNetworkDangerous())
|
||||
private set
|
||||
|
||||
fun hideNetworkWarning() {
|
||||
showNetworkWarningDialog = false
|
||||
alreadyShownNetworkWarning = true
|
||||
}
|
||||
|
||||
// ---------- Config generation ----------
|
||||
val isConfigValid by derivedStateOf {
|
||||
val invalidChecks = arrayOf(
|
||||
|
|
@ -127,6 +136,9 @@ class PatchOptionsModel(
|
|||
}
|
||||
|
||||
companion object {
|
||||
// Global state to avoid showing the warning more than once per launch
|
||||
private var alreadyShownNetworkWarning = false
|
||||
|
||||
private val PACKAGE_REGEX = """^[a-z]\w*(\.[a-z]\w*)+$"""
|
||||
.toRegex(RegexOption.IGNORE_CASE)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
|
|||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
|
@ -67,12 +66,11 @@ class PatchOptionsScreen(
|
|||
context.requestNoBatteryOptimizations()
|
||||
}
|
||||
|
||||
var showNetworkWarningDialog by rememberSaveable { mutableStateOf(model.isNetworkDangerous()) }
|
||||
if (showNetworkWarningDialog) {
|
||||
if (model.showNetworkWarningDialog) {
|
||||
NetworkWarningDialog(
|
||||
onConfirm = { showNetworkWarningDialog = false },
|
||||
onConfirm = model::hideNetworkWarning,
|
||||
onDismiss = {
|
||||
showNetworkWarningDialog = false
|
||||
model.hideNetworkWarning()
|
||||
navigator.pop()
|
||||
},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue