Files
mihon-bookmod/app/src/main/java/eu/kanade/presentation/crash/CrashScreen.kt
T
AntsyLich b695940114 Switch to Material Symbols and use Valkyrie for ImageVector generation (#3873)
* Add material symbols icon module

Assisted-by: Claude:claude-opus-5

* Replace material icons with material symbols

Assisted-by: Claude:claude-opus-5

* Add simple icons module and migrate CustomIcons

Assisted-by: Claude:claude-opus-5
2026-08-29 21:39:55 +06:00

72 lines
2.5 KiB
Kotlin

package eu.kanade.presentation.crash
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.PreviewLightDark
import eu.kanade.presentation.theme.TachiyomiPreviewTheme
import kotlinx.coroutines.launch
import mihon.app.di.appGraph
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.BugReport
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.padding
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.screens.InfoScreen
@Composable
fun CrashScreen(
exception: Throwable?,
onRestartClick: () -> Unit,
) {
val scope = rememberCoroutineScope()
val context = LocalContext.current
val crashLogUtil = remember { context.appGraph.crashLogUtil }
InfoScreen(
icon = MaterialSymbols.Rounded.BugReport,
headingText = stringResource(MR.strings.crash_screen_title),
subtitleText = stringResource(MR.strings.crash_screen_description, stringResource(MR.strings.app_name)),
acceptText = stringResource(MR.strings.pref_dump_crash_logs),
onAcceptClick = {
scope.launch {
crashLogUtil.dumpLogs(exception)
}
},
rejectText = stringResource(MR.strings.crash_screen_restart_application),
onRejectClick = onRestartClick,
) {
Box(
modifier = Modifier
.padding(vertical = MaterialTheme.padding.small)
.clip(MaterialTheme.shapes.small)
.fillMaxSize()
.background(MaterialTheme.colorScheme.surfaceVariant),
) {
Text(
text = exception.toString(),
modifier = Modifier
.padding(all = MaterialTheme.padding.small),
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
}
}
@PreviewLightDark
@Composable
private fun CrashScreenPreview() {
TachiyomiPreviewTheme {
CrashScreen(exception = RuntimeException("Dummy")) {}
}
}