diff --git a/SwiftUIView.swift b/SwiftUIView.swift index a27f624..d12e3bd 100644 --- a/SwiftUIView.swift +++ b/SwiftUIView.swift @@ -1,6 +1,6 @@ // // SwiftUIView.swift -// +// // // Created by Isabella Sulisufi on 16/08/2024. // diff --git a/TaskManager/Model/TaskModel.swift b/TaskManager/Model/TaskModel.swift index 31b9603..044ec13 100644 --- a/TaskManager/Model/TaskModel.swift +++ b/TaskManager/Model/TaskModel.swift @@ -7,26 +7,26 @@ import Foundation -//struct TaskModel { +// struct TaskModel { // var id: UUID = UUID() // var title: String // var description: String? -// +// // var startDate: Date // var dueDate: Date -// +// // var category: Category // var isCompleted: Bool -// +// -//} +// } enum Category: String, CaseIterable { - case school = "School" - case work = "Work" - case personal = "Personal" - case fitness = "Fitness" - } + case school = "School" + case work = "Work" + case personal = "Personal" + case fitness = "Fitness" +} struct Task { let title: String diff --git a/TaskManager/Spacing.swift b/TaskManager/Spacing.swift index d4c37ba..c299dbd 100644 --- a/TaskManager/Spacing.swift +++ b/TaskManager/Spacing.swift @@ -8,28 +8,28 @@ import SwiftUI struct Spacing { - + static let none: CGFloat = 0 - + static let micro: CGFloat = 4 - + static let tiny: CGFloat = 8 - + static let small: CGFloat = 12 - + static let standard: CGFloat = 16 - + static let medium: CGFloat = 20 - + static let considerable: CGFloat = 22 - + static let spacious: CGFloat = 24 - + static let large: CGFloat = 30 - + static let extensive: CGFloat = 32 - + static let big: CGFloat = 36 - + static let huge: CGFloat = 40 } diff --git a/TaskManager/TextStyles.swift b/TaskManager/TextStyles.swift index 44cdd40..bf0903a 100644 --- a/TaskManager/TextStyles.swift +++ b/TaskManager/TextStyles.swift @@ -11,22 +11,22 @@ struct TextStyles { // Style for Titles static func titleStyle() -> some ViewModifier { return TextStyleModifier(font: .custom("Gill Sans", size: Spacing.large), - color: Color("DarkPurple"), - applyPadding: false) + color: Color("DarkPurple"), + applyPadding: false) } // Style for Descriptions static func descriptionStyle() -> some ViewModifier { return TextStyleModifier(font: .custom("Gill Sans", size: Spacing.spacious), - color: Color("DarkPurple"), - applyPadding: false) + color: Color("DarkPurple"), + applyPadding: false) } - + // Style for Bullet Points static func bulletPointStyle() -> some ViewModifier { return TextStyleModifier(font: .custom("Gill Sans", size: Spacing.considerable), - color: Color("DarkPurple"), - applyPadding: true) + color: Color("DarkPurple"), + applyPadding: true) } struct TextStyleModifier: ViewModifier { @@ -42,5 +42,3 @@ struct TextStyles { } } } - - diff --git a/TaskManager/ViewModel/TaskViewModel.swift b/TaskManager/ViewModel/TaskViewModel.swift index 73fdb69..e9ffef4 100644 --- a/TaskManager/ViewModel/TaskViewModel.swift +++ b/TaskManager/ViewModel/TaskViewModel.swift @@ -9,7 +9,7 @@ import SwiftUI class TaskViewModel: ObservableObject { @Published var taskList: [Task] = [] - + @Published var selectedDate: Date = Date() @Published var startDate: Date = Date() @@ -17,15 +17,15 @@ class TaskViewModel: ObservableObject { @Published var isTaskComplete: Bool = false @Published var taskTitle: String = "" @Published var taskDescription: String = "" - + var router: Router - + init(router: Router) { self.router = router } - + var dropdownOptions = Category.allCases.map { $0.rawValue } - + var task1 = Task( title: "Science homework", description: "Biology presentation on anatomy", @@ -39,28 +39,28 @@ class TaskViewModel: ObservableObject { taskList.removeAll() print(taskList) } - + func addToTaskListArray() { let newTask = Task( title: taskTitle, description: taskDescription, startDate: startDate, dueDate: selectedDate, - category:selectedCategory, + category: selectedCategory, isComplete: isTaskComplete ) taskList.append(newTask) print(taskList) } - + func handleButtonToggle() { isTaskComplete.toggle() } - + func navigateToViewAllTasks() { router.navigate(to: .aboutPage) } - + func navigateAddTask() { router.navigate(to: .addTask) } diff --git a/TaskManager/Views/AboutPageView.swift b/TaskManager/Views/AboutPageView.swift index ce93624..c4913c6 100644 --- a/TaskManager/Views/AboutPageView.swift +++ b/TaskManager/Views/AboutPageView.swift @@ -11,103 +11,91 @@ struct AboutPageView: View { @ObservedObject var viewModel: TaskViewModel var body: some View { - + + VStack { + HStack { + Image("LogoImage") + .resizable() + .scaledToFit() + .frame(width: 200, height: 100) + } + .padding(.top) + + Text("This is ToTask!") + .modifier(TextStyles.descriptionStyle()) + + Text("An app which allows you to easily add, update, delete and view your tasks") + .modifier(TextStyles.descriptionStyle()) + .multilineTextAlignment(.center) + VStack { - HStack { - Image("LogoImage") - .resizable() - .scaledToFit() - .frame(width: 200, height: 100) - } - .padding(.top) - - - Text("This is ToTask!") - .modifier(TextStyles.descriptionStyle()) - - - Text("An app which allows you to easily add, update, delete and view your tasks") - .modifier(TextStyles.descriptionStyle()) + Text("\u{2022} **Time Tracking**: Set due dates to easily monitor task progress.") + .modifier(TextStyles.bulletPointStyle()) .multilineTextAlignment(.center) - - - VStack{ - Text("\u{2022} **Time Tracking**: Set due dates to easily monitor task progress.") - .modifier(TextStyles.bulletPointStyle()) - .multilineTextAlignment(.center) - - Text("\u{2022} **Organised Categories**: Categorise tasks for effortless organisation and quick access.") - .modifier(TextStyles.bulletPointStyle()) - .multilineTextAlignment(.center) - - - Text("\u{2022} **Daily Overview**: Instantly view all tasks due today on your homepage.") - .modifier(TextStyles.bulletPointStyle()) - .multilineTextAlignment(.center) - } - .padding(.top) - - Spacer() - - Text("Start Today and Add A Task!") + + Text("\u{2022} **Organised Categories**: Categorise tasks for effortless organisation and quick access.") + .modifier(TextStyles.bulletPointStyle()) + .multilineTextAlignment(.center) + + Text("\u{2022} **Daily Overview**: Instantly view all tasks due today on your homepage.") + .modifier(TextStyles.bulletPointStyle()) .multilineTextAlignment(.center) - - .modifier(TextStyles.descriptionStyle()) - - + } + .padding(.top) + + Spacer() + + Text("Start Today and Add A Task!") + .multilineTextAlignment(.center) + + .modifier(TextStyles.descriptionStyle()) + + Spacer() + + HStack { + + // View All Tasks Button + + Button { + viewModel.navigateAddTask() + + } label: { + Text("View All Tasks") + .font(Font.custom("NotoSansOriya", size: Spacing.medium)) + .foregroundColor(Color.cPink) + .padding(Spacing.standard) + .background(Color("DarkestPurple")) + .cornerRadius(Spacing.medium) + } + Spacer() - - HStack{ - - - // View All Tasks Button - - Button { - viewModel.navigateAddTask() - - } label: { - Text("View All Tasks") - .font(Font.custom("NotoSansOriya", size: Spacing.medium)) - .foregroundColor(Color.cPink) - .padding(Spacing.standard) - .background(Color("DarkestPurple")) - .cornerRadius(Spacing.medium) - } - - - 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) - + + // 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) + } - .padding(Spacing.spacious) - .background(Color("Rose")) - - - + + } + .padding(Spacing.spacious) + .background(Color("Rose")) + } } -//#Preview { +// #Preview { // AboutPageView() -//} +// } diff --git a/TaskManager/Views/AddTaskView.swift b/TaskManager/Views/AddTaskView.swift index eaf9629..3c8a0bb 100644 --- a/TaskManager/Views/AddTaskView.swift +++ b/TaskManager/Views/AddTaskView.swift @@ -9,59 +9,56 @@ struct AddTaskView: View { @ObservedObject var viewModel: TaskViewModel var body: some View { - + NavigationView { VStack { - - //Image and back arrow + + // 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) - - - //Entered text section + + // Entered text section VStack(alignment: .leading) { TextField("Current Task Name", text: $viewModel.taskTitle) .font(.custom("NotoSansOriya", size: Spacing.large)) .foregroundColor(Color("DarkPurple")) - + TextField("Task Description", text: $viewModel.taskDescription) .font(.custom("NotoSansOriya", size: Spacing.spacious)) .foregroundColor(Color("DarkPurple")) } .padding(Spacing.spacious) - - - //Due date and category + + // Due date and category VStack(alignment: .center, spacing: 30) { DatePicker("Due Date", selection: $viewModel.selectedDate, displayedComponents: .date) .foregroundColor(Color("DarkPurple")) .font(.custom("NotoSansOriya", size: Spacing.considerable)) - + HStack { Text("Category") .foregroundColor(Color("DarkPurple")) .font(.custom("NotoSansOriya", size: Spacing.considerable)) Spacer() - + Picker("Select a category", selection: $viewModel.selectedCategory) { - ForEach(viewModel.dropdownOptions, id: \.self) { dropdownOption in - Text(dropdownOption) - } - } + ForEach(viewModel.dropdownOptions, id: \.self) { dropdownOption in + Text(dropdownOption) + } + } .pickerStyle(MenuPickerStyle()) } - - - //Buttons + + // Buttons HStack { Button(action: { viewModel.handleButtonToggle() @@ -71,18 +68,18 @@ struct AddTaskView: View { .frame(width: Spacing.large, height: Spacing.large) .foregroundColor(viewModel.isTaskComplete ? Color.cPink : Color.cPink) } - + Text("Mark As Complete?") .foregroundColor(Color("DarkPurple")) .font(Font.custom("NotoSansOriya", size: Spacing.medium)) .baselineOffset(-3) Spacer() } - - //Save Changes Button + + // Save Changes Button Button(action: { viewModel.addToTaskListArray() - + }) { Text("Save Changes") .font(Font.custom("NotoSansOriya", size: Spacing.medium)) @@ -91,8 +88,7 @@ struct AddTaskView: View { .background(Color.cPink) .cornerRadius(Spacing.medium) } - - + // Delete Button Button(action: { viewModel.emptyTaskListArray() @@ -104,7 +100,7 @@ struct AddTaskView: View { Text("Delete Task") .font(Font.custom("NotoSansOriya", size: Spacing.medium)) .foregroundColor(Color.cPink) - .baselineOffset(-5) + .baselineOffset(-5) } .padding(11.0) .background(Color("DarkestPurple")) @@ -119,7 +115,6 @@ struct AddTaskView: View { } } - -//#Preview { +// #Preview { // AddTaskView() -//} +// } diff --git a/TaskManager/Views/HomeView.swift b/TaskManager/Views/HomeView.swift index a7e6c21..73284d0 100644 --- a/TaskManager/Views/HomeView.swift +++ b/TaskManager/Views/HomeView.swift @@ -10,34 +10,34 @@ import SwiftUI struct HomeView: View { @ObservedObject var viewModel: TaskViewModel @EnvironmentObject var router: Router - + var body: some View { VStack { - //Logo + // Logo Image("LogoImage") .resizable() .scaledToFit() .frame(width: 200, height: 100) - - //Welcome Text + + // Welcome Text VStack(alignment: .leading) { Text("Hi, Welcome Back!") .font(.custom("Gill Sans", size: Spacing.extensive)) .foregroundColor(Color("DarkPurple")) .padding(.bottom, Spacing.small) - + Text("Tasks for Today") .font(.custom("Gill Sans", size: Spacing.large)) .foregroundColor(Color("DarkPurple")) .padding(.bottom, Spacing.micro) - + Text(Date().formatted(date: .complete, time: .omitted)) .font(.custom("Gill Sans", size: Spacing.medium)) .foregroundColor(Color("DarkPurple")) - + Spacer() - - //Card + + // Card HStack { VStack(alignment: .leading) { HStack { @@ -55,17 +55,17 @@ struct HomeView: View { .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() @@ -78,7 +78,7 @@ struct HomeView: View { .foregroundColor(Color("DarkPurple")) } Spacer() - + Button { viewModel.navigateAddTask() } label: { @@ -91,12 +91,11 @@ struct HomeView: View { } } .padding([.bottom, .trailing], Spacing.standard) - - + } .padding(.leading, Spacing.standard) Spacer() - + } .padding(.top, 10.0) .background(Color("Cream")) @@ -104,10 +103,10 @@ struct HomeView: View { RoundedRectangle(cornerRadius: Spacing.small) .stroke(Color("Purple3"), lineWidth: 1) ) - + Spacer() - - //Buttons + + // Buttons HStack { // View All Tasks Button Button("View All Tasks") { @@ -118,10 +117,10 @@ struct HomeView: View { .padding(Spacing.standard) .background(Color("DarkestPurple")) .cornerRadius(Spacing.medium) - + Spacer() - - //Add Task Button + + // Add Task Button Button { router.navigate(to: .addTask) } label: { @@ -146,6 +145,6 @@ struct HomeView: View { } } -//#Preview { +// #Preview { // HomeView() -//} +// }