diff --git a/Typist.swift b/Typist.swift index 7500af4..aefc779 100644 --- a/Typist.swift +++ b/Typist.swift @@ -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] + } + } +} + diff --git a/Typist.xcodeproj/project.pbxproj b/Typist.xcodeproj/project.pbxproj index 2fd13cb..3e94551 100644 --- a/Typist.xcodeproj/project.pbxproj +++ b/Typist.xcodeproj/project.pbxproj @@ -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 */; }; @@ -19,7 +18,6 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 7100A16F1FD36B4E001098A4 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; 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 = ""; }; 990950331D9928210040D759 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -74,7 +72,6 @@ children = ( 990950311D9928210040D759 /* AppDelegate.swift */, 990950331D9928210040D759 /* ViewController.swift */, - 7100A16F1FD36B4E001098A4 /* Extensions.swift */, 990950351D9928210040D759 /* Main.storyboard */, 990950381D9928210040D759 /* Assets.xcassets */, 9909503A1D9928210040D759 /* LaunchScreen.storyboard */, @@ -155,7 +152,7 @@ TargetAttributes = { 9909502D1D9928210040D759 = { CreatedOnToolsVersion = 8.0; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; 995B3BA41DABB30B0027A37E = { @@ -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 */, @@ -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; }; @@ -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; }; diff --git a/Typist/AppDelegate.swift b/Typist/AppDelegate.swift index a73ff49..16c63c6 100644 --- a/Typist/AppDelegate.swift +++ b/Typist/AppDelegate.swift @@ -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 } diff --git a/Typist/Extensions.swift b/Typist/Extensions.swift deleted file mode 100644 index 06cbc2b..0000000 --- a/Typist/Extensions.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// Extensions.swift -// Typist-Demo -// -// Created by Lasha Efremidze on 12/2/17. -// Copyright © 2017 Toto Tvalavadze. All rights reserved. -// - -import UIKit - -extension UIViewAnimationOptions { - init(curve: UIViewAnimationCurve) { - switch curve { - case .easeIn: - self = [.curveEaseIn] - case .easeOut: - self = [.curveEaseOut] - case .easeInOut: - self = [.curveEaseInOut] - case .linear: - self = [.curveLinear] - } - } -} diff --git a/Typist/ViewController.swift b/Typist/ViewController.swift index f1c956b..cd07807 100644 --- a/Typist/ViewController.swift +++ b/Typist/ViewController.swift @@ -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