Skip to content

Commit 1e49de7

Browse files
authored
Work/9.0.5 (SwiftKickMobile#486)
* Notifify will change before changes are made * Account for bounceAnimationOffset with keyboard avoidance * Release prep
1 parent c502648 commit 1e49de7

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## 9.0.5
5+
6+
### Fixes
7+
8+
* #482 Fix timing of `KeyboardTrackingView` callbacks.
9+
* #483 KeyboardTrackingView causes a small space under bottom-style view
10+
411
## 9.0.4
512

613
* #471 Xcode 13 issue - Enum cases with associated values cannot be marked potentially unavailable with '@available'

SwiftMessages.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'SwiftMessages'
3-
spec.version = '9.0.4'
3+
spec.version = '9.0.5'
44
spec.license = { :type => 'MIT' }
55
spec.homepage = 'https://github.com/SwiftKickMobile/SwiftMessages'
66
spec.authors = { 'Timothy Moose' => 'tim@swiftkick.it' }

SwiftMessages/KeyboardTrackingView.swift

+15-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ open class KeyboardTrackingView: UIView {
4444
/// The margin to maintain between the keyboard and the top of the view.
4545
@IBInspectable open var topMargin: CGFloat = 0
4646

47+
/// Subclasses can override this to do something before the change.
48+
open func willChange(
49+
change: KeyboardTrackingView.Change,
50+
userInfo: [AnyHashable : Any]
51+
) {}
52+
53+
/// Subclasses can override this to do something after the change.
54+
open func didChange(
55+
change: KeyboardTrackingView.Change,
56+
userInfo: [AnyHashable : Any]
57+
) {}
58+
4759
override public init(frame: CGRect) {
4860
super.init(frame: frame)
4961
postInit()
@@ -101,11 +113,12 @@ open class KeyboardTrackingView: UIView {
101113
guard !(isPaused || isAutomaticallyPaused),
102114
let userInfo = (notification as NSNotification).userInfo,
103115
let value = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
116+
willChange(change: change, userInfo: userInfo)
117+
delegate?.keyboardTrackingViewWillChange(change: change, userInfo: userInfo)
104118
let keyboardRect = value.cgRectValue
105119
let thisRect = convert(bounds, to: nil)
106120
let newHeight = max(0, thisRect.maxY - keyboardRect.minY) + topMargin
107121
guard heightConstraint.constant != newHeight else { return }
108-
delegate?.keyboardTrackingViewWillChange(change: change, userInfo: userInfo)
109122
animateKeyboardChange(change: change, height: newHeight, userInfo: userInfo)
110123
}
111124

@@ -115,6 +128,7 @@ open class KeyboardTrackingView: UIView {
115128
let curveNumber = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber {
116129
CATransaction.begin()
117130
CATransaction.setCompletionBlock {
131+
self.didChange(change: change, userInfo: userInfo)
118132
self.delegate?.keyboardTrackingViewDidChange(change: change, userInfo: userInfo)
119133
}
120134
UIView.beginAnimations(nil, context: nil)

SwiftMessages/MaskingView.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ class MaskingView: PassthroughView {
6565
guard let keyboardTrackingView = keyboardTrackingView,
6666
view != keyboardTrackingView,
6767
view != backgroundView else { return }
68-
keyboardTrackingView.topAnchor.constraint(greaterThanOrEqualTo: view.bottomAnchor).with(priority: UILayoutPriority(250)).isActive = true
68+
let offset: CGFloat
69+
if let adjustable = view as? MarginAdjustable {
70+
offset = -adjustable.bounceAnimationOffset
71+
} else {
72+
offset = 0
73+
}
74+
keyboardTrackingView.topAnchor.constraint(
75+
greaterThanOrEqualTo: view.bottomAnchor,
76+
constant: offset
77+
).with(priority: UILayoutPriority(250)).isActive = true
6978
}
7079
}

0 commit comments

Comments
 (0)