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
979fa063
Unverified
Commit
979fa063
authored
Feb 12, 2018
by
Zach Knox
Browse files
getting things prepared for persistent campus filters—not there yet
parent
74a1f621
Changes
3
Show whitespace changes
Inline
Side-by-side
WhatsOpen/WhatsOpen/AppDelegate.swift
View file @
979fa063
...
...
@@ -34,6 +34,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
setAlerts
.
updateValue
(
true
,
forKey
:
"major alerts"
)
defaults
.
set
(
setAlerts
,
forKey
:
"alerts"
)
}
let
campuses
=
defaults
.
dictionary
(
forKey
:
"campuses"
)
if
campuses
==
nil
{
defaults
.
set
([
String
:
Bool
](),
forKey
:
"alerts"
)
}
return
true
}
...
...
WhatsOpen/WhatsOpen/Views/FacilitiesListViewController.swift
View file @
979fa063
...
...
@@ -264,6 +264,24 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
// Facilities
filteredFacilities
=
filters
.
applyFiltersOnFacilities
(
facilitiesArray
)
let
defaults
=
UserDefaults
.
standard
// Campuses
// By the time you've called reloadWithFilters(), the defaults list should already be updated to include
// all campuses via updateFilterLists
let
campusFilters
=
defaults
.
dictionary
(
forKey
:
"campuses"
)
as!
[
String
:
Bool
]?
let
filteredByCampus
=
List
<
Facility
>
()
for
facility
in
filteredFacilities
{
if
campusFilters
!
[(
facility
.
facilityLocation
?
.
campus
.
lowercased
())
!
]
!
{
filteredByCampus
.
append
(
facility
)
}
}
filteredFacilities
=
filteredByCampus
shownFacilities
=
filteredFacilities
favoritesControlChanges
(
self
)
...
...
@@ -272,7 +290,6 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
let
formatter
=
ISO8601DateFormatter
()
formatter
.
timeZone
=
TimeZone
(
identifier
:
"America/New_York"
)
let
now
=
Date
()
let
defaults
=
UserDefaults
.
standard
let
alertFilers
=
defaults
.
dictionary
(
forKey
:
"alerts"
)
as!
[
String
:
Bool
]?
for
alert
in
alertsList
{
if
now
.
isGreaterThanDate
(
dateToCompare
:
formatter
.
date
(
from
:
alert
.
startDate
)
!
)
&&
now
.
isLessThanDate
(
dateToCompare
:
formatter
.
date
(
from
:
alert
.
endDate
)
!
)
{
...
...
@@ -413,6 +430,8 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
func
updateFiltersLists
()
{
// Add locations and categories to filters
let
defaults
=
UserDefaults
.
standard
var
campusFilters
=
defaults
.
dictionary
(
forKey
:
"campuses"
)
as!
[
String
:
Bool
]?
for
f
in
facilitiesArray
{
if
(
!
filters
.
onlyFromCategories
.
keys
.
contains
((
f
.
category
?
.
categoryName
)
!
))
{
filters
.
onlyFromCategories
.
updateValue
(
true
,
forKey
:
(
f
.
category
?
.
categoryName
)
!.
lowercased
())
...
...
@@ -420,10 +439,11 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
if
(
!
filters
.
onlyFromLocations
.
keys
.
contains
((
f
.
facilityLocation
?
.
building
)
!
))
{
filters
.
onlyFromLocations
.
updateValue
(
true
,
forKey
:
(
f
.
facilityLocation
?
.
building
)
!.
lowercased
())
}
if
(
!
filters
.
onlyFromCampuses
.
keys
.
contains
((
f
.
facilityLocation
?
.
campus
)
!
))
{
filters
.
onlyFromCampuses
.
updateValue
(
true
,
forKey
:
(
f
.
facilityLocation
?
.
campus
)
!.
lowercased
())
if
(
!
campusFilters
!
.
keys
.
contains
((
f
.
facilityLocation
?
.
campus
)
!
))
{
campusFilters
!
.
updateValue
(
true
,
forKey
:
(
f
.
facilityLocation
?
.
campus
)
!.
lowercased
())
}
}
defaults
.
set
(
campusFilters
,
forKey
:
"campuses"
)
}
/*
...
...
WhatsOpen/WhatsOpen/Views/SettingsTableViewController.swift
View file @
979fa063
...
...
@@ -58,7 +58,7 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
return
1
}
else
if
(
section
==
2
)
{
return
1
return
2
}
else
if
(
section
==
3
)
{
return
3
...
...
@@ -84,20 +84,27 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"settingSelection"
,
for
:
indexPath
)
cell
.
accessoryType
=
.
disclosureIndicator
switch
indexPath
.
row
{
case
0
:
cell
.
textLabel
?
.
text
=
"Show Alerts"
/*
let defaults = UserDefaults.standard
let alertsFromDefaults = defaults.dictionary(forKey: "alerts")
if alertsFromDefaults == nil {
var setAlerts = [String: Bool]()
setAlerts.updateValue(true, forKey: "Informational")
setAlerts.updateValue(true, forKey: "Minor Alerts")
setAlerts.updateValue(true, forKey: "Major Alerts")
defaults.set(setAlerts, forKey: "alerts")
let
alerts
=
Utilities
.
getAlertDefaults
()
var
i
=
0
for
c
in
alerts
{
if
(
c
.
value
==
true
)
{
i
+=
1
}
*/
}
var
detail
:
String
if
(
i
==
alerts
.
count
)
{
detail
=
"All Selected"
}
else
{
detail
=
"
\(
i
)
Selected"
}
cell
.
detailTextLabel
?
.
text
=
detail
return
cell
case
1
:
cell
.
textLabel
?
.
text
=
"Show Campuses"
let
alerts
=
Utilities
.
getAlertDefaults
()
var
i
=
0
for
c
in
alerts
{
...
...
@@ -114,6 +121,10 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
}
cell
.
detailTextLabel
?
.
text
=
detail
return
cell
default
:
return
UITableViewCell
()
// don't do this
}
case
3
:
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"Setting"
,
for
:
indexPath
)
as!
SettingTableViewCell
switch
indexPath
.
row
{
...
...
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