UPD: Modern Design of AddNoteDialog
This commit is contained in:
parent
03f1a55437
commit
37be605c46
@ -1,14 +1,14 @@
|
||||
package come.stormborntales.notevault.ui.screens
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
@ -18,56 +18,28 @@ fun AddNoteDialog(
|
||||
) {
|
||||
var title by remember { mutableStateOf("") }
|
||||
var composer by remember { mutableStateOf("") }
|
||||
var year by remember { mutableStateOf("") }
|
||||
var yearText by remember { mutableStateOf("") }
|
||||
var genre by remember { mutableStateOf("") }
|
||||
var description by remember { mutableStateOf("") }
|
||||
var showTitleError by remember { mutableStateOf(false) }
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
title = { Text("Notenblatt hinzufügen") },
|
||||
text = {
|
||||
Column {
|
||||
OutlinedTextField(
|
||||
value = title,
|
||||
onValueChange = { title = it },
|
||||
label = { Text("Titel*") },
|
||||
singleLine = true
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = composer,
|
||||
onValueChange = { composer = it },
|
||||
label = { Text("Komponist") },
|
||||
singleLine = true
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = year,
|
||||
onValueChange = { year = it },
|
||||
label = { Text("Erscheinungsjahr") },
|
||||
singleLine = true
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = genre,
|
||||
onValueChange = { genre = it },
|
||||
label = { Text("Genre") },
|
||||
singleLine = true
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = description,
|
||||
onValueChange = { description = it },
|
||||
label = { Text("Beschreibung") },
|
||||
modifier = Modifier.height(100.dp)
|
||||
)
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
if (title.isNotBlank()) {
|
||||
val parsedYear = year.toIntOrNull()
|
||||
onSave(title, composer.ifBlank { null }, parsedYear, genre.ifBlank { null }, description.ifBlank { null })
|
||||
}
|
||||
TextButton(onClick = {
|
||||
if (title.isBlank()) {
|
||||
showTitleError = true
|
||||
} else {
|
||||
val year = yearText.toIntOrNull()
|
||||
onSave(
|
||||
title.trim(),
|
||||
composer.takeIf { it.isNotBlank() },
|
||||
year,
|
||||
genre.takeIf { it.isNotBlank() },
|
||||
description.takeIf { it.isNotBlank() }
|
||||
)
|
||||
}
|
||||
) {
|
||||
}) {
|
||||
Text("Speichern")
|
||||
}
|
||||
},
|
||||
@ -75,6 +47,74 @@ fun AddNoteDialog(
|
||||
TextButton(onClick = onDismiss) {
|
||||
Text("Abbrechen")
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text("Notenblatt hinzufügen", style = MaterialTheme.typography.titleLarge)
|
||||
},
|
||||
text = {
|
||||
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
|
||||
OutlinedTextField(
|
||||
value = title,
|
||||
onValueChange = {
|
||||
title = it
|
||||
if (it.isNotBlank()) showTitleError = false
|
||||
},
|
||||
label = { Text("Titel*") },
|
||||
isError = showTitleError,
|
||||
singleLine = true,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp)
|
||||
)
|
||||
if (showTitleError) {
|
||||
Text(
|
||||
"Titel darf nicht leer sein",
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.padding(start = 16.dp, bottom = 4.dp)
|
||||
)
|
||||
}
|
||||
|
||||
OutlinedTextField(
|
||||
value = composer,
|
||||
onValueChange = { composer = it },
|
||||
label = { Text("Komponist (optional)") },
|
||||
singleLine = true,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp)
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
value = yearText,
|
||||
onValueChange = { yearText = it.filter { c -> c.isDigit() } },
|
||||
label = { Text("Erscheinungsjahr (optional)") },
|
||||
singleLine = true,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp)
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
value = genre,
|
||||
onValueChange = { genre = it },
|
||||
label = { Text("Genre (optional)") },
|
||||
singleLine = true,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp)
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
value = description,
|
||||
onValueChange = { description = it },
|
||||
label = { Text("Beschreibung (optional)") },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp),
|
||||
maxLines = 4
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user