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
358dbe6e
Unverified
Commit
358dbe6e
authored
Jan 05, 2018
by
Zach Knox
Browse files
alert filters
parent
9b7b4243
Changes
4
Hide whitespace changes
Inline
Side-by-side
WhatsOpen/WhatsOpen/Filters.swift
View file @
358dbe6e
...
...
@@ -17,7 +17,7 @@ class Filters {
var
sortBy
=
SortMethod
.
alphabetical
var
openFirst
=
true
var
showAlerts
=
[
"
i
nfo"
:
true
,
"
m
inor"
:
true
,
"
m
ajor"
:
true
]
var
showAlerts
=
[
"
I
nfo
rmational
"
:
true
,
"
M
inor
Alerts
"
:
true
,
"
M
ajor
Alerts
"
:
true
]
var
onlyFromLocations
=
[
String
:
Bool
]()
// Locations to show, could simply use Location objects instead if you wanted
var
onlyFromCategories
=
[
String
:
Bool
]()
//same as above, but for Categories, not Locations
...
...
WhatsOpen/WhatsOpen/Views/FacilitiesListViewController.swift
View file @
358dbe6e
...
...
@@ -138,6 +138,12 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
return
}
}
for
f
in
filters
.
showAlerts
{
if
(
f
.
value
!=
true
)
{
LeftButton
.
title
=
"Filter (On)"
return
}
}
LeftButton
.
title
=
"Filter"
return
}
...
...
@@ -252,7 +258,22 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
let
now
=
Date
()
for
alert
in
alertsList
{
if
now
.
isGreaterThanDate
(
dateToCompare
:
formatter
.
date
(
from
:
alert
.
startDate
)
!
)
&&
now
.
isLessThanDate
(
dateToCompare
:
formatter
.
date
(
from
:
alert
.
endDate
)
!
)
{
shown
.
append
(
alert
)
switch
alert
.
urgency
{
case
"info"
:
if
(
filters
.
showAlerts
[
"Informational"
])
!
{
shown
.
append
(
alert
)
}
case
"minor"
:
if
(
filters
.
showAlerts
[
"Minor Alerts"
])
!
{
shown
.
append
(
alert
)
}
case
"major"
:
if
(
filters
.
showAlerts
[
"Major Alerts"
])
!
{
shown
.
append
(
alert
)
}
default
:
shown
.
append
(
alert
)
}
}
}
currentAlerts
=
shown
...
...
@@ -483,7 +504,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
numberOfItemsInSection
section
:
Int
)
->
Int
{
if
(
section
==
1
||
a
lerts
List
.
count
==
0
)
{
if
(
section
==
1
||
currentA
lerts
.
count
==
0
)
{
return
shownFacilities
.
count
}
else
{
...
...
@@ -495,7 +516,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
if
(
indexPath
.
section
==
1
||
a
lerts
List
.
count
==
0
)
{
if
(
indexPath
.
section
==
1
||
currentA
lerts
.
count
==
0
)
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
"CollectionCell"
,
for
:
indexPath
)
as!
FacilityCollectionViewCell
/*
let windowRect = self.view.window!.frame
...
...
@@ -594,7 +615,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
layout
collectionViewLayout
:
UICollectionViewLayout
,
sizeForItemAt
indexPath
:
IndexPath
)
->
CGSize
{
if
(
indexPath
.
section
==
1
||
a
lerts
List
.
count
==
0
)
{
if
(
indexPath
.
section
==
1
||
currentA
lerts
.
count
==
0
)
{
let
height
=
LocationsListLayout
.
itemSize
.
height
let
width
:
CGFloat
...
...
WhatsOpen/WhatsOpen/Views/FilterSelectionTableViewController.swift
View file @
358dbe6e
...
...
@@ -78,6 +78,13 @@ class FilterSelectionTableViewController: UITableViewController {
return
cell
}
override
func
tableView
(
_
tableView
:
UITableView
,
titleForFooterInSection
section
:
Int
)
->
String
?
{
if
navigationItem
.
title
==
"Alerts"
{
return
"Emergency Alerts are always enabled in the app for your safety. We will never send a notification to your device without your consent."
}
return
nil
}
override
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
if
(
indexPath
.
row
==
0
)
{
selectAllFunc
()
...
...
WhatsOpen/WhatsOpen/Views/FiltersTableViewController.swift
View file @
358dbe6e
...
...
@@ -90,7 +90,7 @@ class FiltersTableViewController: UITableViewController {
case
2
:
return
SortMethod
.
count
case
3
:
return
2
return
3
default
:
return
0
}
...
...
@@ -205,6 +205,22 @@ class FiltersTableViewController: UITableViewController {
detail
=
"
\(
i
)
Selected"
}
cell
.
detailTextLabel
?
.
text
=
detail
case
2
:
cell
.
textLabel
?
.
text
=
"Alerts"
var
i
=
0
for
c
in
filters
.
showAlerts
{
if
(
c
.
value
==
true
)
{
i
+=
1
}
}
var
detail
:
String
if
(
i
==
filters
.
showAlerts
.
count
)
{
detail
=
"All Selected"
}
else
{
detail
=
"
\(
i
)
Selected"
}
cell
.
detailTextLabel
?
.
text
=
detail
default
:
return
cell
}
...
...
@@ -292,10 +308,14 @@ class FiltersTableViewController: UITableViewController {
let
destination
=
segue
.
destination
as!
FilterSelectionTableViewController
destination
.
navigationItem
.
title
=
(
sender
as!
UITableViewCell
)
.
textLabel
?
.
text
!
func
get
()
->
[
String
:
Bool
]
{
if
((
sender
as!
UITableViewCell
)
.
textLabel
?
.
text
!
==
"Categories"
)
{
return
filters
.
onlyFromCategories
}
else
if
(
sender
as!
UITableViewCell
)
.
textLabel
?
.
text
!
==
"Alerts"
{
return
filters
.
showAlerts
}
else
{
return
filters
.
onlyFromLocations
}
...
...
@@ -304,6 +324,9 @@ class FiltersTableViewController: UITableViewController {
if
((
sender
as!
UITableViewCell
)
.
textLabel
?
.
text
!
==
"Categories"
)
{
filters
.
onlyFromCategories
[
key
]
=
value
}
else
if
(
sender
as!
UITableViewCell
)
.
textLabel
?
.
text
!
==
"Alerts"
{
filters
.
showAlerts
[
key
]
=
value
}
else
{
filters
.
onlyFromLocations
[
key
]
=
value
}
...
...
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