From cf9fa6cf8be63d2d4bcbf78fed7fa709ee0e180f Mon Sep 17 00:00:00 2001 From: IsabellaSulisufi <114592322+IsabellaSulisufi@users.noreply.github.com> Date: Fri, 3 Jan 2025 14:58:26 +0000 Subject: [PATCH 1/3] Design all tasks page and improve code reusability --- TaskManager.xcodeproj/project.pbxproj | 4 + TaskManager/TaskManagerApp.swift | 8 +- TaskManager/Views/AboutPageView.swift | 28 ++---- TaskManager/Views/AllTasksView.swift | 92 ++------------------ TaskManager/Views/HomeView.swift | 95 +++----------------- TaskManager/Views/TemplateViews.swift | 121 ++++++++++++++++++++++++++ 6 files changed, 153 insertions(+), 195 deletions(-) create mode 100644 TaskManager/Views/TemplateViews.swift diff --git a/TaskManager.xcodeproj/project.pbxproj b/TaskManager.xcodeproj/project.pbxproj index 808e655..93cd108 100644 --- a/TaskManager.xcodeproj/project.pbxproj +++ b/TaskManager.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ EE00D2BC2C6F8D65004FF048 /* TaskViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE00D2BB2C6F8D65004FF048 /* TaskViewModel.swift */; }; EE019E182C9460C600A8B764 /* TaskModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE019E172C9460C600A8B764 /* TaskModel.swift */; }; + EE0AD8132D282DEF00AEF204 /* TemplateViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE0AD8122D282DEF00AEF204 /* TemplateViews.swift */; }; EE3AE1712CC69970001A80C1 /* Router.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE3AE1702CC69970001A80C1 /* Router.swift */; }; EE4BB9C72B88F49F00FFF4F2 /* TextStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE4BB9C62B88F49F00FFF4F2 /* TextStyles.swift */; }; EE59B6B42C342680003D59DF /* AboutPageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE59B6B32C342680003D59DF /* AboutPageView.swift */; }; @@ -24,6 +25,7 @@ /* Begin PBXFileReference section */ EE00D2BB2C6F8D65004FF048 /* TaskViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskViewModel.swift; sourceTree = ""; }; EE019E172C9460C600A8B764 /* TaskModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskModel.swift; sourceTree = ""; }; + EE0AD8122D282DEF00AEF204 /* TemplateViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateViews.swift; sourceTree = ""; }; EE3AE1702CC69970001A80C1 /* Router.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Router.swift; sourceTree = ""; }; EE4BB9C62B88F49F00FFF4F2 /* TextStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextStyles.swift; sourceTree = ""; }; EE59B6B32C342680003D59DF /* AboutPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutPageView.swift; sourceTree = ""; }; @@ -54,6 +56,7 @@ EE59B6B32C342680003D59DF /* AboutPageView.swift */, EED772142B7BC0C6007BDA4A /* AddTaskView.swift */, EEA7106D2C908CA000785086 /* HomeView.swift */, + EE0AD8122D282DEF00AEF204 /* TemplateViews.swift */, EEFAD1902CD3A7F900018043 /* AllTasksView.swift */, ); path = Views; @@ -195,6 +198,7 @@ EE4BB9C72B88F49F00FFF4F2 /* TextStyles.swift in Sources */, EED772132B7BC0C6007BDA4A /* TaskManagerApp.swift in Sources */, EE996DF12B88E1EE0036470C /* Spacing.swift in Sources */, + EE0AD8132D282DEF00AEF204 /* TemplateViews.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/TaskManager/TaskManagerApp.swift b/TaskManager/TaskManagerApp.swift index 33aa2f4..6525feb 100644 --- a/TaskManager/TaskManagerApp.swift +++ b/TaskManager/TaskManagerApp.swift @@ -11,18 +11,20 @@ import SwiftUI struct TaskManagerApp: App { @ObservedObject var router = Router() var body: some Scene { + let viewModel = TaskViewModel(router: router) WindowGroup { NavigationStack(path: $router.navPath) { HomeView(viewModel: TaskViewModel(router: router)) .navigationDestination(for: Router.Destination.self) { destination in switch destination { case .addTask: - AddTaskView(viewModel: TaskViewModel(router: router)) + AddTaskView(viewModel: viewModel) + case .aboutPage: - AboutPageView(viewModel: TaskViewModel(router: router)) + AboutPageView(viewModel: viewModel) case .allTasks: - AllTasksView(viewModel: TaskViewModel(router: router)) + AllTasksView(viewModel: viewModel) } } } diff --git a/TaskManager/Views/AboutPageView.swift b/TaskManager/Views/AboutPageView.swift index 4ffd76a..bf09627 100644 --- a/TaskManager/Views/AboutPageView.swift +++ b/TaskManager/Views/AboutPageView.swift @@ -12,13 +12,8 @@ struct AboutPageView: View { var body: some View { VStack { - HStack { - Image("LogoImage") - .resizable() - .scaledToFit() - .frame(width: 200, height: 100) - } - .padding(.top) + + LogoImage() Text("This is ToTask!") .modifier(TextStyles.descriptionStyle()) @@ -69,23 +64,10 @@ struct AboutPageView: View { Spacer() // Add Task Button - Button { - viewModel.navigateAddTask() - } label: { - Image(systemName: "plus.circle") - .font(.system(size: Spacing.large, weight: .bold)) - .foregroundColor(Color("DarkestPurple")) - Text("Add Task") - .font(Font.custom("NotoSansOriya", size: Spacing.medium)) - .foregroundColor(Color("DarkestPurple")) - .baselineOffset(-5) - } - .padding(12.0) - .background(Color.cPink) - .cornerRadius(Spacing.medium) + AddTaskButton(action: viewModel.navigateAddTask, title: "Add Task") } - .padding(.horizontal, 20.0) - .padding(.bottom, 20.0) + .padding(.horizontal, Spacing.medium) + .padding(.bottom, Spacing.medium) } .padding(10.0) diff --git a/TaskManager/Views/AllTasksView.swift b/TaskManager/Views/AllTasksView.swift index 98c20d9..675804e 100644 --- a/TaskManager/Views/AllTasksView.swift +++ b/TaskManager/Views/AllTasksView.swift @@ -13,94 +13,18 @@ struct AllTasksView: View { var body: some View { ScrollView { VStack { - // if !task.isComplete { + LogoImage() + TaskCardView(viewModel: viewModel, title: "Task 1", category: .school, description: "This is a task", dueDate: Date()) - // } + .padding(.bottom, Spacing.medium) + + TaskCardView(viewModel: viewModel, title: "Task 2", + category: .work, description: "This is another task", dueDate: Date()) Spacer() } } - .padding(10.0) - .background(Color("Cream")) - } - -} - -struct TaskCardView: View { - @ObservedObject var viewModel: TaskViewModel - let title: String - let category: Category - let description: String? - let dueDate: Date - // var isComplete: Bool - - var body: some View { - HStack { - VStack(alignment: .leading) { - HStack { - Text(title) - .font(.custom("Gill Sans", size: Spacing.medium)) - .foregroundColor(Color("DarkPurple")) - .padding(.bottom, 4) - Spacer() - Text(category.rawValue) - .font(.custom("Gill Sans", size: Spacing.small)) - .foregroundColor(Color("DarkPurple")) - .padding(.horizontal, 16) - .padding(.vertical, 8) - .background(Color("CPink")) - .cornerRadius(25) - } - .padding(.trailing, Spacing.small) - - Text(description ?? "") - .font(.custom("Gill Sans", size: Spacing.standard)) - .foregroundColor(Color("DarkPurple")) - .padding(.bottom, 6.0) - - Text(dueDate.formatted(date: .abbreviated, time: .omitted)) - .font(.custom("Gill Sans", size: 13)) - .foregroundColor(Color("DarkPurple")) - .padding(.bottom, Spacing.small) - - HStack { - // complete button - Button { - viewModel.navigateAddTask() - } label: { - Image(systemName: "checkmark.circle") - .font(.system(size: Spacing.medium, weight: .bold)) - .foregroundColor(Color("CPink")) - Text("Complete?") - .font(.custom("Gill Sans", size: Spacing.standard)) - .foregroundColor(Color("DarkPurple")) - } - Spacer() - - // update button - Button { - viewModel.navigateAddTask() - } label: { - Image(systemName: "pencil.circle") - .font(.system(size: Spacing.medium, weight: .bold)) - .foregroundColor(Color("CPink")) - Text("Update?") - .font(.custom("Gill Sans", size: Spacing.standard)) - .foregroundColor(Color("DarkPurple")) - } - } - .padding([.bottom, .trailing], Spacing.standard) - - } - .padding(.leading, Spacing.standard) - Spacer() - - } - .padding(.top, 10.0) - .background(Color("Cream")) - .overlay( - RoundedRectangle(cornerRadius: Spacing.small) - .stroke(Color("Purple3"), lineWidth: 1) - ) + .padding(Spacing.small) + .background(Color("Rose")) } } diff --git a/TaskManager/Views/HomeView.swift b/TaskManager/Views/HomeView.swift index 5c9951a..dceb260 100644 --- a/TaskManager/Views/HomeView.swift +++ b/TaskManager/Views/HomeView.swift @@ -13,11 +13,7 @@ struct HomeView: View { var body: some View { VStack { - // Logo - Image("LogoImage") - .resizable() - .scaledToFit() - .frame(width: 200, height: 100) + LogoImage() // Welcome Text VStack(alignment: .leading) { @@ -38,72 +34,9 @@ struct HomeView: View { Spacer() // Card - HStack { - VStack(alignment: .leading) { - HStack { - Text(viewModel.task1.title) - .font(.custom("Gill Sans", size: Spacing.medium)) - .foregroundColor(Color("DarkPurple")) - .padding(.bottom, 4) - Spacer() - Text(viewModel.task1.category.rawValue) - .font(.custom("Gill Sans", size: Spacing.small)) - .foregroundColor(Color("DarkPurple")) - .padding(.horizontal, 16) - .padding(.vertical, 8) - .background(Color("CPink")) - .cornerRadius(25) - } - .padding(.trailing, Spacing.small) - - Text(viewModel.task1.description ?? "") - .font(.custom("Gill Sans", size: Spacing.standard)) - .foregroundColor(Color("DarkPurple")) - .padding(.bottom, 6.0) - - Text(viewModel.task1.dueDate.formatted(date: .abbreviated, time: .omitted)) - .font(.custom("Gill Sans", size: 13)) - .foregroundColor(Color("DarkPurple")) - .padding(.bottom, Spacing.small) - - HStack { - Button { - viewModel.navigateAddTask() - } label: { - Image(systemName: "checkmark.circle") - .font(.system(size: Spacing.medium, weight: .bold)) - .foregroundColor(Color("CPink")) - Text("Complete?") - .font(.custom("Gill Sans", size: Spacing.standard)) - .foregroundColor(Color("DarkPurple")) - } - Spacer() - - Button { - viewModel.navigateAddTask() - } label: { - Image(systemName: "pencil.circle") - .font(.system(size: Spacing.medium, weight: .bold)) - .foregroundColor(Color("CPink")) - Text("Update?") - .font(.custom("Gill Sans", size: Spacing.standard)) - .foregroundColor(Color("DarkPurple")) - } - } - .padding([.bottom, .trailing], Spacing.standard) - - } - .padding(.leading, Spacing.standard) - Spacer() - - } - .padding(.top, 10.0) - .background(Color("Cream")) - .overlay( - RoundedRectangle(cornerRadius: Spacing.small) - .stroke(Color("Purple3"), lineWidth: 1) - ) - + TaskCardView(viewModel: viewModel, title: viewModel.task1.title, + category: viewModel.task1.category, description: viewModel.task1.description, + dueDate: viewModel.task1.dueDate) Spacer() // Buttons @@ -121,26 +54,18 @@ struct HomeView: View { Spacer() // Add Task Button - Button { - router.navigate(to: .addTask) - } label: { - Image(systemName: "plus.circle") - .font(.system(size: Spacing.large, weight: .bold)) - .foregroundColor(Color("DarkestPurple")) - Text("Add Task") - .font(Font.custom("NotoSansOriya", size: Spacing.medium)) - .foregroundColor(Color("DarkestPurple")) - .baselineOffset(-5) + AddTaskButton(action: viewModel.navigateAddTask, title: "test Add Task") + + //about page button + Button("About Page") { + router.navigate(to: .aboutPage) } - .padding(12.0) - .background(Color.cPink) - .cornerRadius(Spacing.medium) } Spacer() } Spacer() } - .padding(15) + .padding(Spacing.standard) .background(Color("Rose")) } } diff --git a/TaskManager/Views/TemplateViews.swift b/TaskManager/Views/TemplateViews.swift new file mode 100644 index 0000000..3f9c73c --- /dev/null +++ b/TaskManager/Views/TemplateViews.swift @@ -0,0 +1,121 @@ +// +// TemplateViews.swift +// TaskManager +// +// Created by Isabella Sulisufi on 03/01/2025. +// + +import SwiftUI + +struct LogoImage: View { + var body: some View { + Image("LogoImage") + .resizable() + .scaledToFit() + .frame(width: 200, height: 100) + } +} + +struct AddTaskButton: View { + let action: () -> Void + let title: String + + var body: some View { + Button { + action() + } label: { + Image(systemName: "plus.circle") + .font(.system(size: Spacing.large, weight: .bold)) + .foregroundColor(Color("DarkestPurple")) + Text(title) + .font(Font.custom("NotoSansOriya", size: Spacing.medium)) + .foregroundColor(Color("DarkestPurple")) + .baselineOffset(-5) + } + .padding(Spacing.small) + .background(Color.cPink) + .cornerRadius(Spacing.medium) + } +} + + +struct TaskCardView: View { + @ObservedObject var viewModel: TaskViewModel + let title: String + let category: Category + let description: String? + let dueDate: Date + // var isComplete: Bool + + var body: some View { + HStack { + VStack(alignment: .leading) { + HStack { + Text(title) + .font(.custom("Gill Sans", size: Spacing.medium)) + .foregroundColor(Color("DarkPurple")) + .padding(.bottom, Spacing.micro) + Spacer() + Text(category.rawValue) + .font(.custom("Gill Sans", size: Spacing.standard)) + .foregroundColor(Color("DarkPurple")) + .padding(.horizontal, Spacing.standard) + .padding(.vertical, Spacing.tiny) + .background(Color("CPink")) + .cornerRadius(Spacing.spacious) + } + .padding(.trailing, Spacing.small) + + Text(description ?? "") + .font(.custom("Gill Sans", size: Spacing.standard)) + .foregroundColor(Color("DarkPurple")) + .padding(.bottom, 6.0) + + Text(dueDate.formatted(date: .abbreviated, time: .omitted)) + .font(.custom("Gill Sans", size: Spacing.standard)) + .foregroundColor(Color("DarkPurple")) + .padding(.bottom, Spacing.small) + + HStack { + // complete button + Button { + viewModel.navigateAddTask() + } label: { + Image(systemName: "checkmark.circle") + .font(.system(size: Spacing.medium, weight: .bold)) + .foregroundColor(Color("CPink")) + Text("Complete?") + .font(.custom("Gill Sans", size: Spacing.standard)) + .foregroundColor(Color("DarkPurple")) + } + Spacer() + + // update button + Button { + viewModel.navigateAddTask() + } label: { + Image(systemName: "pencil.circle") + .font(.system(size: Spacing.medium, weight: .bold)) + .foregroundColor(Color("CPink")) + Text("Update?") + .font(.custom("Gill Sans", size: Spacing.standard)) + .foregroundColor(Color("DarkPurple")) + } + } + .padding([.bottom, .trailing], Spacing.standard) + + } + .padding(.leading, Spacing.standard) + Spacer() + + } + .padding(.top, Spacing.small) + .background(Color("Cream")) + .overlay( + RoundedRectangle(cornerRadius: Spacing.small) + .stroke(Color("Purple3"), lineWidth: 1) + ) + } +} + + From e9af6ff7073677afd4da7e4e7b59d7a700604a6d Mon Sep 17 00:00:00 2001 From: IsabellaSulisufi <114592322+IsabellaSulisufi@users.noreply.github.com> Date: Fri, 3 Jan 2025 15:36:02 +0000 Subject: [PATCH 2/3] add task and show on home screen --- TaskManager/Router.swift | 1 + TaskManager/TaskManagerApp.swift | 6 ++++- TaskManager/Views/AboutPageView.swift | 5 ---- TaskManager/Views/AddTaskView.swift | 33 +++++++++++++------------- TaskManager/Views/AllTasksView.swift | 24 +++++++++++++++++++ TaskManager/Views/HomeView.swift | 34 ++++++++++++++++++++------- TaskManager/Views/TemplateViews.swift | 2 +- 7 files changed, 72 insertions(+), 33 deletions(-) diff --git a/TaskManager/Router.swift b/TaskManager/Router.swift index 831f87f..29e687f 100644 --- a/TaskManager/Router.swift +++ b/TaskManager/Router.swift @@ -10,6 +10,7 @@ import SwiftUI final class Router: ObservableObject { public enum Destination: Codable, Hashable { + case home case addTask case aboutPage case allTasks diff --git a/TaskManager/TaskManagerApp.swift b/TaskManager/TaskManagerApp.swift index 6525feb..ae20dc0 100644 --- a/TaskManager/TaskManagerApp.swift +++ b/TaskManager/TaskManagerApp.swift @@ -10,11 +10,12 @@ import SwiftUI @main struct TaskManagerApp: App { @ObservedObject var router = Router() + var body: some Scene { let viewModel = TaskViewModel(router: router) WindowGroup { NavigationStack(path: $router.navPath) { - HomeView(viewModel: TaskViewModel(router: router)) + HomeView(viewModel: viewModel) .navigationDestination(for: Router.Destination.self) { destination in switch destination { case .addTask: @@ -25,6 +26,9 @@ struct TaskManagerApp: App { case .allTasks: AllTasksView(viewModel: viewModel) + + case .home: + HomeView(viewModel: viewModel) } } } diff --git a/TaskManager/Views/AboutPageView.swift b/TaskManager/Views/AboutPageView.swift index bf09627..d349065 100644 --- a/TaskManager/Views/AboutPageView.swift +++ b/TaskManager/Views/AboutPageView.swift @@ -12,7 +12,6 @@ struct AboutPageView: View { var body: some View { VStack { - LogoImage() Text("This is ToTask!") @@ -75,7 +74,3 @@ struct AboutPageView: View { } } - -// #Preview { -// AboutPageView() -// } diff --git a/TaskManager/Views/AddTaskView.swift b/TaskManager/Views/AddTaskView.swift index 25e8c11..3101f2b 100644 --- a/TaskManager/Views/AddTaskView.swift +++ b/TaskManager/Views/AddTaskView.swift @@ -6,23 +6,15 @@ import SwiftUI struct AddTaskView: View { + @EnvironmentObject var router: Router @ObservedObject var viewModel: TaskViewModel - + + //might need to pass task list from this view back to home + var body: some View { NavigationView { VStack { - // Image and back arrow - HStack { - Image(systemName: "arrow.left") - .font(.system(size: Spacing.big, weight: .bold)) - .foregroundColor(Color("Purple2")) - - Image("LogoImage") - .resizable() - .scaledToFit() - .frame(width: 200, height: 100) - } - .padding(.top) + LogoImage() // Entered text section VStack(alignment: .leading) { @@ -85,6 +77,17 @@ struct AddTaskView: View { .background(Color.cPink) .cornerRadius(Spacing.medium) }) + + Button { + router.navigate(to: .home) + } label: { + Text("Back to Home") + .font(Font.custom("NotoSansOriya", size: Spacing.medium)) + .foregroundColor(Color.cPink) + .padding(Spacing.standard) + .background(Color("DarkestPurple")) + .cornerRadius(Spacing.medium) + } // Delete Button Button(action: { @@ -112,7 +115,3 @@ struct AddTaskView: View { } } } - -// #Preview { -// AddTaskView() -// } diff --git a/TaskManager/Views/AllTasksView.swift b/TaskManager/Views/AllTasksView.swift index 675804e..f590d80 100644 --- a/TaskManager/Views/AllTasksView.swift +++ b/TaskManager/Views/AllTasksView.swift @@ -9,6 +9,7 @@ import SwiftUI struct AllTasksView: View { @ObservedObject var viewModel: TaskViewModel + var body: some View { ScrollView { @@ -22,6 +23,29 @@ struct AllTasksView: View { TaskCardView(viewModel: viewModel, title: "Task 2", category: .work, description: "This is another task", dueDate: Date()) Spacer() + + + //testing showing task list + if viewModel.taskList.isEmpty { + Text("No tasks to display") + .font(.custom("Gill Sans", size: Spacing.medium)) + .foregroundColor(Color("DarkPurple")) + } else { + ForEach(viewModel.taskList.indices, id: \.self) { index in + TaskCardView(viewModel: viewModel, title: viewModel.taskList[index].title, + category: viewModel.taskList[index].category, + description: viewModel.taskList[index].description, + dueDate: viewModel.taskList[index].dueDate) + } + } + + + ForEach(viewModel.taskList, id: \.title) { task in + Text(task.title) + Text(task.description ?? "No Description") + Text(task.category.rawValue) + Text(task.dueDate, style: .date) + } } } .padding(Spacing.small) diff --git a/TaskManager/Views/HomeView.swift b/TaskManager/Views/HomeView.swift index dceb260..8d413b8 100644 --- a/TaskManager/Views/HomeView.swift +++ b/TaskManager/Views/HomeView.swift @@ -37,6 +37,22 @@ struct HomeView: View { TaskCardView(viewModel: viewModel, title: viewModel.task1.title, category: viewModel.task1.category, description: viewModel.task1.description, dueDate: viewModel.task1.dueDate) + + + if viewModel.taskList.isEmpty { + Text("No tasks to display") + .font(.custom("Gill Sans", size: Spacing.medium)) + .foregroundColor(Color("DarkPurple")) + } else { + ForEach(viewModel.taskList.indices, id: \.self) { index in + TaskCardView(viewModel: viewModel, title: viewModel.taskList[index].title, + category: viewModel.taskList[index].category, + description: viewModel.taskList[index].description, + dueDate: viewModel.taskList[index].dueDate) + } + } + + Spacer() // Buttons @@ -54,12 +70,12 @@ struct HomeView: View { Spacer() // Add Task Button - AddTaskButton(action: viewModel.navigateAddTask, title: "test Add Task") + AddTaskButton(action: viewModel.navigateAddTask, title: "Add Task") - //about page button - Button("About Page") { - router.navigate(to: .aboutPage) - } + } + //about page button + Button("About Page") { + router.navigate(to: .aboutPage) } Spacer() } @@ -67,9 +83,9 @@ struct HomeView: View { } .padding(Spacing.standard) .background(Color("Rose")) + .onAppear { + print("HomeView appeared, task list count: \(viewModel.taskList.count)") + } } + } - -// #Preview { -// HomeView() -// } diff --git a/TaskManager/Views/TemplateViews.swift b/TaskManager/Views/TemplateViews.swift index 3f9c73c..3838a6a 100644 --- a/TaskManager/Views/TemplateViews.swift +++ b/TaskManager/Views/TemplateViews.swift @@ -79,7 +79,7 @@ struct TaskCardView: View { HStack { // complete button Button { - viewModel.navigateAddTask() + viewModel.emptyTaskListArray() } label: { Image(systemName: "checkmark.circle") .font(.system(size: Spacing.medium, weight: .bold)) From f2c9ee98181c9dfe104150e57820c1fcee4b0b8f Mon Sep 17 00:00:00 2001 From: IsabellaSulisufi <114592322+IsabellaSulisufi@users.noreply.github.com> Date: Fri, 3 Jan 2025 15:37:31 +0000 Subject: [PATCH 3/3] swiftlint --- TaskManager/TaskManagerApp.swift | 6 +++--- TaskManager/Views/AddTaskView.swift | 8 ++++---- TaskManager/Views/AllTasksView.swift | 15 ++++++--------- TaskManager/Views/HomeView.swift | 10 ++++------ TaskManager/Views/TemplateViews.swift | 5 +---- 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/TaskManager/TaskManagerApp.swift b/TaskManager/TaskManagerApp.swift index ae20dc0..00b43f4 100644 --- a/TaskManager/TaskManagerApp.swift +++ b/TaskManager/TaskManagerApp.swift @@ -10,7 +10,7 @@ import SwiftUI @main struct TaskManagerApp: App { @ObservedObject var router = Router() - + var body: some Scene { let viewModel = TaskViewModel(router: router) WindowGroup { @@ -20,13 +20,13 @@ struct TaskManagerApp: App { switch destination { case .addTask: AddTaskView(viewModel: viewModel) - + case .aboutPage: AboutPageView(viewModel: viewModel) case .allTasks: AllTasksView(viewModel: viewModel) - + case .home: HomeView(viewModel: viewModel) } diff --git a/TaskManager/Views/AddTaskView.swift b/TaskManager/Views/AddTaskView.swift index 3101f2b..d1d46a4 100644 --- a/TaskManager/Views/AddTaskView.swift +++ b/TaskManager/Views/AddTaskView.swift @@ -8,9 +8,9 @@ import SwiftUI struct AddTaskView: View { @EnvironmentObject var router: Router @ObservedObject var viewModel: TaskViewModel - - //might need to pass task list from this view back to home - + + // might need to pass task list from this view back to home + var body: some View { NavigationView { VStack { @@ -77,7 +77,7 @@ struct AddTaskView: View { .background(Color.cPink) .cornerRadius(Spacing.medium) }) - + Button { router.navigate(to: .home) } label: { diff --git a/TaskManager/Views/AllTasksView.swift b/TaskManager/Views/AllTasksView.swift index f590d80..ee913ae 100644 --- a/TaskManager/Views/AllTasksView.swift +++ b/TaskManager/Views/AllTasksView.swift @@ -9,23 +9,21 @@ import SwiftUI struct AllTasksView: View { @ObservedObject var viewModel: TaskViewModel - var body: some View { ScrollView { VStack { LogoImage() - + TaskCardView(viewModel: viewModel, title: "Task 1", category: .school, description: "This is a task", dueDate: Date()) - .padding(.bottom, Spacing.medium) - + .padding(.bottom, Spacing.medium) + TaskCardView(viewModel: viewModel, title: "Task 2", category: .work, description: "This is another task", dueDate: Date()) Spacer() - - - //testing showing task list + + // testing showing task list if viewModel.taskList.isEmpty { Text("No tasks to display") .font(.custom("Gill Sans", size: Spacing.medium)) @@ -38,8 +36,7 @@ struct AllTasksView: View { dueDate: viewModel.taskList[index].dueDate) } } - - + ForEach(viewModel.taskList, id: \.title) { task in Text(task.title) Text(task.description ?? "No Description") diff --git a/TaskManager/Views/HomeView.swift b/TaskManager/Views/HomeView.swift index 8d413b8..c807b69 100644 --- a/TaskManager/Views/HomeView.swift +++ b/TaskManager/Views/HomeView.swift @@ -37,8 +37,7 @@ struct HomeView: View { TaskCardView(viewModel: viewModel, title: viewModel.task1.title, category: viewModel.task1.category, description: viewModel.task1.description, dueDate: viewModel.task1.dueDate) - - + if viewModel.taskList.isEmpty { Text("No tasks to display") .font(.custom("Gill Sans", size: Spacing.medium)) @@ -52,7 +51,6 @@ struct HomeView: View { } } - Spacer() // Buttons @@ -71,9 +69,9 @@ struct HomeView: View { // Add Task Button AddTaskButton(action: viewModel.navigateAddTask, title: "Add Task") - + } - //about page button + // about page button Button("About Page") { router.navigate(to: .aboutPage) } @@ -87,5 +85,5 @@ struct HomeView: View { print("HomeView appeared, task list count: \(viewModel.taskList.count)") } } - + } diff --git a/TaskManager/Views/TemplateViews.swift b/TaskManager/Views/TemplateViews.swift index 3838a6a..909e9d0 100644 --- a/TaskManager/Views/TemplateViews.swift +++ b/TaskManager/Views/TemplateViews.swift @@ -19,7 +19,7 @@ struct LogoImage: View { struct AddTaskButton: View { let action: () -> Void let title: String - + var body: some View { Button { action() @@ -38,7 +38,6 @@ struct AddTaskButton: View { } } - struct TaskCardView: View { @ObservedObject var viewModel: TaskViewModel let title: String @@ -117,5 +116,3 @@ struct TaskCardView: View { ) } } - -