Skip to content

Commit

Permalink
升级到swift 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
changsanjiang committed Nov 6, 2018
1 parent 2ad6bce commit d98e257
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions SJBackGRProject/SJBackGRProject.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@
PROVISIONING_PROFILE_SPECIFIER = WildcardProfile;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -940,7 +940,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion SJBackGRProject/SwiftVersion/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

// install
SJNavigationPopGesture.install()
Expand Down
10 changes: 5 additions & 5 deletions SJBackGRProject/SwiftVersion/TestViewControllerNav.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ class TestViewControllerNav: UIViewController {
let btn = UIButton.init(type: .custom)
btn.setTitleColor(UIColor.orange, for: .normal)
btn.setTitle("Push", for: .normal)
btn.addTarget(self, action: #selector(push), for: UIControlEvents.touchUpInside)
btn.addTarget(self, action: #selector(push), for: UIControl.Event.touchUpInside)
return btn
}()

private let albumBtn: UIButton = {
let btn = UIButton.init(type: .custom)
btn.setTitleColor(UIColor.orange, for: .normal)
btn.setTitle("Album", for: .normal)
btn.addTarget(self, action: #selector(album), for: UIControlEvents.touchUpInside)
btn.addTarget(self, action: #selector(album), for: UIControl.Event.touchUpInside)
return btn
}()

private let modal_Nav_Btn: UIButton = {
let btn = UIButton.init(type: .custom)
btn.setTitleColor(UIColor.orange, for: .normal)
btn.setTitle("modal_Nav", for: .normal)
btn.addTarget(self, action: #selector(modal_Nav), for: UIControlEvents.touchUpInside)
btn.addTarget(self, action: #selector(modal_Nav), for: UIControl.Event.touchUpInside)
return btn
}()

private let alertBtn: UIButton = {
let btn = UIButton.init(type: .custom)
btn.setTitleColor(UIColor.orange, for: .normal)
btn.setTitle("Alert", for: .normal)
btn.addTarget(self, action: #selector(alert), for: UIControlEvents.touchUpInside)
btn.addTarget(self, action: #selector(alert), for: UIControl.Event.touchUpInside)
return btn
}()

Expand Down Expand Up @@ -107,7 +107,7 @@ class TestViewControllerNav: UIViewController {
}

@objc private func push() -> Void {
self.navigationController?.pushViewController(ViewControllerMapView(), animated: true)
self.navigationController?.pushViewController(ViewControllerTestTableView(), animated: true)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ViewControllerTestTableView: UIViewController, UITableViewDataSource, UITa
override func viewDidLoad() {
super.viewDidLoad()

let tableView = UITableView.init(frame: self.view.frame, style: UITableViewStyle.plain)
let tableView = UITableView.init(frame: self.view.frame, style: UITableView.Style.plain)
tableView.rowHeight = 49;
tableView .register(UITableViewCell.self, forCellReuseIdentifier: UITableViewCellID)
self.view.addSubview(tableView)
Expand Down
60 changes: 30 additions & 30 deletions SJNavigationPopGesture/SJNavigationPopGesture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public extension UINavigationController {
}

/// pop gesture state.
public var sj_popGestureState: UIGestureRecognizerState {
public var sj_popGestureState: UIGestureRecognizer.State {
get {
var gesture: UIGestureRecognizer?
switch SJ_selectedType {
Expand Down Expand Up @@ -386,10 +386,10 @@ extension UINavigationController : UIGestureRecognizerDelegate {
self.topViewController?.sj_considerWebView?.canGoBack == true ) {
return false
}
else if ( self.childViewControllers.count <= 1 ) {
else if ( self.children.count <= 1 ) {
return false
}
else if ( self.childViewControllers.last?.isKind(of: UINavigationController.self) )! {
else if ( self.children.last?.isKind(of: UINavigationController.self) )! {
return false
}
else {
Expand All @@ -414,8 +414,8 @@ extension UINavigationController : UIGestureRecognizerDelegate {
}

public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
if ( gestureRecognizer.state == UIGestureRecognizerState.failed ||
gestureRecognizer.state == UIGestureRecognizerState.cancelled ) {
if ( gestureRecognizer.state == UIGestureRecognizer.State.failed ||
gestureRecognizer.state == UIGestureRecognizer.State.cancelled ) {
return false
}

Expand All @@ -437,21 +437,21 @@ extension UINavigationController : UIGestureRecognizerDelegate {
if ( !otherGestureRecognizer.view!.isKind(of: cls) ) {
return false
}
}

// if `MKMapContentView`
let point = gestureRecognizer.location(in: gestureRecognizer.view)
if ( (self.topViewController?.sj_fadeArea != nil || self.topViewController?.sj_fadeAreaViews != nil)
&& !SJ_isFadeArea(point) ) {
self.SJ_cancellGesture(otherGestureRecognizer)
return true
}

// map view default fade area
let rect = CGRect.init(origin: CGPoint.init(x: 50, y: 0), size: self.view.frame.size)
if ( !self.rect(rect, containerPoint: point) ) {
self.SJ_cancellGesture(otherGestureRecognizer)
return true
// if `MKMapContentView`
let point = gestureRecognizer.location(in: gestureRecognizer.view)
if ( (self.topViewController?.sj_fadeArea != nil || self.topViewController?.sj_fadeAreaViews != nil)
&& !SJ_isFadeArea(point) ) {
self.SJ_cancellGesture(otherGestureRecognizer)
return true
}
// map view default fade area
let rect = CGRect.init(origin: CGPoint.init(x: 50, y: 0), size: self.view.frame.size)
if ( !self.rect(rect, containerPoint: point) ) {
self.SJ_cancellGesture(otherGestureRecognizer)
return true
}
}

return false
Expand Down Expand Up @@ -552,7 +552,7 @@ extension UINavigationController : UIGestureRecognizerDelegate {
}

private func SJ_cancellGesture(_ gesture: UIGestureRecognizer) -> Void {
gesture.setValue(UIGestureRecognizerState.cancelled.rawValue, forKey: "state")
gesture.setValue(UIGestureRecognizer.State.cancelled.rawValue, forKey: "state")
}

@objc private func SJ_handlePanGR(_ pan:UIPanGestureRecognizer) -> Void {
Expand All @@ -571,7 +571,7 @@ extension UINavigationController : UIGestureRecognizerDelegate {
private func SJ_ViewWillBeginDragging(_ offset: CGFloat) -> Void {
self.view.endEditing(true)

_SJSnapshotServer.nav(self, preparePopViewController: self.childViewControllers.last!)
_SJSnapshotServer.nav(self, preparePopViewController: self.children.last!)

if ( self.topViewController?.sj_viewWillBeginDragging != nil ) {
self.topViewController?.sj_viewWillBeginDragging!(self.topViewController!)
Expand All @@ -587,7 +587,7 @@ extension UINavigationController : UIGestureRecognizerDelegate {
}

self.view.transform = CGAffineTransform.init(translationX: offset, y: 0)
_SJSnapshotServer.nav(self, poppingViewController: self.childViewControllers.last!, offset: offset)
_SJSnapshotServer.nav(self, poppingViewController: self.children.last!, offset: offset)
if ( self.topViewController?.sj_viewDidDrag != nil ) {
self.topViewController?.sj_viewDidDrag!(self.topViewController!)
}
Expand All @@ -608,15 +608,15 @@ extension UINavigationController : UIGestureRecognizerDelegate {
}

UIView.animate(withDuration: TimeInterval(duration), animations: {
_SJSnapshotServer .nav(self, willEndPopViewController: self.childViewControllers.last!, pop: pop)
_SJSnapshotServer .nav(self, willEndPopViewController: self.children.last!, pop: pop)
if ( pop ) {
self.view.transform = CGAffineTransform.init(translationX: self.view.frame.width, y: 0)
}
else {
self.view.transform = CGAffineTransform.identity
}
}) { (finished) in
_SJSnapshotServer.nav(self, endPopViewController: self.childViewControllers.last!)
_SJSnapshotServer.nav(self, endPopViewController: self.children.last!)
if ( pop ) {
self.popViewController(animated: false)
self.view.transform = CGAffineTransform.identity
Expand Down Expand Up @@ -739,12 +739,12 @@ fileprivate class _SJSnapshotServer {

// MARK: nav action
class func nav(_ nav: UINavigationController, pushViewController: UIViewController) {
if ( nav.childViewControllers.count == 0 ) {
if ( nav.children.count == 0 ) {
return
}

let index = nav.childViewControllers.count - 1
let currentVC = nav.childViewControllers[index]
let index = nav.children.count - 1
let currentVC = nav.children[index]
if ( nav.isKind(of: UIImagePickerController.self) ) {
currentVC.sj_displayMode = .snapshot
}
Expand Down Expand Up @@ -841,7 +841,7 @@ fileprivate class _SJSnapshotRecorder {
var index: Int

func preparePopViewController() {
let vc = nav.childViewControllers[index]
let vc = nav.children[index]
switch vc.sj_displayMode {
case .origin:
let preview = vc.view
Expand Down Expand Up @@ -885,7 +885,7 @@ fileprivate class _SJSnapshotRecorder {

rootView.addSubview(pre_container!)

let vc = nav.childViewControllers[index]
let vc = nav.children[index]
switch vc.sj_displayMode {
case .snapshot:
pre_snapshot = nav.view.window?.snapshotView(afterScreenUpdates: false)
Expand Down

0 comments on commit d98e257

Please sign in to comment.