111 lines
4.2 KiB
Kotlin
111 lines
4.2 KiB
Kotlin
package de.schanbro.weekfocus.screens
|
|
|
|
import androidx.compose.foundation.layout.*
|
|
import androidx.compose.foundation.rememberScrollState
|
|
import androidx.compose.foundation.verticalScroll
|
|
import androidx.compose.material.icons.Icons
|
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
|
import androidx.compose.material3.*
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.mutableStateOf
|
|
import androidx.compose.runtime.remember
|
|
import androidx.compose.ui.Alignment
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.platform.LocalContext
|
|
import androidx.compose.ui.platform.LocalUriHandler
|
|
import androidx.compose.ui.res.stringResource
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
import androidx.compose.ui.unit.dp
|
|
import de.schanbro.weekfocus.R
|
|
import de.schanbro.weekfocus.components.ClickRow
|
|
import de.schanbro.weekfocus.components.SectionTitle
|
|
import de.schanbro.weekfocus.update.ReleaseNotes
|
|
import de.schanbro.weekfocus.update.UpdateChecker
|
|
import de.schanbro.weekfocus.update.WhatsNewDialog
|
|
import androidx.compose.runtime.getValue
|
|
import androidx.compose.runtime.setValue
|
|
|
|
private const val REPO_URL = "https://git.schamagusa.de/robin/WeekFocus"
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@Composable
|
|
fun AboutScreen(
|
|
modifier: Modifier = Modifier
|
|
) {
|
|
val context = LocalContext.current
|
|
val uriHandler = LocalUriHandler.current
|
|
val version = remember { UpdateChecker.currentVersion(context) }
|
|
|
|
Column(modifier = modifier.fillMaxSize()) {
|
|
Column(
|
|
modifier = Modifier
|
|
.fillMaxSize()
|
|
.verticalScroll(rememberScrollState())
|
|
) {
|
|
Column(
|
|
modifier = Modifier
|
|
.fillMaxWidth()
|
|
.padding(horizontal = 24.dp, vertical = 32.dp),
|
|
horizontalAlignment = Alignment.CenterHorizontally
|
|
) {
|
|
Text(
|
|
text = stringResource(R.string.app_name),
|
|
style = MaterialTheme.typography.headlineMedium
|
|
)
|
|
Spacer(Modifier.height(4.dp))
|
|
Text(
|
|
text = stringResource(R.string.about_version, version),
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
|
)
|
|
Spacer(Modifier.height(16.dp))
|
|
Text(
|
|
text = stringResource(R.string.about_description),
|
|
style = MaterialTheme.typography.bodyLarge,
|
|
textAlign = TextAlign.Center
|
|
)
|
|
}
|
|
|
|
HorizontalDivider()
|
|
|
|
SectionTitle(stringResource(R.string.about_section_links))
|
|
|
|
ClickRow(
|
|
title = stringResource(R.string.settings_source_title),
|
|
summary = stringResource(R.string.settings_source_summary),
|
|
onClick = { uriHandler.openUri(REPO_URL) }
|
|
)
|
|
ClickRow(
|
|
title = stringResource(R.string.about_issues_title),
|
|
summary = stringResource(R.string.about_issues_summary),
|
|
onClick = { uriHandler.openUri("$REPO_URL/issues") }
|
|
)
|
|
ClickRow(
|
|
title = stringResource(R.string.about_releases_title),
|
|
summary = stringResource(R.string.about_releases_summary),
|
|
onClick = { uriHandler.openUri("$REPO_URL/releases") }
|
|
)
|
|
|
|
HorizontalDivider()
|
|
|
|
SectionTitle(stringResource(R.string.about_whats_new_section_title))
|
|
|
|
var showNotes by remember { mutableStateOf(false) }
|
|
val notes = remember { ReleaseNotes.load(context) }
|
|
|
|
if (notes != null) {
|
|
ClickRow(
|
|
title = stringResource(R.string.about_whats_new_title),
|
|
summary = stringResource(R.string.about_whats_new_summary),
|
|
onClick = { showNotes = true }
|
|
)
|
|
}
|
|
|
|
if (showNotes && notes != null) {
|
|
WhatsNewDialog(version = version, notes = notes, onDismiss = { showNotes = false })
|
|
}
|
|
|
|
Spacer(Modifier.height(16.dp))
|
|
}
|
|
}
|
|
} |