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
+22
-5
No files matched your search
@@ -272,7 +272,8 @@ fun PlaylistDetailScreen(
|
|||||||
|
|
||||||
// ── Rename dialog ─────────────────────────────────────────────────────────
|
// ── Rename dialog ─────────────────────────────────────────────────────────
|
||||||
if (showRenameDialog) {
|
if (showRenameDialog) {
|
||||||
var nameInput by remember { mutableStateOf(pl.name) }
|
var nameInput by remember { mutableStateOf(pl.name) }
|
||||||
|
var commentInput by remember { mutableStateOf(pl.comment ?: "") }
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = { showRenameDialog = false },
|
onDismissRequest = { showRenameDialog = false },
|
||||||
title = { Text("Playlist bearbeiten", fontFamily = Outfit, fontWeight = FontWeight.Bold) },
|
title = { Text("Playlist bearbeiten", fontFamily = Outfit, fontWeight = FontWeight.Bold) },
|
||||||
@@ -283,6 +284,21 @@ fun PlaylistDetailScreen(
|
|||||||
onValueChange = { nameInput = it },
|
onValueChange = { nameInput = it },
|
||||||
label = { Text("Name") },
|
label = { Text("Name") },
|
||||||
singleLine = true,
|
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),
|
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
|
||||||
shape = RoundedCornerShape(12.dp),
|
shape = RoundedCornerShape(12.dp),
|
||||||
colors = OutlinedTextFieldDefaults.colors(
|
colors = OutlinedTextFieldDefaults.colors(
|
||||||
@@ -305,7 +321,7 @@ fun PlaylistDetailScreen(
|
|||||||
},
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = { vm.rename(nameInput); showRenameDialog = false },
|
onClick = { vm.rename(nameInput, commentInput); showRenameDialog = false },
|
||||||
enabled = nameInput.isNotBlank(),
|
enabled = nameInput.isNotBlank(),
|
||||||
) {
|
) {
|
||||||
Text("Speichern", color = NsAccent, fontFamily = Outfit, fontWeight = FontWeight.Bold)
|
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 id = playlistId ?: return
|
||||||
val pl = _state.value.playlist ?: return
|
val pl = _state.value.playlist ?: return
|
||||||
val trimmed = newName.trim()
|
val trimmed = newName.trim()
|
||||||
if (trimmed.isBlank()) return
|
if (trimmed.isBlank()) return
|
||||||
|
val comment = newComment?.trim() ?: pl.comment
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
_state.value = _state.value.copy(isSaving = true)
|
_state.value = _state.value.copy(isSaving = true)
|
||||||
try {
|
try {
|
||||||
repo.updatePlaylistMeta(id, trimmed, pl.comment)
|
repo.updatePlaylistMeta(id, trimmed, comment)
|
||||||
_state.value = _state.value.copy(
|
_state.value = _state.value.copy(
|
||||||
playlist = pl.copy(name = trimmed),
|
playlist = pl.copy(name = trimmed, comment = comment),
|
||||||
isSaving = false,
|
isSaving = false,
|
||||||
)
|
)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|||||||
Reference in new issue
Block a user