feat(android): add description field to playlist edit dialog
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
43cf11465e
commit
93c5fb481d
2 files changed
+21
-4
No files matched your search
@@ -273,6 +273,7 @@ fun PlaylistDetailScreen(
|
||||
// ── Rename dialog ─────────────────────────────────────────────────────────
|
||||
if (showRenameDialog) {
|
||||
var nameInput by remember { mutableStateOf(pl.name) }
|
||||
var commentInput by remember { mutableStateOf(pl.comment ?: "") }
|
||||
AlertDialog(
|
||||
onDismissRequest = { showRenameDialog = false },
|
||||
title = { Text("Playlist bearbeiten", fontFamily = Outfit, fontWeight = FontWeight.Bold) },
|
||||
@@ -283,6 +284,21 @@ fun PlaylistDetailScreen(
|
||||
onValueChange = { nameInput = it },
|
||||
label = { Text("Name") },
|
||||
singleLine = true,
|
||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors = OutlinedTextFieldDefaults.colors(
|
||||
focusedBorderColor = NsAccent,
|
||||
unfocusedBorderColor = NsOnSurface3,
|
||||
cursorColor = NsAccent,
|
||||
),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = commentInput,
|
||||
onValueChange = { commentInput = it },
|
||||
label = { Text("Beschreibung") },
|
||||
minLines = 2,
|
||||
maxLines = 4,
|
||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors = OutlinedTextFieldDefaults.colors(
|
||||
@@ -305,7 +321,7 @@ fun PlaylistDetailScreen(
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = { vm.rename(nameInput); showRenameDialog = false },
|
||||
onClick = { vm.rename(nameInput, commentInput); showRenameDialog = false },
|
||||
enabled = nameInput.isNotBlank(),
|
||||
) {
|
||||
Text("Speichern", color = NsAccent, fontFamily = Outfit, fontWeight = FontWeight.Bold)
|
||||
|
||||
@@ -45,17 +45,18 @@ class PlaylistViewModel(app: Application, savedState: SavedStateHandle) : Androi
|
||||
}
|
||||
}
|
||||
|
||||
fun rename(newName: String) {
|
||||
fun rename(newName: String, newComment: String? = null) {
|
||||
val id = playlistId ?: return
|
||||
val pl = _state.value.playlist ?: return
|
||||
val trimmed = newName.trim()
|
||||
if (trimmed.isBlank()) return
|
||||
val comment = newComment?.trim() ?: pl.comment
|
||||
viewModelScope.launch {
|
||||
_state.value = _state.value.copy(isSaving = true)
|
||||
try {
|
||||
repo.updatePlaylistMeta(id, trimmed, pl.comment)
|
||||
repo.updatePlaylistMeta(id, trimmed, comment)
|
||||
_state.value = _state.value.copy(
|
||||
playlist = pl.copy(name = trimmed),
|
||||
playlist = pl.copy(name = trimmed, comment = comment),
|
||||
isSaving = false,
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
|
||||
Reference in new issue
Block a user