Skip to content

Commit

Permalink
Move UIView.AnimationOptions to Typists as an convenience extension
Browse files Browse the repository at this point in the history
  • Loading branch information
totocaster committed Apr 8, 2019
1 parent 984733f commit f809414
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 35 deletions.
21 changes: 21 additions & 0 deletions Typist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,24 @@ extension Typist: UIGestureRecognizerDelegate {
}

}


// MARK: UIView extensions (convenience)

extension UIView.AnimationOptions {
public init(curve: UIView.AnimationCurve) {
switch curve {
case .easeIn:
self = [.curveEaseIn]
case .easeOut:
self = [.curveEaseOut]
case .easeInOut:
self = [.curveEaseInOut]
case .linear:
self = [.curveLinear]
@unknown default:
self = [.curveLinear]
}
}
}

12 changes: 3 additions & 9 deletions Typist.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
7100A1701FD36B4E001098A4 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7100A16F1FD36B4E001098A4 /* Extensions.swift */; };
990950321D9928210040D759 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 990950311D9928210040D759 /* AppDelegate.swift */; };
990950341D9928210040D759 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 990950331D9928210040D759 /* ViewController.swift */; };
990950371D9928210040D759 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 990950351D9928210040D759 /* Main.storyboard */; };
Expand All @@ -19,7 +18,6 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
7100A16F1FD36B4E001098A4 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; };
9909502E1D9928210040D759 /* Typist-Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Typist-Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
990950311D9928210040D759 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
990950331D9928210040D759 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -74,7 +72,6 @@
children = (
990950311D9928210040D759 /* AppDelegate.swift */,
990950331D9928210040D759 /* ViewController.swift */,
7100A16F1FD36B4E001098A4 /* Extensions.swift */,
990950351D9928210040D759 /* Main.storyboard */,
990950381D9928210040D759 /* Assets.xcassets */,
9909503A1D9928210040D759 /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -155,7 +152,7 @@
TargetAttributes = {
9909502D1D9928210040D759 = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
995B3BA41DABB30B0027A37E = {
Expand Down Expand Up @@ -209,7 +206,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7100A1701FD36B4E001098A4 /* Extensions.swift in Sources */,
995B3BB11DABB46D0027A37E /* Typist.swift in Sources */,
990950341D9928210040D759 /* ViewController.swift in Sources */,
990950321D9928210040D759 /* AppDelegate.swift in Sources */,
Expand Down Expand Up @@ -366,8 +362,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = tototvalavadze.Typist;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -380,8 +375,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = tototvalavadze.Typist;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Typist/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
24 changes: 0 additions & 24 deletions Typist/Extensions.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Typist/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ViewController: UIViewController {
.on(event: .willHide) { [unowned self] options in
// .willHide is used in cases when keyboard is *not* dismiss interactively.
// e.g. when `.resignFirstResponder()` is called on textField.
UIView.animate(withDuration: options.animationDuration, delay: 0, options: UIViewAnimationOptions(curve: options.animationCurve), animations: {
UIView.animate(withDuration: options.animationDuration, delay: 0, options: UIView.AnimationOptions(curve: options.animationCurve), animations: {
self.bottom.constant = 0
self.tableView.contentInset.bottom = self.toolbar.bounds.height
self.tableView.scrollIndicatorInsets.bottom = self.toolbar.bounds.height
Expand Down

0 comments on commit f809414

Please sign in to comment.