Skip to content
Merged
Changes from all commits
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
20 changes: 14 additions & 6 deletions Rideau/Core/RideauView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,21 @@ public final class RideauView: RideauTouchThroughView {
return
}

var keyboardHeight: CGFloat? {
guard let v = note.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else {
return nil
var keyboardOverlapHeight: CGFloat {
guard
let value = note.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue,
let window
else {
return 0
}

let screenHeight = UIScreen.main.bounds.height
return max(0, screenHeight - v.cgRectValue.minY)
let frame = convert(value.cgRectValue, from: window.screen.coordinateSpace)

guard !frame.isEmpty, frame.maxY >= bounds.maxY else {
return 0
}

return max(0, bounds.maxY - frame.minY)
}

var animationDuration: Double {
Expand All @@ -307,7 +315,7 @@ public final class RideauView: RideauTouchThroughView {
delay: 0,
options: UIView.AnimationOptions(rawValue: UInt(animationCurve << 16)),
animations: {
self.bottom.constant = -keyboardHeight!
self.bottom.constant = -keyboardOverlapHeight
self.layoutIfNeeded()
},
completion: nil
Expand Down
Loading