From 963245f94236eee3f624b2b251863f7639070783 Mon Sep 17 00:00:00 2001 From: IsabellaSulisufi <114592322+IsabellaSulisufi@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:49:23 +0000 Subject: [PATCH] Make small style and functioanlity changes --- TaskManager.xcodeproj/project.pbxproj | 4 + TaskManager/Router.swift | 1 + TaskManager/TaskManagerApp.swift | 3 + TaskManager/ViewModel/TaskViewModel.swift | 5 + TaskManager/Views/AboutPageView.swift | 14 ++- TaskManager/Views/AddTaskView.swift | 1 + TaskManager/Views/AllTasksView.swift | 106 ++++++++++++++++++++++ TaskManager/Views/HomeView.swift | 4 +- 8 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 TaskManager/Views/AllTasksView.swift diff --git a/TaskManager.xcodeproj/project.pbxproj b/TaskManager.xcodeproj/project.pbxproj index 8cff047..808e655 100644 --- a/TaskManager.xcodeproj/project.pbxproj +++ b/TaskManager.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ EED772152B7BC0C6007BDA4A /* AddTaskView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EED772142B7BC0C6007BDA4A /* AddTaskView.swift */; }; EED772172B7BC0C8007BDA4A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EED772162B7BC0C8007BDA4A /* Assets.xcassets */; }; EED7721A2B7BC0C8007BDA4A /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EED772192B7BC0C8007BDA4A /* Preview Assets.xcassets */; }; + EEFAD1912CD3A7F900018043 /* AllTasksView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEFAD1902CD3A7F900018043 /* AllTasksView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -33,6 +34,7 @@ EED772142B7BC0C6007BDA4A /* AddTaskView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTaskView.swift; sourceTree = ""; }; EED772162B7BC0C8007BDA4A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; EED772192B7BC0C8007BDA4A /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + EEFAD1902CD3A7F900018043 /* AllTasksView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllTasksView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -52,6 +54,7 @@ EE59B6B32C342680003D59DF /* AboutPageView.swift */, EED772142B7BC0C6007BDA4A /* AddTaskView.swift */, EEA7106D2C908CA000785086 /* HomeView.swift */, + EEFAD1902CD3A7F900018043 /* AllTasksView.swift */, ); path = Views; sourceTree = ""; @@ -185,6 +188,7 @@ EEA7106E2C908CA000785086 /* HomeView.swift in Sources */, EE59B6B42C342680003D59DF /* AboutPageView.swift in Sources */, EE3AE1712CC69970001A80C1 /* Router.swift in Sources */, + EEFAD1912CD3A7F900018043 /* AllTasksView.swift in Sources */, EE00D2BC2C6F8D65004FF048 /* TaskViewModel.swift in Sources */, EE019E182C9460C600A8B764 /* TaskModel.swift in Sources */, EED772152B7BC0C6007BDA4A /* AddTaskView.swift in Sources */, diff --git a/TaskManager/Router.swift b/TaskManager/Router.swift index 74e9c3f..831f87f 100644 --- a/TaskManager/Router.swift +++ b/TaskManager/Router.swift @@ -12,6 +12,7 @@ final class Router: ObservableObject { public enum Destination: Codable, Hashable { case addTask case aboutPage + case allTasks } @Published var navPath = NavigationPath() diff --git a/TaskManager/TaskManagerApp.swift b/TaskManager/TaskManagerApp.swift index 7d7c343..33aa2f4 100644 --- a/TaskManager/TaskManagerApp.swift +++ b/TaskManager/TaskManagerApp.swift @@ -20,6 +20,9 @@ struct TaskManagerApp: App { AddTaskView(viewModel: TaskViewModel(router: router)) case .aboutPage: AboutPageView(viewModel: TaskViewModel(router: router)) + + case .allTasks: + AllTasksView(viewModel: TaskViewModel(router: router)) } } } diff --git a/TaskManager/ViewModel/TaskViewModel.swift b/TaskManager/ViewModel/TaskViewModel.swift index e9ffef4..c67d2cc 100644 --- a/TaskManager/ViewModel/TaskViewModel.swift +++ b/TaskManager/ViewModel/TaskViewModel.swift @@ -57,7 +57,12 @@ class TaskViewModel: ObservableObject { isTaskComplete.toggle() } + // Routing func navigateToViewAllTasks() { + router.navigate(to: .allTasks) + } + + func navigateToAboutPage() { router.navigate(to: .aboutPage) } diff --git a/TaskManager/Views/AboutPageView.swift b/TaskManager/Views/AboutPageView.swift index 1d81c44..4ffd76a 100644 --- a/TaskManager/Views/AboutPageView.swift +++ b/TaskManager/Views/AboutPageView.swift @@ -32,8 +32,10 @@ struct AboutPageView: View { .modifier(TextStyles.bulletPointStyle()) .multilineTextAlignment(.center) - Text("\u{2022} **Organised Categories**: Categorise tasks for effortless " + - "organisation and quick access.") + Text(""" + \u{2022} **Organised Categories**: Categorise tasks \ + for effortless organisation and quick access. + """) .modifier(TextStyles.bulletPointStyle()) .multilineTextAlignment(.center) @@ -79,8 +81,16 @@ struct AboutPageView: View { .baselineOffset(-5) } .padding(12.0) + .background(Color.cPink) + .cornerRadius(Spacing.medium) } + .padding(.horizontal, 20.0) + .padding(.bottom, 20.0) + } + .padding(10.0) + .background(Color("Rose")) + } } diff --git a/TaskManager/Views/AddTaskView.swift b/TaskManager/Views/AddTaskView.swift index b585310..25e8c11 100644 --- a/TaskManager/Views/AddTaskView.swift +++ b/TaskManager/Views/AddTaskView.swift @@ -106,6 +106,7 @@ struct AddTaskView: View { Spacer() } .padding(.horizontal, Spacing.spacious) + Spacer() } .background(Color("Rose")) } diff --git a/TaskManager/Views/AllTasksView.swift b/TaskManager/Views/AllTasksView.swift new file mode 100644 index 0000000..98c20d9 --- /dev/null +++ b/TaskManager/Views/AllTasksView.swift @@ -0,0 +1,106 @@ +// +// AllTasksView.swift +// TaskManager +// +// Created by Isabella Sulisufi on 31/10/2024. +// + +import SwiftUI + +struct AllTasksView: View { + @ObservedObject var viewModel: TaskViewModel + + var body: some View { + ScrollView { + VStack { + // if !task.isComplete { + TaskCardView(viewModel: viewModel, title: "Task 1", + category: .school, description: "This is a 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) + ) + } +} diff --git a/TaskManager/Views/HomeView.swift b/TaskManager/Views/HomeView.swift index 73284d0..5c9951a 100644 --- a/TaskManager/Views/HomeView.swift +++ b/TaskManager/Views/HomeView.swift @@ -110,7 +110,7 @@ struct HomeView: View { HStack { // View All Tasks Button Button("View All Tasks") { - viewModel.navigateToViewAllTasks() + router.navigate(to: .allTasks) } .font(Font.custom("NotoSansOriya", size: Spacing.medium)) .foregroundColor(Color.cPink) @@ -138,10 +138,10 @@ struct HomeView: View { } Spacer() } + Spacer() } .padding(15) .background(Color("Rose")) - Spacer() } }