Skip to content

Commit

Permalink
Builds with Xcode 11 & Swift 5.1 (1.5.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
s4cha committed Oct 1, 2019
1 parent eb08739 commit 7cf2835
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Keyboard+LayoutGuide.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Keyboard+LayoutGuide'
s.version = "1.4.2"
s.version = "1.5.0"
s.summary = "Apple's missing KeyboardLayoutGuide"
s.homepage = "https://github.com/freshOS/KeyboardLayoutGuide"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand All @@ -13,5 +13,5 @@ Pod::Spec.new do |s|
s.ios.deployment_target = "9"
s.description = "An alternative approach to handling keyboard in iOS with Autolayout"
s.module_name = 'KeyboardLayoutGuide'
s.swift_versions = ['4', '4.1', '4.2', '5.0']
s.swift_versions = ['4', '4.1', '4.2', '5.0', '5.1']
end
Binary file modified KeyboardLayoutGuide.framework.zip
Binary file not shown.
Expand Up @@ -380,6 +380,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.5.0;
PRODUCT_BUNDLE_IDENTIFIER = com.freshos.KeyboardLayoutGuide;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand All @@ -402,6 +403,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.5.0;
PRODUCT_BUNDLE_IDENTIFIER = com.freshos.KeyboardLayoutGuide;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
2 changes: 1 addition & 1 deletion KeyboardLayoutGuide/KeyboardLayoutGuide/Info.plist
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.4.2</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
24 changes: 12 additions & 12 deletions KeyboardLayoutGuide/KeyboardLayoutGuide/Keyboard+LayoutGuide.swift
Expand Up @@ -8,7 +8,7 @@

import UIKit

private class Keyboard {
internal class Keyboard {
static let shared = Keyboard()
var currentHeight: CGFloat = 0
}
Expand All @@ -17,7 +17,7 @@ extension UIView {
private enum AssociatedKeys {
static var keyboardLayoutGuide = "keyboardLayoutGuide"
}

/// A layout guide representing the inset for the keyboard.
/// Use this layout guide’s top anchor to create constraints pinning to the top of the keyboard.
public var keyboardLayoutGuide: KeyboardLayoutGuide {
Expand All @@ -38,14 +38,14 @@ open class KeyboardLayoutGuide: UILayoutGuide {
updateButtomAnchor()
}
}

private var bottomConstraint: NSLayoutConstraint?

@available(*, unavailable)
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

public init(notificationCenter: NotificationCenter = NotificationCenter.default) {
super.init()
// Observe keyboardWillChangeFrame notifications
Expand All @@ -56,7 +56,7 @@ open class KeyboardLayoutGuide: UILayoutGuide {
object: nil
)
}

internal func setUp() {
guard let view = owningView else { return }
NSLayoutConstraint.activate(
Expand All @@ -68,25 +68,25 @@ open class KeyboardLayoutGuide: UILayoutGuide {
)
updateButtomAnchor()
}

func updateButtomAnchor() {
if let bottomConstraint = bottomConstraint {
bottomConstraint.isActive = false
}

guard let view = owningView else { return }

let viewBottomAnchor: NSLayoutYAxisAnchor
if #available(iOS 11.0, *), usesSafeArea {
viewBottomAnchor = view.safeAreaLayoutGuide.bottomAnchor
} else {
viewBottomAnchor = view.bottomAnchor
}

bottomConstraint = bottomAnchor.constraint(equalTo: viewBottomAnchor)
bottomConstraint?.isActive = true
}

@objc
private func keyboardWillChangeFrame(_ note: Notification) {
if var height = note.keyboardHeight {
Expand All @@ -98,7 +98,7 @@ open class KeyboardLayoutGuide: UILayoutGuide {
Keyboard.shared.currentHeight = height
}
}

private func animate(_ note: Notification) {
if
let owningView = self.owningView,
Expand Down

0 comments on commit 7cf2835

Please sign in to comment.