Verified Commit b9444a1c authored by Eyad Hasan's avatar Eyad Hasan
Browse files

Merge branch 'issue32-warningUserOfNoNetwork' into dev-1.2

Closes #32
parents a0b8850e 0d94ce89
......@@ -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
......@@ -9,6 +9,9 @@
/* Begin PBXBuildFile section */
230EC5797C17C0F859125EEE /* Pods_WhatsOpen.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 927A8466141434969CE74044 /* Pods_WhatsOpen.framework */; };
3BF943DF148D3237C16DEB97 /* Pods_WhatsOpen___AppStore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 857A9086C28DB736094E251F /* Pods_WhatsOpen___AppStore.framework */; };
7B2F14EF214705EF006FB94A /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B2F14EE214705EF006FB94A /* Reachability.swift */; };
7B2F14F0214705EF006FB94A /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B2F14EE214705EF006FB94A /* Reachability.swift */; };
7B2F14F1214705EF006FB94A /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B2F14EE214705EF006FB94A /* Reachability.swift */; };
7F4743271E11D1BC00E6E3D1 /* MainTableViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F4743261E11D1BC00E6E3D1 /* MainTableViewControllerTests.swift */; };
9203CB862023D51A006ACC3B /* FilterSelectionTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92B2D2FE1FF8599500349E90 /* FilterSelectionTableViewController.swift */; };
9203CB872023D51A006ACC3B /* FacilityDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92182EC31E95C38400192ABA /* FacilityDetailViewController.swift */; };
......@@ -83,6 +86,7 @@
2A5CE0045EF9683B296DF70C /* Pods-WhatsOpen.app store.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WhatsOpen.app store.xcconfig"; path = "Pods/Target Support Files/Pods-WhatsOpen/Pods-WhatsOpen.app store.xcconfig"; sourceTree = "<group>"; };
310EA38816D0F5ADA89E7E4E /* Pods-WhatsOpen - AppStore.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WhatsOpen - AppStore.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WhatsOpen - AppStore/Pods-WhatsOpen - AppStore.debug.xcconfig"; sourceTree = "<group>"; };
4CB5379771C173448AFCB711 /* Pods-WhatsOpen.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WhatsOpen.release.xcconfig"; path = "Pods/Target Support Files/Pods-WhatsOpen/Pods-WhatsOpen.release.xcconfig"; sourceTree = "<group>"; };
7B2F14EE214705EF006FB94A /* Reachability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = "<group>"; };
7F4743181E11C7D100E6E3D1 /* WhatsOpenTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WhatsOpenTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7F4743261E11D1BC00E6E3D1 /* MainTableViewControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainTableViewControllerTests.swift; sourceTree = "<group>"; };
857A9086C28DB736094E251F /* Pods_WhatsOpen___AppStore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = "Pods_WhatsOpen___AppStore.framework"; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -275,6 +279,7 @@
children = (
CD763A791DE24EF100ADFD6B /* Model.swift */,
CD3C97481DC18AB300A84434 /* DownloadController.swift */,
7B2F14EE214705EF006FB94A /* Reachability.swift */,
);
name = "Data Retrieval";
sourceTree = "<group>";
......@@ -655,6 +660,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7B2F14F0214705EF006FB94A /* Reachability.swift in Sources */,
7F4743271E11D1BC00E6E3D1 /* MainTableViewControllerTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......@@ -677,6 +683,7 @@
9203CB922023D51A006ACC3B /* FacilityCollectionViewCell.swift in Sources */,
9203CB932023D51A006ACC3B /* SettingTableViewCell.swift in Sources */,
9203CB942023D51A006ACC3B /* Filters.swift in Sources */,
7B2F14F1214705EF006FB94A /* Reachability.swift in Sources */,
9203CB952023D51A006ACC3B /* FiltersTableViewController.swift in Sources */,
9203CB962023D51A006ACC3B /* PullingViewController.swift in Sources */,
9203CB972023D51A006ACC3B /* Utilities.swift in Sources */,
......@@ -707,6 +714,7 @@
924840F81EA915F200DBFF4E /* FacilityCollectionViewCell.swift in Sources */,
9265F3A11F2969E500A54A21 /* SettingTableViewCell.swift in Sources */,
9270A4DD1EC0010300DFBDA3 /* Filters.swift in Sources */,
7B2F14EF214705EF006FB94A /* Reachability.swift in Sources */,
927C80DC1EB18B89009079AD /* FiltersTableViewController.swift in Sources */,
92B89E302009444E00928284 /* PullingViewController.swift in Sources */,
CD763A7E1DE253B900ADFD6B /* Utilities.swift in Sources */,
......@@ -952,7 +960,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
......@@ -1104,7 +1112,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
......@@ -1133,7 +1141,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
......
......@@ -258,8 +258,15 @@ class Alert: Object, MapContext, Mappable {
startDate <- map["start_datetime"]
endDate <- map["end_datetime"]
}
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<FacilityTag>
......
//
// 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 = NSURL(string: "https://google.com")
let request = NSMutableURLRequest(url: url! as URL)
request.httpMethod = "HEAD"
request.cachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalAndRemoteCacheData
request.timeoutInterval = 10.0
var response:URLResponse?
do {
let _ = try NSURLConnection.sendSynchronousRequest(request as URLRequest, returning: &response) as NSData?
}
catch let error as NSError {
print(error.localizedDescription)
}
if let httpResponse = response as? HTTPURLResponse {
if httpResponse.statusCode == 200 {
status = true
}
}
return status
}
}
......@@ -356,6 +356,15 @@ 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.
var noNetwork = Reachability.isConnectedToNetwork()
let noNetworkAlert = Alert()
noNetworkAlert.noNetwork()
if !noNetwork {
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 {
......@@ -601,7 +610,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
self.alertsList = model.alerts
}
else {
self.alertsList = List<Alert>()
self.alertsList = List<Alert>()
}
}
}
......
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