|
| 1 | +package app.myfaq.android.screens |
| 2 | + |
| 3 | +import androidx.compose.foundation.layout.Arrangement |
| 4 | +import androidx.compose.foundation.layout.Column |
| 5 | +import androidx.compose.foundation.layout.PaddingValues |
| 6 | +import androidx.compose.foundation.layout.fillMaxSize |
| 7 | +import androidx.compose.foundation.layout.padding |
| 8 | +import androidx.compose.foundation.lazy.LazyColumn |
| 9 | +import androidx.compose.foundation.lazy.items |
| 10 | +import androidx.compose.material.icons.Icons |
| 11 | +import androidx.compose.material.icons.automirrored.filled.ArrowBack |
| 12 | +import androidx.compose.material3.ExperimentalMaterial3Api |
| 13 | +import androidx.compose.material3.HorizontalDivider |
| 14 | +import androidx.compose.material3.Icon |
| 15 | +import androidx.compose.material3.IconButton |
| 16 | +import androidx.compose.material3.MaterialTheme |
| 17 | +import androidx.compose.material3.Scaffold |
| 18 | +import androidx.compose.material3.Text |
| 19 | +import androidx.compose.material3.TopAppBar |
| 20 | +import androidx.compose.runtime.Composable |
| 21 | +import androidx.compose.ui.Modifier |
| 22 | +import androidx.compose.ui.unit.dp |
| 23 | + |
| 24 | +private data class LibraryEntry( |
| 25 | + val name: String, |
| 26 | + val license: String, |
| 27 | + val url: String, |
| 28 | +) |
| 29 | + |
| 30 | +private val libraries: List<LibraryEntry> = |
| 31 | + listOf( |
| 32 | + LibraryEntry("Kotlin", "Apache 2.0", "https://kotlinlang.org"), |
| 33 | + LibraryEntry("Kotlin Coroutines", "Apache 2.0", "https://github.com/Kotlin/kotlinx.coroutines"), |
| 34 | + LibraryEntry("kotlinx.serialization", "Apache 2.0", "https://github.com/Kotlin/kotlinx.serialization"), |
| 35 | + LibraryEntry("Ktor", "Apache 2.0", "https://ktor.io"), |
| 36 | + LibraryEntry("SQLDelight", "Apache 2.0", "https://github.com/cashapp/sqldelight"), |
| 37 | + LibraryEntry("Koin", "Apache 2.0", "https://insert-koin.io"), |
| 38 | + LibraryEntry("Jetpack Compose", "Apache 2.0", "https://developer.android.com/jetpack/compose"), |
| 39 | + LibraryEntry("Material Icons", "Apache 2.0", "https://fonts.google.com/icons"), |
| 40 | + LibraryEntry("AndroidX Security Crypto", "Apache 2.0", "https://developer.android.com/jetpack/androidx"), |
| 41 | + LibraryEntry("SQLCipher", "BSD-Style", "https://www.zetetic.net/sqlcipher/"), |
| 42 | + ) |
| 43 | + |
| 44 | +@OptIn(ExperimentalMaterial3Api::class) |
| 45 | +@Composable |
| 46 | +fun LicensesScreen(onBack: () -> Unit) { |
| 47 | + Scaffold( |
| 48 | + topBar = { |
| 49 | + TopAppBar( |
| 50 | + title = { Text("Licenses") }, |
| 51 | + navigationIcon = { |
| 52 | + IconButton(onClick = onBack) { |
| 53 | + Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back") |
| 54 | + } |
| 55 | + }, |
| 56 | + ) |
| 57 | + }, |
| 58 | + ) { padding -> |
| 59 | + LazyColumn( |
| 60 | + modifier = Modifier.fillMaxSize().padding(padding), |
| 61 | + contentPadding = PaddingValues(vertical = 8.dp), |
| 62 | + verticalArrangement = Arrangement.Top, |
| 63 | + ) { |
| 64 | + item { |
| 65 | + Column(modifier = Modifier.padding(16.dp)) { |
| 66 | + Text( |
| 67 | + "MyFAQ.app", |
| 68 | + style = MaterialTheme.typography.titleMedium, |
| 69 | + ) |
| 70 | + Text( |
| 71 | + "Native client for phpMyFAQ — © phpMyFAQ Team.", |
| 72 | + style = MaterialTheme.typography.bodySmall, |
| 73 | + color = MaterialTheme.colorScheme.onSurfaceVariant, |
| 74 | + ) |
| 75 | + Text( |
| 76 | + "Licensed under MPL 2.0.", |
| 77 | + style = MaterialTheme.typography.bodySmall, |
| 78 | + color = MaterialTheme.colorScheme.onSurfaceVariant, |
| 79 | + ) |
| 80 | + } |
| 81 | + HorizontalDivider() |
| 82 | + } |
| 83 | + items(libraries, key = { it.name }) { entry -> |
| 84 | + Column(modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp)) { |
| 85 | + Text(entry.name, style = MaterialTheme.typography.bodyLarge) |
| 86 | + Text( |
| 87 | + "${entry.license} • ${entry.url}", |
| 88 | + style = MaterialTheme.typography.bodySmall, |
| 89 | + color = MaterialTheme.colorScheme.onSurfaceVariant, |
| 90 | + ) |
| 91 | + } |
| 92 | + HorizontalDivider() |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | +} |
0 commit comments