Skip to content

A rootless Android app that boots Alpine Linux: run containers (Podman/Docker/LXC) and GUI desktop apps.

feat: adaptive UI for landscape / tablets and chip-row selectors

ExTv3f1e4a196be1
diff --git a/app/src/main/java/com/excp/podroid/ui/screens/home/HomeScreen.kt b/app/src/main/java/com/excp/podroid/ui/screens/home/HomeScreen.kt
index e190eb1..5d74722 100644
--- a/app/src/main/java/com/excp/podroid/ui/screens/home/HomeScreen.kt
+++ b/app/src/main/java/com/excp/podroid/ui/screens/home/HomeScreen.kt
@@ -5,6 +5,7 @@ import android.net.Uri
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
@@ -12,6 +13,8 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.PowerSettingsNew
@@ -33,6 +36,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
+import androidx.compose.material3.windowsizeclass.WindowHeightSizeClass
import androidx.compose.material3.windowsizeclass.WindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -89,6 +93,8 @@ fun HomeScreen(
)
}
+ val isCompactHeight = windowSizeClass.heightSizeClass == WindowHeightSizeClass.Compact
+
Scaffold(
topBar = {
TopAppBar(
@@ -105,168 +111,206 @@ fun HomeScreen(
windowSizeClass = windowSizeClass,
modifier = Modifier
.fillMaxSize()
- .padding(innerPadding)
+ .padding(innerPadding),
+ maxWidth = if (isCompactHeight) 900 else 600,
) {
- Column(
- modifier = Modifier
- .fillMaxSize()
- .padding(horizontal = 24.dp),
- horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(20.dp),
- ) {
- Spacer(modifier = Modifier.height(24.dp))
-
- // Animated boot progress replaces the plain CircularProgressIndicator
- // Visible only while boot is starting to keep existing VM/state logic intact
- Box(modifier = Modifier.size(72.dp), contentAlignment = Alignment.Center) {
- if (isStarting) {
- // Custom animated boot progress
- com.excp.podroid.ui.screens.home.AnimatedBootProgress(
- bootStage = bootStage,
- modifier = Modifier.size(72.dp)
- )
- } else {
- Icon(
- imageVector = Icons.Default.Terminal,
- contentDescription = null,
- modifier = Modifier.size(72.dp),
- tint = if (isRunning)
- MaterialTheme.colorScheme.primary
- else
- MaterialTheme.colorScheme.onSurfaceVariant,
- )
- }
- }
-
- // Status text
- Column(horizontalAlignment = Alignment.CenterHorizontally) {
- Text(
- text = when {
- isStarting -> "Starting…"
- isRunning -> "VM is running"
- else -> "VM is stopped"
- },
- style = MaterialTheme.typography.headlineSmall,
- fontWeight = FontWeight.SemiBold,
- color = when {
- isStarting -> MaterialTheme.colorScheme.primary
- isRunning -> MaterialTheme.colorScheme.primary
- else -> MaterialTheme.colorScheme.onSurfaceVariant
- },
- )
-
- if (isStarting && bootStage.isNotEmpty()) {
- Spacer(Modifier.height(4.dp))
- Text(
- text = bootStage,
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- )
- }
- }
-
- // Start / Stop button
- Button(
- onClick = {
- if (isRunning || isStarting) viewModel.stopVm()
- else viewModel.startPodroid()
- },
- modifier = Modifier
- .fillMaxWidth()
- .height(56.dp),
- shape = RoundedCornerShape(16.dp),
- colors = ButtonDefaults.buttonColors(
- containerColor = if (isRunning || isStarting)
- MaterialTheme.colorScheme.error
- else
- MaterialTheme.colorScheme.primary,
- ),
- ) {
- Icon(Icons.Default.PowerSettingsNew, contentDescription = null,
- modifier = Modifier.size(22.dp))
- Spacer(Modifier.width(10.dp))
- Text(
- text = if (isRunning || isStarting) "Stop VM" else "Start VM",
- style = MaterialTheme.typography.titleMedium,
- )
- }
-
- // Restart button
- if (isRunning) {
- FilledTonalButton(
- onClick = { viewModel.restartVm() },
+ if (isCompactHeight) {
+ // Landscape phone: hero on left, action buttons on right
+ Row(
modifier = Modifier
- .fillMaxWidth()
- .height(48.dp),
- shape = RoundedCornerShape(16.dp),
+ .fillMaxSize()
+ .padding(horizontal = 24.dp, vertical = 16.dp),
+ verticalAlignment = Alignment.CenterVertically,
) {
- Icon(Icons.Default.Refresh, contentDescription = null,
- modifier = Modifier.size(20.dp))
- Spacer(Modifier.width(8.dp))
- Text("Restart VM")
- }
- }
-
- // Error card
- if (vmState is VmState.Error) {
- Card(
- modifier = Modifier.fillMaxWidth(),
- shape = RoundedCornerShape(16.dp),
- colors = CardDefaults.cardColors(
- containerColor = MaterialTheme.colorScheme.errorContainer,
- ),
- ) {
- Column(modifier = Modifier.padding(16.dp)) {
- Text(
- text = (vmState as VmState.Error).message,
- color = MaterialTheme.colorScheme.onErrorContainer,
- style = MaterialTheme.typography.bodyMedium,
+ Column(
+ modifier = Modifier.weight(1f),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.Center,
+ ) {
+ StatusHero(isStarting = isStarting, isRunning = isRunning, bootStage = bootStage, iconSize = 64)
+ }
+ Spacer(Modifier.width(24.dp))
+ Column(
+ modifier = Modifier
+ .weight(1f)
+ .verticalScroll(rememberScrollState()),
+ verticalArrangement = Arrangement.spacedBy(12.dp),
+ ) {
+ HomeActionButtons(
+ vmState = vmState,
+ isRunning = isRunning,
+ isStarting = isStarting,
+ onStart = { viewModel.startPodroid() },
+ onStop = { viewModel.stopVm() },
+ onRestart = { viewModel.restartVm() },
+ onOpenTerminal = onNavigateToTerminal,
)
- Spacer(Modifier.height(12.dp))
- Button(
- onClick = { viewModel.startPodroid() },
- modifier = Modifier.fillMaxWidth(),
- shape = RoundedCornerShape(12.dp),
- ) {
- Icon(Icons.Default.Refresh, contentDescription = null,
- modifier = Modifier.size(18.dp))
- Spacer(Modifier.width(8.dp))
- Text("Try again")
- }
}
}
- }
-
- // Open Terminal button
- if (isRunning) {
- FilledTonalButton(
- onClick = onNavigateToTerminal,
+ } else {
+ // Portrait / tall: vertical stack
+ Column(
modifier = Modifier
- .fillMaxWidth()
- .height(56.dp),
- shape = RoundedCornerShape(16.dp),
+ .fillMaxSize()
+ .verticalScroll(rememberScrollState())
+ .padding(horizontal = 24.dp),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.spacedBy(20.dp),
) {
- Icon(Icons.Default.Terminal, contentDescription = null,
- modifier = Modifier.size(22.dp))
- Spacer(Modifier.width(10.dp))
+ Spacer(modifier = Modifier.height(24.dp))
+ StatusHero(isStarting = isStarting, isRunning = isRunning, bootStage = bootStage, iconSize = 72)
+ HomeActionButtons(
+ vmState = vmState,
+ isRunning = isRunning,
+ isStarting = isStarting,
+ onStart = { viewModel.startPodroid() },
+ onStop = { viewModel.stopVm() },
+ onRestart = { viewModel.restartVm() },
+ onOpenTerminal = onNavigateToTerminal,
+ )
+ Spacer(Modifier.height(8.dp))
Text(
- text = "Open Terminal",
- style = MaterialTheme.typography.titleMedium,
+ text = "Alpine Linux · Podman · QEMU",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ textAlign = TextAlign.Center,
)
+ Spacer(Modifier.height(8.dp))
}
}
+ }
+ }
+}
- Spacer(modifier = Modifier.weight(1f))
-
+@Composable
+private fun StatusHero(
+ isStarting: Boolean,
+ isRunning: Boolean,
+ bootStage: String,
+ iconSize: Int,
+) {
+ Box(modifier = Modifier.size(iconSize.dp), contentAlignment = Alignment.Center) {
+ if (isStarting) {
+ com.excp.podroid.ui.screens.home.AnimatedBootProgress(
+ bootStage = bootStage,
+ modifier = Modifier.size(iconSize.dp)
+ )
+ } else {
+ Icon(
+ imageVector = Icons.Default.Terminal,
+ contentDescription = null,
+ modifier = Modifier.size(iconSize.dp),
+ tint = if (isRunning)
+ MaterialTheme.colorScheme.primary
+ else
+ MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ }
+ }
+ Spacer(Modifier.height(16.dp))
+ Column(horizontalAlignment = Alignment.CenterHorizontally) {
+ Text(
+ text = when {
+ isStarting -> "Starting…"
+ isRunning -> "VM is running"
+ else -> "VM is stopped"
+ },
+ style = MaterialTheme.typography.headlineSmall,
+ fontWeight = FontWeight.SemiBold,
+ color = when {
+ isStarting -> MaterialTheme.colorScheme.primary
+ isRunning -> MaterialTheme.colorScheme.primary
+ else -> MaterialTheme.colorScheme.onSurfaceVariant
+ },
+ )
+ if (isStarting && bootStage.isNotEmpty()) {
+ Spacer(Modifier.height(4.dp))
Text(
- text = "Alpine Linux · Podman · QEMU",
+ text = bootStage,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
textAlign = TextAlign.Center,
)
+ }
+ }
+}
- Spacer(Modifier.height(8.dp))
+@Composable
+private fun HomeActionButtons(
+ vmState: VmState,
+ isRunning: Boolean,
+ isStarting: Boolean,
+ onStart: () -> Unit,
+ onStop: () -> Unit,
+ onRestart: () -> Unit,
+ onOpenTerminal: () -> Unit,
+) {
+ Button(
+ onClick = { if (isRunning || isStarting) onStop() else onStart() },
+ modifier = Modifier.fillMaxWidth().height(56.dp),
+ shape = RoundedCornerShape(16.dp),
+ colors = ButtonDefaults.buttonColors(
+ containerColor = if (isRunning || isStarting)
+ MaterialTheme.colorScheme.error
+ else
+ MaterialTheme.colorScheme.primary,
+ ),
+ ) {
+ Icon(Icons.Default.PowerSettingsNew, contentDescription = null, modifier = Modifier.size(22.dp))
+ Spacer(Modifier.width(10.dp))
+ Text(
+ text = if (isRunning || isStarting) "Stop VM" else "Start VM",
+ style = MaterialTheme.typography.titleMedium,
+ )
+ }
+ if (isRunning) {
+ FilledTonalButton(
+ onClick = onRestart,
+ modifier = Modifier.fillMaxWidth().height(48.dp),
+ shape = RoundedCornerShape(16.dp),
+ ) {
+ Icon(Icons.Default.Refresh, contentDescription = null, modifier = Modifier.size(20.dp))
+ Spacer(Modifier.width(8.dp))
+ Text("Restart VM")
+ }
+ }
+ if (vmState is VmState.Error) {
+ Card(
+ modifier = Modifier.fillMaxWidth(),
+ shape = RoundedCornerShape(16.dp),
+ colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.errorContainer),
+ ) {
+ Column(modifier = Modifier.padding(16.dp)) {
+ Text(
+ text = vmState.message,
+ color = MaterialTheme.colorScheme.onErrorContainer,
+ style = MaterialTheme.typography.bodyMedium,
+ )
+ Spacer(Modifier.height(12.dp))
+ Button(
+ onClick = onStart,
+ modifier = Modifier.fillMaxWidth(),
+ shape = RoundedCornerShape(12.dp),
+ ) {
+ Icon(Icons.Default.Refresh, contentDescription = null, modifier = Modifier.size(18.dp))
+ Spacer(Modifier.width(8.dp))
+ Text("Try again")
+ }
}
}
}
+ if (isRunning) {
+ FilledTonalButton(
+ onClick = onOpenTerminal,
+ modifier = Modifier.fillMaxWidth().height(56.dp),
+ shape = RoundedCornerShape(16.dp),
+ ) {
+ Icon(Icons.Default.Terminal, contentDescription = null, modifier = Modifier.size(22.dp))
+ Spacer(Modifier.width(10.dp))
+ Text(
+ text = "Open Terminal",
+ style = MaterialTheme.typography.titleMedium,
+ )
+ }
+ }
}
diff --git a/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.kt b/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.kt
index 65dfcc0..d071bb5 100644
--- a/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.kt
+++ b/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.kt
@@ -10,6 +10,8 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ExperimentalLayoutApi
+import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
@@ -17,6 +19,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
@@ -35,6 +38,7 @@ import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip
+import androidx.compose.material3.FilterChipDefaults
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
@@ -120,81 +124,42 @@ fun SettingsScreen(
.verticalScroll(rememberScrollState())
.padding(horizontal = 16.dp),
) {
- Spacer(Modifier.height(8.dp))
+ Spacer(Modifier.height(16.dp))
// ── VM Resources ─────────────────────────────────────────
- SettingsSectionHeader("VM Resources")
+ SettingsSection(title = "VM Resources") {
+ if (!vmNotRunning) {
+ Text(
+ text = "Stop the VM to change these settings.",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.error,
+ modifier = Modifier.padding(bottom = 8.dp),
+ )
+ }
- if (!vmNotRunning) {
- Text(
- text = "Stop the VM to change these settings.",
- style = MaterialTheme.typography.labelSmall,
- color = MaterialTheme.colorScheme.error,
- modifier = Modifier.padding(bottom = 8.dp),
+ Text("Memory", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.onSurfaceVariant)
+ Text("$vmRamMb MB", style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Bold)
+ Spacer(Modifier.height(8.dp))
+ ChipRow(
+ options = ramOptions,
+ selected = vmRamMb,
+ enabled = vmNotRunning,
+ label = { ram -> if (ram >= 1024) "${ram / 1024} GB" else "$ram MB" },
+ onSelect = { viewModel.setVmRamMb(it) },
)
- }
-
- Text(
- text = "Memory: $vmRamMb MB",
- style = MaterialTheme.typography.bodyMedium,
- )
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .padding(vertical = 4.dp),
- horizontalArrangement = Arrangement.spacedBy(8.dp),
- ) {
- ramOptions.forEach { ram ->
- FilledTonalButton(
- onClick = { viewModel.setVmRamMb(ram) },
- enabled = vmNotRunning,
- modifier = Modifier.weight(1f),
- colors = if (vmRamMb == ram) {
- ButtonDefaults.filledTonalButtonColors(
- containerColor = MaterialTheme.colorScheme.primary,
- contentColor = MaterialTheme.colorScheme.onPrimary,
- )
- } else {
- ButtonDefaults.filledTonalButtonColors()
- },
- ) {
- Text(
- if (ram >= 1024) "${ram / 1024}G" else "${ram}M",
- style = MaterialTheme.typography.labelSmall,
- )
- }
- }
- }
- Spacer(Modifier.height(8.dp))
+ Spacer(Modifier.height(16.dp))
- Text(
- text = "CPU cores: $vmCpus",
- style = MaterialTheme.typography.bodyMedium,
- )
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .padding(vertical = 4.dp),
- horizontalArrangement = Arrangement.spacedBy(8.dp),
- ) {
- cpuOptions.forEach { cpu ->
- FilledTonalButton(
- onClick = { viewModel.setVmCpus(cpu) },
- enabled = vmNotRunning,
- modifier = Modifier.weight(1f),
- colors = if (vmCpus == cpu) {
- ButtonDefaults.filledTonalButtonColors(
- containerColor = MaterialTheme.colorScheme.primary,
- contentColor = MaterialTheme.colorScheme.onPrimary,
- )
- } else {
- ButtonDefaults.filledTonalButtonColors()
- },
- ) {
- Text("$cpu", style = MaterialTheme.typography.labelSmall)
- }
- }
+ Text("CPU cores", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.onSurfaceVariant)
+ Text("$vmCpus", style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Bold)
+ Spacer(Modifier.height(8.dp))
+ ChipRow(
+ options = cpuOptions,
+ selected = vmCpus,
+ enabled = vmNotRunning,
+ label = { cpu -> "$cpu" },
+ onSelect = { viewModel.setVmCpus(it) },
+ )
}
Spacer(Modifier.height(8.dp))
@@ -203,140 +168,151 @@ fun SettingsScreen(
Spacer(Modifier.height(4.dp))
- // Storage size (read-only — set at first boot)
- Text(
- text = "Persistent storage: $storageSizeGb GB",
- style = MaterialTheme.typography.bodyMedium,
- )
- Text(
- text = "Set during initial setup. Reset the VM to change.",
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- modifier = Modifier.padding(top = 2.dp, bottom = 8.dp),
- )
-
- DownloadsSharingCard(
- enabled = storageAccessEnabled,
- vmNotRunning = vmNotRunning,
- onToggle = { viewModel.setStorageAccessEnabled(it) },
- )
+ // ── Storage ───────────────────────────────────────────────
+ SettingsSection(title = "Storage") {
+ Text("Persistent storage", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.onSurfaceVariant)
+ Text("$storageSizeGb GB", style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Bold)
+ Text(
+ text = "Set during initial setup. Reset the VM to change.",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ modifier = Modifier.padding(top = 2.dp, bottom = 12.dp),
+ )
+ DownloadsSharingCard(
+ enabled = storageAccessEnabled,
+ vmNotRunning = vmNotRunning,
+ onToggle = { viewModel.setStorageAccessEnabled(it) },
+ )
+ }
- Spacer(Modifier.height(16.dp))
+ Spacer(Modifier.height(8.dp))
// ── Network ───────────────────────────────────────────────
- SettingsSectionHeader("Network")
-
- val phoneIp = viewModel.phoneIp
- Text(
- text = "Phone IP: $phoneIp — point your devices here.",
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.primary,
- fontWeight = FontWeight.Medium,
- modifier = Modifier.padding(bottom = 4.dp),
- )
- SettingsSwitchRow(
- title = "Enable SSH",
- subtitle = if (sshEnabled) "ssh root@<phone-ip> -p 9922 | password: podroid" else "Access the VM over your local network via SSH",
- checked = sshEnabled,
- onCheckedChange = { viewModel.setSshEnabled(it) },
- )
- Text(
- text = "Rules forward ports from your Android device into the VM. Active immediately when VM is running.",
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- modifier = Modifier.padding(bottom = 8.dp),
- )
-
- if (portForwardRules.isEmpty()) {
+ SettingsSection(title = "Network") {
+ val phoneIp = viewModel.phoneIp
Text(
- text = "No rules configured.",
+ text = "Phone IP: $phoneIp",
style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.primary,
+ fontWeight = FontWeight.SemiBold,
+ )
+ Text(
+ text = "Point your devices here to reach the VM.",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ modifier = Modifier.padding(bottom = 12.dp),
+ )
+ SettingsSwitchRow(
+ title = "Enable SSH",
+ subtitle = if (sshEnabled) "ssh root@<phone-ip> -p 9922 | password: podroid" else "Access the VM over your local network via SSH",
+ checked = sshEnabled,
+ onCheckedChange = { viewModel.setSshEnabled(it) },
+ )
+ Spacer(Modifier.height(8.dp))
+ HorizontalDivider()
+ Spacer(Modifier.height(12.dp))
+ Text("Port forwards", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.SemiBold)
+ Text(
+ text = "Forward ports from your Android device into the VM. Active immediately when VM is running.",
+ style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
- modifier = Modifier.padding(vertical = 8.dp),
+ modifier = Modifier.padding(top = 2.dp, bottom = 8.dp),
)
- } else {
- portForwardRules.forEach { rule ->
- PortForwardRuleRow(
- rule = rule,
- onDelete = { viewModel.removePortForward(rule) },
+
+ if (portForwardRules.isEmpty()) {
+ Text(
+ text = "No rules configured.",
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ modifier = Modifier.padding(vertical = 8.dp),
+ )
+ } else {
+ portForwardRules.forEach { rule ->
+ PortForwardRuleRow(
+ rule = rule,
+ onDelete = { viewModel.removePortForward(rule) },
+ )
+ }
+ }
+ Spacer(Modifier.height(8.dp))
+ FilledTonalButton(
+ onClick = { showAddDialog = true },
+ modifier = Modifier.fillMaxWidth(),
+ shape = RoundedCornerShape(14.dp),
+ ) {
+ Icon(Icons.Default.Add, contentDescription = null)
+ Spacer(Modifier.width(8.dp))
+ Text("Add Port Forward")
+ }
+ if (vmState is VmState.Running) {
+ Text(
+ text = "VM is running — new rules take effect immediately.",
+ style = MaterialTheme.typography.labelSmall,
+ color = MaterialTheme.colorScheme.primary,
+ modifier = Modifier.padding(top = 6.dp),
)
}
}
Spacer(Modifier.height(8.dp))
- FilledTonalButton(
- onClick = { showAddDialog = true },
- modifier = Modifier.fillMaxWidth(),
- ) {
- Icon(Icons.Default.Add, contentDescription = null)
- Spacer(Modifier.width(8.dp))
- Text("Add Port Forward")
- }
-
- if (vmState is VmState.Running) {
- Text(
- text = "VM is running — new rules take effect immediately.",
- style = MaterialTheme.typography.labelSmall,
- color = MaterialTheme.colorScheme.primary,
- modifier = Modifier.padding(top = 4.dp),
+ // ── Appearance ────────────────────────────────────────────
+ SettingsSection(title = "Appearance") {
+ SettingsSwitchRow(
+ title = "Dark theme",
+ subtitle = "Use a dark color scheme",
+ checked = darkTheme,
+ onCheckedChange = { viewModel.setDarkTheme(it) },
)
}
- Spacer(Modifier.height(16.dp))
-
- SettingsSectionHeader("Appearance")
- SettingsSwitchRow(
- title = "Dark theme",
- subtitle = "Use a dark color scheme",
- checked = darkTheme,
- onCheckedChange = { viewModel.setDarkTheme(it) },
- )
- Spacer(Modifier.height(16.dp))
-
- SettingsSectionHeader("Diagnostics")
-
- FilledTonalButton(
- onClick = { viewModel.exportConsoleLogs() },
- modifier = Modifier.fillMaxWidth(),
- ) {
- Icon(Icons.Default.Share, contentDescription = null)
- Spacer(Modifier.width(8.dp))
- Text("Export Diagnostic Log")
- }
- Text(
- text = "Shares log.txt with app info, settings, VM state, app logcat, and QEMU console output. Attach this when reporting bugs.",
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- modifier = Modifier.padding(top = 4.dp),
- )
-
Spacer(Modifier.height(8.dp))
- FilledTonalButton(
- onClick = { showResetDialog = true },
- enabled = vmNotRunning,
- modifier = Modifier.fillMaxWidth(),
- colors = ButtonDefaults.filledTonalButtonColors(
- containerColor = MaterialTheme.colorScheme.errorContainer,
- contentColor = MaterialTheme.colorScheme.onErrorContainer,
- ),
- ) {
- Icon(Icons.Default.RestartAlt, contentDescription = null)
- Spacer(Modifier.width(8.dp))
- Text("Full App Reset")
- }
-
- if (!vmNotRunning) {
+ // ── Diagnostics ───────────────────────────────────────────
+ SettingsSection(title = "Diagnostics") {
+ FilledTonalButton(
+ onClick = { viewModel.exportConsoleLogs() },
+ modifier = Modifier.fillMaxWidth(),
+ shape = RoundedCornerShape(14.dp),
+ ) {
+ Icon(Icons.Default.Share, contentDescription = null)
+ Spacer(Modifier.width(8.dp))
+ Text("Export Diagnostic Log")
+ }
Text(
- text = "Stop the VM before resetting.",
- style = MaterialTheme.typography.labelSmall,
- color = MaterialTheme.colorScheme.error,
- modifier = Modifier.padding(top = 4.dp),
+ text = "Shares log.txt with app info, settings, VM state, app logcat, and QEMU console output. Attach this when reporting bugs.",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ modifier = Modifier.padding(top = 8.dp),
)
+
+ Spacer(Modifier.height(12.dp))
+
+ FilledTonalButton(
+ onClick = { showResetDialog = true },
+ enabled = vmNotRunning,
+ modifier = Modifier.fillMaxWidth(),
+ shape = RoundedCornerShape(14.dp),
+ colors = ButtonDefaults.filledTonalButtonColors(
+ containerColor = MaterialTheme.colorScheme.errorContainer,
+ contentColor = MaterialTheme.colorScheme.onErrorContainer,
+ ),
+ ) {
+ Icon(Icons.Default.RestartAlt, contentDescription = null)
+ Spacer(Modifier.width(8.dp))
+ Text("Full App Reset")
+ }
+ if (!vmNotRunning) {
+ Text(
+ text = "Stop the VM before resetting.",
+ style = MaterialTheme.typography.labelSmall,
+ color = MaterialTheme.colorScheme.error,
+ modifier = Modifier.padding(top = 6.dp),
+ )
+ }
}
- Spacer(Modifier.height(16.dp))
+ Spacer(Modifier.height(8.dp))
// ── Advanced QEMU ─────────────────────────────────────────
Row(
@@ -423,14 +399,14 @@ fun SettingsScreen(
}
// ── About ─────────────────────────────────────────────────
- SettingsSectionHeader("About")
-
- SettingsInfoRow("Version", BuildConfig.VERSION_NAME)
- SettingsInfoRow("QEMU", BuildConfig.QEMU_VERSION)
- SettingsInfoRow("Architecture", "AArch64 (ARM64)")
- SettingsInfoRow("Linux distro", "Alpine Linux 3.23")
- SettingsInfoRow("Container runtime", "Podman + crun")
- SettingsInfoRow("Storage", "$storageSizeGb GB persistent overlay")
+ SettingsSection(title = "About") {
+ SettingsInfoRow("Version", BuildConfig.VERSION_NAME)
+ SettingsInfoRow("QEMU", BuildConfig.QEMU_VERSION)
+ SettingsInfoRow("Architecture", "AArch64 (ARM64)")
+ SettingsInfoRow("Linux distro", "Alpine Linux 3.23")
+ SettingsInfoRow("Container runtime", "Podman + crun")
+ SettingsInfoRow("Storage", "$storageSizeGb GB persistent overlay")
+ }
Spacer(Modifier.height(32.dp))
}
@@ -598,6 +574,69 @@ private fun SettingsSectionHeader(title: String) {
}
}
+/** Card-grouped section: header above + a surface-tinted card around the content. */
+@Composable
+private fun SettingsSection(
+ title: String,
+ content: @Composable () -> Unit,
+) {
+ Text(
+ text = title.uppercase(),
+ style = MaterialTheme.typography.labelMedium,
+ color = MaterialTheme.colorScheme.primary,
+ fontWeight = FontWeight.SemiBold,
+ modifier = Modifier.padding(start = 4.dp, top = 12.dp, bottom = 8.dp),
+ )
+ Card(
+ modifier = Modifier.fillMaxWidth(),
+ shape = RoundedCornerShape(20.dp),
+ colors = CardDefaults.cardColors(
+ containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.4f),
+ ),
+ ) {
+ Column(modifier = Modifier.padding(horizontal = 16.dp, vertical = 16.dp)) {
+ content()
+ }
+ }
+}
+
+/** Row of FilterChips for picking one value out of a list (RAM, CPUs, etc.). */
+@OptIn(ExperimentalLayoutApi::class)
+@Composable
+private fun <T> ChipRow(
+ options: List<T>,
+ selected: T,
+ enabled: Boolean,
+ label: (T) -> String,
+ onSelect: (T) -> Unit,
+) {
+ FlowRow(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(8.dp),
+ verticalArrangement = Arrangement.spacedBy(8.dp),
+ ) {
+ options.forEach { option ->
+ FilterChip(
+ selected = option == selected,
+ enabled = enabled,
+ onClick = { onSelect(option) },
+ label = {
+ Text(
+ text = label(option),
+ style = MaterialTheme.typography.labelLarge,
+ fontWeight = if (option == selected) FontWeight.Bold else FontWeight.Normal,
+ )
+ },
+ shape = RoundedCornerShape(14.dp),
+ colors = FilterChipDefaults.filterChipColors(
+ selectedContainerColor = MaterialTheme.colorScheme.primaryContainer,
+ selectedLabelColor = MaterialTheme.colorScheme.onPrimaryContainer,
+ ),
+ )
+ }
+ }
+}
+
@Composable
private fun SettingsSwitchRow(
title: String,
diff --git a/app/src/main/java/com/excp/podroid/ui/screens/setup/SetupScreen.kt b/app/src/main/java/com/excp/podroid/ui/screens/setup/SetupScreen.kt
index 8a20439..5efe515 100644
--- a/app/src/main/java/com/excp/podroid/ui/screens/setup/SetupScreen.kt
+++ b/app/src/main/java/com/excp/podroid/ui/screens/setup/SetupScreen.kt
@@ -16,8 +16,11 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.ExperimentalLayoutApi
+import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
@@ -45,15 +48,17 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
-import androidx.compose.material3.Slider
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.ElevatedCard
+import androidx.compose.material3.FilterChip
+import androidx.compose.material3.FilterChipDefaults
+import androidx.compose.material3.windowsizeclass.WindowHeightSizeClass
import androidx.compose.material3.windowsizeclass.WindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableFloatStateOf
+import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
@@ -70,6 +75,7 @@ import com.excp.podroid.ui.components.AdaptiveContainer
import kotlinx.coroutines.launch
private val storageSizes = listOf(2, 4, 8, 16, 32, 64)
+private const val DEFAULT_STORAGE_GB = 8
@Composable
fun SetupScreen(
@@ -78,10 +84,9 @@ fun SetupScreen(
viewModel: SetupViewModel = hiltViewModel(),
) {
val context = LocalContext.current
- var sliderPosition by remember { mutableFloatStateOf(0f) }
+ var selectedGb by remember { mutableIntStateOf(DEFAULT_STORAGE_GB) }
var sshEnabled by remember { mutableStateOf(true) }
var storageAccessEnabled by remember { mutableStateOf(false) }
- val selectedGb = storageSizes[sliderPosition.toInt().coerceIn(0, storageSizes.lastIndex)]
val setupComplete by viewModel.setupComplete.collectAsStateWithLifecycle()
val pagerState = rememberPagerState(pageCount = { 3 })
val scope = rememberCoroutineScope()
@@ -126,9 +131,8 @@ fun SetupScreen(
when (page) {
0 -> StoragePage(
windowSizeClass = windowSizeClass,
- sliderPosition = sliderPosition,
selectedGb = selectedGb,
- onSliderChange = { sliderPosition = it },
+ onSelect = { selectedGb = it },
onNext = { scope.launch { pagerState.animateScrollToPage(1) } },
)
1 -> VmConfigPage(
@@ -208,21 +212,24 @@ fun SetupScreen(
}
}
-// ── Page 1: Storage ───────────────────────────────────────────────────────────
+// ── Setup page scaffold (handles landscape vs portrait, hero vs side-by-side) ──
@Composable
-private fun StoragePage(
+private fun SetupPageLayout(
windowSizeClass: WindowSizeClass,
- sliderPosition: Float,
- selectedGb: Int,
- onSliderChange: (Float) -> Unit,
- onNext: () -> Unit,
+ icon: androidx.compose.ui.graphics.vector.ImageVector,
+ title: String,
+ description: String,
+ bottomBar: @Composable () -> Unit,
+ content: @Composable () -> Unit,
) {
- // Outer column keeps button fixed at bottom while inner column scrolls
+ val isCompactHeight = windowSizeClass.heightSizeClass == WindowHeightSizeClass.Compact
+ val maxCardWidth = if (isCompactHeight) 920 else 600
+
AdaptiveContainer(
windowSizeClass = windowSizeClass,
modifier = Modifier.fillMaxSize(),
- maxWidth = 600
+ maxWidth = maxCardWidth,
) {
Column(
modifier = Modifier
@@ -239,129 +246,119 @@ private fun StoragePage(
containerColor = MaterialTheme.colorScheme.surface
)
) {
- Column(
- modifier = Modifier
- .fillMaxSize()
- .verticalScroll(rememberScrollState())
- .padding(horizontal = 24.dp),
- horizontalAlignment = Alignment.CenterHorizontally,
- ) {
- Spacer(Modifier.height(40.dp))
-
- Icon(
- imageVector = Icons.Default.Storage,
- contentDescription = null,
- modifier = Modifier.size(64.dp),
- tint = MaterialTheme.colorScheme.primary,
- )
-
- Spacer(Modifier.height(20.dp))
-
- Text(
- text = "Persistent Storage",
- style = MaterialTheme.typography.headlineMedium,
- fontWeight = FontWeight.Bold,
- textAlign = TextAlign.Center,
- )
-
- Spacer(Modifier.height(8.dp))
-
- Text(
- text = "Stores installed packages, container images, and your files.",
- style = MaterialTheme.typography.bodyLarge,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- textAlign = TextAlign.Center,
- )
-
- Spacer(Modifier.height(48.dp))
-
- Text(
- text = "$selectedGb GB",
- style = MaterialTheme.typography.displayMedium,
- fontWeight = FontWeight.Bold,
- color = MaterialTheme.colorScheme.primary,
- )
-
- Spacer(Modifier.height(8.dp))
-
- Slider(
- value = sliderPosition,
- onValueChange = onSliderChange,
- valueRange = 0f..(storageSizes.lastIndex.toFloat()),
- steps = 4,
- modifier = Modifier.fillMaxWidth(),
- )
-
+ if (isCompactHeight) {
Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- ) {
- Text(
- "2 GB",
- style = MaterialTheme.typography.labelSmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- )
- Text(
- "64 GB",
- style = MaterialTheme.typography.labelSmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- )
- }
-
- Spacer(Modifier.height(24.dp))
-
- Card(
- modifier = Modifier.fillMaxWidth(),
- shape = RoundedCornerShape(12.dp),
- colors = CardDefaults.cardColors(
- containerColor = MaterialTheme.colorScheme.secondaryContainer,
- ),
+ modifier = Modifier
+ .fillMaxSize()
+ .verticalScroll(rememberScrollState())
+ .padding(horizontal = 24.dp, vertical = 16.dp),
+ verticalAlignment = Alignment.Top,
) {
- Row(
- modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),
- verticalAlignment = Alignment.CenterVertically,
+ // Hero column (icon + title + description)
+ Column(
+ modifier = Modifier.weight(1f).padding(top = 20.dp),
+ horizontalAlignment = Alignment.CenterHorizontally,
) {
Icon(
- Icons.Default.Info,
+ imageVector = icon,
contentDescription = null,
- tint = MaterialTheme.colorScheme.secondary,
- modifier = Modifier.size(18.dp),
+ modifier = Modifier.size(48.dp),
+ tint = MaterialTheme.colorScheme.primary,
+ )
+ Spacer(Modifier.height(12.dp))
+ Text(
+ text = title,
+ style = MaterialTheme.typography.headlineSmall,
+ fontWeight = FontWeight.Bold,
+ textAlign = TextAlign.Center,
)
- Spacer(Modifier.width(12.dp))
+ Spacer(Modifier.height(6.dp))
Text(
- text = "Cannot be resized later without a full VM reset.",
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onSecondaryContainer,
+ text = description,
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ textAlign = TextAlign.Center,
)
}
+ Spacer(Modifier.width(24.dp))
+ // Content column (top-aligned; outer scroll handles overflow)
+ Column(
+ modifier = Modifier.weight(1f),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ ) {
+ content()
+ }
+ }
+ } else {
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .verticalScroll(rememberScrollState())
+ .padding(horizontal = 24.dp),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ ) {
+ Spacer(Modifier.height(40.dp))
+ Icon(
+ imageVector = icon,
+ contentDescription = null,
+ modifier = Modifier.size(64.dp),
+ tint = MaterialTheme.colorScheme.primary,
+ )
+ Spacer(Modifier.height(20.dp))
+ Text(
+ text = title,
+ style = MaterialTheme.typography.headlineMedium,
+ fontWeight = FontWeight.Bold,
+ textAlign = TextAlign.Center,
+ )
+ Spacer(Modifier.height(8.dp))
+ Text(
+ text = description,
+ style = MaterialTheme.typography.bodyLarge,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ textAlign = TextAlign.Center,
+ )
+ Spacer(Modifier.height(32.dp))
+ content()
+ Spacer(Modifier.height(16.dp))
}
-
- Spacer(Modifier.height(16.dp))
- }
- }
-
- // Fixed next button
- Column(modifier = Modifier.padding(horizontal = 24.dp, vertical = 16.dp)) {
- Button(
- onClick = onNext,
- modifier = Modifier
- .fillMaxWidth()
- .height(56.dp),
- shape = RoundedCornerShape(16.dp),
- ) {
- Text(
- "Next",
- style = MaterialTheme.typography.titleMedium,
- fontWeight = FontWeight.SemiBold,
- )
- Spacer(Modifier.width(8.dp))
- Icon(Icons.AutoMirrored.Filled.ArrowForward, contentDescription = null)
}
}
+ bottomBar()
}
}
}
+// ── Page 1: Storage ───────────────────────────────────────────────────────────
+
+@Composable
+private fun StoragePage(
+ windowSizeClass: WindowSizeClass,
+ selectedGb: Int,
+ onSelect: (Int) -> Unit,
+ onNext: () -> Unit,
+) {
+ val isCompact = windowSizeClass.heightSizeClass == WindowHeightSizeClass.Compact
+ SetupPageLayout(
+ windowSizeClass = windowSizeClass,
+ icon = Icons.Default.Storage,
+ title = "Persistent Storage",
+ description = "Stores installed packages, container images, and your files.",
+ bottomBar = { SetupNextBar(onNext = onNext) },
+ ) {
+ Text(
+ text = "$selectedGb GB",
+ style = if (isCompact) MaterialTheme.typography.headlineLarge else MaterialTheme.typography.displayMedium,
+ fontWeight = FontWeight.Bold,
+ color = MaterialTheme.colorScheme.primary,
+ )
+ Spacer(Modifier.height(if (isCompact) 8.dp else 12.dp))
+ StorageSizeChips(selectedGb, onSelect)
+ Spacer(Modifier.height(if (isCompact) 12.dp else 16.dp))
+ StorageInfoCard()
+ }
+}
+
// ── Page 2: VM config + SSH ───────────────────────────────────────────────────
@Composable
@@ -372,177 +369,78 @@ private fun VmConfigPage(
onBack: () -> Unit,
onNext: () -> Unit,
) {
- AdaptiveContainer(
+ SetupPageLayout(
windowSizeClass = windowSizeClass,
- modifier = Modifier.fillMaxSize(),
- maxWidth = 600
+ icon = Icons.Default.Memory,
+ title = "Configure Your VM",
+ description = "Defaults are tuned for the best balance of performance and battery. Adjust anytime in Settings.",
+ bottomBar = { SetupNavBar(onBack = onBack, onNext = onNext, nextLabel = "Next") },
) {
- Column(
- modifier = Modifier
- .fillMaxSize()
- .padding(vertical = 16.dp),
- horizontalAlignment = Alignment.CenterHorizontally,
+ // Performance defaults
+ Card(
+ modifier = Modifier.fillMaxWidth(),
+ shape = RoundedCornerShape(16.dp),
+ colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
) {
- ElevatedCard(
- modifier = Modifier
- .weight(1f)
- .padding(horizontal = 16.dp),
- shape = RoundedCornerShape(24.dp),
- colors = CardDefaults.elevatedCardColors(
- containerColor = MaterialTheme.colorScheme.surface
+ Column(modifier = Modifier.padding(20.dp)) {
+ Text(
+ "Default Performance",
+ style = MaterialTheme.typography.labelLarge,
+ color = MaterialTheme.colorScheme.primary,
)
- ) {
- Column(
- modifier = Modifier
- .fillMaxSize()
- .verticalScroll(rememberScrollState())
- .padding(horizontal = 24.dp),
- horizontalAlignment = Alignment.CenterHorizontally,
- ) {
- Spacer(Modifier.height(40.dp))
-
- Icon(
- imageVector = Icons.Default.Memory,
- contentDescription = null,
- modifier = Modifier.size(64.dp),
- tint = MaterialTheme.colorScheme.primary,
- )
-
- Spacer(Modifier.height(20.dp))
-
- Text(
- text = "Configure Your VM",
- style = MaterialTheme.typography.headlineMedium,
- fontWeight = FontWeight.Bold,
- textAlign = TextAlign.Center,
- )
-
- Spacer(Modifier.height(8.dp))
-
- Text(
- text = "Defaults are tuned for the best balance of performance and battery. Adjust anytime in Settings.",
- style = MaterialTheme.typography.bodyLarge,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- textAlign = TextAlign.Center,
- )
-
- Spacer(Modifier.height(32.dp))
-
- // Performance defaults
- Card(
- modifier = Modifier.fillMaxWidth(),
- shape = RoundedCornerShape(16.dp),
- colors = CardDefaults.cardColors(
- containerColor = MaterialTheme.colorScheme.surfaceVariant,
- ),
- ) {
- Column(modifier = Modifier.padding(20.dp)) {
- Text(
- "Default Performance",
- style = MaterialTheme.typography.labelLarge,
- color = MaterialTheme.colorScheme.primary,
- )
- Spacer(Modifier.height(16.dp))
- SetupInfoRow(label = "CPU", value = "1 core")
- Spacer(Modifier.height(8.dp))
- SetupInfoRow(label = "RAM", value = "512 MB")
- }
- }
-
- Spacer(Modifier.height(12.dp))
-
- // SSH toggle
- Card(
- modifier = Modifier.fillMaxWidth(),
- shape = RoundedCornerShape(16.dp),
- colors = CardDefaults.cardColors(
- containerColor = if (sshEnabled)
- MaterialTheme.colorScheme.primaryContainer
- else
- MaterialTheme.colorScheme.surfaceVariant,
- ),
- ) {
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .padding(20.dp),
- verticalAlignment = Alignment.CenterVertically,
- ) {
- Icon(
- Icons.Default.Security,
- contentDescription = null,
- tint = if (sshEnabled)
- MaterialTheme.colorScheme.primary
- else
- MaterialTheme.colorScheme.onSurfaceVariant,
- modifier = Modifier.size(24.dp),
- )
- Spacer(Modifier.width(16.dp))
- Column(modifier = Modifier.weight(1f)) {
- Text(
- "SSH Access",
- style = MaterialTheme.typography.titleMedium,
- fontWeight = FontWeight.SemiBold,
- )
- Spacer(Modifier.height(4.dp))
- Text(
- if (sshEnabled)
- "ssh root@<phone-ip> -p 9922\nPassword: podroid"
- else
- "Connect to the VM over your local network.",
- style = MaterialTheme.typography.bodySmall,
- color = if (sshEnabled)
- MaterialTheme.colorScheme.onPrimaryContainer
- else
- MaterialTheme.colorScheme.onSurfaceVariant,
- )
- }
- Spacer(Modifier.width(12.dp))
- Switch(
- checked = sshEnabled,
- onCheckedChange = onSshToggle,
- )
- }
- }
-
- Spacer(Modifier.height(16.dp))
- }
+ Spacer(Modifier.height(12.dp))
+ SetupInfoRow(label = "CPU", value = "1 core")
+ Spacer(Modifier.height(6.dp))
+ SetupInfoRow(label = "RAM", value = "512 MB")
}
-
- // Fixed back + next buttons
+ }
+ Spacer(Modifier.height(12.dp))
+ // SSH toggle
+ Card(
+ modifier = Modifier.fillMaxWidth(),
+ shape = RoundedCornerShape(16.dp),
+ colors = CardDefaults.cardColors(
+ containerColor = if (sshEnabled)
+ MaterialTheme.colorScheme.primaryContainer
+ else
+ MaterialTheme.colorScheme.surfaceVariant,
+ ),
+ ) {
Row(
- modifier = Modifier
- .fillMaxWidth()
- .padding(horizontal = 24.dp, vertical = 16.dp),
- horizontalArrangement = Arrangement.spacedBy(12.dp),
+ modifier = Modifier.fillMaxWidth().padding(20.dp),
verticalAlignment = Alignment.CenterVertically,
) {
- FilledTonalButton(
- onClick = onBack,
- modifier = Modifier
- .weight(1f)
- .height(56.dp),
- shape = RoundedCornerShape(16.dp),
- ) {
- Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null)
- Spacer(Modifier.width(8.dp))
- Text("Back", style = MaterialTheme.typography.titleMedium)
- }
- Button(
- onClick = onNext,
- modifier = Modifier
- .weight(2f)
- .height(56.dp),
- shape = RoundedCornerShape(16.dp),
- ) {
+ Icon(
+ Icons.Default.Security,
+ contentDescription = null,
+ tint = if (sshEnabled)
+ MaterialTheme.colorScheme.primary
+ else
+ MaterialTheme.colorScheme.onSurfaceVariant,
+ modifier = Modifier.size(24.dp),
+ )
+ Spacer(Modifier.width(16.dp))
+ Column(modifier = Modifier.weight(1f)) {
Text(
- "Next",
+ "SSH Access",
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.SemiBold,
)
- Spacer(Modifier.width(8.dp))
- Icon(Icons.AutoMirrored.Filled.ArrowForward, contentDescription = null)
+ Spacer(Modifier.height(4.dp))
+ Text(
+ if (sshEnabled)
+ "ssh root@<phone-ip> -p 9922\nPassword: podroid"
+ else
+ "Connect to the VM over your local network.",
+ style = MaterialTheme.typography.bodySmall,
+ color = if (sshEnabled)
+ MaterialTheme.colorScheme.onPrimaryContainer
+ else
+ MaterialTheme.colorScheme.onSurfaceVariant,
+ )
}
+ Spacer(Modifier.width(12.dp))
+ Switch(checked = sshEnabled, onCheckedChange = onSshToggle)
}
}
}
@@ -560,157 +458,120 @@ private fun StorageAccessPage(
val canManageAllFiles = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
val hasStoragePermission = !canManageAllFiles || Environment.isExternalStorageManager()
- AdaptiveContainer(
+ SetupPageLayout(
windowSizeClass = windowSizeClass,
- modifier = Modifier.fillMaxSize(),
- maxWidth = 600
+ icon = Icons.Default.Security,
+ title = "Downloads Sharing",
+ description = "Optional access to your Downloads folder inside the VM.",
+ bottomBar = { SetupNavBar(onBack = onBack, onNext = onGetStarted, nextLabel = "Get Started", showNextIcon = false) },
) {
- Column(
- modifier = Modifier
- .fillMaxSize()
- .padding(vertical = 16.dp),
- horizontalAlignment = Alignment.CenterHorizontally,
+ Card(
+ modifier = Modifier.fillMaxWidth(),
+ shape = RoundedCornerShape(16.dp),
+ colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
) {
- ElevatedCard(
- modifier = Modifier
- .weight(1f)
- .padding(horizontal = 16.dp),
- shape = RoundedCornerShape(24.dp),
- colors = CardDefaults.elevatedCardColors(
- containerColor = MaterialTheme.colorScheme.surface
- )
- ) {
- Column(
- modifier = Modifier
- .fillMaxSize()
- .verticalScroll(rememberScrollState())
- .padding(horizontal = 24.dp),
- horizontalAlignment = Alignment.CenterHorizontally,
+ Column(modifier = Modifier.padding(20.dp)) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically,
) {
- Spacer(Modifier.height(40.dp))
-
- Icon(
- imageVector = Icons.Default.Security,
- contentDescription = null,
- modifier = Modifier.size(64.dp),
- tint = MaterialTheme.colorScheme.primary,
- )
-
- Spacer(Modifier.height(20.dp))
-
- Text(
- text = "Downloads Sharing",
- style = MaterialTheme.typography.headlineMedium,
- fontWeight = FontWeight.Bold,
- textAlign = TextAlign.Center,
+ Column(modifier = Modifier.weight(1f)) {
+ Text(
+ text = "Enable Downloads sharing",
+ style = MaterialTheme.typography.titleMedium,
+ fontWeight = FontWeight.SemiBold,
+ )
+ Spacer(Modifier.height(4.dp))
+ Text(
+ text = "Shares the Android Downloads folder with the VM over virtio-9p.",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ }
+ Spacer(Modifier.width(12.dp))
+ Switch(
+ checked = storageAccessEnabled,
+ onCheckedChange = onStorageAccessToggle,
)
-
- Spacer(Modifier.height(8.dp))
-
+ }
+ Spacer(Modifier.height(16.dp))
+ Text(
+ text = "On some devices this may crash the VM.",
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.error,
+ fontWeight = FontWeight.SemiBold,
+ )
+ if (storageAccessEnabled && canManageAllFiles && !hasStoragePermission) {
+ Spacer(Modifier.height(16.dp))
+ Button(
+ onClick = onOpenStorageAccessSettings,
+ shape = RoundedCornerShape(12.dp),
+ ) {
+ Text("Grant storage access")
+ }
+ } else if (storageAccessEnabled && canManageAllFiles) {
+ Spacer(Modifier.height(12.dp))
Text(
- text = "Optional access to your Downloads folder inside the VM.",
- style = MaterialTheme.typography.bodyLarge,
+ text = if (hasStoragePermission) "All files access granted." else "All files access not granted.",
+ style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
- textAlign = TextAlign.Center,
)
-
- Spacer(Modifier.height(32.dp))
-
- Card(
- modifier = Modifier.fillMaxWidth(),
- shape = RoundedCornerShape(16.dp),
- colors = CardDefaults.cardColors(
- containerColor = MaterialTheme.colorScheme.surfaceVariant,
- ),
- ) {
- Column(modifier = Modifier.padding(20.dp)) {
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically,
- ) {
- Column(modifier = Modifier.weight(1f)) {
- Text(
- text = "Enable Downloads sharing",
- style = MaterialTheme.typography.titleMedium,
- fontWeight = FontWeight.SemiBold,
- )
- Spacer(Modifier.height(4.dp))
- Text(
- text = "Shares the Android Downloads folder with the VM over virtio-9p.",
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- )
- }
- Spacer(Modifier.width(12.dp))
- Switch(
- checked = storageAccessEnabled,
- onCheckedChange = onStorageAccessToggle,
- )
- }
-
- Spacer(Modifier.height(16.dp))
-
- Text(
- text = "On some devices this may crash the VM.",
- style = MaterialTheme.typography.bodyMedium,
- color = MaterialTheme.colorScheme.error,
- fontWeight = FontWeight.SemiBold,
- )
-
- if (storageAccessEnabled && canManageAllFiles && !hasStoragePermission) {
- Spacer(Modifier.height(16.dp))
- Button(
- onClick = onOpenStorageAccessSettings,
- shape = RoundedCornerShape(12.dp),
- ) {
- Text("Grant storage access")
- }
- } else if (storageAccessEnabled && canManageAllFiles) {
- Spacer(Modifier.height(12.dp))
- Text(
- text = if (hasStoragePermission) "All files access granted." else "All files access not granted.",
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
- )
- }
- }
- }
- Spacer(Modifier.height(16.dp))
}
}
+ }
+ }
+}
- Row(
- modifier = Modifier
- .fillMaxWidth()
- .padding(horizontal = 24.dp, vertical = 16.dp),
- horizontalArrangement = Arrangement.spacedBy(12.dp),
- verticalAlignment = Alignment.CenterVertically,
- ) {
- FilledTonalButton(
- onClick = onBack,
- modifier = Modifier
- .weight(1f)
- .height(56.dp),
- shape = RoundedCornerShape(16.dp),
- ) {
- Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null)
- Spacer(Modifier.width(8.dp))
- Text("Back", style = MaterialTheme.typography.titleMedium)
- }
- Button(
- onClick = onGetStarted,
- modifier = Modifier
- .weight(2f)
- .height(56.dp),
- shape = RoundedCornerShape(16.dp),
- ) {
- Text(
- "Get Started",
- style = MaterialTheme.typography.titleMedium,
- fontWeight = FontWeight.SemiBold,
- )
- }
+// ── Setup bottom bars ─────────────────────────────────────────────────────────
+
+@Composable
+private fun SetupNextBar(onNext: () -> Unit) {
+ Column(modifier = Modifier.padding(horizontal = 24.dp, vertical = 16.dp)) {
+ Button(
+ onClick = onNext,
+ modifier = Modifier
+ .fillMaxWidth()
+ .height(56.dp),
+ shape = RoundedCornerShape(16.dp),
+ ) {
+ Text("Next", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
+ Spacer(Modifier.width(8.dp))
+ Icon(Icons.AutoMirrored.Filled.ArrowForward, contentDescription = null)
+ }
+ }
+}
+
+@Composable
+private fun SetupNavBar(
+ onBack: () -> Unit,
+ onNext: () -> Unit,
+ nextLabel: String,
+ showNextIcon: Boolean = true,
+) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 24.dp, vertical = 16.dp),
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ FilledTonalButton(
+ onClick = onBack,
+ modifier = Modifier.weight(1f).height(56.dp),
+ shape = RoundedCornerShape(16.dp),
+ ) {
+ Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null)
+ Spacer(Modifier.width(8.dp))
+ Text("Back", style = MaterialTheme.typography.titleMedium)
+ }
+ Button(
+ onClick = onNext,
+ modifier = Modifier.weight(2f).height(56.dp),
+ shape = RoundedCornerShape(16.dp),
+ ) {
+ Text(nextLabel, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
+ if (showNextIcon) {
+ Spacer(Modifier.width(8.dp))
+ Icon(Icons.AutoMirrored.Filled.ArrowForward, contentDescription = null)
}
}
}
@@ -735,3 +596,61 @@ private fun SetupInfoRow(label: String, value: String) {
)
}
}
+
+@OptIn(ExperimentalLayoutApi::class)
+@Composable
+private fun StorageSizeChips(selectedGb: Int, onSelect: (Int) -> Unit) {
+ FlowRow(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),
+ verticalArrangement = Arrangement.spacedBy(8.dp),
+ ) {
+ storageSizes.forEach { gb ->
+ FilterChip(
+ selected = gb == selectedGb,
+ onClick = { onSelect(gb) },
+ label = {
+ Text(
+ text = "$gb GB",
+ style = MaterialTheme.typography.labelLarge,
+ fontWeight = if (gb == selectedGb) FontWeight.Bold else FontWeight.Normal,
+ )
+ },
+ shape = RoundedCornerShape(16.dp),
+ colors = FilterChipDefaults.filterChipColors(
+ selectedContainerColor = MaterialTheme.colorScheme.primaryContainer,
+ selectedLabelColor = MaterialTheme.colorScheme.onPrimaryContainer,
+ ),
+ )
+ }
+ }
+}
+
+@Composable
+private fun StorageInfoCard() {
+ Card(
+ modifier = Modifier.fillMaxWidth(),
+ shape = RoundedCornerShape(12.dp),
+ colors = CardDefaults.cardColors(
+ containerColor = MaterialTheme.colorScheme.secondaryContainer,
+ ),
+ ) {
+ Row(
+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Icon(
+ Icons.Default.Info,
+ contentDescription = null,
+ tint = MaterialTheme.colorScheme.secondary,
+ modifier = Modifier.size(18.dp),
+ )
+ Spacer(Modifier.width(12.dp))
+ Text(
+ text = "Cannot be resized later without a full VM reset.",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSecondaryContainer,
+ )
+ }
+ }
+}
diff --git a/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalScreen.kt b/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalScreen.kt
index cb948fb..5d517e7 100644
--- a/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalScreen.kt
+++ b/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalScreen.kt
@@ -6,8 +6,11 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
+import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
@@ -27,12 +30,16 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.AlertDialog
+import androidx.compose.material3.FilterChip
+import androidx.compose.material3.FilterChipDefaults
+import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
+import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
@@ -59,7 +66,15 @@ import kotlinx.coroutines.delay
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
+import androidx.compose.ui.draw.drawWithContent
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.graphics.BlendMode
+import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.CompositingStrategy
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.unit.Dp
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
@@ -429,87 +444,115 @@ private fun QuickSettingsDialog(
onColorThemeChange: (String) -> Unit,
terminalFont: String,
onFontChange: (String) -> Unit,
+ viewModel: TerminalViewModel = hiltViewModel(),
) {
- var showThemeDialog by remember { mutableStateOf(false) }
- var showFontDialog by remember { mutableStateOf(false) }
-
- if (showThemeDialog) {
- ThemeSelectionDialog(
- currentTheme = colorTheme,
- onThemeSelect = {
- onColorThemeChange(it)
- showThemeDialog = false
- },
- onDismiss = { showThemeDialog = false }
- )
- }
-
- if (showFontDialog) {
- FontSelectionDialog(
- currentFont = terminalFont,
- onFontSelect = {
- onFontChange(it)
- showFontDialog = false
- },
- onDismiss = { showFontDialog = false }
- )
- }
-
+ val themes = remember { viewModel.listAssetNames("colors", ".properties") }
+ val fonts = remember { viewModel.listAssetNames("fonts", ".ttf") }
+ val fontSizes = listOf(12, 14, 16, 18, 20, 22, 24, 28, 32)
+
+ val scrollState = rememberScrollState()
+ val scrollbarColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.55f)
+ val scrollTrackColor = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.08f)
+
AlertDialog(
onDismissRequest = onDismiss,
title = { Text("Quick Settings") },
text = {
- Column {
- Text("Font Size: $fontSize sp", style = MaterialTheme.typography.labelMedium)
- androidx.compose.material3.Slider(
- value = fontSize.toFloat(),
- onValueChange = { onFontSizeChange(it.toInt()) },
- valueRange = 12f..32f,
- steps = 20,
- modifier = Modifier.padding(top = 4.dp, bottom = 16.dp)
- )
-
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(8.dp)
- ) {
- FilledTonalButton(
- onClick = { showThemeDialog = true },
- modifier = Modifier.weight(1f)
+ Box(
+ modifier = Modifier.verticalScrollbar(
+ state = scrollState,
+ thumbColor = scrollbarColor,
+ trackColor = scrollTrackColor,
+ ),
+ ) {
+ Column(
+ modifier = Modifier
+ .verticalScroll(scrollState)
+ .padding(start = 10.dp),
+ verticalArrangement = Arrangement.spacedBy(20.dp),
+ ) {
+ // ── Font size ──────────────────────────────────────
+ val sizeIdx = fontSizes.indexOf(fontSize).coerceAtLeast(0)
+ val sizeListState = rememberLazyListState(sizeIdx)
+ QuickSettingsRow(label = "Font size", value = "$fontSize sp") {
+ LazyRow(
+ state = sizeListState,
+ horizontalArrangement = Arrangement.spacedBy(8.dp),
+ contentPadding = PaddingValues(horizontal = 4.dp),
+ modifier = Modifier.fadingEdges(sizeListState),
) {
- Text("Theme")
+ items(fontSizes.size) { i ->
+ val sz = fontSizes[i]
+ QuickChip(
+ label = "$sz",
+ selected = sz == fontSize,
+ onClick = { onFontSizeChange(sz) },
+ )
+ }
}
- FilledTonalButton(
- onClick = { showFontDialog = true },
- modifier = Modifier.weight(1f)
+ }
+
+ // ── Color theme ────────────────────────────────────
+ val themeIdx = themes.indexOf(colorTheme).coerceAtLeast(0)
+ val themeListState = rememberLazyListState(themeIdx)
+ QuickSettingsRow(label = "Color theme", value = prettyName(colorTheme)) {
+ LazyRow(
+ state = themeListState,
+ horizontalArrangement = Arrangement.spacedBy(8.dp),
+ contentPadding = PaddingValues(horizontal = 4.dp),
+ modifier = Modifier.fadingEdges(themeListState),
) {
- Text("Font")
+ items(themes.size) { i ->
+ val t = themes[i]
+ QuickChip(
+ label = prettyName(t),
+ selected = t == colorTheme,
+ onClick = { onColorThemeChange(t) },
+ )
+ }
+ }
+ }
+
+ // ── Font family ────────────────────────────────────
+ val fontIdx = fonts.indexOf(terminalFont).coerceAtLeast(0)
+ val fontListState = rememberLazyListState(fontIdx)
+ QuickSettingsRow(label = "Font family", value = prettyName(terminalFont)) {
+ LazyRow(
+ state = fontListState,
+ horizontalArrangement = Arrangement.spacedBy(8.dp),
+ contentPadding = PaddingValues(horizontal = 4.dp),
+ modifier = Modifier.fadingEdges(fontListState),
+ ) {
+ items(fonts.size) { i ->
+ val f = fonts[i]
+ QuickChip(
+ label = prettyName(f),
+ selected = f == terminalFont,
+ onClick = { onFontChange(f) },
+ )
+ }
}
}
-
- Spacer(modifier = Modifier.height(16.dp))
-
+
+ HorizontalDivider()
+
+ // ── Switches ───────────────────────────────────────
Row(
modifier = Modifier.fillMaxWidth(),
- verticalAlignment = Alignment.CenterVertically
+ verticalAlignment = Alignment.CenterVertically,
) {
- Text("Show extra keys", modifier = Modifier.weight(1f))
- androidx.compose.material3.Switch(
- checked = showExtraKeys,
- onCheckedChange = onToggleExtraKeys
- )
+ Text("Show extra keys", style = MaterialTheme.typography.bodyMedium, modifier = Modifier.weight(1f))
+ Switch(checked = showExtraKeys, onCheckedChange = onToggleExtraKeys)
}
Row(
modifier = Modifier.fillMaxWidth(),
- verticalAlignment = Alignment.CenterVertically
+ verticalAlignment = Alignment.CenterVertically,
) {
- Text("Haptic feedback", modifier = Modifier.weight(1f))
- androidx.compose.material3.Switch(
- checked = hapticsEnabled,
- onCheckedChange = onToggleHaptics
- )
+ Text("Haptic feedback", style = MaterialTheme.typography.bodyMedium, modifier = Modifier.weight(1f))
+ Switch(checked = hapticsEnabled, onCheckedChange = onToggleHaptics)
}
}
+ }
},
confirmButton = {
TextButton(onClick = onDismiss) {
@@ -519,6 +562,142 @@ private fun QuickSettingsDialog(
)
}
+@Composable
+private fun QuickSettingsRow(
+ label: String,
+ value: String,
+ content: @Composable () -> Unit,
+) {
+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.Bottom,
+ ) {
+ Text(
+ label,
+ style = MaterialTheme.typography.labelLarge,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ Text(
+ value,
+ style = MaterialTheme.typography.labelMedium,
+ color = MaterialTheme.colorScheme.primary,
+ fontWeight = FontWeight.SemiBold,
+ )
+ }
+ content()
+ }
+}
+
+@Composable
+private fun QuickChip(
+ label: String,
+ selected: Boolean,
+ onClick: () -> Unit,
+) {
+ FilterChip(
+ selected = selected,
+ onClick = onClick,
+ label = {
+ Text(
+ label,
+ style = MaterialTheme.typography.labelLarge,
+ fontWeight = if (selected) FontWeight.Bold else FontWeight.Normal,
+ )
+ },
+ shape = RoundedCornerShape(14.dp),
+ colors = FilterChipDefaults.filterChipColors(
+ selectedContainerColor = MaterialTheme.colorScheme.primaryContainer,
+ selectedLabelColor = MaterialTheme.colorScheme.onPrimaryContainer,
+ ),
+ )
+}
+
+/** "monokai-bright" → "Monokai bright"; trims `.properties`/`.ttf` if present. */
+private fun prettyName(raw: String): String =
+ raw.substringBeforeLast('.')
+ .replace('-', ' ')
+ .replace('_', ' ')
+ .replaceFirstChar { it.uppercaseChar() }
+
+/**
+ * Horizontal gradient fade at the edges of a scrollable container, drawn only
+ * on the side(s) where more content exists. Uses an offscreen layer + DstIn
+ * blend so the fade actually masks the chips rather than overpainting them.
+ */
+private fun Modifier.fadingEdges(
+ state: androidx.compose.foundation.lazy.LazyListState,
+ fadeWidth: Dp = 28.dp,
+): Modifier = this
+ .graphicsLayer { compositingStrategy = CompositingStrategy.Offscreen }
+ .drawWithContent {
+ drawContent()
+ val fadePx = fadeWidth.toPx()
+ if (state.canScrollBackward) {
+ drawRect(
+ topLeft = Offset.Zero,
+ size = Size(fadePx, size.height),
+ brush = Brush.horizontalGradient(
+ listOf(Color.Transparent, Color.Black),
+ startX = 0f,
+ endX = fadePx,
+ ),
+ blendMode = BlendMode.DstIn,
+ )
+ }
+ if (state.canScrollForward) {
+ drawRect(
+ topLeft = Offset(size.width - fadePx, 0f),
+ size = Size(fadePx, size.height),
+ brush = Brush.horizontalGradient(
+ listOf(Color.Black, Color.Transparent),
+ startX = size.width - fadePx,
+ endX = size.width,
+ ),
+ blendMode = BlendMode.DstIn,
+ )
+ }
+ }
+
+/**
+ * Thin scrollbar drawn on the LEFT edge of the container. Track is always
+ * visible (so users see "scrollable area"), thumb only appears when the
+ * content actually overflows. The thumb size is proportional to viewport /
+ * total content; its Y offset reflects current scroll position.
+ */
+private fun Modifier.verticalScrollbar(
+ state: androidx.compose.foundation.ScrollState,
+ width: Dp = 3.dp,
+ thumbColor: Color,
+ trackColor: Color,
+ minThumbHeight: Dp = 32.dp,
+): Modifier = this.drawWithContent {
+ drawContent()
+ val maxValue = state.maxValue
+ if (maxValue <= 0) return@drawWithContent
+
+ val widthPx = width.toPx()
+ val viewportH = size.height
+ val totalH = viewportH + maxValue
+ val thumbH = (viewportH * viewportH / totalH).coerceAtLeast(minThumbHeight.toPx())
+ val thumbY = (state.value.toFloat() / maxValue) * (viewportH - thumbH)
+ val cornerPx = widthPx / 2f
+
+ drawRoundRect(
+ color = trackColor,
+ topLeft = Offset(0f, 0f),
+ size = Size(widthPx, viewportH),
+ cornerRadius = androidx.compose.ui.geometry.CornerRadius(cornerPx, cornerPx),
+ )
+ drawRoundRect(
+ color = thumbColor,
+ topLeft = Offset(0f, thumbY),
+ size = Size(widthPx, thumbH),
+ cornerRadius = androidx.compose.ui.geometry.CornerRadius(cornerPx, cornerPx),
+ )
+}
+
@Composable
private fun ThemeSelectionDialog(
currentTheme: String,