-
Notifications
You must be signed in to change notification settings - Fork 0
[#273] TodoEditorView에서 마감일이 있을 때의 ui/ux를 개선한다 #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,7 @@ struct TodoEditorView: View { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Environment(\.dismiss) private var dismiss | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @FocusState private var field: Field? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @State private var showDueDatePicker: Bool = false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private let calendar = Calendar.current | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var onSubmit: ((Todo) -> Void)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var body: some View { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -175,30 +176,30 @@ struct TodoEditorView: View { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .adaptiveButtonStyle() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DueDatePicker(selection: Binding( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| get: { viewModel.state.dueDate ?? Date() }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set: { viewModel.send(.setDueDate($0)) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HStack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Label { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Text("마감일") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } icon: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Image(systemName: "calendar") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .foregroundStyle(.gray) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dueDateControl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private var dueDateControl: some View { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DueDatePicker(selection: Binding( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| get: { viewModel.state.dueDate ?? Date() }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set: { viewModel.send(.setDueDate($0)) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Label { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if let dueDate = viewModel.state.dueDate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Tag(dueDateText(for: dueDate), isEditing: true) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| viewModel.send(.setDueDate(nil)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Image(systemName: "checkmark.square") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .symbolRenderingMode(.palette) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .foregroundStyle( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| viewModel.state.hasDueDate ? .blue : .clear, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .gray | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .onTapGesture { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| viewModel.send(.setDueDate(viewModel.state.hasDueDate ? nil : Date())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .padding(.vertical, -4) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Text("마감일") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .adaptiveButtonStyle() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } icon: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Image(systemName: "calendar") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .foregroundStyle(.gray) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .adaptiveButtonStyle() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private func submit() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -210,6 +211,21 @@ struct TodoEditorView: View { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private enum Field: Hashable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case title, description, tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private func dueDateText(for dueDate: Date) -> String { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let currentYear = calendar.component(.year, from: Date()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let dueDateYear = calendar.component(.year, from: dueDate) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if currentYear == dueDateYear { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return dueDate.formatted( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .dateTime.month(.defaultDigits).day(.defaultDigits) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return dueDate.formatted( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .dateTime.year(.twoDigits).month(.defaultDigits).day(.defaultDigits) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+215
to
+228
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private struct TagEditor<Content: View>: View { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.toggleDueDate액션이TodoEditorView에서 사용되지 않는 것으로 보입니다. 이 PR에서 변경된 UI에서는 마감일 설정/해제를 위해.setDueDate액션을 사용하고 있습니다. 만약 다른 곳에서도.toggleDueDate를 사용하지 않는다면, 코드 명확성과 유지보수성 향상을 위해Actionenum에서 해당 케이스와reduce함수의 관련 로직을 제거하는 것을 고려해 보세요.