Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-correct to swift 4.2 #203

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/ShoutFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ open class ShoutView: UIView {
backgroundView.addGestureRecognizer(tapGestureRecognizer)
addGestureRecognizer(panGestureRecognizer)

NotificationCenter.default.addObserver(self, selector: #selector(ShoutView.orientationDidChange), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(ShoutView.orientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil)
}

public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

deinit {
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil)
}

// MARK: - Configuration
Expand Down
27 changes: 20 additions & 7 deletions Source/WhisperFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ class WhisperFactory: NSObject {

override init() {
super.init()
NotificationCenter.default.addObserver(self, selector: #selector(WhisperFactory.orientationDidChange), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(WhisperFactory.orientationDidChange),
name: UIDevice.orientationDidChangeNotification,
object: nil)
}

deinit {
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
NotificationCenter.default.removeObserver(self,
name: UIDevice.orientationDidChangeNotification,
object: nil)
}

func craft(_ message: Message, navigationController: UINavigationController, action: WhisperAction) {
Expand Down Expand Up @@ -237,14 +242,23 @@ class WhisperFactory: NSObject {

if let tableView = viewController.view as? UITableView
, viewController is UITableViewController {
tableView.contentInset = UIEdgeInsetsMake(tableView.contentInset.top + edgeInsetHeight, tableView.contentInset.left, tableView.contentInset.bottom, tableView.contentInset.right)
tableView.contentInset = UIEdgeInsets(top: tableView.contentInset.top + edgeInsetHeight,
left: tableView.contentInset.left,
bottom: tableView.contentInset.bottom,
right: tableView.contentInset.right)
} else if let collectionView = viewController.view as? UICollectionView
, viewController is UICollectionViewController {
collectionView.contentInset = UIEdgeInsetsMake(collectionView.contentInset.top + edgeInsetHeight, collectionView.contentInset.left, collectionView.contentInset.bottom, collectionView.contentInset.right)
collectionView.contentInset = UIEdgeInsets(top: collectionView.contentInset.top + edgeInsetHeight,
left: collectionView.contentInset.left,
bottom: collectionView.contentInset.bottom,
right: collectionView.contentInset.right)
} else {
for view in viewController.view.subviews {
if let scrollView = view as? UIScrollView {
scrollView.contentInset = UIEdgeInsetsMake(scrollView.contentInset.top + edgeInsetHeight, scrollView.contentInset.left, scrollView.contentInset.bottom, scrollView.contentInset.right)
scrollView.contentInset = UIEdgeInsets(top: scrollView.contentInset.top + edgeInsetHeight,
left: scrollView.contentInset.left,
bottom: scrollView.contentInset.bottom,
right: scrollView.contentInset.right)
}
}
}
Expand Down Expand Up @@ -280,8 +294,7 @@ extension WhisperFactory: UINavigationControllerDelegate {
var maximumY = navigationController.navigationBar.frame.maxY - UIApplication.shared.statusBarFrame.height

for subview in navigationController.navigationBar.subviews {
if subview is WhisperView { navigationController.navigationBar.bringSubview(toFront: subview) }

if subview is WhisperView { navigationController.navigationBar.bringSubviewToFront(subview) }
if subview.frame.maxY > maximumY && !(subview is WhisperView) {
maximumY = subview.frame.maxY
}
Expand Down
10 changes: 5 additions & 5 deletions Source/WhistleFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ open class WhistleFactory: UIViewController {

view.addGestureRecognizer(tapGestureRecognizer)

NotificationCenter.default.addObserver(self, selector: #selector(WhistleFactory.orientationDidChange), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(WhistleFactory.orientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil)
}

public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

deinit {
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil)
}

// MARK: - Configuration
Expand Down Expand Up @@ -96,7 +96,7 @@ open class WhistleFactory: UIViewController {
}

func moveWindowToFront() {
whistleWindow.windowLevel = view.isiPhoneX ? UIWindowLevelNormal : UIWindowLevelStatusBar
whistleWindow.windowLevel = view.isiPhoneX ? UIWindow.Level.normal : UIWindow.Level.statusBar
setNeedsStatusBarAppearanceUpdate()
}

Expand All @@ -117,7 +117,7 @@ open class WhistleFactory: UIViewController {
NSString(string: text).boundingRect(
with: CGSize(width: labelWidth, height: CGFloat.infinity),
options: NSStringDrawingOptions.usesLineFragmentOrigin,
attributes: [NSAttributedStringKey.font: titleLabel.font],
attributes: [NSAttributedString.Key.font: titleLabel.font],
context: nil
)
titleLabelHeight = CGFloat(neededDimensions.size.height)
Expand Down Expand Up @@ -172,7 +172,7 @@ open class WhistleFactory: UIViewController {
}, completion: { _ in
if let window = self.previousKeyWindow {
window.isHidden = false
self.whistleWindow.windowLevel = UIWindowLevelNormal - 1
self.whistleWindow.windowLevel = UIWindow.Level.normal
self.previousKeyWindow = nil
window.rootViewController?.setNeedsStatusBarAppearanceUpdate()
}
Expand Down
4 changes: 2 additions & 2 deletions Whisper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -290,7 +290,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down