Skip to content

Commit

Permalink
fix: classes are sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
Chandram-Dutta committed Jan 8, 2024
1 parent 68b35c6 commit 8b43668
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 7 additions & 1 deletion VITTY/VITTY/Core/Model/Classes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

import Foundation

struct Classes: Hashable, Codable {
struct Classes: Hashable, Codable, Comparable {

static func < (lhs: Classes, rhs: Classes) -> Bool {
return lhs.startTime! < rhs.startTime!
}

var courseType: String?
var courseCode: String?
var courseName: String?
Expand All @@ -26,6 +31,7 @@ struct Classes: Hashable, Codable {
case location = "location"
case slot = "slot"
}


}

Expand Down
3 changes: 1 addition & 2 deletions VITTY/VITTY/Core/Schedule/View/SchedulePage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ extension SchedulePage {
func timeTableView() -> some View {
ScrollView {
ForEach(timetableViewModel.timetable.keys.sorted(), id: \.self) { day in
ForEach(timetableViewModel.timetable[day] ?? [], id: \.self) { classes in

ForEach(timetableViewModel.timetable[day]?.sorted() ?? [], id: \.self) { classes in
if day.description.lowercased() == TimetableViewModel.daysOfTheWeek[tabSelected]
{
ClassCards(classInfo: classes)
Expand Down

0 comments on commit 8b43668

Please sign in to comment.