|
|
@@ -0,0 +1,105 @@
|
|
|
+package io.legado.app.ui.about
|
|
|
+
|
|
|
+import androidx.compose.foundation.layout.Arrangement
|
|
|
+import androidx.compose.foundation.layout.Column
|
|
|
+import androidx.compose.foundation.layout.Row
|
|
|
+import androidx.compose.foundation.layout.fillMaxSize
|
|
|
+import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
+import androidx.compose.foundation.layout.padding
|
|
|
+import androidx.compose.foundation.rememberScrollState
|
|
|
+import androidx.compose.foundation.text.selection.SelectionContainer
|
|
|
+import androidx.compose.foundation.verticalScroll
|
|
|
+import androidx.compose.material3.Button
|
|
|
+import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
+import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
|
|
+import androidx.compose.material3.OutlinedButton
|
|
|
+import androidx.compose.material3.Text
|
|
|
+import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.ui.Modifier
|
|
|
+import androidx.compose.ui.input.nestedscroll.nestedScroll
|
|
|
+import androidx.compose.ui.res.stringResource
|
|
|
+import androidx.compose.ui.text.font.FontFamily
|
|
|
+import androidx.compose.ui.unit.dp
|
|
|
+import io.legado.app.R
|
|
|
+import io.legado.app.ui.theme.LegadoTheme
|
|
|
+import io.legado.app.ui.widget.components.AppScaffold
|
|
|
+import io.legado.app.ui.widget.components.icon.AppIcons
|
|
|
+import io.legado.app.ui.widget.components.text.AppText
|
|
|
+import io.legado.app.ui.widget.components.topbar.GlassMediumFlexibleTopAppBar
|
|
|
+import io.legado.app.ui.widget.components.topbar.GlassTopAppBarDefaults
|
|
|
+import io.legado.app.ui.widget.components.topbar.TopBarNavigationButton
|
|
|
+
|
|
|
+@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
|
|
|
+@Composable
|
|
|
+fun CrashReportScreen(
|
|
|
+ errorText: String,
|
|
|
+ onCopy: () -> Unit,
|
|
|
+ onRestart: () -> Unit,
|
|
|
+ onClose: () -> Unit
|
|
|
+) {
|
|
|
+ val scrollBehavior = GlassTopAppBarDefaults.defaultScrollBehavior()
|
|
|
+ val displayText = errorText.ifBlank {
|
|
|
+ stringResource(R.string.crash_report_empty)
|
|
|
+ }
|
|
|
+
|
|
|
+ AppScaffold(
|
|
|
+ modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
|
|
+ topBar = {
|
|
|
+ GlassMediumFlexibleTopAppBar(
|
|
|
+ title = stringResource(R.string.crash_report),
|
|
|
+ navigationIcon = {
|
|
|
+ TopBarNavigationButton(
|
|
|
+ onClick = onClose,
|
|
|
+ imageVector = AppIcons.Close
|
|
|
+ )
|
|
|
+ },
|
|
|
+ scrollBehavior = scrollBehavior
|
|
|
+ )
|
|
|
+ }
|
|
|
+ ) { padding ->
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
+ .padding(padding)
|
|
|
+ .padding(horizontal = 16.dp, vertical = 12.dp),
|
|
|
+ verticalArrangement = Arrangement.spacedBy(12.dp)
|
|
|
+ ) {
|
|
|
+ AppText(
|
|
|
+ text = stringResource(R.string.crash_report_message),
|
|
|
+ style = LegadoTheme.typography.bodyMedium
|
|
|
+ )
|
|
|
+
|
|
|
+ SelectionContainer(
|
|
|
+ modifier = Modifier
|
|
|
+ .weight(1f)
|
|
|
+ .fillMaxWidth()
|
|
|
+ .verticalScroll(rememberScrollState())
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = displayText,
|
|
|
+ style = LegadoTheme.typography.bodySmall,
|
|
|
+ fontFamily = FontFamily.Monospace
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ Row(
|
|
|
+ modifier = Modifier.fillMaxWidth(),
|
|
|
+ horizontalArrangement = Arrangement.spacedBy(12.dp)
|
|
|
+ ) {
|
|
|
+ OutlinedButton(
|
|
|
+ onClick = onRestart,
|
|
|
+ modifier = Modifier.weight(1f)
|
|
|
+ ) {
|
|
|
+ Text(text = stringResource(R.string.restart_app))
|
|
|
+ }
|
|
|
+ Button(
|
|
|
+ onClick = onCopy,
|
|
|
+ enabled = errorText.isNotBlank(),
|
|
|
+ modifier = Modifier.weight(1f)
|
|
|
+ ) {
|
|
|
+ Text(text = stringResource(R.string.copy_text))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|