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
06e2a4d5
Commit
06e2a4d5
authored
Apr 28, 2017
by
Zach Knox
Browse files
Favorites control works
Note: needs data, currently returns an empty array for favorites
parent
366dde17
Changes
2
Hide whitespace changes
Inline
Side-by-side
WhatsOpen/WhatsOpen/Base.lproj/Main.storyboard
View file @
06e2a4d5
...
...
@@ -288,7 +288,6 @@
</constraints>
</view>
<navigationItem
key=
"navigationItem"
id=
"lS5-pu-Adr"
>
<nil
key=
"title"
/>
<barButtonItem
key=
"leftBarButtonItem"
title=
"Filter"
id=
"v4j-oA-7Fa"
>
<color
key=
"tintColor"
white=
"1"
alpha=
"1"
colorSpace=
"calibratedWhite"
/>
<connections>
...
...
@@ -306,6 +305,9 @@
<segment
title=
"Favorites"
/>
</segments>
<color
key=
"tintColor"
white=
"1"
alpha=
"1"
colorSpace=
"calibratedWhite"
/>
<connections>
<action
selector=
"favoritesControlChanges:"
destination=
"aaB-Go-aWd"
eventType=
"valueChanged"
id=
"5Ij-Z9-Gsa"
/>
</connections>
</segmentedControl>
<barButtonItem
key=
"rightBarButtonItem"
systemItem=
"search"
id=
"vtX-VZ-RB4"
>
<color
key=
"tintColor"
white=
"1"
alpha=
"1"
colorSpace=
"calibratedWhite"
/>
...
...
WhatsOpen/WhatsOpen/LocationsListViewController.swift
View file @
06e2a4d5
...
...
@@ -25,6 +25,20 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
@IBOutlet
var
LocationsListLayout
:
UICollectionViewFlowLayout
!
@IBOutlet
var
favoritesControl
:
UISegmentedControl
!
var
showFavorites
=
false
@IBAction
func
favoritesControlChanges
(
_
sender
:
Any
)
{
switch
(
self
.
favoritesControl
.
selectedSegmentIndex
)
{
case
0
:
showFavorites
=
false
case
1
:
showFavorites
=
true
default
:
showFavorites
=
false
}
self
.
LocationsList
.
reloadData
()
}
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
...
...
@@ -50,7 +64,8 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
numberOfItemsInSection
section
:
Int
)
->
Int
{
let
count
=
countForOpenAndClosedFacilities
(
facilitiesArray
)
let
count
=
countForOpenAndClosedFacilities
(
getLocationArray
(
facilitiesArray
))
if
(
section
==
1
)
{
return
count
.
open
}
...
...
@@ -83,6 +98,17 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
return
cell
}
func
getLocationArray
(
_
facilitiesArray
:
[
Facility
])
->
[
Facility
]
{
if
(
!
showFavorites
)
{
return
placeOpenFacilitiesFirstInArray
(
facilitiesArray
)
}
else
{
return
[]
//TODO - INCOMPLETE
}
}
//Returns an array which has the open locations listed first
//Could be improved in the future because currently this means you're checking
//open status twice per cell
...
...
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