Unverified Commit 30dd2546 authored by Zach Knox's avatar Zach Knox
Browse files

skeleton functions for Filters

No actual logic yet, just planning things out
parent 791ba248
......@@ -10,25 +10,53 @@ import Foundation
//This may be a stupid way to handle filters, but it should work; at least for now
struct Filters {
class Filters {
var showOpen = true
var showClosed = true
var sortBy = SortMethod.alphabetical
var allAllFacilities = true
var openFirst = true
init() {
//nothing to do here
}
func applyFiltersOnFacilities(_ facilities: [Facility]) -> [Facility] {
return []
}
// Takes in array of Facilities, separates them into those open and closed, returning a tuple of 2 arrays
private func separateOpenAndClosed(_ facilities: [Facility]) -> (open: [Facility], closed: [Facility]) {
return ([], [])
}
// Sorts items in the given Facility array by name alphabetically (reverse if told)
private func sortAlphabetically(_ facilities: [Facility], reverse: Bool = false) -> [Facility] {
return []
}
// Sorts Facilities by their given location's name, and within those sorts A->Z
private func sortByLocation(_ facilities: [Facility]) -> [Facility] {
return []
}
}
//Is this a viable way to do this?
enum SortMethod {
case alphabetical //A -> Z
case reverseAlphabetical //Z -> A
case openLongest //Places things open longest on top; if only showing closed, shows opening soonest
case openShortest //Places things closing soonest on top; if only showing closed, shows opening furthest from now
case byLocation // A -> Z Locations, w/ A -> Z Facilities inside
//case openLongest //Places things open longest on top; if only showing closed, shows opening soonest
//case openShortest //Places things closing soonest on top; if only showing closed, shows opening furthest from now
//We should figure out how we want to allow sorting
}
......@@ -27,11 +27,10 @@ class Utilities: NSObject {
if today(facility: facility) != nil {
open = time(facility)
}
}
}
} else {
open = false
}
open = false
}
}
return open
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment