Skip to content

Commit

Permalink
Self review 2
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleve committed Feb 23, 2020
1 parent 7b12a23 commit e7caea5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,25 @@ final class KeyboardObserver
}
}

private func animate(with info : NotificationInfo, _ block : @escaping () -> ())
private func animate(with info : NotificationInfo, _ animations : @escaping () -> ())
{
if info.animationDuration > 0.0 {
/**
Create an animation curve with the correct curve for showing or hiding the keyboard.

This is unfortunately a private UIView curve. However, we can map it to the animation options' curve
like so: https://stackoverflow.com/questions/26939105/keyboard-animation-curve-as-int
*/
let animationOptions = UIView.AnimationOptions(rawValue: info.animationCurve << 16)

UIView.animate(
withDuration: info.animationDuration,
delay: 0.0,
options: .init(rawValue: info.animationCurve << 16),
animations: block
options: animationOptions,
animations: animations
)
} else {
block()
animations()
}
}

Expand Down Expand Up @@ -110,16 +118,12 @@ final class KeyboardObserver

@objc func keyboardFrameChanged(_ notification : Notification)
{
let info : NotificationInfo

do {
info = try NotificationInfo(with: notification)
let info = try NotificationInfo(with: notification)
self.receivedUpdatedKeyboardInfo(info)
} catch {
assertionFailure("Blueprint could not read system keyboard notification. This error needs to be fixed in Blueprint. Error: \(error)")
return
}

self.receivedUpdatedKeyboardInfo(info)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
//
// KeyboardObserverTests.swift
// Listable-Unit-Tests
//
// Created by Kyle Van Essen on 11/22/19.
//

import XCTest
import UIKit

Expand Down
2 changes: 0 additions & 2 deletions SampleApp/Podfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
platform :ios, '12.0'
inhibit_all_warnings!
use_frameworks!

project 'SampleApp.xcodeproj'

Expand Down
2 changes: 1 addition & 1 deletion SampleApp/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ SPEC CHECKSUMS:
BlueprintUI: e5f89d442f225e1865aa8f153dc9da3f1adcbfc4
BlueprintUICommonControls: 081862011936eaad26f8d606803fa9539ce188ab

PODFILE CHECKSUM: 5490b44dd22c31a1927df648f14fa88cce462867
PODFILE CHECKSUM: 1e8513f2ddc9f8511335f2c2c2378c4da8250058

COCOAPODS: 1.8.4
Loading

0 comments on commit e7caea5

Please sign in to comment.