Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified Progress and resolution model/samples and modified ToDoListView #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
20 changes: 13 additions & 7 deletions VineyardInternal/Progress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@ struct Progress: Identifiable {
// //}

static var samples: [Progress] {

var andrew = Person(name: "Andrew", email: "[email protected]")
var yash = Person(name: "Yash", email: "[email protected]")
var sankaet = Person(name: "Sankaet", email: "[email protected]")
var rahul = Person(name: "Rahul", email: "[email protected]")
var vishnesh = Person(name: "Vishnesh", email: "[email protected]")


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]
}
Expand Down
38 changes: 27 additions & 11 deletions VineyardInternal/Resolution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
}
73 changes: 20 additions & 53 deletions VineyardInternal/ToDoListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 3 additions & 6 deletions VineyardInternal/ToDoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ import SwiftUI

struct ToDoView: View {
var resolution: Resolution
var group: Group
var group: String
var body: some View {
NavigationView {
ScrollView {
VStack {
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)
Expand All @@ -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]")
}
6 changes: 2 additions & 4 deletions VineyardInternal/ToDoViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion VineyardInternal/VineyardInternalApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct VineyardInternalApp: App {

var body: some Scene {
WindowGroup {
GroupView()
ToDoListView()
}
}
}