diff --git a/App/Sources/Views/NewTaskView.swift b/App/Sources/Views/NewTaskView.swift index e5485de..b2a08e8 100644 --- a/App/Sources/Views/NewTaskView.swift +++ b/App/Sources/Views/NewTaskView.swift @@ -21,6 +21,10 @@ struct NewTaskView: View { /// SwiftData model context for saving todo tasks. @Environment(\.modelContext) private var modelContext + + /// Tracks which text field currently has keyboard focus. + @FocusState + private var inputFocus: InputFieldFocus? /// The view model managing the state and logic for this view. @State @@ -53,20 +57,33 @@ struct NewTaskView: View { text: $viewModel.title, axis: .vertical ) - .autocapitalization(.sentences) - .autocorrectionDisabled(false) - .keyboardType(.asciiCapable) + .focused( + $inputFocus, + equals: .title + ) + .onNewlineFocus( + $viewModel.title, + to: .note, + on: $inputFocus + ) TextField( "view.new-task.placeholder.note", text: $viewModel.note, axis: .vertical ) - .autocapitalization(.sentences) - .autocorrectionDisabled(false) - .keyboardType(.asciiCapable) - .lineLimit(3 ... 6) + .focused( + $inputFocus, + equals: .note + ) + .onEmptyNewlineResignFocus( + text: $viewModel.note, + from: $inputFocus + ) } + .autocapitalization(.sentences) + .autocorrectionDisabled(false) + .keyboardType(.default) Section("view.new-task.section.due-date") { DatePicker(