diff --git a/VineyardInternal/Progress.swift b/VineyardInternal/Progress.swift index 52e1591..74e96ba 100644 --- a/VineyardInternal/Progress.swift +++ b/VineyardInternal/Progress.swift @@ -24,20 +24,26 @@ struct Progress: Identifiable { // //} static var samples: [Progress] { - + var andrew = Person(name: "Andrew", email: "a@gmail.com") + var yash = Person(name: "Yash", email: "y@outlook.com") + var sankaet = Person(name: "Sankaet", email: "s@yahoo.com") + var rahul = Person(name: "Rahul", email: "r@apple.com") + var vishnesh = Person(name: "Vishnesh", email: "v@aol.com") + + let resolution1 = Resolution.samples[0] - let progress1 = Progress(resolution: resolution1, quantityGoal: 1, frequencyGoal: Frequency.weekly(count: 3), person: Person.samples[0]) + let progress1 = Progress(resolution: resolution1, quantityGoal: 1, frequencyGoal: Frequency(frequencyType: FrequencyType.weekly, count: 3), person: andrew) - let progress2 = Progress(resolution: resolution1, quantityGoal: 1, frequencyGoal: Frequency.weekly(count: 3), person: Person.samples[1]) + let progress2 = Progress(resolution: resolution1, quantityGoal: 1, frequencyGoal: Frequency(frequencyType: FrequencyType.weekly, count: 3), person: yash) - let progress3 = Progress(resolution: resolution1, quantityGoal: 1, frequencyGoal: Frequency.weekly(count: 3), person: Person.samples[2]) + let progress3 = Progress(resolution: resolution1, quantityGoal: 1, frequencyGoal: Frequency(frequencyType: FrequencyType.weekly, count: 3), person: sankaet) let resolution2 = Resolution.samples[1] - let progress4 = Progress(resolution: resolution2, quantityGoal: 1, frequencyGoal: Frequency.weekly(count: 3), person: Person.samples[0]) + let progress4 = Progress(resolution: resolution2, quantityGoal: 1, frequencyGoal: Frequency(frequencyType: FrequencyType.weekly, count: 3), person: andrew) - let progress5 = Progress(resolution: resolution2, quantityGoal: 1, frequencyGoal: Frequency.weekly(count: 3), person: Person.samples[1]) + let progress5 = Progress(resolution: resolution2, quantityGoal: 1, frequencyGoal: Frequency(frequencyType: FrequencyType.weekly, count: 3), person: yash) - let progress6 = Progress(resolution: resolution2, quantityGoal: 1, frequencyGoal: Frequency.weekly(count: 3), person: Person.samples[2]) + let progress6 = Progress(resolution: resolution2, quantityGoal: 1, frequencyGoal: Frequency(frequencyType: FrequencyType.weekly, count: 3), person: sankaet) return [progress1, progress2, progress3, progress4, progress5, progress6] } diff --git a/VineyardInternal/Resolution.swift b/VineyardInternal/Resolution.swift index 550cb5b..9f0fa93 100644 --- a/VineyardInternal/Resolution.swift +++ b/VineyardInternal/Resolution.swift @@ -7,39 +7,55 @@ import Foundation -enum Frequency { - case daily(count: Int) - case weekly(count: Int) - case monthly(count: Int) + +struct Frequency { + var frequencyType: FrequencyType + var count: Int +} + +enum FrequencyType { + case daily + case weekly + case monthly +} +struct Difficulty { + var difficultyLevel: DifficultyLevel + var score: Int } enum DifficultyLevel { - case easy(score: Int) - case medium(score: Int) - case hard(score: Int) + case easy + case medium + case hard } + + class Resolution: Identifiable { let id: UUID var title: String var description: String var defaultQuantity: Int? = nil var defaultFrequency: Frequency - var diffLevel: DifficultyLevel + var diffLevel: Difficulty + var groupName: String - init(title: String, description: String, quantity: Int? = nil, frequency: Frequency, diffLevel: DifficultyLevel) { + init(title: String, description: String, quantity: Int? = nil, frequency: Frequency, diffLevel: Difficulty, group: String) { self.id = UUID() self.title = title self.description = description self.defaultQuantity = quantity self.defaultFrequency = frequency self.diffLevel = diffLevel + self.groupName = group } static var samples: [Resolution] { - let resolution1 = Resolution(title: "Run miles", description: "Run a certain number of miles", quantity: 5, frequency: Frequency.weekly(count: 1), diffLevel: DifficultyLevel.medium(score: 5)) - let resolution2 = Resolution(title: "Drink 7 cups of water", description: "Drink more water", frequency: Frequency.daily(count: 1), diffLevel: DifficultyLevel.easy(score: 2)) + let group1 = "hahahahha" + let resolution1 = Resolution(title: "Run miles", description: "Run a certain number of miles", quantity: 5, frequency: Frequency(frequencyType: FrequencyType.weekly, count: 1), diffLevel: Difficulty(difficultyLevel: DifficultyLevel.medium, score: 5), group: group1) + let resolution2 = Resolution(title: "Drink 7 cups of water", description: "Drink more water", frequency: Frequency(frequencyType: FrequencyType.daily, count: 1), diffLevel: Difficulty(difficultyLevel: DifficultyLevel.easy, score: 2), group: group1) + return [resolution1, resolution2] } } diff --git a/VineyardInternal/ToDoListView.swift b/VineyardInternal/ToDoListView.swift index cc66e9a..0fa36c4 100644 --- a/VineyardInternal/ToDoListView.swift +++ b/VineyardInternal/ToDoListView.swift @@ -6,66 +6,33 @@ // import SwiftUI -// -//struct ToDoListView: View { -// var body: some View { -// let placeholder = ["Task 1", "Task 2", "Task 3", "Task 4", "Task 5"] -// -// NavigationView { -// VStack(spacing: 20) { -// ScrollView { -// ForEach(placeholder, id: \.self) { task in -// NavigationLink(destination: ToDoView()) { -// VStack{ -// Text(task) -// Text("Group") -// }.font(.system(size: 25)) -// .foregroundColor(.black) -// .padding(60) -// .frame(maxWidth: .infinity, alignment: .leading) -// .background( -// RoundedRectangle(cornerRadius: 16) -// .fill(Color.gray.opacity(0.2)) -// .padding(5) -// ) -// } -// } -// .padding() -// } -// } -// .navigationTitle("Today's Tasks") -// } -// } -//} -// -//#Preview { -// ToDoListView() -//} -// + struct ToDoListView: View { @StateObject private var viewModel = ToDoViewModel() - + var body: some View { NavigationView { VStack(spacing: 20) { ScrollView { - ForEach(viewModel.groups) { group in - ForEach(group.resolutions) { resolution in - NavigationLink(destination: ToDoView(resolution: resolution, group: group)) { - VStack(alignment: .leading) { - Text(resolution.title) - Text(group.name) - } - .font(.system(size: 25)) - .foregroundColor(.black) - .padding(60) - .frame(maxWidth: .infinity, alignment: .leading) - .background( - RoundedRectangle(cornerRadius: 16) - .fill(Color.gray.opacity(0.2)) - .padding(5) - ) + ForEach(viewModel.person.allProgress) { progress in + + let activityProg = progress.completionArray.count / progress.frequencyGoal.count + NavigationLink(destination: ToDoView(resolution: progress.resolution, group: progress.resolution.groupName)) { + VStack(alignment: .leading) { + Text(progress.resolution.title) + Text(progress.resolution.groupName) +// Text("Progress: \(Int(progress.quantityGoal))") + Text("\(activityProg)") } + .font(.system(size: 25)) + .foregroundColor(.black) + .padding(60) + .frame(maxWidth: .infinity, alignment: .leading) + .background( + RoundedRectangle(cornerRadius: 16) + .fill(Color.gray.opacity(0.2)) + .padding(5) + ) } } .padding() diff --git a/VineyardInternal/ToDoView.swift b/VineyardInternal/ToDoView.swift index fcb9b58..0511ec5 100644 --- a/VineyardInternal/ToDoView.swift +++ b/VineyardInternal/ToDoView.swift @@ -9,7 +9,7 @@ import SwiftUI struct ToDoView: View { var resolution: Resolution - var group: Group + var group: String var body: some View { NavigationView { ScrollView { @@ -17,10 +17,7 @@ struct ToDoView: View { Text(resolution.description).frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/, alignment: .leading) .padding(20) Spacer(minLength: 100) - Text("Group Members:").fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/).font(.system(size: 25)) - ForEach(group.people) {member in - Text(member.name) - } + } } // .frame(maxWidth: .infinity, alignment: .leading) @@ -30,5 +27,5 @@ struct ToDoView: View { } #Preview { - ToDoView(resolution: Resolution.samples[0], group: Group.samples[0]) + ToDoView(resolution: Resolution.samples[0], group: "Group.samples[0]") } diff --git a/VineyardInternal/ToDoViewModel.swift b/VineyardInternal/ToDoViewModel.swift index f8e2d01..428f584 100644 --- a/VineyardInternal/ToDoViewModel.swift +++ b/VineyardInternal/ToDoViewModel.swift @@ -8,9 +8,7 @@ import Foundation class ToDoViewModel: ObservableObject { - @Published var groups: [Group] = Group.samples + @Published var person = Person.samples[0] + - func groupResolutions(for group: Group) -> [Resolution] { - return group.resolutions - } } diff --git a/VineyardInternal/VineyardInternalApp.swift b/VineyardInternal/VineyardInternalApp.swift index 96aba9f..1654611 100644 --- a/VineyardInternal/VineyardInternalApp.swift +++ b/VineyardInternal/VineyardInternalApp.swift @@ -25,7 +25,7 @@ struct VineyardInternalApp: App { var body: some Scene { WindowGroup { - GroupView() + ToDoListView() } } }