Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Renamed property pin.keyboardMargins -> pin.keyBoardArea. This ne…
…w name better represent what `UIKit`'s `UIView.keyboardLayoutGuide` is.
  • Loading branch information
lucdion committed Feb 2, 2022
commit 703f262c0068bb3ed463fa8758c996080d134066
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion PinLayout.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -1362,15 +1362,15 @@ PinLayout's `UIView.pin.layoutMargins` property expose directly the value of UIK

<br/>

### 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)
```


Expand Down
10 changes: 2 additions & 8 deletions Sources/PinLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,11 @@ public class PinLayout<View: Layoutable> {
#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

Expand Down