Unverified Commit 7bcf2fcf authored by Zach Knox's avatar Zach Knox
Browse files

getting the filters view a bit better - INCOMPLETE

parent ae027603
......@@ -19,6 +19,7 @@
9270A4DD1EC0010300DFBDA3 /* Filters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9270A4DC1EC0010300DFBDA3 /* Filters.swift */; };
927C80DA1EB02566009079AD /* SettingsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 927C80D91EB02566009079AD /* SettingsTableViewController.swift */; };
927C80DC1EB18B89009079AD /* FiltersTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 927C80DB1EB18B89009079AD /* FiltersTableViewController.swift */; };
929157221FF4662F00ED63C7 /* PickingTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929157211FF4662F00ED63C7 /* PickingTableViewCell.swift */; };
92EA81971FB7D1B500B1F6E3 /* PaddedUILabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92EA81961FB7D1B500B1F6E3 /* PaddedUILabel.swift */; };
92F681581FC1353700393DF4 /* Pods-WhatsOpen-acknowledgements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 92F681571FC1353700393DF4 /* Pods-WhatsOpen-acknowledgements.plist */; };
92F6815A1FC137CF00393DF4 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 92F681591FC137CF00393DF4 /* Settings.bundle */; };
......@@ -59,6 +60,7 @@
927A8466141434969CE74044 /* Pods_WhatsOpen.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WhatsOpen.framework; sourceTree = BUILT_PRODUCTS_DIR; };
927C80D91EB02566009079AD /* SettingsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsTableViewController.swift; sourceTree = "<group>"; };
927C80DB1EB18B89009079AD /* FiltersTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FiltersTableViewController.swift; sourceTree = "<group>"; };
929157211FF4662F00ED63C7 /* PickingTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickingTableViewCell.swift; sourceTree = "<group>"; };
92EA81961FB7D1B500B1F6E3 /* PaddedUILabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PaddedUILabel.swift; path = WhatsOpen/PaddedUILabel.swift; sourceTree = SOURCE_ROOT; };
92F681571FC1353700393DF4 /* Pods-WhatsOpen-acknowledgements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Pods-WhatsOpen-acknowledgements.plist"; path = "Pods/Target Support Files/Pods-WhatsOpen/Pods-WhatsOpen-acknowledgements.plist"; sourceTree = SOURCE_ROOT; };
92F681591FC137CF00393DF4 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
......@@ -158,6 +160,7 @@
924840F71EA915F200DBFF4E /* FacilityCollectionViewCell.swift */,
92EA81961FB7D1B500B1F6E3 /* PaddedUILabel.swift */,
CD81F5201DC0334600009FBD /* Main.storyboard */,
929157211FF4662F00ED63C7 /* PickingTableViewCell.swift */,
920D17961F6C5CD200D63295 /* Views */,
CD81F5231DC0334600009FBD /* Assets.xcassets */,
CD81F5251DC0334600009FBD /* LaunchScreen.storyboard */,
......@@ -366,6 +369,7 @@
buildActionMask = 2147483647;
files = (
92182EC41E95C38400192ABA /* FacilityDetailViewController.swift in Sources */,
929157221FF4662F00ED63C7 /* PickingTableViewCell.swift in Sources */,
92108A331ED755F100675E16 /* CheckingTableViewCell.swift in Sources */,
92182EC01E95BD2C00192ABA /* FacilitiesListViewController.swift in Sources */,
CD763A7A1DE24EF100ADFD6B /* examplejson.swift in Sources */,
......
......@@ -45,6 +45,28 @@
</tableViewCellContentView>
<color key="tintColor" red="0.0" green="0.40000000000000002" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="picking" rowHeight="157" id="Qzo-pS-g9l" customClass="PickingTableViewCell" customModule="WhatsOpen" customModuleProvider="target">
<rect key="frame" x="0.0" y="143.5" width="375" height="157"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Qzo-pS-g9l" id="gyt-MF-bQ2">
<rect key="frame" x="0.0" y="0.0" width="375" height="156.5"/>
<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"/>
</pickerView>
</subviews>
</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>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="jkQ-vu-LQa" id="DbO-38-R86"/>
......@@ -61,7 +83,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yyJ-38-T8j" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-8599" y="-349"/>
<point key="canvasLocation" x="-8599.2000000000007" y="-349.47526236881561"/>
</scene>
<!--What's Open-->
<scene sceneID="w5e-Fb-rsR">
......
......@@ -130,8 +130,21 @@ class Filters {
return []
}
func setShowOpen(_ to: Bool) -> Bool {
showOpen = to
return true
}
func setShowClosed(_ to: Bool) -> Bool {
showClosed = to
return true
}
func setOpenFirst(_ to: Bool) -> Bool {
openFirst = to
return true
}
}
......@@ -144,5 +157,9 @@ enum SortMethod {
//case openLongest //Places things open longest on top; if only showing closed, shows opening soonest
//case openShortest //Places things closing soonest on top; if only showing closed, shows opening furthest from now
static var count = 3 // REMEMBER TO CHANGE THIS IF YOU ADD MORE CASES
//We should figure out how we want to allow sorting
}
......@@ -54,9 +54,10 @@ class Locations: Object, Mappable {
@objc dynamic var onCampus = false
required convenience init?(map: Map){
self.init()
self.init()
}
func mapping(map: Map){
func mapping(map: Map){
id <- map["id"]
created <- map["created"]
lastmodified <- map["modified"]
......
//
// PickingTableViewCell.swift
// WhatsOpen
//
// Created by Zach Knox on 12/27/17.
// Copyright © 2017 SRCT. All rights reserved.
//
import UIKit
class PickingTableViewCell: UITableViewCell, UIPickerViewDelegate, UIPickerViewDataSource {
@IBOutlet var pickerView: UIPickerView!
var pickerStrings: [String]!
var pickerItems: [Any?]! //literally just here for convienence
var pickerChecked: [Bool]! //Should I use a dictionary? maybe, but this is way easier
override func awakeFromNib() {
super.awakeFromNib()
self.selectionStyle = .none
pickerView.dataSource = self
pickerView.delegate = self
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerStrings.count
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return pickerStrings[row]
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
pickerChecked[row] = !pickerChecked[row]
pickerView.showsSelectionIndicator = pickerChecked[row]
}
}
......@@ -11,6 +11,7 @@ import UIKit
class SwitchingTableViewCell: UITableViewCell {
let switchControl = UISwitch()
var toggleFunc: ((Bool)->Bool)!
override func awakeFromNib() {
super.awakeFromNib()
......@@ -27,8 +28,11 @@ class SwitchingTableViewCell: UITableViewCell {
@objc func toggleSwitch(_ sender: Any) {
print("toggle")
dump(sender)
//LocationsListViewController.checkForReload(sander, switchControl.isOn)
let res = toggleFunc(self.switchControl.isOn)
if( res == false ) {
// Probably should do some error handling here
}
}
}
......@@ -7,6 +7,7 @@
//
import UIKit
import RealmSwift
class FiltersTableViewController: UITableViewController {
......@@ -19,8 +20,11 @@ class FiltersTableViewController: UITableViewController {
}
var filters: Filters!
var facilities: List<Facility>!
var allLocations: [Locations] = [Locations]()
var allCategories: [Categories]! = [Categories]()
var showOpen, showClosed: SwitchingTableViewCell!
var showOpen, showClosed, openFirst: SwitchingTableViewCell!
var sortOptions: [CheckingTableViewCell] = []
var onlyOne: OnlyOneChecked!
......@@ -31,6 +35,17 @@ class FiltersTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
for f in facilities {
if(!allLocations.contains(f.facilityLocation!)) {
allLocations.append(f.facilityLocation!)
}
if(!allCategories.contains(f.category!)) {
allCategories.append(f.category!)
}
}
tableView.reloadData()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
......@@ -47,18 +62,23 @@ class FiltersTableViewController: UITableViewController {
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 2
return 5
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
if(section == 0) {
switch section {
case 0:
return 2
}
else if(section == 1) {
return 4
}
else {
case 1:
return 1
case 2:
return SortMethod.count
case 3:
return 1
case 4:
return 1
default:
return 0
}
}
......@@ -71,20 +91,41 @@ class FiltersTableViewController: UITableViewController {
case 0:
cell = tableView.dequeueReusableCell(withIdentifier: "Switching", for: indexPath) as! SwitchingTableViewCell
cell.textLabel!.text = "Show Open Locations"
self.showOpen = cell
cell.switchControl.isOn = filters.showOpen
cell.toggleFunc = updateOpenFirstEnabledState
//self.showOpen = cell
case 1:
cell = tableView.dequeueReusableCell(withIdentifier: "Switching", for: indexPath) as! SwitchingTableViewCell
cell.textLabel!.text = "Show Closed Locations"
self.showClosed = cell
cell.switchControl.isOn = filters.showClosed
cell.toggleFunc = filters.setShowClosed
//self.showClosed = cell
default:
cell = UITableViewCell() as! SwitchingTableViewCell //this is bad don't let this happen
}
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.toggleFunc = filters.setOpenFirst
case 2: // TODO
let cell: CheckingTableViewCell
cell = tableView.dequeueReusableCell(withIdentifier: "Checkbox Filter", for: indexPath) as! CheckingTableViewCell
cell.onlyOne = self.onlyOne
cell.cellIndex = indexPath.row
sortOptions.append(cell)
return cell
case 3: // TODO
let cell = tableView.dequeueReusableCell(withIdentifier: "picking", for: indexPath) as! PickingTableViewCell
cell.pickerStrings = []
cell.pickerItems = []
return cell
case 4: // TODO
let cell = tableView.dequeueReusableCell(withIdentifier: "picking", for: indexPath) as! PickingTableViewCell
cell.pickerStrings = []
cell.pickerItems = []
return cell
default:
let cell = UITableViewCell() //this is bad don't let this happen
......@@ -95,6 +136,12 @@ class FiltersTableViewController: UITableViewController {
// Configure the cell...
}
func updateOpenFirstEnabledState(_ to: Bool) -> Bool {
filters.setShowOpen(to)
tableView.reloadData()
return true
}
/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment