Skip to content

Commit fda25c2

Browse files
authored
Merge pull request #243 from layoutBox/rename_keyBoardArea
Renamed property `pin.keyboardMargins` -> `pin.keyboardArea`
2 parents 65fc484 + 0029365 commit fda25c2

File tree

6 files changed

+22
-19
lines changed

6 files changed

+22
-19
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77

88
# Change Log
99

10+
## [1.10.2](https://github.com/layoutBox/PinLayout/releases/tag/1.10.2)
11+
Released on 2022-02-01
12+
13+
#### Renamed property `pin.keyboardMargins` -> `pin.keyboardArea`
14+
15+
This new name better represent what `UIKit`'s `UIView.keyboardLayoutGuide` is
16+
17+
Added by [Luc Dion](https://github.com/lucdion) in Pull Request [#243](https://github.com/layoutBox/PinLayout/pull/243)
18+
1019
## [1.10.1](https://github.com/layoutBox/PinLayout/releases/tag/1.10.1)
1120
Released on 2022-02-01
1221

Example/PinLayoutSample/UI/Menu/MenuView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ extension MenuView {
8383
// Compilation validation
8484
#if compiler(>=5.5) // Xcode 13+
8585
// iOS 15+
86-
_ = tableView.pin.keyboardMargins
86+
_ = tableView.pin.keyboardArea
8787
#endif
8888
}
89-
9089
}

PinLayout.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |spec|
1010
spec.name = "PinLayout"
11-
spec.version = "1.10.1"
11+
spec.version = "1.10.2"
1212
spec.summary = "Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast."
1313
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]"
1414
spec.homepage = "https://github.com/layoutBox/PinLayout"

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Extremely Fast views layouting without auto layout. No magic, pure code, full co
3838
* Xcode 13 / 12 / 11 / 10
3939

4040
### Recent changes/features
41-
* :star: Add [`pin.keyboardMargins`](#safeAreaInsets) property [iOS 15+]
41+
* :star: Add [`pin.keyboardArea`](#safeAreaInsets) property [iOS 15+]
4242
* :star: New chainable Objective-C syntax. See [PinLayout using Objective-C](#objective_c_interface)
4343
* :star: Automatic Sizing, use PinLayout to compute view size. See [Automatic sizing](#automatic_sizing)
4444
* :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:
12301230
1. **`UIView.pin.safeArea`**: Expose UIKit `UIView.safeAreaInsets` / `UIView.safeAreaLayoutGuide`.
12311231
2. **`UIView.pin.readableMargins`**: Expose UIKit `UIView.readableContentGuide`.
12321232
3. **`UIView.pin.layoutMargins`**: Expose UIKit `UIView.layoutMargins` / `UIView.layoutMarginsGuide`.
1233-
4. **`UIView.pin.keyboardMargins`**: Expose UIKit `UIView.keyboardLayoutGuide`. [iOS 15+]
1233+
4. **`UIView.pin.keyboardArea`**: Expose UIKit `UIView.keyboardLayoutGuide`. [iOS 15+]
12341234

12351235
The following image display the 3 areas on an iPad in landscape mode. (safeArea, readableMargins, layoutMargins)
12361236

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

13631363
<br/>
13641364

1365-
### 4. pin.keyboardMargins:
1365+
### 4. pin.keyboardArea:
13661366

13671367
##### Property:
1368-
* **`pin.keyboardMargins: UIEdgeInset` [iOS 15+]**
1369-
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+]
1368+
* **`pin.keyboardArea: CGRect` [iOS 15+]**
1369+
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+]
13701370

13711371
##### Usage example:
13721372
```swift
1373-
container.pin.bottom(view.pin.keyboardMargins.top)
1373+
container.pin.bottom(view.pin.keyboardArea.top)
13741374
```
13751375

13761376

Sources/PinLayout.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,11 @@ public class PinLayout<View: Layoutable> {
116116
#endif
117117

118118
#if os(iOS) && compiler(>=5.5) // Xcode 13+
119-
public var keyboardMargins: PEdgeInsets {
119+
public var keyboardArea: CGRect {
120120
guard #available(iOS 15.0, *) else { return .zero }
121121
guard let view = view as? UIView else { return .zero }
122122

123-
let layoutFrame = view.keyboardLayoutGuide.layoutFrame
124-
guard !layoutFrame.isEmpty else { return .zero }
125-
126-
return UIEdgeInsets(top: layoutFrame.origin.y,
127-
left: layoutFrame.origin.x,
128-
bottom: view.frame.height - layoutFrame.origin.y - layoutFrame.height,
129-
right: view.frame.width - layoutFrame.origin.x - layoutFrame.width)
123+
return view.keyboardLayoutGuide.layoutFrame
130124
}
131125
#endif
132126

Tests/iOS/ReadableLayoutMarginsSpec.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,15 @@ class ReadableLayoutMargins: QuickSpec {
110110
}
111111

112112
#if os(iOS) && compiler(>=5.5)
113-
describe("Using pin.keyboardMargins") {
113+
describe("Using pin.keyboardArea") {
114114
it("test") {
115115
setupWindow(with: viewController)
116116

117117
rootView.pin.top(0).horizontally()
118-
rootView.pin.bottom(rootView.pin.keyboardMargins.top)
118+
rootView.pin.bottom(rootView.pin.keyboardArea.minY)
119119

120120
expect(rootView.frame).to(equal(CGRect(x: 0, y: 267, width: 375, height: 400)))
121+
expect(rootView.pin.keyboardArea).to(equal(CGRect(x: 0, y: 0, width: 0, height: 0)))
121122
}
122123
}
123124
#endif

0 commit comments

Comments
 (0)