Unverified Commit fa7becbe authored by Zach Knox's avatar Zach Knox
Browse files

fixed lots of warnings, added some more items to facility schema, and added search by tag and label

parent d78cbf62
......@@ -270,7 +270,7 @@
};
CD81F5181DC0334600009FBD = {
CreatedOnToolsVersion = 8.0;
DevelopmentTeam = K5MMVK2UFR;
DevelopmentTeam = N5GM564QWL;
LastSwiftMigration = 0910;
ProvisioningStyle = Automatic;
};
......@@ -569,7 +569,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = K5MMVK2UFR;
DEVELOPMENT_TEAM = N5GM564QWL;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
......@@ -723,7 +723,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = K5MMVK2UFR;
DEVELOPMENT_TEAM = N5GM564QWL;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
......@@ -751,7 +751,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = K5MMVK2UFR;
DEVELOPMENT_TEAM = N5GM564QWL;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
......
......@@ -176,8 +176,8 @@
</items>
<color key="tintColor" red="0.0" green="0.40000000000000002" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
</toolbar>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" misplaced="YES" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="naC-sZ-bcy">
<rect key="frame" x="-3" y="116" width="375" height="507"/>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="naC-sZ-bcy">
<rect key="frame" x="0.0" y="116" width="375" height="507"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="eqw-AF-DSB">
......@@ -194,20 +194,14 @@
<rect key="frame" x="0.0" y="0.0" width="300" height="131"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Closes in 2 hours" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="o7N-To-w50">
<rect key="frame" x="4" y="55" width="291" height="21"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Closes in 2 hours" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="o7N-To-w50">
<rect key="frame" x="4" y="57" width="291" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Location" lineBreakMode="tailTruncation" minimumScaleFactor="0.55000000000000004" translatesAutoresizingMaskIntoConstraints="NO" id="6QR-8Q-n4s">
<rect key="frame" x="4" y="25" width="291" height="30"/>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="29"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="RESTAURANT" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uhu-6U-8Tx">
<rect key="frame" x="4" y="8" width="291" height="20"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="RESTAURANT" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uhu-6U-8Tx">
<rect key="frame" x="4" y="8" width="291" height="17"/>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="14"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
......@@ -231,6 +225,12 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Location" lineBreakMode="tailTruncation" minimumScaleFactor="0.55000000000000004" translatesAutoresizingMaskIntoConstraints="NO" id="6QR-8Q-n4s">
<rect key="frame" x="4" y="22" width="291" height="35"/>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="29"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</view>
<color key="backgroundColor" red="0.0" green="0.40000000000000002" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
......@@ -242,6 +242,7 @@
<constraint firstItem="6QR-8Q-n4s" firstAttribute="leading" secondItem="6qn-VX-mZx" secondAttribute="leading" constant="4" id="FcK-k7-0NQ"/>
<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 firstAttribute="trailing" secondItem="o7N-To-w50" secondAttribute="trailing" constant="5" id="bkz-Hf-1Ds"/>
<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="9" id="kFY-Lf-EkL"/>
......@@ -355,7 +356,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="cQW-T4-yZv" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-8151.1999999999998" y="-1884.1079460269866"/>
<point key="canvasLocation" x="-8151.5" y="-1884.5"/>
</scene>
<!--What's Open-->
<scene sceneID="rbo-Xh-B4S">
......@@ -428,7 +429,7 @@
<rect key="frame" x="16" y="174" width="343" height="37"/>
<constraints>
<constraint firstAttribute="height" constant="37" id="5xu-tD-Fqa"/>
<constraint firstAttribute="width" constant="343" id="nAs-Xy-cBU"/>
<constraint firstAttribute="width" constant="343" placeholder="YES" id="nAs-Xy-cBU"/>
</constraints>
<attributedString key="attributedText">
<fragment content="Version 1.0 (10)">
......@@ -831,6 +832,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="IER-Fh-tIe" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-5936" y="-1127"/>
</scene>
</scenes>
<resources>
......
......@@ -23,7 +23,7 @@ class CheckingTableViewCell: UITableViewCell {
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
if(selected) {
selectFunc(selectingEnum)
_ = selectFunc(selectingEnum)
onlyOne.setCheckToCellWithID(cellIndex)
super.setSelected(false, animated: animated)
}
......
......@@ -24,11 +24,14 @@ class Facility: Object, MapContext, Mappable {
@objc dynamic var facilityName = ""
@objc dynamic var facilityLocation: Locations? = Locations()
@objc dynamic var category: Categories? = Categories()
var facilityTags: List<FacilityTags>? = List<FacilityTags>()
var facilityTags: List<FacilityTag>? = List<FacilityTag>()
@objc dynamic var mainSchedule: MainSchedule? = MainSchedule()
@objc dynamic var specialSchedule: SpecialSchedule? = SpecialSchedule()
var labels: List<FacilityTag>? = List<FacilityTag>()
@objc dynamic var tapingoURL = ""
@objc dynamic var note = ""
@objc dynamic var logoURL = ""
required convenience init?(map: Map) {
self.init()
}
......@@ -37,9 +40,15 @@ class Facility: Object, MapContext, Mappable {
facilityName <- map["facility_name"]
facilityLocation <- map["facility_location"]
category <- map["facility_category"]
facilityTags <- map["facility_product_tags"]
facilityTags <- (map["facility_product_tags"], TagTransform())
mainSchedule <- map["main_schedule"]
specialSchedule <- map["special_schedules"]
labels <- (map["facility_labels"], TagTransform())
tapingoURL <- map["tapingo_url"]
note <- map["note"]
logoURL <- map["logo"]
}
}
......@@ -103,18 +112,20 @@ class Categories: Object, Mappable {
}
class FacilityTags: Object, Mappable {
required convenience init?(map: Map) {
self.init()
}
func mapping(map: Map) {
tags <- map["tags"]
}
@objc dynamic var tags = ""
class FacilityTag: Object, Mappable {
@objc dynamic var tag = ""
required convenience init?(map: Map){
self.init()
}
func mapping(map: Map) {
tag <- map["facility_product_tags"]
tag <- map["facility_labels"]
}
}
class MainSchedule: Object, Mappable {
......@@ -234,6 +245,37 @@ class Alert: Object, MapContext, Mappable {
}
}
// Updated for Swift 4, based on https://gist.github.com/Jerrot/fe233a94c5427a4ec29b but I removed the generics sorry code reuse
class TagTransform : TransformType {
typealias Object = List<FacilityTag>
typealias JSON = [String]
func transformFromJSON(_ value: Any?) -> List<FacilityTag>? {
let result = List<FacilityTag>()
if let tempArr = value as! [String]? {
for entry in tempArr {
let tag = FacilityTag()
tag.tag = entry
result.append(tag)
}
}
return result
}
func transformToJSON(_ value: List<FacilityTag>?) -> [String]? {
if (value!.count > 0) {
var result = [String]()
for entry in value! {
result.append(entry.tag)
}
return result
}
return nil
}
}
/**struct OpenTimes: CreatableFromJSON { // TODO: Rename this struct
let endDay: Int
let endTime: Date
......
......@@ -45,7 +45,7 @@ class PickingTableViewCell: UITableViewCell, UIPickerViewDelegate, UIPickerViewD
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
pickerChecked[row] = !pickerChecked[row]
pickFunc(pickerStrings[row], pickerChecked[row])
_ = pickFunc(pickerStrings[row], pickerChecked[row])
pickerView.reloadComponent(component)
}
......
......@@ -53,8 +53,6 @@ class Utilities: NSObject {
return "Saturday"
case .Sunday:
return "Sunday"
default:
return nil
}
}
else {
......@@ -73,8 +71,6 @@ class Utilities: NSObject {
return "Sat"
case .Sunday:
return "Sun"
default:
return nil
}
}
......@@ -187,6 +183,8 @@ class Utilities: NSObject {
}
return nil
}
//TODO: THIS PROBABLY DOESN'T WORK WITH SPECIAL SCHEDULES
static func openOrClosedUntil(_ facility: Facility) -> String? {
let viewingFormatter = DateFormatter.easternCoastTimeFormatForViewing
......@@ -205,16 +203,14 @@ class Utilities: NSObject {
}
//Eventually add more detailled text here, allowing for more custom
//messages as it gets closer to closing time
} else {
if startEnd != nil {
let time = viewingFormatter.string(from: startEnd!.startTime)
return "Closed until \(time)."
}
}
} else {
return "Closed"
if startEnd != nil {
let time = viewingFormatter.string(from: startEnd!.startTime)
return "Closed until \(time)"
} else {
return "Closed"
}
}
return nil
}
......
......@@ -25,18 +25,11 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
let realm = try! Realm(configuration: Realm.Configuration(
// Set the new schema version. This must be greater than the previously used
// version (if you've never set a schema version before, the version is 0).
schemaVersion: 1,
// Set the block which will be called automatically when opening a Realm with
// a schema version lower than the one set above
migrationBlock: { migration, oldSchemaVersion in
// We haven’t migrated anything yet, so oldSchemaVersion == 0
if (oldSchemaVersion < 1) {
migration.enumerateObjects(ofType: "FacilitiesModel", { (oldObject, newObject) in
newObject!["alerts"] = List<Alert>()
})
}
}))
schemaVersion: 3,
// We replace the data stored every 12 hours, do we _really_ need to worry about schema updates?
// I say nay.
deleteRealmIfMigrationNeeded: true
))
var facilitiesArray = List<Facility>()
var alertsList = List<Alert>()
......@@ -356,8 +349,25 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
let hasName = facility.facilityName.lowercased().contains(searchText.lowercased())
let hasBuilding = facility.facilityLocation?.building.lowercased().contains(searchText.lowercased()) ?? false
let hasCategory = facility.category?.categoryName.lowercased().contains(searchText.lowercased()) ?? false
return hasName || hasBuilding || hasCategory
var hasTag = false
for tag in facility.facilityTags! {
if hasTag {
break
}
if tag.tag.lowercased().contains(searchText.lowercased()) {
hasTag = true
}
}
var hasLabel = false
for label in facility.labels! {
if hasLabel {
break
}
if label.tag.lowercased().contains(searchText.lowercased()) {
hasLabel = true
}
}
return hasName || hasBuilding || hasCategory || hasTag
})
LocationsList.reloadData()
......
......@@ -39,10 +39,10 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
*/
@IBAction func setFavButton(_ sender: Any) {
if(Utilities.isFavoriteFacility(facility)) { // if the facility is a favorite
Utilities.removeFavoriteFacility(facility) // remove it from favorites
_ = Utilities.removeFavoriteFacility(facility) // remove it from favorites
}
else { // else add it to favorites
Utilities.addFavoriteFacility(facility)
_ = Utilities.addFavoriteFacility(facility)
}
setFavoriteButtonText()
}
......@@ -146,10 +146,10 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
func markAsFavoritePreviewAction(_ sendingAction: UIPreviewAction, sender: UIViewController) {
if(Utilities.isFavoriteFacility(facility)) {
Utilities.removeFavoriteFacility(facility)
_ = Utilities.removeFavoriteFacility(facility)
}
else {
Utilities.addFavoriteFacility(facility)
_ = Utilities.addFavoriteFacility(facility)
}
}
}
......@@ -81,7 +81,7 @@ class FilterSelectionTableViewController: UITableViewController {
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if(indexPath.row == 0) {
selectAllFunc()
_ = selectAllFunc()
tableView.reloadData()
}
else {
......@@ -93,7 +93,7 @@ class FilterSelectionTableViewController: UITableViewController {
else {
res = false
}
selectFunc((tableCell?.textLabel?.text)!.lowercased(), res)
_ = selectFunc((tableCell?.textLabel?.text)!.lowercased(), res)
tableView.reloadRows(at: [IndexPath(row: 0, section: 0), indexPath], with: .automatic)
}
}
......
......@@ -246,7 +246,7 @@ class FiltersTableViewController: UITableViewController {
return cell
}
return UITableViewCell() //shouldn't come to this
//return UITableViewCell() //shouldn't come to this
// Configure the cell...
}
......@@ -258,7 +258,7 @@ class FiltersTableViewController: UITableViewController {
}
func updateOpenFirstEnabledState(_ to: Bool) -> Bool {
filters.setShowOpen(to)
_ = filters.setShowOpen(to)
let index = IndexPath(row: 0, section: 1)
tableView.reloadRows(at: [index], with: .automatic)
return true
......
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