From 703f262c0068bb3ed463fa8758c996080d134066 Mon Sep 17 00:00:00 2001 From: Luc Dion Date: Tue, 1 Feb 2022 19:55:40 -0500 Subject: [PATCH 1/4] Renamed property `pin.keyboardMargins` -> `pin.keyBoardArea`. This new name better represent what `UIKit`'s `UIView.keyboardLayoutGuide` is. --- CHANGELOG.md | 9 +++++++++ PinLayout.podspec | 2 +- README.md | 12 ++++++------ Sources/PinLayout.swift | 10 ++-------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8ed403..65c787d 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 [#238](https://github.com/layoutBox/PinLayout/pull/238) + ## [1.10.1](https://github.com/layoutBox/PinLayout/releases/tag/1.10.1) Released on 2022-02-01 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..0f93b82 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 e614b16..831f9e4 100644 --- a/Sources/PinLayout.swift +++ b/Sources/PinLayout.swift @@ -116,17 +116,11 @@ public class PinLayout { #endif #if os(iOS) - 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 From 1dee021bebac32c23fb25fbf5ebe92c47b589693 Mon Sep 17 00:00:00 2001 From: Luc Dion Date: Tue, 1 Feb 2022 19:57:07 -0500 Subject: [PATCH 2/4] Update changelog.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65c787d..480f178 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ Released on 2022-02-01 This new name better represent what `UIKit`'s `UIView.keyboardLayoutGuide` is. -Added by [Luc Dion](https://github.com/lucdion) in Pull Request [#238](https://github.com/layoutBox/PinLayout/pull/238) +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 From e06cac64ce3ec28e64162549da2e385494883694 Mon Sep 17 00:00:00 2001 From: Luc Dion Date: Tue, 1 Feb 2022 20:03:38 -0500 Subject: [PATCH 3/4] Fix typo in `keyboardArea` name. --- CHANGELOG.md | 2 +- README.md | 10 +++++----- Sources/PinLayout.swift | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 480f178..e6238c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ## [1.10.2](https://github.com/layoutBox/PinLayout/releases/tag/1.10.2) Released on 2022-02-01 -#### Renamed property `pin.keyboardMargins` -> `pin.keyBoardArea` +#### Renamed property `pin.keyboardMargins` -> `pin.keyboardArea` This new name better represent what `UIKit`'s `UIView.keyboardLayoutGuide` is. diff --git a/README.md b/README.md index 0f93b82..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.keyBoardArea`](#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.keyBoardArea`**: 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.keyBoardArea: +### 4. pin.keyboardArea: ##### Property: -* **`pin.keyBoardArea: CGRect` [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.keyBoardArea.top) + container.pin.bottom(view.pin.keyboardArea.top) ``` diff --git a/Sources/PinLayout.swift b/Sources/PinLayout.swift index 831f9e4..a9cd360 100644 --- a/Sources/PinLayout.swift +++ b/Sources/PinLayout.swift @@ -116,7 +116,7 @@ public class PinLayout { #endif #if os(iOS) - public var keyBoardArea: CGRect { + public var keyboardArea: CGRect { guard #available(iOS 15.0, *) else { return .zero } guard let view = view as? UIView else { return .zero } From 1fca80aee879587f5dcf817e50a275d23ffbdbeb Mon Sep 17 00:00:00 2001 From: Luc Dion Date: Wed, 2 Feb 2022 08:06:05 -0500 Subject: [PATCH 4/4] Update readme --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6238c9..2d252dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,9 @@ Released on 2022-02-01 #### Renamed property `pin.keyboardMargins` -> `pin.keyboardArea` -This new name better represent what `UIKit`'s `UIView.keyboardLayoutGuide` is. +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) +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