feat: about screen
This commit is contained in:
1 parent
3aedc51b97
commit
31a1f5158f
7 files changed
+281
-104
No files matched your search
@@ -27,6 +27,9 @@ import de.schanbro.weekfocus.update.ReleaseInfo
|
||||
import de.schanbro.weekfocus.update.UpdateChecker
|
||||
import de.schanbro.weekfocus.update.UpdateDialog
|
||||
import kotlinx.coroutines.launch
|
||||
import de.schanbro.weekfocus.components.SectionTitle
|
||||
import de.schanbro.weekfocus.components.ClickRow
|
||||
import de.schanbro.weekfocus.components.SwitchRow
|
||||
|
||||
private const val REPO_URL = "https://git.schamagusa.de/robin/WeekFocus"
|
||||
|
||||
@@ -34,7 +37,10 @@ private enum class CheckStatus { IDLE, CHECKING, UP_TO_DATE, FAILED, AVAILABLE }
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SettingsScreen(modifier: Modifier = Modifier) {
|
||||
fun SettingsScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
onOpenAbout: () -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val settings = remember { SettingsRepository.get(context) }
|
||||
val haptic = LocalHapticFeedback.current
|
||||
@@ -170,15 +176,10 @@ fun SettingsScreen(modifier: Modifier = Modifier) {
|
||||
// ---------- Info ----------
|
||||
SectionTitle(stringResource(R.string.settings_section_about))
|
||||
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.settings_version_title)) },
|
||||
supportingContent = { Text(currentVersion) }
|
||||
)
|
||||
|
||||
ClickRow(
|
||||
title = stringResource(R.string.settings_source_title),
|
||||
summary = stringResource(R.string.settings_source_summary),
|
||||
onClick = { uriHandler.openUri(REPO_URL) }
|
||||
title = stringResource(R.string.title_about),
|
||||
summary = stringResource(R.string.settings_about_summary),
|
||||
onClick = onOpenAbout
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
@@ -188,49 +189,4 @@ fun SettingsScreen(modifier: Modifier = Modifier) {
|
||||
availableRelease?.let { info ->
|
||||
UpdateDialog(info = info, onDismiss = { availableRelease = null })
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SectionTitle(text: String) {
|
||||
Text(
|
||||
text = text,
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 4.dp)
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SwitchRow(
|
||||
title: String,
|
||||
summary: String,
|
||||
checked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit
|
||||
) {
|
||||
ListItem(
|
||||
headlineContent = { Text(title) },
|
||||
supportingContent = { Text(summary) },
|
||||
trailingContent = { Switch(checked = checked, onCheckedChange = null) },
|
||||
// Die ganze Zeile ist klickbar, der Switch selbst nur Anzeige (gut für TalkBack)
|
||||
modifier = Modifier.toggleable(
|
||||
value = checked,
|
||||
role = Role.Switch,
|
||||
onValueChange = onCheckedChange
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ClickRow(
|
||||
title: String,
|
||||
summary: String,
|
||||
onClick: () -> Unit,
|
||||
trailing: (@Composable () -> Unit)? = null
|
||||
) {
|
||||
ListItem(
|
||||
headlineContent = { Text(title) },
|
||||
supportingContent = { Text(summary) },
|
||||
trailingContent = trailing,
|
||||
modifier = Modifier.clickable(onClick = onClick)
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user