Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.

Xcode 10 / Swift 4.2 upgrade. #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 6 additions & 14 deletions ALTextInputBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
/* Begin PBXBuildFile section */
FA41B0B21AEBC57D00593A04 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FA41B0B01AEBC57D00593A04 /* Images.xcassets */; };
FA4AE6741B0494200086AEBF /* ALTextInputBarDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6731B0494200086AEBF /* ALTextInputBarDelegate.swift */; };
FA4AE6751B0494200086AEBF /* ALTextInputBarDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6731B0494200086AEBF /* ALTextInputBarDelegate.swift */; };
FA4AE6771B0494AE0086AEBF /* ALKeyboardObservingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6761B0494AE0086AEBF /* ALKeyboardObservingView.swift */; };
FA4AE6781B0494AE0086AEBF /* ALKeyboardObservingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6761B0494AE0086AEBF /* ALKeyboardObservingView.swift */; };
FA4AE67A1B0495F60086AEBF /* ALTextInputUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6791B0495F60086AEBF /* ALTextInputUtilities.swift */; };
FA4AE67B1B0495F60086AEBF /* ALTextInputUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4AE6791B0495F60086AEBF /* ALTextInputUtilities.swift */; };
FA61C9471AEAEC5F00920E37 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA61C9461AEAEC5F00920E37 /* AppDelegate.swift */; };
FA61C9491AEAEC5F00920E37 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA61C9481AEAEC5F00920E37 /* ViewController.swift */; };
FA61C95D1AEAEC5F00920E37 /* ALTextInputBarTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA61C95C1AEAEC5F00920E37 /* ALTextInputBarTests.swift */; };
Expand Down Expand Up @@ -184,11 +181,11 @@
FA61C9401AEAEC5F00920E37 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = GAPQH4AM76;
LastSwiftMigration = 0920;
LastSwiftMigration = 1010;
};
FA61C9551AEAEC5F00920E37 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 1010;
TestTargetID = FA61C9401AEAEC5F00920E37;
};
};
Expand Down Expand Up @@ -250,9 +247,6 @@
buildActionMask = 2147483647;
files = (
FA61C95D1AEAEC5F00920E37 /* ALTextInputBarTests.swift in Sources */,
FA4AE6751B0494200086AEBF /* ALTextInputBarDelegate.swift in Sources */,
FA4AE6781B0494AE0086AEBF /* ALKeyboardObservingView.swift in Sources */,
FA4AE67B1B0495F60086AEBF /* ALTextInputUtilities.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -379,8 +373,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.TextInputBar;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -396,8 +389,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.zero.TextInputBar;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -418,7 +410,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.zero.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ALTextInputBar.app/ALTextInputBar";
};
name = Debug;
Expand All @@ -435,7 +427,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.zero.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ALTextInputBar.app/ALTextInputBar";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
6 changes: 3 additions & 3 deletions ALTextInputBar/ALKeyboardObservingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ALKeyboardObservingView: UIView {
private var defaultHeight: CGFloat = 44

override public var intrinsicContentSize: CGSize {
return CGSize(width: UIViewNoIntrinsicMetric, height: defaultHeight)
return CGSize(width: UIView.noIntrinsicMetric, height: defaultHeight)
}


Expand Down Expand Up @@ -52,7 +52,7 @@ public class ALKeyboardObservingView: UIView {

public func updateHeight(height: CGFloat) {
for constraint in constraints {
if constraint.firstAttribute == NSLayoutAttribute.height && constraint.firstItem as! NSObject == self {
if constraint.firstAttribute == NSLayoutConstraint.Attribute.height && constraint.firstItem as! NSObject == self {
constraint.constant = height < defaultHeight ? defaultHeight : height
}
}
Expand All @@ -75,7 +75,7 @@ public class ALKeyboardObservingView: UIView {
}

private func keyboardDidChangeFrame(frame: CGRect) {
let userInfo: [AnyHashable : Any] = [UIKeyboardFrameEndUserInfoKey: NSValue(cgRect:frame)]
let userInfo: [AnyHashable : Any] = [UIResponder.keyboardFrameEndUserInfoKey: NSValue(cgRect:frame)]
NotificationCenter.default.post(name: NSNotification.Name(rawValue: ALKeyboardFrameDidChangeNotification), object: nil, userInfo: userInfo)
}

Expand Down
8 changes: 4 additions & 4 deletions ALTextInputBar/ALTextInputBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ open class ALTextInputBar: UIView, ALTextViewDelegate {
// MARK: - View positioning and layout -

override open var intrinsicContentSize: CGSize {
return CGSize(width: UIViewNoIntrinsicMetric, height: defaultHeight)
return CGSize(width: UIView.noIntrinsicMetric, height: defaultHeight)
}

override open func layoutSubviews() {
Expand Down Expand Up @@ -240,8 +240,8 @@ open class ALTextInputBar: UIView, ALTextViewDelegate {

textView.frame = CGRect(x: textViewX, y: textViewY, width: textViewWidth, height: textViewHeight)

let offset = UIEdgeInsetsMake(-textViewBorderPadding.top, -textViewBorderPadding.left, -textViewBorderPadding.bottom, -textViewBorderPadding.right)
textViewBorderView.frame = UIEdgeInsetsInsetRect(textView.frame, offset)
let offset = UIEdgeInsets(top: -textViewBorderPadding.top, left: -textViewBorderPadding.left, bottom: -textViewBorderPadding.bottom, right: -textViewBorderPadding.right)
textViewBorderView.frame = textView.frame.inset(by: offset)
}

public func updateViews(animated: Bool) {
Expand All @@ -265,7 +265,7 @@ open class ALTextInputBar: UIView, ALTextViewDelegate {
let height = padding + newHeight

for constraint in constraints {
if constraint.firstAttribute == NSLayoutAttribute.height && constraint.firstItem as! NSObject == self {
if constraint.firstAttribute == NSLayoutConstraint.Attribute.height && constraint.firstItem as! NSObject == self {
constraint.constant = height < defaultHeight ? defaultHeight : height
}
}
Expand Down
6 changes: 3 additions & 3 deletions ALTextInputBar/ALTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public class ALTextView: UITextView {
placeholderLabel.isHidden = shouldHidePlaceholder()
if !placeholderLabel.isHidden {
placeholderLabel.frame = placeholderRectThatFits(rect: bounds)
sendSubview(toBack: placeholderLabel)
sendSubviewToBack(placeholderLabel)
}
}

Expand Down Expand Up @@ -153,7 +153,7 @@ public class ALTextView: UITextView {
var newHeight: CGFloat = 0

if let font = font {
let attributes = [NSAttributedStringKey.font: font]
let attributes = [NSAttributedString.Key.font: font]
let boundingSize = CGSize(width: frame.size.width - textContainerInset.left - textContainerInset.right, height: .greatestFiniteMagnitude)
let size = text.boundingRect(with: boundingSize, options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes: attributes, context: nil)
newHeight = ceil(size.height)
Expand Down Expand Up @@ -201,7 +201,7 @@ public class ALTextView: UITextView {
*/
private func placeholderRectThatFits(rect: CGRect) -> CGRect {
let padding = textContainer.lineFragmentPadding
var placeHolderRect = UIEdgeInsetsInsetRect(rect, textContainerInset)
var placeHolderRect = rect.inset(by: textContainerInset)
placeHolderRect.origin.x += padding
placeHolderRect.size.width -= padding * 2

Expand Down
2 changes: 1 addition & 1 deletion Example/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]? = nil) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

// Override point for customization after application launch.

Expand Down
10 changes: 5 additions & 5 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class ViewController: UIViewController {
configureInputBar()

NotificationCenter.default.addObserver(self, selector: #selector(keyboardFrameChanged(notification:)), name: NSNotification.Name(rawValue: ALKeyboardFrameDidChangeNotification), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}

override func viewWillLayoutSubviews() {
Expand Down Expand Up @@ -77,21 +77,21 @@ class ViewController: UIViewController {

@objc func keyboardFrameChanged(notification: NSNotification) {
if let userInfo = notification.userInfo {
let frame = userInfo[UIKeyboardFrameEndUserInfoKey] as! CGRect
let frame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! CGRect
textInputBar.frame.origin.y = frame.origin.y
}
}

@objc func keyboardWillShow(notification: NSNotification) {
if let userInfo = notification.userInfo {
let frame = userInfo[UIKeyboardFrameEndUserInfoKey] as! CGRect
let frame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! CGRect
textInputBar.frame.origin.y = frame.origin.y
}
}

@objc func keyboardWillHide(notification: NSNotification) {
if let userInfo = notification.userInfo {
let frame = userInfo[UIKeyboardFrameEndUserInfoKey] as! CGRect
let frame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! CGRect
textInputBar.frame.origin.y = frame.origin.y
}
}
Expand Down