diff --git a/CHANGELOG.md b/CHANGELOG.md index c8ed403..2d252dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ # Change Log +## [1.10.2](https://github.com/layoutBox/PinLayout/releases/tag/1.10.2) +Released on 2022-02-01 + +#### Renamed property `pin.keyboardMargins` -> `pin.keyboardArea` + +This new name better represent what `UIKit`'s `UIView.keyboardLayoutGuide` is + +Added by [Luc Dion](https://github.com/lucdion) in Pull Request [#243](https://github.com/layoutBox/PinLayout/pull/243) + ## [1.10.1](https://github.com/layoutBox/PinLayout/releases/tag/1.10.1) Released on 2022-02-01 diff --git a/Example/PinLayoutSample/UI/Menu/MenuView.swift b/Example/PinLayoutSample/UI/Menu/MenuView.swift index 10e7146..5311462 100644 --- a/Example/PinLayoutSample/UI/Menu/MenuView.swift +++ b/Example/PinLayoutSample/UI/Menu/MenuView.swift @@ -83,8 +83,7 @@ extension MenuView { // Compilation validation #if compiler(>=5.5) // Xcode 13+ // iOS 15+ - _ = tableView.pin.keyboardMargins + _ = tableView.pin.keyboardArea #endif } - } diff --git a/PinLayout.podspec b/PinLayout.podspec index 6ccc920..ef869d1 100644 --- a/PinLayout.podspec +++ b/PinLayout.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |spec| spec.name = "PinLayout" - spec.version = "1.10.1" + spec.version = "1.10.2" spec.summary = "Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast." spec.description = "Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]" spec.homepage = "https://github.com/layoutBox/PinLayout" diff --git a/README.md b/README.md index 9bfd15b..0389564 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Extremely Fast views layouting without auto layout. No magic, pure code, full co * Xcode 13 / 12 / 11 / 10 ### Recent changes/features -* :star: Add [`pin.keyboardMargins`](#safeAreaInsets) property [iOS 15+] +* :star: Add [`pin.keyboardArea`](#safeAreaInsets) property [iOS 15+] * :star: New chainable Objective-C syntax. See [PinLayout using Objective-C](#objective_c_interface) * :star: Automatic Sizing, use PinLayout to compute view size. See [Automatic sizing](#automatic_sizing) * :star: Add methods to position a view between two other views. See [Layout between other views](#layout_between). @@ -1230,7 +1230,7 @@ PinLayout expose them using these properties: 1. **`UIView.pin.safeArea`**: Expose UIKit `UIView.safeAreaInsets` / `UIView.safeAreaLayoutGuide`. 2. **`UIView.pin.readableMargins`**: Expose UIKit `UIView.readableContentGuide`. 3. **`UIView.pin.layoutMargins`**: Expose UIKit `UIView.layoutMargins` / `UIView.layoutMarginsGuide`. -4. **`UIView.pin.keyboardMargins`**: Expose UIKit `UIView.keyboardLayoutGuide`. [iOS 15+] +4. **`UIView.pin.keyboardArea`**: Expose UIKit `UIView.keyboardLayoutGuide`. [iOS 15+] The following image display the 3 areas on an iPad in landscape mode. (safeArea, readableMargins, layoutMargins) @@ -1362,15 +1362,15 @@ PinLayout's `UIView.pin.layoutMargins` property expose directly the value of UIK
-### 4. pin.keyboardMargins: +### 4. pin.keyboardArea: ##### Property: -* **`pin.keyboardMargins: UIEdgeInset` [iOS 15+]** -PinLayout's `UIView.pin.keyboardMargins` property expose directly the value of UIKit [`UIView.keyboardLayoutGuide`](https://developer.apple.com/documentation/uikit/keyboards_and_input/adjusting_your_layout_with_keyboard_layout_guide). This is really useful when layout adjustment due to the keyboard is required. [iOS 15+] +* **`pin.keyboardArea: CGRect` [iOS 15+]** +The property expose the `UIKit` value [`UIView.keyboardLayoutGuide`](https://developer.apple.com/documentation/uikit/keyboards_and_input/adjusting_your_layout_with_keyboard_layout_guide). It represents the area (`CGRect`) of the keyboard that is covering the view. Useful to adjust the layout when the keyboard is visible. [iOS 15+] ##### Usage example: ```swift - container.pin.bottom(view.pin.keyboardMargins.top) + container.pin.bottom(view.pin.keyboardArea.top) ``` diff --git a/Sources/PinLayout.swift b/Sources/PinLayout.swift index 3d60994..4a40aa4 100644 --- a/Sources/PinLayout.swift +++ b/Sources/PinLayout.swift @@ -116,17 +116,11 @@ public class PinLayout { #endif #if os(iOS) && compiler(>=5.5) // Xcode 13+ - public var keyboardMargins: PEdgeInsets { + public var keyboardArea: CGRect { guard #available(iOS 15.0, *) else { return .zero } guard let view = view as? UIView else { return .zero } - let layoutFrame = view.keyboardLayoutGuide.layoutFrame - guard !layoutFrame.isEmpty else { return .zero } - - return UIEdgeInsets(top: layoutFrame.origin.y, - left: layoutFrame.origin.x, - bottom: view.frame.height - layoutFrame.origin.y - layoutFrame.height, - right: view.frame.width - layoutFrame.origin.x - layoutFrame.width) + return view.keyboardLayoutGuide.layoutFrame } #endif diff --git a/Tests/iOS/ReadableLayoutMarginsSpec.swift b/Tests/iOS/ReadableLayoutMarginsSpec.swift index bc740a0..d03099b 100644 --- a/Tests/iOS/ReadableLayoutMarginsSpec.swift +++ b/Tests/iOS/ReadableLayoutMarginsSpec.swift @@ -110,14 +110,15 @@ class ReadableLayoutMargins: QuickSpec { } #if os(iOS) && compiler(>=5.5) - describe("Using pin.keyboardMargins") { + describe("Using pin.keyboardArea") { it("test") { setupWindow(with: viewController) rootView.pin.top(0).horizontally() - rootView.pin.bottom(rootView.pin.keyboardMargins.top) + rootView.pin.bottom(rootView.pin.keyboardArea.minY) expect(rootView.frame).to(equal(CGRect(x: 0, y: 267, width: 375, height: 400))) + expect(rootView.pin.keyboardArea).to(equal(CGRect(x: 0, y: 0, width: 0, height: 0))) } } #endif