M3: extension manager screen (list, enable/disable)
Browse files
app/src/main/java/dev/nova/browser/ExtensionManagerScreen.kt
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package dev.nova.browser
|
| 2 |
+
|
| 3 |
+
import androidx.compose.foundation.layout.*
|
| 4 |
+
import androidx.compose.foundation.lazy.LazyColumn
|
| 5 |
+
import androidx.compose.foundation.lazy.items
|
| 6 |
+
import androidx.compose.material3.*
|
| 7 |
+
import androidx.compose.runtime.Composable
|
| 8 |
+
import androidx.compose.ui.Alignment
|
| 9 |
+
import androidx.compose.ui.Modifier
|
| 10 |
+
import androidx.compose.ui.text.style.TextOverflow
|
| 11 |
+
import androidx.compose.ui.unit.dp
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* M3 extension manager: lists installed WebExtensions (from
|
| 15 |
+
* WebExtensionController.list()) with name/version/description and an
|
| 16 |
+
* enable/disable switch per add-on.
|
| 17 |
+
*/
|
| 18 |
+
@Composable
|
| 19 |
+
fun ExtensionManagerScreen(
|
| 20 |
+
extensions: List<TabManager.ExtInfo>,
|
| 21 |
+
enabledStates: Map<String, Boolean>,
|
| 22 |
+
loading: Boolean,
|
| 23 |
+
onToggle: (String, Boolean) -> Unit,
|
| 24 |
+
onDismiss: () -> Unit,
|
| 25 |
+
) {
|
| 26 |
+
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.surface) {
|
| 27 |
+
Column(Modifier.fillMaxSize().padding(12.dp)) {
|
| 28 |
+
Row(verticalAlignment = Alignment.CenterVertically) {
|
| 29 |
+
Text(
|
| 30 |
+
"Add-ons",
|
| 31 |
+
style = MaterialTheme.typography.titleMedium,
|
| 32 |
+
modifier = Modifier.weight(1f),
|
| 33 |
+
)
|
| 34 |
+
TextButton(onClick = onDismiss) { Text("Done") }
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
if (loading) {
|
| 38 |
+
LinearProgressIndicator(Modifier.fillMaxWidth())
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
if (extensions.isEmpty() && !loading) {
|
| 42 |
+
Text(
|
| 43 |
+
"No extensions installed",
|
| 44 |
+
style = MaterialTheme.typography.bodyMedium,
|
| 45 |
+
modifier = Modifier.padding(vertical = 24.dp),
|
| 46 |
+
)
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
LazyColumn(Modifier.weight(1f)) {
|
| 50 |
+
items(extensions, key = { it.id }) { ext ->
|
| 51 |
+
val enabled = enabledStates[ext.id] ?: true
|
| 52 |
+
Card(
|
| 53 |
+
modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp),
|
| 54 |
+
) {
|
| 55 |
+
Row(
|
| 56 |
+
Modifier.padding(horizontal = 12.dp, vertical = 8.dp),
|
| 57 |
+
verticalAlignment = Alignment.CenterVertically,
|
| 58 |
+
) {
|
| 59 |
+
Column(Modifier.weight(1f)) {
|
| 60 |
+
Text(
|
| 61 |
+
ext.name,
|
| 62 |
+
style = MaterialTheme.typography.bodyLarge,
|
| 63 |
+
maxLines = 1,
|
| 64 |
+
overflow = TextOverflow.Ellipsis,
|
| 65 |
+
)
|
| 66 |
+
Text(
|
| 67 |
+
if (ext.version.isBlank()) ext.id else "${ext.name.takeIf { false } ?: ext.id} · v${ext.version}",
|
| 68 |
+
style = MaterialTheme.typography.labelSmall,
|
| 69 |
+
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
| 70 |
+
maxLines = 1,
|
| 71 |
+
overflow = TextOverflow.Ellipsis,
|
| 72 |
+
)
|
| 73 |
+
if (ext.description.isNotBlank()) {
|
| 74 |
+
Text(
|
| 75 |
+
ext.description,
|
| 76 |
+
style = MaterialTheme.typography.bodySmall,
|
| 77 |
+
maxLines = 2,
|
| 78 |
+
overflow = TextOverflow.Ellipsis,
|
| 79 |
+
)
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
Switch(
|
| 83 |
+
checked = enabled,
|
| 84 |
+
onCheckedChange = { checked -> onToggle(ext.id, checked) },
|
| 85 |
+
)
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
Text(
|
| 92 |
+
"Bundled add-ons ship inside Nova; AMO (.xpi) installs arrive in M5.",
|
| 93 |
+
style = MaterialTheme.typography.labelSmall,
|
| 94 |
+
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
| 95 |
+
modifier = Modifier.padding(top = 8.dp),
|
| 96 |
+
)
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
}
|