crash ui tweaks

This commit is contained in:
qimiko committed 2024-02-16 17:59:38 -07:00
1 parent c53a23faf9
commit 4165c22c2b
2 files changed
+35 -20

No files matched your search

@@ -619,6 +619,32 @@ fun onSettings(context: Context) {
context.startActivity(launchIntent) context.startActivity(launchIntent)
} }
suspend fun showFailureSnackbar(
context: Context,
loadFailureInfo: LoadFailureInfo,
snackbarHostState: SnackbarHostState,
onActionPerformed: () -> Unit
) {
val message = if (loadFailureInfo.title == LaunchUtils.LauncherError.CRASHED) {
context.getString(R.string.launcher_crashed)
} else {
context.getString(R.string.launcher_failed_to_load)
}
val res = snackbarHostState.showSnackbar(
message = message,
actionLabel = context.getString(R.string.launcher_error_more),
duration = SnackbarDuration.Indefinite,
)
when (res) {
SnackbarResult.ActionPerformed -> {
onActionPerformed()
}
SnackbarResult.Dismissed -> {}
}
}
@Composable @Composable
fun MainScreen( fun MainScreen(
gdInstalled: Boolean = true, gdInstalled: Boolean = true,
@@ -654,28 +680,17 @@ fun MainScreen(
val snackbarHostState = remember { SnackbarHostState() } val snackbarHostState = remember { SnackbarHostState() }
var showErrorInfo by remember { mutableStateOf(false) } // automatically show load failed dialog (but not crash)
var showErrorInfo by remember { mutableStateOf(
loadFailureInfo != null && loadFailureInfo.title != LaunchUtils.LauncherError.CRASHED
)}
val hasError = loadFailureInfo != null val hasError = loadFailureInfo != null
LaunchedEffect(hasError) { LaunchedEffect(hasError, showErrorInfo) {
if (loadFailureInfo != null) { if (!showErrorInfo && loadFailureInfo != null) {
val message = if (loadFailureInfo.title == LaunchUtils.LauncherError.CRASHED) { showFailureSnackbar(context, loadFailureInfo, snackbarHostState) {
context.getString(R.string.launcher_crashed)
} else {
context.getString(R.string.launcher_failed_to_load)
}
val res = snackbarHostState.showSnackbar(
message = message,
actionLabel = context.getString(R.string.launcher_error_more),
duration = SnackbarDuration.Indefinite,
)
when (res) {
SnackbarResult.ActionPerformed -> {
showErrorInfo = true showErrorInfo = true
} }
SnackbarResult.Dismissed -> {}
}
} }
} }
+1 -1
View File
@@ -34,7 +34,7 @@
<string name="safe_mode_enable_description">Safe mode disables loading of all mods, allowing one to remove problematic mods or diagnose crashes. If you\'re not experiencing issues with Geode, you should probably not be using safe mode.</string> <string name="safe_mode_enable_description">Safe mode disables loading of all mods, allowing one to remove problematic mods or diagnose crashes. If you\'re not experiencing issues with Geode, you should probably not be using safe mode.</string>
<string name="launcher_failed_to_load">Geode failed to load.</string> <string name="launcher_failed_to_load">Geode failed to load.</string>
<string name="launcher_crashed">Geode crashed.</string> <string name="launcher_crashed">Geode crashed.</string>
<string name="launcher_error_more">Learn more</string> <string name="launcher_error_more">Help</string>
<string name="launcher_error_details">Error details</string> <string name="launcher_error_details">Error details</string>
<string name="launcher_error_view_logs">View logs</string> <string name="launcher_error_view_logs">View logs</string>
<string name="launcher_error_copy_error_alt">Copy</string> <string name="launcher_error_copy_error_alt">Copy</string>