Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions TaskManager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -24,6 +25,7 @@
/* Begin PBXFileReference section */
EE00D2BB2C6F8D65004FF048 /* TaskViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskViewModel.swift; sourceTree = "<group>"; };
EE019E172C9460C600A8B764 /* TaskModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskModel.swift; sourceTree = "<group>"; };
EE0AD8122D282DEF00AEF204 /* TemplateViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateViews.swift; sourceTree = "<group>"; };
EE3AE1702CC69970001A80C1 /* Router.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Router.swift; sourceTree = "<group>"; };
EE4BB9C62B88F49F00FFF4F2 /* TextStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextStyles.swift; sourceTree = "<group>"; };
EE59B6B32C342680003D59DF /* AboutPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutPageView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -54,6 +56,7 @@
EE59B6B32C342680003D59DF /* AboutPageView.swift */,
EED772142B7BC0C6007BDA4A /* AddTaskView.swift */,
EEA7106D2C908CA000785086 /* HomeView.swift */,
EE0AD8122D282DEF00AEF204 /* TemplateViews.swift */,
EEFAD1902CD3A7F900018043 /* AllTasksView.swift */,
);
path = Views;
Expand Down Expand Up @@ -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;
};
Expand Down
1 change: 1 addition & 0 deletions TaskManager/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SwiftUI
final class Router: ObservableObject {

public enum Destination: Codable, Hashable {
case home
case addTask
case aboutPage
case allTasks
Expand Down
14 changes: 10 additions & 4 deletions TaskManager/TaskManagerApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@ 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:
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)

case .home:
HomeView(viewModel: viewModel)
}
}
}
Expand Down
31 changes: 4 additions & 27 deletions TaskManager/Views/AboutPageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ 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())
Expand Down Expand Up @@ -69,31 +63,14 @@ 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)
.background(Color("Rose"))

}
}

// #Preview {
// AboutPageView()
// }
31 changes: 15 additions & 16 deletions TaskManager/Views/AddTaskView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -86,6 +78,17 @@ struct AddTaskView: View {
.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: {
viewModel.emptyTaskListArray()
Expand All @@ -112,7 +115,3 @@ struct AddTaskView: View {
}
}
}

// #Preview {
// AddTaskView()
// }
101 changes: 23 additions & 78 deletions TaskManager/Views/AllTasksView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,94 +13,39 @@ 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())
// }
Spacer()
}
}
.padding(10.0)
.background(Color("Cream"))
}
.padding(.bottom, Spacing.medium)

}

struct TaskCardView: View {
@ObservedObject var viewModel: TaskViewModel
let title: String
let category: Category
let description: String?
let dueDate: Date
// var isComplete: Bool
TaskCardView(viewModel: viewModel, title: "Task 2",
category: .work, description: "This is another task", dueDate: Date())
Spacer()

var body: some View {
HStack {
VStack(alignment: .leading) {
HStack {
Text(title)
// testing showing task list
if viewModel.taskList.isEmpty {
Text("No tasks to display")
.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"))
} 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)
}
}
.padding([.bottom, .trailing], Spacing.standard)

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(.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"))
}
}
Loading
Loading