I’m studying some swiftui in my free time and I’m presently creating a Todo app simply to study and I’ve an issue that I can’t remedy, I believe will probably be really easy to unravel however I have no idea how.
That is what the Preview exhibits
I simply must delete the white background, that is my code:
VStack {
Listing {
ForEach(taskManager.duties) { job in
TodoItem(todoTask: job, removeTodoTask: { taskToRemove in
taskManager.removeTask(taskToRemove)
})
.listRowBackground(Shade.clear)
}
if isAddingTask {
AddTaskView(newTask: $newTask, taskDate: $taskDate, taskManager: taskManager, scheduleNotification: scheduleNotification, isAddingTask: $isAddingTask)
}
}
.scrollContentBackground(.hidden)
.listStyle(.plain)
.padding(.prime, 16)
.padding(.main, 8)
Spacer()
AddTodoTaskButton(isAddingTask: $isAddingTask)
}
.body(maxWidth: .infinity, maxHeight: .infinity)
.background(Shade.backgroundApp
And that is the struct
struct AddTaskView: View {
@Binding var newTask: String
@Binding var taskDate: Date
var taskManager: TaskManager
var scheduleNotification: (String, Date) -> Void
@Binding var isAddingTask: Bool
var physique: some View {
VStack {
HStack {
TextField("", textual content: $newTask, immediate: Textual content("Write new Todo")
.foregroundColor(.grey) // Texto de placeholder más suave
)
.foregroundColor(.white) // Shade del texto introducido
.padding()
.background(Shade.black.opacity(0.8)) // Fondo del TextField más oscuro
.cornerRadius(10) // Bordes redondeados para un look más moderno
Button(motion: {
taskManager.addTask(title: newTask, date: taskDate) // Usar addTask del TaskManager
scheduleNotification(newTask, taskDate) // Programar notificación
newTask = "" // Limpiar el campo de texto
isAddingTask = false // Ocultar el formulario
}) {
Picture(systemName: "checkmark.circle.fill")
.foregroundColor(Shade.black.opacity(0.8))
.font(.title)
}
.padding(.main, 8)
}
.padding(.vertical, 8)
// Personalizar la apariencia del DatePicker
DatePicker("Date & Time", choice: $taskDate, displayedComponents: [.date, .hourAndMinute])
.datePickerStyle(CompactDatePickerStyle())
.cornerRadius(10)
.accentColor(.grey) // Shade del selector
.foregroundColor(.grey) // Shade del texto de la etiqueta
}
}
}