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.material.icons.filled.SystemUpdate
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
|
|
@ -446,58 +447,88 @@ internal fun SettingsScreen(
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
|
||||||
when (val s = updateState.status) {
|
when (val s = updateState.status) {
|
||||||
is UpdateStatus.Available -> TextButton(
|
is UpdateStatus.Checking -> {
|
||||||
onClick = updateViewModel::startDownload
|
OutlinedButton(
|
||||||
) {
|
onClick = {},
|
||||||
Text(
|
enabled = false,
|
||||||
text = "Update ${s.versionName}.${s.versionCode} verfügbar – jetzt installieren",
|
modifier = Modifier.fillMaxWidth()
|
||||||
style = MaterialTheme.typography.bodySmall,
|
) {
|
||||||
color = MaterialTheme.colorScheme.primary
|
CircularProgressIndicator(modifier = Modifier.size(18.dp), strokeWidth = 2.dp)
|
||||||
)
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
|
Text("Suche nach Updates…")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is UpdateStatus.Checking -> Row(
|
is UpdateStatus.Available -> {
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
Button(
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
onClick = updateViewModel::startDownload,
|
||||||
) {
|
modifier = Modifier.fillMaxWidth(),
|
||||||
CircularProgressIndicator(modifier = Modifier.size(16.dp), strokeWidth = 2.dp)
|
colors = ButtonDefaults.buttonColors(
|
||||||
Text("Suche nach Updates…", style = MaterialTheme.typography.bodySmall)
|
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 {
|
is UpdateStatus.Downloading -> {
|
||||||
Text("Lädt herunter…", style = MaterialTheme.typography.bodySmall)
|
OutlinedButton(
|
||||||
|
onClick = {},
|
||||||
|
enabled = false,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
Text("Lädt herunter…")
|
||||||
|
}
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
LinearProgressIndicator(
|
LinearProgressIndicator(
|
||||||
progress = { s.progress },
|
progress = { s.progress },
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is UpdateStatus.ReadyToInstall -> Text(
|
is UpdateStatus.ReadyToInstall -> {
|
||||||
text = "${s.versionName}.${s.versionCode} bereit zur Installation",
|
Button(
|
||||||
style = MaterialTheme.typography.bodySmall,
|
onClick = {},
|
||||||
color = MaterialTheme.colorScheme.primary
|
enabled = false,
|
||||||
)
|
modifier = Modifier.fillMaxWidth(),
|
||||||
is UpdateStatus.Error -> Text(
|
colors = ButtonDefaults.buttonColors(
|
||||||
text = s.message,
|
containerColor = MaterialTheme.colorScheme.primary
|
||||||
style = MaterialTheme.typography.bodySmall,
|
)
|
||||||
color = MaterialTheme.colorScheme.error
|
) {
|
||||||
)
|
Text("${s.versionName}.${s.versionCode} wird installiert…")
|
||||||
is UpdateStatus.Hidden -> {}
|
}
|
||||||
}
|
}
|
||||||
|
is UpdateStatus.Error -> {
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Text(
|
||||||
|
text = s.message,
|
||||||
OutlinedButton(
|
style = MaterialTheme.typography.bodySmall,
|
||||||
onClick = updateViewModel::checkForUpdate,
|
color = MaterialTheme.colorScheme.error
|
||||||
enabled = updateState.status !is UpdateStatus.Checking &&
|
)
|
||||||
updateState.status !is UpdateStatus.Downloading,
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
modifier = Modifier.fillMaxWidth()
|
OutlinedButton(
|
||||||
) {
|
onClick = updateViewModel::checkForUpdate,
|
||||||
Icon(
|
modifier = Modifier.fillMaxWidth()
|
||||||
imageVector = Icons.Default.SystemUpdate,
|
) {
|
||||||
contentDescription = null,
|
Text("Erneut prüfen")
|
||||||
modifier = Modifier.size(18.dp)
|
}
|
||||||
)
|
}
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
is UpdateStatus.Hidden -> {
|
||||||
Text("Auf Updates prüfen")
|
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))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue