Skip to content

Commit 3fef4e5

Browse files
committed
Rewrite ReachabilityUtils in Swift
1 parent c5c10cd commit 3fef4e5

File tree

5 files changed

+37
-113
lines changed

5 files changed

+37
-113
lines changed

WordPress/Classes/System/WordPress-Bridging-Header.h

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#import "PostTag.h"
3939
#import "PostTagService.h"
4040

41-
#import "ReachabilityUtils.h"
4241
#import "ReaderGapMarker.h"
4342
#import "ReaderPost.h"
4443
#import "ReaderPostService.h"

WordPress/Classes/Utility/Reachability/ReachabilityAlert.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Foundation
22

3-
private var currentReachabilityAlert: _ReachabilityAlert?
3+
var currentReachabilityAlert: ReachabilityAlert?
44

5-
class _ReachabilityAlert: NSObject {
5+
class ReachabilityAlert: NSObject {
66

77
let retryBlock: (() -> Void)?
88

@@ -38,6 +38,6 @@ class _ReachabilityAlert: NSObject {
3838
// Note: This viewController might not be visible anymore
3939
alertController.presentFromRootViewController()
4040

41-
currentReachabilityAlert = self;
41+
currentReachabilityAlert = self
4242
}
4343
}

WordPress/Classes/Utility/Reachability/ReachabilityUtils.h

-19
This file was deleted.

WordPress/Classes/Utility/Reachability/ReachabilityUtils.m

-90
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Foundation
2+
3+
@objc
4+
public class ReachabilityUtils: NSObject {
5+
6+
@objc
7+
public static func isInternetReachable() -> Bool {
8+
(UIApplication.shared as? NetworkConnectionAvailabilityGetting)?.connectionAvailable ?? false
9+
}
10+
11+
@objc
12+
public static func showAlertNoInternetConnection() {
13+
ReachabilityAlert(retryBlock: nil).show()
14+
}
15+
16+
@objc
17+
public static func showAlertNoInternetConnection(retryBlock: (() -> Void)? = nil) {
18+
ReachabilityAlert(retryBlock: retryBlock).show()
19+
}
20+
21+
@objc
22+
public static func noConnectionMessage() -> String {
23+
NSLocalizedString(
24+
"reachability-utils.alert.utils",
25+
value: "The internet connection appears to be offline.",
26+
comment: "Message of error prompt shown when no internet connection is available"
27+
)
28+
}
29+
30+
@objc
31+
public static func isAlertShowing() -> Bool {
32+
currentReachabilityAlert != nil
33+
}
34+
}

0 commit comments

Comments
 (0)