Unverified Commit a9d10e88 authored by Zach Knox's avatar Zach Knox

Merge branch 'dev-1.2' into 48-frameworks

and also fixed up the connection banner
parents e17143af e5986c10
......@@ -73,3 +73,6 @@ WhatsOpen/WhatsOpen/crashlyticsbuild.sh
# Maybe this should be in VC but it's only going to be used by people pushing builds out
# and has a Slack webhook token in it
WhatsOpen/fastlane/
#crashlytics file
crashlyticsbuild.sh
......@@ -846,7 +846,7 @@
};
CD81F5181DC0334600009FBD = {
CreatedOnToolsVersion = 8.0;
DevelopmentTeam = N5GM564QWL;
DevelopmentTeam = HQSN7HX89U;
LastSwiftMigration = 0910;
ProvisioningStyle = Automatic;
};
......@@ -1888,7 +1888,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = K5MMVK2UFR;
DEVELOPMENT_TEAM = HQSN7HX89U;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
......@@ -1898,7 +1898,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" -D APPSTORE";
PRIMARYICON = appicon;
PRODUCT_BUNDLE_IDENTIFIER = space.srct.whatsopen;
PRODUCT_BUNDLE_IDENTIFIER = io.srct.whatsopen;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
......@@ -2242,7 +2242,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = N5GM564QWL;
DEVELOPMENT_TEAM = HQSN7HX89U;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
......@@ -2251,7 +2251,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRIMARYICON = "appicon-dev";
PRODUCT_BUNDLE_IDENTIFIER = space.srct.whatsopen;
PRODUCT_BUNDLE_IDENTIFIER = io.srct.whatsopen;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
......@@ -2272,7 +2272,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = N5GM564QWL;
DEVELOPMENT_TEAM = HQSN7HX89U;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
......@@ -2281,7 +2281,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRIMARYICON = "appicon-dev";
PRODUCT_BUNDLE_IDENTIFIER = space.srct.whatsopen;
PRODUCT_BUNDLE_IDENTIFIER = io.srct.whatsopen;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
......
//
// Reachability.swift
// WhatsOpen
//
// Created by Eyad Hasan on 9/10/18.
// Copyright © 2018 SRCT. All rights reserved.
//
import Foundation
import SystemConfiguration
public class Reachability {
class func isConnectedToNetwork() -> Bool {
var status:Bool = false
let url = URL(string: "https://api.srct.gmu.edu/whatsopen/v2/facilities/?format=json")
var request = URLRequest(url: url! as URL)
request.httpMethod = "HEAD"
request.cachePolicy = URLRequest.CachePolicy.reloadIgnoringLocalAndRemoteCacheData
request.timeoutInterval = 10.0
var response:URLResponse?
do {
//let _ = try NSURLConnection.sendSynchronousRequest(request as URLRequest, returning: &response) as NSData?
let _ = try URLSession.dataTaskWithRequest(request as URLRequest, completionHandler: &response)
}
catch let error as NSError {
print(error.localizedDescription)
}
if let httpResponse = response as? HTTPURLResponse {
if httpResponse.statusCode == 200 {
status = true
}
}
return status
}
}
......@@ -441,6 +441,14 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
formatter.timeZone = TimeZone(identifier: "America/New_York")
let now = Date()
let alertFilers = defaults.dictionary(forKey: "alerts") as! [String: Bool]?
// Probably a better way to do the check for network results, but it really doesn't matter so this will do for now.
let noNetworkAlert = WOPAlert()
noNetworkAlert.noNetwork()
if networkCheck.network == false {
shown.append(noNetworkAlert)
}
for alert in alertsList {
if now.isGreaterThanDate(dateToCompare: formatter.date(from: alert.startDate)!) && now.isLessThanDate(dateToCompare: formatter.date(from: alert.endDate)!) {
switch alert.urgency {
......@@ -556,6 +564,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
facilitiesArray = facilities
alertsList = alerts
self.refreshControl.attributedTitle = NSAttributedString(string: "Last Updated: " + self.shortDateFormat(lastUpdated))
networkCheck.network = true
goodToGo = true
}
}
......@@ -605,6 +614,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
let lastUpdated = model.lastUpdated
self.facilitiesArray = facilitiesFromDB
networkCheck.network = false
self.updateFiltersLists()
self.reloadWithFilters()
self.refreshControl.attributedTitle = NSAttributedString(string: "Last Updated: " + self.shortDateFormat(lastUpdated))
......@@ -615,6 +625,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
}
}
else {
networkCheck.network = false
self.facilitiesArray = List<WOPFacility>()
}
}
......@@ -667,9 +678,11 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
let results = self.realm.objects(WOPFacilitiesModel.self)
if results.count > 0 {
let model = results[0]
networkCheck.network = false
self.alertsList = model.alerts
}
else {
networkCheck.network = false
self.alertsList = List<WOPAlert>()
}
}
......
......@@ -30,6 +30,7 @@ public class WOPDownloadController: NSObject {
let httpResponse = response as! HTTPURLResponse
let statusCode = httpResponse.statusCode
if (statusCode == 200) {
networkCheck.network = true
if let dataN = data {
if let json = try? JSONSerialization.jsonObject(with: dataN, options: []) as? [[String: Any]] {
// Map function to iterate through each JSON tree
......
......@@ -21,6 +21,10 @@ public enum WOPDay: Int {
// Add functions here later if we need them
}
public struct networkCheck {
public static var network = true
}
public class WOPFacility: Object, MapContext, Mappable {
@objc public dynamic var slug = ""
@objc public dynamic var facilityName = ""
......@@ -274,8 +278,15 @@ public class WOPAlert: Object, MapContext, Mappable {
startDate <- map["start_datetime"]
endDate <- map["end_datetime"]
}
public func noNetwork(){
urgency = "emergency"
message = "No Internet Connection"
}
}
// 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<WOPFacilityTag>
......
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