Skip to content

Commit

Permalink
chore: update swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
DingSoung authored and dingsongwenxm committed Nov 24, 2019
1 parent 7042c1f commit 0eef340
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 138 deletions.
4 changes: 0 additions & 4 deletions Extension.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
CE0F0CE822C8B17300F72849 /* NSAttributedString+Content.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0F0C9E22C8B17200F72849 /* NSAttributedString+Content.swift */; };
CE0F0CEB22C8B17300F72849 /* Array+UIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0F0C9F22C8B17200F72849 /* Array+UIImage.swift */; };
CE0F0CEE22C8B17300F72849 /* UINavigationController+Autorotate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0F0CA022C8B17200F72849 /* UINavigationController+Autorotate.swift */; };
CE0F0CF122C8B17300F72849 /* UIWebView+JavaScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0F0CA122C8B17200F72849 /* UIWebView+JavaScript.swift */; };
CE0F0CF422C8B17300F72849 /* Image+pdf.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0F0CA222C8B17200F72849 /* Image+pdf.swift */; };
CE0F0CF722C8B17300F72849 /* Image+CoreGraphics.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0F0CA322C8B17200F72849 /* Image+CoreGraphics.swift */; };
CE0F0CFA22C8B17300F72849 /* Image+Process.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0F0CA422C8B17200F72849 /* Image+Process.swift */; };
Expand Down Expand Up @@ -84,7 +83,6 @@
CE0F0C9E22C8B17200F72849 /* NSAttributedString+Content.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSAttributedString+Content.swift"; sourceTree = "<group>"; };
CE0F0C9F22C8B17200F72849 /* Array+UIImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Array+UIImage.swift"; sourceTree = "<group>"; };
CE0F0CA022C8B17200F72849 /* UINavigationController+Autorotate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Autorotate.swift"; sourceTree = "<group>"; };
CE0F0CA122C8B17200F72849 /* UIWebView+JavaScript.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIWebView+JavaScript.swift"; sourceTree = "<group>"; };
CE0F0CA222C8B17200F72849 /* Image+pdf.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Image+pdf.swift"; sourceTree = "<group>"; };
CE0F0CA322C8B17200F72849 /* Image+CoreGraphics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Image+CoreGraphics.swift"; sourceTree = "<group>"; };
CE0F0CA422C8B17200F72849 /* Image+Process.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Image+Process.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -189,7 +187,6 @@
CE940DDB22DD933D00BC38B5 /* UIFont+SymbolicTraits.swift */,
CE0F0CA022C8B17200F72849 /* UINavigationController+Autorotate.swift */,
CE0F0C9D22C8B17200F72849 /* UITableView+UIImage.swift */,
CE0F0CA122C8B17200F72849 /* UIWebView+JavaScript.swift */,
);
path = UIKit;
sourceTree = "<group>";
Expand Down Expand Up @@ -459,7 +456,6 @@
CE0F0D1E22C8B17300F72849 /* URL+Cookie.swift in Sources */,
CE0F0D4222C8B17300F72849 /* Color.swift in Sources */,
CE0F0D3922C8B17300F72849 /* Color+components.swift in Sources */,
CE0F0CF122C8B17300F72849 /* UIWebView+JavaScript.swift in Sources */,
CEBC590522ED46FC00FA3182 /* SCNetworkReachability+flags.swift in Sources */,
CE0F0D5D22C8B17300F72849 /* Swift+Association.swift in Sources */,
CE0F0D5A22C8B17300F72849 /* Swift+log.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ let package = Package(
.target(name: "Extension", path: "Sources")
],
swiftLanguageVersions: [
.version("5.0.0")
.version("5")
]
)
6 changes: 2 additions & 4 deletions Sources/Common/Color/Color+components.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Created by Songwen on 2018/11/7.
// Copyright © 2018 DingSoung. All rights reserved.

#if canImport(CoreGraphics)
import CoreGraphics
#endif
#if canImport(UIKit)
import UIKit

#if !os(Linux)
extension Color {
public struct FloatPath {
var red: CGFloat
Expand Down
11 changes: 3 additions & 8 deletions Sources/Common/Color/Color+css.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
// Copyright © 2019 DingSoung. All rights reserved.
//

#if canImport(Foundation)
import Foundation
#endif

#if canImport(CoreGraphics)
import CoreGraphics
#endif
#if canImport(UIKit)
import UIKit

#if !os(Linux)
extension Color {
private static let map: [String: UInt] = [
"black": 0x000000,
Expand Down Expand Up @@ -172,4 +166,5 @@ extension Color {
}
}
}

#endif
10 changes: 2 additions & 8 deletions Sources/Common/Color/Color+hex.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
// Created by Songwen on 2018/11/7.
// Copyright © 2018 DingSoung. All rights reserved.

#if canImport(Foundation)
import Foundation
#endif

#if canImport(CoreGraphics)
import CoreGraphics
#endif
#if canImport(UIKit)
import UIKit

#if !os(Linux)
extension Color {
private static let association = Association<NSCache<NSString, Color>>()
public class final var memoryCache: NSCache<NSString, Color> {
Expand Down
6 changes: 2 additions & 4 deletions Sources/Common/Color/Color+rgba.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Created by Songwen on 2018/11/7.
// Copyright © 2018 DingSoung. All rights reserved.

#if canImport(CoreGraphics)
import CoreGraphics
#endif
#if canImport(UIKit)
import UIKit

#if !os(Linux)
extension Color {
/// init color with RGBA Hex 0x00 ~ 0xFF
public convenience init(red: UInt, green: UInt, blue: UInt, alpha: UInt) {
Expand Down
5 changes: 0 additions & 5 deletions Sources/Common/Color/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@
import UIKit
public typealias Color = UIColor
#endif

#if canImport(AppKit)
import AppKit
public typealias Color = NSColor
#endif
5 changes: 0 additions & 5 deletions Sources/Common/Image/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import UIKit
public typealias Image = UIImage
#endif

#if canImport(AppKit)
import AppKit
public typealias Image = NSImage
#endif

#if !os(watchOS)
import CoreImage
#endif
5 changes: 0 additions & 5 deletions Sources/Common/View/View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@
import UIKit
public typealias View = UIView
#endif

#if canImport(AppKit)
import AppKit
public typealias View = NSView
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,15 @@
import SystemConfiguration

extension SCNetworkReachability {
private var flags: SCNetworkReachabilityFlags {
public var flags: SCNetworkReachabilityFlags {
var networkReachabilityFlags: SCNetworkReachabilityFlags = []
SCNetworkReachabilityGetFlags(self, &networkReachabilityFlags)
return networkReachabilityFlags
}

public var connectionRequired: Bool {
return flags.contains(.connectionRequired)
}

public var reachable: Bool {
return flags.contains(.reachable)
}

public var isOnline: Bool {
let flags = self.flags
return flags.contains(.reachable) && !flags.contains(.connectionRequired)
}

public enum Status: Int {
case notReachable = 0
case reachableViaWiFi
case reachableViaWWAN
}

public var status: Status {
let flags = self.flags
guard flags.contains(.reachable) else {
return .notReachable
}
var ret: Status = .notReachable
if flags.contains(.connectionRequired) == false {
ret = .reachableViaWiFi
}
if flags.contains(.connectionOnDemand) || flags.contains(.connectionOnTraffic) {
if flags.contains(.interventionRequired) == false {
ret = .reachableViaWiFi
}
}
if flags.contains(SCNetworkReachabilityFlags.isWWAN) {
ret = .reachableViaWWAN
}
return ret
}
}

#endif
58 changes: 0 additions & 58 deletions Sources/UIKit/UIWebView+JavaScript.swift

This file was deleted.

0 comments on commit 0eef340

Please sign in to comment.