-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/main'
Conflicts: planner/ContentView.swift
- Loading branch information
Showing
12 changed files
with
233 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Binary file added
BIN
+41.9 KB
...codeproj/project.xcworkspace/xcuserdata/martin.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
planner.xcodeproj/xcuserdata/martin.xcuserdatad/xcschemes/xcschememanagement.plist
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>planner.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
<key>SuppressBuildableAutocreation</key> | ||
<dict> | ||
<key>5B2630DD2BCEC521002E200D</key> | ||
<dict> | ||
<key>primary</key> | ||
<true/> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
Binary file not shown.
Binary file not shown.
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// TodoItem.swift | ||
// planner | ||
// | ||
// Created by martin on 2024/04/22. | ||
// | ||
|
||
import Foundation | ||
struct TodoItem: Identifiable, Hashable { | ||
var id = UUID() | ||
var title: String | ||
var isCompleted: Bool | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// TodoViewModel.swift | ||
// planner | ||
// | ||
// Created by martin on 2024/04/22. | ||
// | ||
|
||
import Foundation | ||
class TodoViewModel: ObservableObject { | ||
@Published var items: [TodoItem] = [ | ||
TodoItem(title: "청소하기", isCompleted: false), | ||
TodoItem(title: "쇼핑하기", isCompleted: false) | ||
] | ||
@Published var completedItems: [TodoItem] = [] | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// AddView.swift | ||
// planner | ||
// | ||
// Created by martin on 2024/04/22. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct AddView: View { | ||
var body: some View { | ||
Text("새 항목 추가") | ||
} | ||
} | ||
|
||
struct AddView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
AddView() | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// HistoryView.swift | ||
// planner | ||
// | ||
// Created by martin on 2024/04/22. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct HistoryView: View { | ||
@State private var selectedDate = Date() | ||
|
||
var body: some View { | ||
VStack { | ||
Text("날짜 선택: \(selectedDate, formatter: dateFormatter)") | ||
.padding() | ||
|
||
DatePicker( | ||
"날짜 선택", | ||
selection: $selectedDate, | ||
displayedComponents: .date | ||
) | ||
.datePickerStyle(GraphicalDatePickerStyle()) | ||
.padding() | ||
} | ||
} | ||
} | ||
|
||
extension HistoryView { | ||
private var dateFormatter: DateFormatter { | ||
let formatter = DateFormatter() | ||
formatter.dateStyle = .long | ||
return formatter | ||
} | ||
} | ||
|
||
struct HistoryView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
HistoryView() | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// TodoList.swift | ||
// planner | ||
// | ||
// Created by martin on 2024/04/22. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct TodoView: View { | ||
@ObservedObject var viewModel = TodoViewModel() | ||
|
||
var body: some View { | ||
VStack { | ||
List { | ||
ForEach(viewModel.items) { item in | ||
HStack { | ||
Button(action: { | ||
completeItem(item) | ||
}) { | ||
Image(systemName: item.isCompleted ? "checkmark.circle.fill" : "circle") | ||
} | ||
Text(item.title) | ||
} | ||
} | ||
} | ||
|
||
Divider() | ||
|
||
List { | ||
ForEach(viewModel.completedItems) { item in | ||
HStack { | ||
Button(action: { | ||
uncompleteItem(item) | ||
}) { | ||
Image(systemName: "circle") | ||
} | ||
Text(item.title).strikethrough() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func completeItem(_ item: TodoItem) { | ||
if let index = viewModel.items.firstIndex(of: item) { | ||
var newItem = item | ||
newItem.isCompleted = true | ||
viewModel.items.remove(at: index) | ||
viewModel.completedItems.append(newItem) | ||
} | ||
} | ||
|
||
func uncompleteItem(_ item: TodoItem) { | ||
if let index = viewModel.completedItems.firstIndex(of: item) { | ||
var newItem = item | ||
newItem.isCompleted = false | ||
viewModel.completedItems.remove(at: index) | ||
viewModel.items.append(newItem) | ||
} | ||
} | ||
} | ||
|
||
struct TodoView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
TodoView() | ||
} | ||
} |