refactor(ui): Update-Status-Anzeige in Settings überarbeiten
- Einzelne Buttons pro Status statt gemeinsamer 'Auf Updates prüfen'-Button - Available-Status als prominenter Button mit Icon - Checking/Downloading als disabled OutlinedButton - Error-Status mit 'Erneut prüfen'-Button - Hidden-Status zeigt den Check-Button
This commit is contained in:
parent
ddf9272dda
commit
1492fa879b
1 changed files with 75 additions and 44 deletions
|
|
@ -26,6 +26,7 @@ import androidx.compose.material.icons.Icons
|
|||
import androidx.compose.material.icons.filled.SystemUpdate
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.CardDefaults
|
||||
|
|
@ -446,58 +447,88 @@ internal fun SettingsScreen(
|
|||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
when (val s = updateState.status) {
|
||||
is UpdateStatus.Available -> TextButton(
|
||||
onClick = updateViewModel::startDownload
|
||||
) {
|
||||
Text(
|
||||
text = "Update ${s.versionName}.${s.versionCode} verfügbar – jetzt installieren",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
is UpdateStatus.Checking -> {
|
||||
OutlinedButton(
|
||||
onClick = {},
|
||||
enabled = false,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
CircularProgressIndicator(modifier = Modifier.size(18.dp), strokeWidth = 2.dp)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text("Suche nach Updates…")
|
||||
}
|
||||
}
|
||||
is UpdateStatus.Checking -> Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
CircularProgressIndicator(modifier = Modifier.size(16.dp), strokeWidth = 2.dp)
|
||||
Text("Suche nach Updates…", style = MaterialTheme.typography.bodySmall)
|
||||
is UpdateStatus.Available -> {
|
||||
Button(
|
||||
onClick = updateViewModel::startDownload,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.SystemUpdate,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(18.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text("Update durchführen (${s.versionName}.${s.versionCode})")
|
||||
}
|
||||
}
|
||||
is UpdateStatus.Downloading -> Column {
|
||||
Text("Lädt herunter…", style = MaterialTheme.typography.bodySmall)
|
||||
is UpdateStatus.Downloading -> {
|
||||
OutlinedButton(
|
||||
onClick = {},
|
||||
enabled = false,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text("Lädt herunter…")
|
||||
}
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
LinearProgressIndicator(
|
||||
progress = { s.progress },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
is UpdateStatus.ReadyToInstall -> Text(
|
||||
text = "${s.versionName}.${s.versionCode} bereit zur Installation",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
is UpdateStatus.Error -> Text(
|
||||
text = s.message,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error
|
||||
)
|
||||
is UpdateStatus.Hidden -> {}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
OutlinedButton(
|
||||
onClick = updateViewModel::checkForUpdate,
|
||||
enabled = updateState.status !is UpdateStatus.Checking &&
|
||||
updateState.status !is UpdateStatus.Downloading,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.SystemUpdate,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(18.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text("Auf Updates prüfen")
|
||||
is UpdateStatus.ReadyToInstall -> {
|
||||
Button(
|
||||
onClick = {},
|
||||
enabled = false,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
) {
|
||||
Text("${s.versionName}.${s.versionCode} wird installiert…")
|
||||
}
|
||||
}
|
||||
is UpdateStatus.Error -> {
|
||||
Text(
|
||||
text = s.message,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
OutlinedButton(
|
||||
onClick = updateViewModel::checkForUpdate,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text("Erneut prüfen")
|
||||
}
|
||||
}
|
||||
is UpdateStatus.Hidden -> {
|
||||
OutlinedButton(
|
||||
onClick = updateViewModel::checkForUpdate,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.SystemUpdate,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(18.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text("Auf Updates prüfen")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
|
|
|||
Loading…
Reference in a new issue