Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open-ios
Commits
ae027603
Unverified
Commit
ae027603
authored
Dec 15, 2017
by
Zach Knox
Browse files
added a few helper functions and some TODOs
parent
1a53b05a
Changes
2
Hide whitespace changes
Inline
Side-by-side
WhatsOpen/WhatsOpen/Filters.swift
View file @
ae027603
...
...
@@ -16,14 +16,21 @@ class Filters {
var
sortBy
=
SortMethod
.
alphabetical
var
openFirst
=
true
var
onlyFromLocations
=
[
Locations
]()
// Locations to show, could simply use Location objects instead if you wanted
var
onlyFromCategories
=
[
Categories
]()
//same as above, but for Categories, not Locations
//can check these using the .equals() functions in Locations and Categories
init
()
{
//nothing to do here
}
func
applyFiltersOnFacilities
(
_
facilities
:
[
Facility
])
->
[
Facility
]
{
let
(
open
,
closed
)
=
separateOpenAndClosed
(
facilities
)
//TODO: Add checks for onlyFromLocations and onlyFromCategories here before doing the rest
let
(
open
,
closed
)
=
separateOpenAndClosed
(
facilities
)
//
I imagine that a function per enum may be more useful than this switch statement of copied code, but whatever
//
This switch statement figures out what sort method is being used, and will sort accordingly
switch
sortBy
{
case
.
alphabetical
:
if
(
openFirst
)
{
...
...
@@ -102,19 +109,22 @@ class Filters {
}
}
}
//TODO
// 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
([],
[])
}
//TODO
// Sorts items in the given Facility array by name alphabetically (reverse if told)
private
func
sortAlphabetically
(
_
facilities
:
[
Facility
],
reverse
:
Bool
=
false
)
->
[
Facility
]
{
return
[]
}
//TODO
// Sorts Facilities by their given location's name, and within those sorts A->Z
private
func
sortByLocation
(
_
facilities
:
[
Facility
])
->
[
Facility
]
{
...
...
WhatsOpen/WhatsOpen/Object Model/examplejson.swift
View file @
ae027603
...
...
@@ -65,6 +65,18 @@ class Locations: Object, Mappable {
campus
<-
map
[
"campus_region"
]
onCampus
<-
map
[
"on_campus"
]
}
func
equals
(
_
another
:
Locations
)
->
Bool
{
if
self
.
building
==
another
.
building
&&
self
.
address
==
another
.
address
&&
self
.
campus
==
another
.
campus
&&
self
.
onCampus
==
another
.
onCampus
{
return
true
}
else
{
return
false
}
}
}
...
...
@@ -83,6 +95,10 @@ class Categories: Object, Mappable {
modified
<-
map
[
"modified"
]
categoryName
<-
map
[
"name"
]
}
func
equals
(
_
another
:
Categories
)
->
Bool
{
return
another
.
categoryName
==
self
.
categoryName
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment