Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main'
Browse files Browse the repository at this point in the history
Conflicts:
	planner/ContentView.swift
  • Loading branch information
SuhJaeHyeon committed Apr 22, 2024
2 parents 9d77957 + 5b04761 commit 751a71d
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 6 deletions.
Binary file added .DS_Store
Binary file not shown.
36 changes: 36 additions & 0 deletions planner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
5B35C23B2BCEC70C009885EC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5B35C2362BCEC70B009885EC /* Assets.xcassets */; };
5B35C23C2BCEC70C009885EC /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5B35C2382BCEC70B009885EC /* Preview Assets.xcassets */; };
5B35C23D2BCEC70C009885EC /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B35C2392BCEC70B009885EC /* ContentView.swift */; };
5B35C2402BD6A81A009885EC /* TodoItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B35C23F2BD6A81A009885EC /* TodoItem.swift */; };
5B35C2422BD6A82B009885EC /* TodoViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B35C2412BD6A82B009885EC /* TodoViewModel.swift */; };
5B35C2452BD6A860009885EC /* TodoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B35C2442BD6A860009885EC /* TodoView.swift */; };
5B35C2472BD6A8CC009885EC /* AddView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B35C2462BD6A8CC009885EC /* AddView.swift */; };
5B35C2492BD6A8E8009885EC /* HistoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B35C2482BD6A8E8009885EC /* HistoryView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -19,6 +24,11 @@
5B35C2362BCEC70B009885EC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
5B35C2382BCEC70B009885EC /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
5B35C2392BCEC70B009885EC /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
5B35C23F2BD6A81A009885EC /* TodoItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoItem.swift; sourceTree = "<group>"; };
5B35C2412BD6A82B009885EC /* TodoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoViewModel.swift; sourceTree = "<group>"; };
5B35C2442BD6A860009885EC /* TodoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoView.swift; sourceTree = "<group>"; };
5B35C2462BD6A8CC009885EC /* AddView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddView.swift; sourceTree = "<group>"; };
5B35C2482BD6A8E8009885EC /* HistoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -51,6 +61,8 @@
5B35C2342BCEC70B009885EC /* planner */ = {
isa = PBXGroup;
children = (
5B35C2432BD6A84D009885EC /* View */,
5B35C23E2BD6A7F7009885EC /* Model */,
5B35C2352BCEC70B009885EC /* plannerApp.swift */,
5B35C2392BCEC70B009885EC /* ContentView.swift */,
5B35C2362BCEC70B009885EC /* Assets.xcassets */,
Expand All @@ -67,6 +79,25 @@
path = "Preview Content";
sourceTree = "<group>";
};
5B35C23E2BD6A7F7009885EC /* Model */ = {
isa = PBXGroup;
children = (
5B35C23F2BD6A81A009885EC /* TodoItem.swift */,
5B35C2412BD6A82B009885EC /* TodoViewModel.swift */,
);
path = Model;
sourceTree = "<group>";
};
5B35C2432BD6A84D009885EC /* View */ = {
isa = PBXGroup;
children = (
5B35C2442BD6A860009885EC /* TodoView.swift */,
5B35C2462BD6A8CC009885EC /* AddView.swift */,
5B35C2482BD6A8E8009885EC /* HistoryView.swift */,
);
path = View;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -137,7 +168,12 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5B35C2492BD6A8E8009885EC /* HistoryView.swift in Sources */,
5B35C2452BD6A860009885EC /* TodoView.swift in Sources */,
5B35C2422BD6A82B009885EC /* TodoViewModel.swift in Sources */,
5B35C2472BD6A8CC009885EC /* AddView.swift in Sources */,
5B35C23D2BCEC70C009885EC /* ContentView.swift in Sources */,
5B35C2402BD6A81A009885EC /* TodoItem.swift in Sources */,
5B35C23A2BCEC70C009885EC /* plannerApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Binary file not shown.
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 added planner/.DS_Store
Binary file not shown.
Binary file added planner/Assets.xcassets/.DS_Store
Binary file not shown.
24 changes: 18 additions & 6 deletions planner/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,25 @@ import SwiftUI

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, martin!")
TabView {
TodoView()
.tabItem {
Image(systemName: "list.bullet")
Text("할 일")
}

AddView()
.tabItem {
Image(systemName: "plus.circle")
Text("추가")
}

HistoryView()
.tabItem {
Image(systemName: "clock.arrow.circlepath")
Text("기록")
}
}
.padding()
}
}

Expand Down
13 changes: 13 additions & 0 deletions planner/Model/TodoItem.swift
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
}
15 changes: 15 additions & 0 deletions planner/Model/TodoViewModel.swift
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] = []
}
20 changes: 20 additions & 0 deletions planner/View/AddView.swift
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()
}
}
41 changes: 41 additions & 0 deletions planner/View/HistoryView.swift
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()
}
}
68 changes: 68 additions & 0 deletions planner/View/TodoView.swift
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()
}
}

0 comments on commit 751a71d

Please sign in to comment.