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
5b298bce
Unverified
Commit
5b298bce
authored
Jan 18, 2018
by
Zach Knox
Browse files
a good start on persistence, incomplete
parent
0e4dc8d1
Changes
7
Hide whitespace changes
Inline
Side-by-side
WhatsOpen/WhatsOpen/AppDelegate.swift
View file @
5b298bce
...
...
@@ -25,6 +25,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
Fabric
.
with
([
Crashlytics
.
self
])
#endif
let
defaults
=
UserDefaults
.
standard
let
alerts
=
defaults
.
dictionary
(
forKey
:
"alerts"
)
if
alerts
==
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"
)
}
return
true
}
...
...
WhatsOpen/WhatsOpen/Base.lproj/Main.storyboard
View file @
5b298bce
...
...
@@ -145,7 +145,7 @@
</tableViewController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"5t1-ko-HSd"
userLabel=
"First Responder"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"-8
599
"
y=
"
362
"
/>
<point
key=
"canvasLocation"
x=
"-8
153
"
y=
"
448
"
/>
</scene>
<!--What's Open-->
<scene
sceneID=
"w5e-Fb-rsR"
>
...
...
@@ -376,6 +376,33 @@
<autoresizingMask
key=
"autoresizingMask"
/>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell
clipsSubviews=
"YES"
contentMode=
"scaleToFill"
preservesSuperviewLayoutMargins=
"YES"
selectionStyle=
"default"
accessoryType=
"disclosureIndicator"
indentationWidth=
"10"
reuseIdentifier=
"settingSelection"
textLabel=
"uld-Wy-NHl"
detailTextLabel=
"D5h-89-67A"
style=
"IBUITableViewCellStyleValue1"
id=
"tdz-HQ-rmz"
>
<rect
key=
"frame"
x=
"0.0"
y=
"99.5"
width=
"375"
height=
"44"
/>
<autoresizingMask
key=
"autoresizingMask"
/>
<tableViewCellContentView
key=
"contentView"
opaque=
"NO"
clipsSubviews=
"YES"
multipleTouchEnabled=
"YES"
contentMode=
"center"
preservesSuperviewLayoutMargins=
"YES"
insetsLayoutMarginsFromSafeArea=
"NO"
tableViewCell=
"tdz-HQ-rmz"
id=
"H43-kY-wZi"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"341"
height=
"43.5"
/>
<autoresizingMask
key=
"autoresizingMask"
/>
<subviews>
<label
opaque=
"NO"
multipleTouchEnabled=
"YES"
contentMode=
"left"
insetsLayoutMarginsFromSafeArea=
"NO"
text=
"Title"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
id=
"uld-Wy-NHl"
>
<rect
key=
"frame"
x=
"16"
y=
"12"
width=
"33.5"
height=
"20.5"
/>
<autoresizingMask
key=
"autoresizingMask"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"17"
/>
<nil
key=
"textColor"
/>
<nil
key=
"highlightedColor"
/>
</label>
<label
opaque=
"NO"
multipleTouchEnabled=
"YES"
contentMode=
"left"
insetsLayoutMarginsFromSafeArea=
"NO"
text=
"Detail"
textAlignment=
"right"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
id=
"D5h-89-67A"
>
<rect
key=
"frame"
x=
"296"
y=
"12"
width=
"44"
height=
"20.5"
/>
<autoresizingMask
key=
"autoresizingMask"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"17"
/>
<nil
key=
"textColor"
/>
<nil
key=
"highlightedColor"
/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue
destination=
"yIT-AR-gdn"
kind=
"show"
identifier=
"settingSelection"
id=
"b6G-Gf-D4M"
/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet
property=
"dataSource"
destination=
"Lhp-lE-ieb"
id=
"B56-3p-ltP"
/>
...
...
@@ -844,5 +871,8 @@
<image
name=
"info"
width=
"266"
height=
"266"
/>
<image
name=
"major"
width=
"266"
height=
"266"
/>
</resources>
<inferredMetricsTieBreakers>
<segue
reference=
"b6G-Gf-D4M"
/>
</inferredMetricsTieBreakers>
<color
key=
"tintColor"
red=
"0.0"
green=
"0.40000000000000002"
blue=
"0.20000000000000001"
alpha=
"1"
colorSpace=
"calibratedRGB"
/>
</document>
WhatsOpen/WhatsOpen/SRCTUtilities.swift
View file @
5b298bce
...
...
@@ -313,10 +313,17 @@ class Utilities: NSObject {
- returns:
true if the alerts was added correctly.
*/
static
func
setAlertDefaults
(
_
alerts
:
[
String
:
Bool
]
)
->
Bool
{
static
func
setAlertDefaults
(
_
key
:
String
,
value
:
Bool
)
->
Bool
{
let
defaults
=
UserDefaults
.
standard
defaults
.
set
(
alerts
,
forKey
:
"alerts"
)
return
true
var
alerts
=
defaults
.
dictionary
(
forKey
:
"alerts"
)
as!
[
String
:
Bool
]?
if
alerts
!=
nil
{
alerts
!.
updateValue
(
value
,
forKey
:
key
)
defaults
.
set
(
alerts
,
forKey
:
"alerts"
)
return
true
}
else
{
return
false
}
}
/**
...
...
@@ -325,15 +332,22 @@ class Utilities: NSObject {
- returns:
true if the alerts was changed correctly, false if nil was retrieved from User Defaults.
*/
static
func
setAllAlertDefaults
True
()
->
Bool
{
static
func
setAllAlertDefaults
()
->
Bool
{
let
defaults
=
UserDefaults
.
standard
let
alerts
=
defaults
.
dictionary
(
forKey
:
"alerts"
)
as!
[
String
:
Bool
]?
var
newAlerts
:
[
String
:
Bool
]
=
[:]
var
alerts
=
defaults
.
dictionary
(
forKey
:
"alerts"
)
as!
[
String
:
Bool
]?
if
alerts
!=
nil
{
var
foundFalse
=
false
for
a
in
alerts
!
{
if
a
.
value
==
false
{
foundFalse
=
true
break
}
}
for
alert
in
alerts
!
{
newA
lerts
.
updateValue
(
tru
e
,
forKey
:
alert
.
key
)
a
lerts
!
.
updateValue
(
!
foundFals
e
,
forKey
:
alert
.
key
)
}
defaults
.
set
(
newA
lerts
,
forKey
:
"alerts"
)
defaults
.
set
(
a
lerts
,
forKey
:
"alerts"
)
return
true
}
else
{
...
...
@@ -347,9 +361,15 @@ class Utilities: NSObject {
- returns:
item stored in User Defaults for key 'alerts'
*/
static
func
getAlertDefaults
()
->
[
String
:
Bool
]
?
{
static
func
getAlertDefaults
()
->
[
String
:
Bool
]
{
let
defaults
=
UserDefaults
.
standard
return
defaults
.
dictionary
(
forKey
:
"alerts"
)
as!
[
String
:
Bool
]?
let
returning
=
defaults
.
dictionary
(
forKey
:
"alerts"
)
as!
[
String
:
Bool
]?
if
returning
==
nil
{
return
[:]
}
else
{
return
returning
!
}
}
}
...
...
WhatsOpen/WhatsOpen/Views/FacilitiesListViewController.swift
View file @
5b298bce
...
...
@@ -148,12 +148,6 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
return
}
}
for
f
in
filters
.
showAlerts
{
if
(
f
.
value
!=
true
)
{
LeftButton
.
title
=
"Filter (On)"
return
}
}
LeftButton
.
title
=
"Filter"
return
}
...
...
@@ -278,19 +272,21 @@ 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
)
!
)
{
switch
alert
.
urgency
{
case
"info"
:
if
(
filters
.
showA
ler
t
s
[
"Informational"
])
!
{
if
(
alertFi
lers
!
[
"Informational"
])
!
{
shown
.
append
(
alert
)
}
case
"minor"
:
if
(
filters
.
showA
ler
t
s
[
"Minor Alerts"
])
!
{
if
(
alertFi
lers
!
[
"Minor Alerts"
])
!
{
shown
.
append
(
alert
)
}
case
"major"
:
if
(
filters
.
showA
ler
t
s
[
"Major Alerts"
])
!
{
if
(
alertFi
lers
!
[
"Major Alerts"
])
!
{
shown
.
append
(
alert
)
}
default
:
...
...
WhatsOpen/WhatsOpen/Views/FilterSelectionTableViewController.swift
View file @
5b298bce
...
...
@@ -73,7 +73,7 @@ class FilterSelectionTableViewController: UITableViewController {
}
override
func
tableView
(
_
tableView
:
UITableView
,
titleForFooterInSection
section
:
Int
)
->
String
?
{
if
navigationItem
.
title
==
"Alerts"
{
if
navigationItem
.
title
==
"
Show
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
...
...
WhatsOpen/WhatsOpen/Views/FiltersTableViewController.swift
View file @
5b298bce
...
...
@@ -90,7 +90,7 @@ class FiltersTableViewController: UITableViewController {
case
2
:
return
SortMethod
.
count
case
3
:
return
4
return
3
default
:
return
0
}
...
...
@@ -221,22 +221,6 @@ class FiltersTableViewController: UITableViewController {
detail
=
"
\(
i
)
Selected"
}
cell
.
detailTextLabel
?
.
text
=
detail
case
3
:
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
}
...
...
WhatsOpen/WhatsOpen/Views/SettingsTableViewController.swift
View file @
5b298bce
...
...
@@ -42,8 +42,7 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
// MARK: - Table view data source
override
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
// #warning Incomplete implementation, return the number of sections
return
3
return
4
}
override
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
...
...
@@ -55,6 +54,9 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
return
1
}
else
if
(
section
==
2
)
{
return
1
}
else
if
(
section
==
3
)
{
return
3
}
else
{
...
...
@@ -63,15 +65,53 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
}
override
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"Setting"
,
for
:
indexPath
)
as!
SettingTableViewCell
switch
indexPath
.
section
{
case
0
:
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"Setting"
,
for
:
indexPath
)
as!
SettingTableViewCell
cell
.
textLabel
!.
text
=
"Are Our Hours Wrong?"
return
cell
case
1
:
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"Setting"
,
for
:
indexPath
)
as!
SettingTableViewCell
cell
.
textLabel
!.
text
=
"Select App Icon"
cell
.
accessoryType
=
.
disclosureIndicator
return
cell
case
2
:
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"settingSelection"
,
for
:
indexPath
)
cell
.
accessoryType
=
.
disclosureIndicator
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
3
:
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"Setting"
,
for
:
indexPath
)
as!
SettingTableViewCell
switch
indexPath
.
row
{
case
0
:
cell
.
textLabel
!.
text
=
"Review on the App Store"
...
...
@@ -83,18 +123,13 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
default
:
cell
.
textLabel
!.
text
=
"rip"
}
if
indexPath
.
row
==
0
{
}
else
if
indexPath
.
row
==
1
{
}
return
cell
default
:
break
}
// Configure the cell...
return
cell
return
tableView
.
dequeueReusableCell
(
withIdentifier
:
"Setting"
,
for
:
indexPath
)
as!
SettingTableViewCell
// don't let this happen
}
override
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
...
...
@@ -126,21 +161,13 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
self
.
show
(
vc
!
,
sender
:
settingcell
)
}
else
if
settingcell
.
textLabel
?
.
text
==
"Review on the App Store"
{
let
appPage
=
SKStoreProductViewController
()
let
params
=
[
SKStoreProductParameterITunesItemIdentifier
:
1331260366
]
appPage
.
loadProduct
(
withParameters
:
params
,
completionBlock
:
{
(
result
,
err
)
in
if
err
==
nil
&&
result
==
true
{
self
.
present
(
appPage
,
animated
:
true
)
print
(
"presenting"
)
}
else
{
let
alert
=
UIAlertController
(
title
:
"Cound Not Find App in Store"
,
message
:
"Check your network connection"
,
preferredStyle
:
.
alert
)
alert
.
addAction
(
UIAlertAction
(
title
:
NSLocalizedString
(
"OK"
,
comment
:
"Default action"
),
style
:
.
`
default
`,
handler
:
{
_
in
}))
self
.
present
(
alert
,
animated
:
true
)
print
(
"alerting"
)
}
})
let
appId
=
"1331260366"
let
urlString
=
"itms-apps://itunes.apple.com/us/app/whats-open-at-mason/id
\(
appId
)
?action=write-review"
if
let
url
=
URL
(
string
:
urlString
)
{
UIApplication
.
shared
.
open
((
url
),
options
:
[:],
completionHandler
:
nil
)
}
}
else
if
settingcell
.
textLabel
!.
text
==
"About What's Open"
{
let
avc
=
self
.
storyboard
?
.
instantiateViewController
(
withIdentifier
:
"about"
)
...
...
@@ -206,14 +233,22 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override
func
prepare
(
for
segue
:
UIStoryboardSegue
,
sender
:
Any
?)
{
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
if
segue
.
identifier
==
"settingSelection"
{
let
destination
=
segue
.
destination
as!
FilterSelectionTableViewController
destination
.
navigationItem
.
title
=
"Show Alerts"
destination
.
getFunc
=
Utilities
.
getAlertDefaults
destination
.
selectFunc
=
Utilities
.
setAlertDefaults
destination
.
selectAllFunc
=
Utilities
.
setAllAlertDefaults
}
}
*/
}
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