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
8dc14266
Unverified
Commit
8dc14266
authored
Dec 30, 2017
by
Zach Knox
Browse files
lots more progress on filters UI
parent
7bcf2fcf
Changes
7
Hide whitespace changes
Inline
Side-by-side
WhatsOpen/WhatsOpen/Base.lproj/Main.storyboard
View file @
8dc14266
...
...
@@ -53,16 +53,16 @@
<autoresizingMask
key=
"autoresizingMask"
/>
<subviews>
<pickerView
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"Rpt-Of-2BY"
>
<rect
key=
"frame"
x=
"0.0"
y=
"
0.
0"
width=
"375"
height=
"
157
"
/>
<rect
key=
"frame"
x=
"0.0"
y=
"
-3
0"
width=
"375"
height=
"
216
"
/>
</pickerView>
</subviews>
<constraints>
<constraint
firstItem=
"Rpt-Of-2BY"
firstAttribute=
"top"
secondItem=
"gyt-MF-bQ2"
secondAttribute=
"topMargin"
constant=
"-41"
id=
"7mi-Wh-JBQ"
/>
<constraint
firstItem=
"Rpt-Of-2BY"
firstAttribute=
"centerY"
secondItem=
"gyt-MF-bQ2"
secondAttribute=
"centerY"
id=
"NoV-nt-cIb"
/>
<constraint
firstItem=
"Rpt-Of-2BY"
firstAttribute=
"leading"
secondItem=
"gyt-MF-bQ2"
secondAttribute=
"leading"
id=
"eka-9S-DfO"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"Rpt-Of-2BY"
secondAttribute=
"trailing"
id=
"tBC-fA-0Nf"
/>
</constraints>
</tableViewCellContentView>
<constraints>
<constraint
firstItem=
"Rpt-Of-2BY"
firstAttribute=
"centerX"
secondItem=
"Qzo-pS-g9l"
secondAttribute=
"centerX"
id=
"CjR-K6-Sgm"
/>
<constraint
firstItem=
"Rpt-Of-2BY"
firstAttribute=
"width"
secondItem=
"Qzo-pS-g9l"
secondAttribute=
"width"
id=
"d22-Bv-Rtp"
/>
<constraint
firstItem=
"Rpt-Of-2BY"
firstAttribute=
"height"
secondItem=
"Qzo-pS-g9l"
secondAttribute=
"height"
id=
"eS7-jA-ZGG"
/>
<constraint
firstItem=
"Rpt-Of-2BY"
firstAttribute=
"centerY"
secondItem=
"Qzo-pS-g9l"
secondAttribute=
"centerY"
id=
"ejW-ir-L9k"
/>
</constraints>
<connections>
<outlet
property=
"pickerView"
destination=
"Rpt-Of-2BY"
id=
"ek7-I8-MFW"
/>
</connections>
...
...
@@ -160,6 +160,7 @@
<constraint
firstItem=
"6QR-8Q-n4s"
firstAttribute=
"width"
secondItem=
"uhu-6U-8Tx"
secondAttribute=
"width"
id=
"Ftl-Xc-Ebe"
/>
<constraint
firstItem=
"o7N-To-w50"
firstAttribute=
"leading"
secondItem=
"6qn-VX-mZx"
secondAttribute=
"leading"
constant=
"4"
id=
"SX9-Zt-4A1"
/>
<constraint
firstItem=
"6QR-8Q-n4s"
firstAttribute=
"top"
secondItem=
"uhu-6U-8Tx"
secondAttribute=
"bottom"
constant=
"-3"
id=
"eIM-MS-uXs"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"6QR-8Q-n4s"
secondAttribute=
"trailing"
constant=
"5"
id=
"fPa-e2-kxS"
/>
<constraint
firstAttribute=
"bottom"
secondItem=
"DEx-BH-Fun"
secondAttribute=
"bottom"
constant=
"6"
id=
"kFY-Lf-EkL"
/>
<constraint
firstItem=
"DEx-BH-Fun"
firstAttribute=
"leading"
secondItem=
"6qn-VX-mZx"
secondAttribute=
"leading"
constant=
"4"
id=
"khv-Ot-qRM"
/>
<constraint
firstItem=
"uhu-6U-8Tx"
firstAttribute=
"top"
secondItem=
"6qn-VX-mZx"
secondAttribute=
"top"
constant=
"8"
id=
"yOA-sO-1or"
/>
...
...
WhatsOpen/WhatsOpen/CheckingTableViewCell.swift
View file @
8dc14266
...
...
@@ -12,6 +12,8 @@ class CheckingTableViewCell: UITableViewCell {
var
onlyOne
:
OnlyOneChecked
!
var
cellIndex
:
Int
!
var
selectingEnum
:
Any
?
var
selectFunc
:
((
Any
?)
->
Bool
)
!
override
func
awakeFromNib
()
{
super
.
awakeFromNib
()
...
...
WhatsOpen/WhatsOpen/Filters.swift
View file @
8dc14266
...
...
@@ -16,8 +16,9 @@ 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
// TODO: Deal with these
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
//can check these using the .equals() functions in Locations and Categories
...
...
WhatsOpen/WhatsOpen/PickingTableViewCell.swift
View file @
8dc14266
...
...
@@ -11,16 +11,17 @@ import UIKit
class
PickingTableViewCell
:
UITableViewCell
,
UIPickerViewDelegate
,
UIPickerViewDataSource
{
@IBOutlet
var
pickerView
:
UIPickerView
!
var
pickerStrings
:
[
String
]
!
var
pickerStrings
:
[
String
]
=
[
String
]()
var
pickerItems
:
[
Any
?]
!
//literally just here for convienence
var
pickerChecked
:
[
Bool
]
!
//Should I use a dictionary? maybe, but this is way easier
var
pickerChecked
=
[
Bool
]
()
//Should I use a dictionary? maybe, but this is way easier
var
pickFunc
:
((
String
?)
->
Bool
)
!
override
func
awakeFromNib
()
{
super
.
awakeFromNib
()
self
.
selectionStyle
=
.
none
pickerView
.
dataSource
=
self
pickerView
.
delegate
=
self
super
.
awakeFromNib
()
// Initialization code
}
...
...
WhatsOpen/WhatsOpen/SwitchingTableViewCell.swift
View file @
8dc14266
...
...
@@ -18,6 +18,7 @@ class SwitchingTableViewCell: UITableViewCell {
// Initialization code
switchControl
.
addTarget
(
self
,
action
:
#selector(
toggleSwitch
)
,
for
:
.
valueChanged
)
self
.
accessoryView
=
switchControl
self
.
selectionStyle
=
.
none
}
override
func
setSelected
(
_
selected
:
Bool
,
animated
:
Bool
)
{
...
...
WhatsOpen/WhatsOpen/Views/FacilitiesListViewController.swift
View file @
8dc14266
...
...
@@ -218,7 +218,20 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
*/
refresh
(
self
,
forceUpdate
:
false
)
// Add locations and categories to filters
for
f
in
facilitiesArray
{
if
(
!
filters
.
onlyFromCategories
.
keys
.
contains
((
f
.
category
?
.
categoryName
)
!
))
{
filters
.
onlyFromCategories
.
updateValue
(
true
,
forKey
:
(
f
.
category
?
.
categoryName
)
!
)
}
if
(
!
filters
.
onlyFromLocations
.
keys
.
contains
((
f
.
facilityLocation
?
.
building
)
!
))
{
filters
.
onlyFromLocations
.
updateValue
(
true
,
forKey
:
(
f
.
facilityLocation
?
.
building
)
!
)
}
}
LocationsList
.
reloadData
()
}
...
...
@@ -490,30 +503,31 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
// 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.
// if(segue.identifier == "toDetailView") {
// let destination = segue.destination as! FacilityDetailViewController
// let destDelegate = DeckTransitioningDelegate()
// destination.transitioningDelegate = destDelegate
// let tapped = sender as! FacilityCollectionViewCell //this is probably a bad idea just FYI future me
// destination.facility = tapped.facility
//
// // if we're in the search view, present on its controller
// if searchController.isActive {
// searchController.present(destination, animated: true, completion: nil)
// } else {
// present(destination, animated: true, completion: nil)
// }
// }
// else if(segue.identifier == "toFilters") {
// let destination = segue.destination as! UINavigationController
// let filterView = destination.topViewController as! FiltersTableViewController
// filterView.filters = self.filters
// }
//
// // Pass the selected object to the new view controller.
// }
override
func
prepare
(
for
segue
:
UIStoryboardSegue
,
sender
:
Any
?)
{
// Get the new view controller using segue.destinationViewController.
if
(
segue
.
identifier
==
"toDetailView"
)
{
let
destination
=
segue
.
destination
as!
FacilityDetailViewController
let
destDelegate
=
DeckTransitioningDelegate
()
destination
.
transitioningDelegate
=
destDelegate
let
tapped
=
sender
as!
FacilityCollectionViewCell
//this is probably a bad idea just FYI future me
destination
.
facility
=
tapped
.
facility
// if we're in the search view, present on its controller
if
searchController
.
isActive
{
searchController
.
present
(
destination
,
animated
:
true
,
completion
:
nil
)
}
else
{
present
(
destination
,
animated
:
true
,
completion
:
nil
)
}
}
else
if
(
segue
.
identifier
==
"toFilters"
)
{
let
destination
=
segue
.
destination
as!
UINavigationController
let
filterView
=
destination
.
topViewController
as!
FiltersTableViewController
filterView
.
facilities
=
self
.
facilitiesArray
filterView
.
filters
=
self
.
filters
}
// Pass the selected object to the new view controller.
}
// MARK: - Peek and Pop
...
...
WhatsOpen/WhatsOpen/Views/FiltersTableViewController.swift
View file @
8dc14266
...
...
@@ -21,8 +21,8 @@ class FiltersTableViewController: UITableViewController {
var
filters
:
Filters
!
var
facilities
:
List
<
Facility
>!
var
allLocations
:
[
Locations
]
=
[
Locations
]()
var
allCategories
:
[
Categories
]
!
=
[
Categories
]()
//
var allLocations: [Locations] = [Locations]()
//
var allCategories: [Categories]! = [Categories]()
var
showOpen
,
showClosed
,
openFirst
:
SwitchingTableViewCell
!
var
sortOptions
:
[
CheckingTableViewCell
]
=
[]
...
...
@@ -35,6 +35,7 @@ class FiltersTableViewController: UITableViewController {
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
/*
for f in facilities {
if(!allLocations.contains(f.facilityLocation!)) {
allLocations.append(f.facilityLocation!)
...
...
@@ -43,6 +44,7 @@ class FiltersTableViewController: UITableViewController {
allCategories.append(f.category!)
}
}
*/
tableView
.
reloadData
()
...
...
@@ -83,6 +85,21 @@ class FiltersTableViewController: UITableViewController {
}
}
override
func
tableView
(
_
tableView
:
UITableView
,
titleForHeaderInSection
section
:
Int
)
->
String
?
{
switch
section
{
case
0
,
1
:
return
nil
case
2
:
return
"Sort Facilities"
case
3
:
return
"Show Locations"
case
4
:
return
"Show Categories"
default
:
return
nil
}
}
override
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
switch
indexPath
.
section
{
case
0
:
...
...
@@ -103,28 +120,68 @@ class FiltersTableViewController: UITableViewController {
default
:
cell
=
UITableViewCell
()
as!
SwitchingTableViewCell
//this is bad don't let this happen
}
return
cell
case
1
:
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"Switching"
,
for
:
indexPath
)
as!
SwitchingTableViewCell
cell
.
textLabel
!.
text
=
"Show Open Facilities First"
cell
.
switchControl
.
isEnabled
=
filters
.
showOpen
cell
.
switchControl
.
isOn
=
filters
.
openFirst
cell
.
toggleFunc
=
filters
.
setOpenFirst
return
cell
case
2
:
// TODO
let
method
:
SortMethod
let
cellText
:
String
switch
indexPath
.
row
{
case
0
:
method
=
SortMethod
.
alphabetical
cellText
=
"Alphabetically (A-Z)"
case
1
:
method
=
SortMethod
.
reverseAlphabetical
cellText
=
"Reverse Alphabetically (Z-A)"
case
2
:
method
=
SortMethod
.
byLocation
cellText
=
"By Location Name (A-Z)"
default
:
method
=
SortMethod
.
alphabetical
cellText
=
"Alphabetically (A-Z)"
}
let
cell
:
CheckingTableViewCell
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"Checkbox Filter"
,
for
:
indexPath
)
as!
CheckingTableViewCell
cell
.
onlyOne
=
self
.
onlyOne
cell
.
cellIndex
=
indexPath
.
row
cell
.
selectingEnum
=
method
cell
.
selectFunc
=
onlyCheckOne
if
(
filters
.
sortBy
==
method
)
{
cell
.
accessoryType
=
.
checkmark
}
else
{
cell
.
accessoryType
=
.
none
}
cell
.
textLabel
!.
text
=
cellText
sortOptions
.
append
(
cell
)
return
cell
case
3
:
// TODO
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"picking"
,
for
:
indexPath
)
as!
PickingTableViewCell
cell
.
pickerStrings
=
[]
cell
.
pickerItems
=
[]
var
strings
=
[
String
]()
var
items
=
[
Bool
]()
for
l
in
filters
.
onlyFromLocations
{
strings
.
append
(
l
.
key
)
items
.
append
(
l
.
value
)
}
cell
.
pickerStrings
=
strings
cell
.
pickerChecked
=
items
return
cell
case
4
:
// TODO
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"picking"
,
for
:
indexPath
)
as!
PickingTableViewCell
cell
.
pickerStrings
=
[]
cell
.
pickerItems
=
[]
var
strings
=
[
String
]()
var
items
=
[
Bool
]()
for
l
in
filters
.
onlyFromCategories
{
strings
.
append
(
l
.
key
)
items
.
append
(
l
.
value
)
}
cell
.
pickerStrings
=
strings
cell
.
pickerChecked
=
items
return
cell
default
:
...
...
@@ -138,6 +195,13 @@ class FiltersTableViewController: UITableViewController {
func
updateOpenFirstEnabledState
(
_
to
:
Bool
)
->
Bool
{
filters
.
setShowOpen
(
to
)
var
index
=
IndexPath
(
row
:
0
,
section
:
1
)
tableView
.
reloadRows
(
at
:
[
index
],
with
:
.
automatic
)
return
true
}
func
onlyCheckOne
(
_
method
:
Any
?)
->
Bool
{
filters
.
sortBy
=
method
as!
SortMethod
// Be careful when calling this
tableView
.
reloadData
()
return
true
}
...
...
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