diff --git a/Podfile b/Podfile index edbd09b..9ca4d97 100644 --- a/Podfile +++ b/Podfile @@ -13,14 +13,3 @@ target "UnitTests" do project 'examples/apps/Catalog/MaterialMotionCatalog.xcodeproj' end - -post_install do |installer| - installer.pods_project.targets.each do |target| - target.build_configurations.each do |configuration| - configuration.build_settings['SWIFT_VERSION'] = "3.0" - if target.name.start_with?("Material") - configuration.build_settings['WARNING_CFLAGS'] ="$(inherited) -Wall -Wcast-align -Wconversion -Werror -Wextra -Wimplicit-atomic-properties -Wmissing-prototypes -Wno-sign-conversion -Wno-unused-parameter -Woverlength-strings -Wshadow -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code" - end - end - end -end diff --git a/Podfile.lock b/Podfile.lock index 99dfb50..d19fb6e 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - CatalogByConvention (2.1.0) + - CatalogByConvention (2.5.1) - IndefiniteObservable (4.0.0): - IndefiniteObservable/lib (= 4.0.0) - IndefiniteObservable/lib (4.0.0) @@ -10,15 +10,20 @@ DEPENDENCIES: - CatalogByConvention - MaterialMotion (from `./`) +SPEC REPOS: + trunk: + - CatalogByConvention + - IndefiniteObservable + EXTERNAL SOURCES: MaterialMotion: - :path: ./ + :path: "./" SPEC CHECKSUMS: - CatalogByConvention: ef0913973b86b4234bcadf22aa84037c4a47cbbd + CatalogByConvention: 2b58a9b64e5b1049abb5d3f8e764a551bbe843a7 IndefiniteObservable: 1ee6af37efa8763a222cc6d414cd125e26ed9b6a MaterialMotion: a412b109cfe4ab7b1fd956409a5da9a3635d3dce -PODFILE CHECKSUM: f503265a0d60526a0d28c96dd4bdcfb40fb562fc +PODFILE CHECKSUM: 04070b6b0e30166a620e99ef4fe5ec69fd90cf85 -COCOAPODS: 1.3.1 +COCOAPODS: 1.8.3 diff --git a/examples/ContextualTransitionExample.swift b/examples/ContextualTransitionExample.swift index f4a05dc..69dde4f 100644 --- a/examples/ContextualTransitionExample.swift +++ b/examples/ContextualTransitionExample.swift @@ -221,7 +221,7 @@ class PhotoAlbumViewController: UIViewController, UICollectionViewDataSource, UI navigationController?.setNavigationBarHidden(true, animated: animated) - let photoIndex = album.photos.index { $0.image == currentPhoto.image }! + let photoIndex = album.photos.firstIndex { $0.image == currentPhoto.image }! let indexPath = IndexPath(item: photoIndex, section: 0) collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: false) } diff --git a/examples/FabTransitionExample.swift b/examples/FabTransitionExample.swift index 03660c8..5721489 100644 --- a/examples/FabTransitionExample.swift +++ b/examples/FabTransitionExample.swift @@ -27,7 +27,7 @@ class FabTransitionExampleViewController: ExampleViewController, TransitionConte actionButton.backgroundColor = .primaryColor actionButton.bounds = .init(x: 0, y: 0, width: 50, height: 50) actionButton.layer.cornerRadius = actionButton.bounds.width / 2 - actionButton.layer.position = .init(x: view.bounds.width - actionButton.bounds.width / 2 - 24, + actionButton.layer.position = CGPoint(x: view.bounds.width - actionButton.bounds.width / 2 - 24, y: view.bounds.height - actionButton.bounds.height / 2 - 24) actionButton.autoresizingMask = [.flexibleLeftMargin, .flexibleTopMargin] actionButton.layer.shadowOpacity = 0.5 @@ -39,7 +39,7 @@ class FabTransitionExampleViewController: ExampleViewController, TransitionConte actionButton.addTarget(self, action: #selector(didTap), for: .touchUpInside) } - func didTap() { + @objc func didTap() { let vc = ModalViewController() vc.transitionController.transition = CircularRevealTransition() present(vc, animated: true) @@ -69,7 +69,7 @@ private class ModalViewController: UIViewController { view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTap))) } - func didTap() { + @objc func didTap() { dismiss(animated: true) } } diff --git a/examples/InteractivePushBackTransitionExample.swift b/examples/InteractivePushBackTransitionExample.swift index a47e072..e411c41 100644 --- a/examples/InteractivePushBackTransitionExample.swift +++ b/examples/InteractivePushBackTransitionExample.swift @@ -25,7 +25,7 @@ class InteractivePushBackTransitionExampleViewController: ExampleViewController view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTap))) } - func didTap() { + @objc func didTap() { let vc = ModalViewController() present(vc, animated: true) } diff --git a/examples/MaterialExpansionExample.swift b/examples/MaterialExpansionExample.swift index 7948146..54de581 100644 --- a/examples/MaterialExpansionExample.swift +++ b/examples/MaterialExpansionExample.swift @@ -59,7 +59,7 @@ class MaterialExpansionExampleViewController: ExampleViewController { system: coreAnimation) let floodExpansion = Tween(duration: 0.375, values: [0, 1]) - floodExpansion.timingFunctions.value = [CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)] + floodExpansion.timingFunctions.value = [CAMediaTimingFunction(name: .easeOut)] let fadeOut = Tween(duration: 0.375, values: [0.75, 0]) fadeOut.offsets.value = [0.2, 1] diff --git a/examples/ModalDialogExample.swift b/examples/ModalDialogExample.swift index 482f5fd..0ba21b9 100644 --- a/examples/ModalDialogExample.swift +++ b/examples/ModalDialogExample.swift @@ -25,7 +25,7 @@ class ModalDialogExampleViewController: ExampleViewController { view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTap))) } - func didTap() { + @objc func didTap() { let vc = ModalDialogViewController() present(vc, animated: true) } diff --git a/examples/PushBackTransitionExample.swift b/examples/PushBackTransitionExample.swift index 8cf2571..4763678 100644 --- a/examples/PushBackTransitionExample.swift +++ b/examples/PushBackTransitionExample.swift @@ -25,7 +25,7 @@ class PushBackTransitionExampleViewController: ExampleViewController { view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTap))) } - func didTap() { + @objc func didTap() { let vc = ModalViewController() present(vc, animated: true) } @@ -56,7 +56,7 @@ private class ModalViewController: UIViewController { view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTap))) } - func didTap() { + @objc func didTap() { dismiss(animated: true) } diff --git a/examples/StickerPickerExample.swift b/examples/StickerPickerExample.swift index 31a83b4..c377f2b 100644 --- a/examples/StickerPickerExample.swift +++ b/examples/StickerPickerExample.swift @@ -43,7 +43,7 @@ class StickerPickerExampleViewController: ExampleViewController, StickerListView runtime.add(DirectlyManipulable(), to: stickerView) } - func didTapAdd() { + @objc func didTapAdd() { let picker = StickerListViewController() picker.delegate = self present(picker, animated: true) diff --git a/examples/apps/Catalog/Catalog/AppDelegate.swift b/examples/apps/Catalog/Catalog/AppDelegate.swift index 7af7823..0a44e5d 100644 --- a/examples/apps/Catalog/Catalog/AppDelegate.swift +++ b/examples/apps/Catalog/Catalog/AppDelegate.swift @@ -22,7 +22,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { let window = UIWindow(frame: UIScreen.main.bounds) self.window = window diff --git a/examples/apps/Catalog/Catalog/Base.lproj/LaunchScreen.storyboard b/examples/apps/Catalog/Catalog/Base.lproj/LaunchScreen.storyboard index 2e721e1..dd4f256 100644 --- a/examples/apps/Catalog/Catalog/Base.lproj/LaunchScreen.storyboard +++ b/examples/apps/Catalog/Catalog/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,10 @@ - - + + + - + + + @@ -13,10 +16,9 @@ - + - - + diff --git a/examples/apps/Catalog/Catalog/TableOfContents.swift b/examples/apps/Catalog/Catalog/TableOfContents.swift index 517756b..f530ce8 100644 --- a/examples/apps/Catalog/Catalog/TableOfContents.swift +++ b/examples/apps/Catalog/Catalog/TableOfContents.swift @@ -19,81 +19,81 @@ import Foundation extension CarouselExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Carousel"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Carousel"] } } extension ContextualTransitionExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Contextual transition"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Contextual transition"] } } extension FabTransitionExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Case studies", "FAB transition"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Case studies", "FAB transition"] } } extension MaterialExpansionExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Material expansion"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Material expansion"] } } extension ModalDialogExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Modal dialog"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Modal dialog"] } } extension PushBackTransitionExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Push back transition"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Push back transition"] } } extension InteractivePushBackTransitionExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Push back transition (interactive)"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Push back transition (interactive)"] } } extension StickerPickerExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Sticker picker"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Case studies", "Sticker picker"] } } extension HowToUseReactiveConstraintsExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["How to...", "Use reactive constraints"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["How to...", "Use reactive constraints"] } } extension HowToMakeACustomOperatorExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["How to...", "Make a custom operator"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["How to...", "Make a custom operator"] } } extension ArcMoveExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Arc move"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Arc move"] } } extension ChangeDirectionOnReleaseExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Change direction on release"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Change direction on release"] } } extension DirectlyManipulableExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Directly manipulable"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Directly manipulable"] } } extension DraggableExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Draggable"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Draggable"] } } extension RotatableExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Rotatable"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Rotatable"] } } extension ScalableExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Scalable"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Scalable"] } } extension SetPositionOnTapExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Set position on tap"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Set position on tap"] } } extension SpringExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Spring"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Spring"] } } extension TweenExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Tween"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Tween"] } } extension TossableExampleViewController { - class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Tossable"] } + @objc class func catalogBreadcrumbs() -> [String] { return ["Interactions", "Tossable"] } } diff --git a/examples/apps/Catalog/MaterialMotionCatalog.xcodeproj/project.pbxproj b/examples/apps/Catalog/MaterialMotionCatalog.xcodeproj/project.pbxproj index 11d3c34..7b3b8d7 100644 --- a/examples/apps/Catalog/MaterialMotionCatalog.xcodeproj/project.pbxproj +++ b/examples/apps/Catalog/MaterialMotionCatalog.xcodeproj/project.pbxproj @@ -431,7 +431,6 @@ 666FAA7E1D384A6B000363DA /* Resources */, D1C0B5DF5DCE9D3EE28C4526 /* Frameworks */, 74F7AE96B98817D9D81C5665 /* [CP] Embed Pods Frameworks */, - 1C06EC17C50EA89E7572042C /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -451,7 +450,6 @@ 666FAA921D384A6B000363DA /* Resources */, FEF09F4949A5B89F40E1A07C /* Frameworks */, C2218D6A72EAF2AEFF087B63 /* [CP] Embed Pods Frameworks */, - 1F2A834AEF8014455C179F88 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -470,7 +468,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 1130; ORGANIZATIONNAME = Google; TargetAttributes = { 666FAA7F1D384A6B000363DA = { @@ -487,7 +485,7 @@ }; buildConfigurationList = 666FAA7B1D384A6B000363DA /* Build configuration list for PBXProject "MaterialMotionCatalog" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -525,43 +523,13 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 1C06EC17C50EA89E7572042C /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/../../../Pods/Target Support Files/Pods-MaterialMotionCatalog/Pods-MaterialMotionCatalog-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 1F2A834AEF8014455C179F88 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/../../../Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; 74F7AE96B98817D9D81C5665 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${SRCROOT}/../../../Pods/Target Support Files/Pods-MaterialMotionCatalog/Pods-MaterialMotionCatalog-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-MaterialMotionCatalog/Pods-MaterialMotionCatalog-frameworks.sh", "${BUILT_PRODUCTS_DIR}/CatalogByConvention/CatalogByConvention.framework", "${BUILT_PRODUCTS_DIR}/IndefiniteObservable/IndefiniteObservable.framework", "${BUILT_PRODUCTS_DIR}/MaterialMotion/MaterialMotion.framework", @@ -574,7 +542,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/../../../Pods/Target Support Files/Pods-MaterialMotionCatalog/Pods-MaterialMotionCatalog-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MaterialMotionCatalog/Pods-MaterialMotionCatalog-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; C2218D6A72EAF2AEFF087B63 /* [CP] Embed Pods Frameworks */ = { @@ -583,7 +551,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/../../../Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-UnitTests/Pods-UnitTests-frameworks.sh", "${BUILT_PRODUCTS_DIR}/IndefiniteObservable/IndefiniteObservable.framework", "${BUILT_PRODUCTS_DIR}/MaterialMotion/MaterialMotion.framework", ); @@ -594,7 +562,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/../../../Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-UnitTests/Pods-UnitTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; F1710CBAF0E494D36483A4BE /* [CP] Check Pods Manifest.lock */ = { @@ -744,14 +712,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -792,14 +768,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -834,7 +818,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.google.MaterialMotion; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -849,7 +833,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.google.MaterialMotion; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -864,7 +848,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.google.CatalogTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MaterialMotionCatalog.app/MaterialMotionCatalog"; }; name = Debug; @@ -880,7 +864,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.google.CatalogTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MaterialMotionCatalog.app/MaterialMotionCatalog"; }; name = Release; diff --git a/examples/apps/Catalog/MaterialMotionCatalog.xcodeproj/xcshareddata/xcschemes/MaterialMotionCatalog.xcscheme b/examples/apps/Catalog/MaterialMotionCatalog.xcodeproj/xcshareddata/xcschemes/MaterialMotionCatalog.xcscheme index 2f0f1f0..1e09f61 100644 --- a/examples/apps/Catalog/MaterialMotionCatalog.xcodeproj/xcshareddata/xcschemes/MaterialMotionCatalog.xcscheme +++ b/examples/apps/Catalog/MaterialMotionCatalog.xcodeproj/xcshareddata/xcschemes/MaterialMotionCatalog.xcscheme @@ -1,6 +1,6 @@ + + + + @@ -40,17 +49,6 @@ - - - - - - - - - - - - CGFloat { let seconds: CGFloat + + // `.never` was introduced in the latest SDK. In order to support both Xcode 8 and 9 we have to + // implement the `case .never` while not implementing it on Xcode 8. Unfortunately, `#if swift` + // statements placed inside of switch statements can't build, so we're stuck duplicating the + // switch statement. + // + // If we try to write the code like so: + // + // #if swift(>=3.2) + // case .never: + // seconds = CGFloat.infinity + // #endif + // + // We get the following errors: + // + // Extraneous '.' in enum 'case' declaration + // 'case' label can only appear inside a 'switch' statement + +#if swift(>=3.2) + switch self { + case let .seconds(arg): + seconds = CGFloat(arg) + case let .milliseconds(arg): + seconds = CGFloat(arg) / 1000.0 + case let .microseconds(arg): + seconds = CGFloat(arg) / 1000000.0 + case let .nanoseconds(arg): + seconds = CGFloat(arg) / 1000000000.0 + case .never: + seconds = CGFloat.infinity + @unknown default: + fatalError() + } +#else switch self { case let .seconds(arg): seconds = CGFloat(arg) @@ -30,6 +64,7 @@ extension DispatchTimeInterval { case let .nanoseconds(arg): seconds = CGFloat(arg) / 1000000000.0 } +#endif return seconds } } diff --git a/src/debugging/simulatorDragCoefficient.swift b/src/debugging/simulatorDragCoefficient.swift index 737d2fc..63b9c46 100644 --- a/src/debugging/simulatorDragCoefficient.swift +++ b/src/debugging/simulatorDragCoefficient.swift @@ -20,7 +20,7 @@ import UIKit // This is a simulator-only API for detecting simulator slow-motion animations being enabled. // simulatorDragCoefficient() returns a value that is greater than 1 when slow-motion is enabled. -#if (arch(i386) || arch(x86_64)) && os(iOS) +#if targetEnvironment(simulator) @_silgen_name("UIAnimationDragCoefficient") func UIAnimationDragCoefficient() -> Float public func simulatorDragCoefficient() -> CGFloat { return CGFloat(UIAnimationDragCoefficient()) diff --git a/src/interactions/DirectlyManipulable.swift b/src/interactions/DirectlyManipulable.swift index 8c474c1..7c90c7c 100644 --- a/src/interactions/DirectlyManipulable.swift +++ b/src/interactions/DirectlyManipulable.swift @@ -74,7 +74,7 @@ public final class DirectlyManipulable: NSObject, Interaction, Togglable, Statef runtime.connect(enabled, to: scalable.enabled) let gestures: [UIGestureRecognizer?] = [rotatable.nextGestureRecognizer, scalable.nextGestureRecognizer] - let anchorPointRecognizers = gestures.flatMap { $0 } + let anchorPointRecognizers = gestures.compactMap { $0 } let adjustsAnchorPoint = AdjustsAnchorPoint(gestureRecognizers: anchorPointRecognizers) runtime.add(adjustsAnchorPoint, to: view) diff --git a/src/interactions/Spring.swift b/src/interactions/Spring.swift index 55fdbd0..90c6e4b 100644 --- a/src/interactions/Spring.swift +++ b/src/interactions/Spring.swift @@ -45,7 +45,7 @@ public let defaultSpringMass: CGFloat = 1 T-value constraints may be applied to this interaction. */ -public class Spring: Interaction, Togglable, Stateful where T: Zeroable, T: Subtractable { +public class Spring: Interaction, Togglable, Stateful where T: ZeroableAndSubtractable { /** Creates a spring with a given threshold and system. @@ -138,7 +138,7 @@ public class Spring: Interaction, Togglable, Stateful where T: Zeroable, T: S private var activeSprings = Set>() } -public struct SpringShadow: Hashable where T: Zeroable, T: Subtractable { +public struct SpringShadow: Hashable where T: ZeroableAndSubtractable { public let enabled: ReactiveProperty public let state = createProperty(withInitialValue: MotionState.atRest) public let initialValue: ReactiveProperty @@ -167,6 +167,10 @@ public struct SpringShadow: Hashable where T: Zeroable, T: Subtractable { return uuid.hashValue } + public func hash(into hasher: inout Hasher) { + hasher.combine(self.hashValue) + } + public static func ==(lhs: SpringShadow, rhs: SpringShadow) -> Bool { return lhs.uuid == rhs.uuid } diff --git a/src/interactions/TransitionSpring.swift b/src/interactions/TransitionSpring.swift index ea14732..1d7656b 100644 --- a/src/interactions/TransitionSpring.swift +++ b/src/interactions/TransitionSpring.swift @@ -61,7 +61,7 @@ public let defaultTransitionSpringSuggestedDuration: CGFloat = 0.5 T-value constraints may be applied to this interaction. */ -public final class TransitionSpring: Spring where T: Zeroable, T: Subtractable { +public final class TransitionSpring: Spring where T: ZeroableAndSubtractable { /** The destination when the transition is moving backward. diff --git a/src/interactions/Tween.swift b/src/interactions/Tween.swift index 82c8910..cdef2c1 100644 --- a/src/interactions/Tween.swift +++ b/src/interactions/Tween.swift @@ -95,7 +95,7 @@ public class Tween: Interaction, Togglable, Stateful { See CAKeyframeAnimation documentation for more details. */ public let timingFunctions = createProperty(withInitialValue: - [CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)] + [CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)] ) /** diff --git a/src/operators/distanceFrom.swift b/src/operators/distanceFrom.swift index 4093e2f..43e9fbf 100644 --- a/src/operators/distanceFrom.swift +++ b/src/operators/distanceFrom.swift @@ -24,7 +24,7 @@ extension MotionObservableConvertible where T == CGFloat { */ public func distance(from location: CGFloat) -> MotionObservable { return _map { - fabs($0 - location) + abs($0 - location) } } } diff --git a/src/operators/foundation/_remember.swift b/src/operators/foundation/_remember.swift index beedc6d..797b800 100644 --- a/src/operators/foundation/_remember.swift +++ b/src/operators/foundation/_remember.swift @@ -69,7 +69,7 @@ extension MotionObservableConvertible { } return { - if let index = observers.index(where: { $0 === observer }) { + if let index = observers.firstIndex(where: { $0 === observer }) { observers.remove(at: index) if observers.count == 0 { subscription?.unsubscribe() diff --git a/src/operators/gestures/whenRecognitionStateIs.swift b/src/operators/gestures/whenRecognitionStateIs.swift index 15fb55f..b3d5221 100644 --- a/src/operators/gestures/whenRecognitionStateIs.swift +++ b/src/operators/gestures/whenRecognitionStateIs.swift @@ -20,14 +20,14 @@ import UIKit extension MotionObservableConvertible where T: UIGestureRecognizer { /** Only forwards the gesture recognizer if its state matches the provided value. */ - public func whenRecognitionState(is state: UIGestureRecognizerState) -> MotionObservable { + public func whenRecognitionState(is state: UIGestureRecognizer.State) -> MotionObservable { return _filter { value in return value.state == state } } /** Only forwards the gesture recognizer if its state matches any of the provided values. */ - public func whenRecognitionState(isAnyOf states: [UIGestureRecognizerState]) -> MotionObservable { + public func whenRecognitionState(isAnyOf states: [UIGestureRecognizer.State]) -> MotionObservable { return _filter { value in return states.contains(value.state) } diff --git a/src/protocols/ZeroableAndSubtractable.swift b/src/protocols/ZeroableAndSubtractable.swift new file mode 100644 index 0000000..2d0cec7 --- /dev/null +++ b/src/protocols/ZeroableAndSubtractable.swift @@ -0,0 +1,30 @@ +/* + Copyright 2017-present The Material Motion Authors. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +import Foundation +import UIKit + +extension CGPoint: ZeroableAndSubtractable { +} + +extension CGSize: ZeroableAndSubtractable { +} + +extension CGRect: ZeroableAndSubtractable { +} + +extension CGFloat: ZeroableAndSubtractable { +} diff --git a/src/reactivetypes/Reactive+UIButton.swift b/src/reactivetypes/Reactive+UIButton.swift index 50b68dc..ad3fe88 100644 --- a/src/reactivetypes/Reactive+UIButton.swift +++ b/src/reactivetypes/Reactive+UIButton.swift @@ -39,17 +39,17 @@ public final class ReactiveButtonTarget: NSObject { return MotionObservable { observer in self.didHighlightObservers.append(observer) return { - if let index = self.didHighlightObservers.index(where: { $0 === observer }) { + if let index = self.didHighlightObservers.firstIndex(where: { $0 === observer }) { self.didHighlightObservers.remove(at: index) } } } } - func didEnterEvent(_ button: UIButton) { + @objc func didEnterEvent(_ button: UIButton) { didHighlightObservers.forEach { $0.next(true) } } - func didExitEvent(_ button: UIButton) { + @objc func didExitEvent(_ button: UIButton) { didHighlightObservers.forEach { $0.next(false) } } private var didHighlightObservers: [MotionObserver] = [] diff --git a/src/reactivetypes/ReactiveScrollViewDelegate.swift b/src/reactivetypes/ReactiveScrollViewDelegate.swift index de2168c..765e792 100644 --- a/src/reactivetypes/ReactiveScrollViewDelegate.swift +++ b/src/reactivetypes/ReactiveScrollViewDelegate.swift @@ -44,7 +44,7 @@ public final class ReactiveScrollViewDelegate: NSObject, UIScrollViewDelegate, M return MotionObservable { observer in self.didScrollObservers.append(observer) return { - if let index = self.didScrollObservers.index(where: { $0 === observer }) { + if let index = self.didScrollObservers.firstIndex(where: { $0 === observer }) { self.didScrollObservers.remove(at: index) } } diff --git a/src/systems/coreAnimationPathTweenToStream.swift b/src/systems/coreAnimationPathTweenToStream.swift index b5b9e46..3802985 100644 --- a/src/systems/coreAnimationPathTweenToStream.swift +++ b/src/systems/coreAnimationPathTweenToStream.swift @@ -58,7 +58,7 @@ public func coreAnimation(_ tween: PathTweenShadow) -> MotionObservable brushLayer.lineWidth = 2 brushLayer.strokeStart = 0 brushLayer.strokeEnd = 1 - brushLayer.lineCap = kCALineJoinRound + brushLayer.lineCap = .round brushLayer.fillColor = UIColor.white.withAlphaComponent(0).cgColor brushLayer.strokeColor = UIColor(red: 0xC5/255.0, green: 0x11/255.0, blue: 0x62/255.0, alpha: 1).cgColor brushLayer.path = pathValue @@ -79,11 +79,11 @@ public func coreAnimation(_ tween: PathTweenShadow) -> MotionObservable let strokeStartAnimation = CABasicAnimation(keyPath: "strokeStart") strokeStartAnimation.duration = animation.duration * 0.75 - strokeStartAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn) + strokeStartAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn) strokeStartAnimation.fromValue = 0 strokeStartAnimation.toValue = 1 strokeStartAnimation.beginTime = CACurrentMediaTime() + animation.duration * 0.75 - strokeStartAnimation.fillMode = kCAFillModeBackwards + strokeStartAnimation.fillMode = CAMediaTimingFillMode.backwards brushLayer.add(strokeStartAnimation, forKey: "strokeStart") let lineWidthAnimation = CABasicAnimation(keyPath: "lineWidth") @@ -122,14 +122,15 @@ extension CGPath { // Iterates over each registered point in the CGPath. We must use @convention notation to bridge // between the swift and objective-c block APIs. // Source: http://stackoverflow.com/questions/12992462/how-to-get-the-cgpoints-of-a-cgpath#36374209 - private func forEach(body: @convention(block) (CGPathElement) -> Void) { - typealias Body = @convention(block) (CGPathElement) -> Void - let callback: @convention(c) (UnsafeMutableRawPointer, UnsafePointer) -> Void = { (info, element) in - let body = unsafeBitCast(info, to: Body.self) - body(element.pointee) - } - let unsafeBody = unsafeBitCast(body, to: UnsafeMutableRawPointer.self) - self.apply(info: unsafeBody, function: unsafeBitCast(callback, to: CGPathApplierFunction.self)) + func forEach( body: @escaping @convention(block) (CGPathElement) -> Void) { + typealias Body = @convention(block) (CGPathElement) -> Void + let callback: @convention(c) (UnsafeMutableRawPointer, UnsafePointer) -> Void = { (info, element) in + let body = unsafeBitCast(info, to: Body.self) + body(element.pointee) + } + //print(MemoryLayout.size(ofValue: body)) + let unsafeBody = unsafeBitCast(body, to: UnsafeMutableRawPointer.self) + self.apply(info: unsafeBody, function: unsafeBitCast(callback, to: CGPathApplierFunction.self)) } fileprivate func getAllPoints() -> [CGPoint] { diff --git a/src/systems/coreAnimationSpringToStream.swift b/src/systems/coreAnimationSpringToStream.swift index 1a8f7f0..8f34018 100644 --- a/src/systems/coreAnimationSpringToStream.swift +++ b/src/systems/coreAnimationSpringToStream.swift @@ -22,7 +22,7 @@ import UIKit Only works with Subtractable types due to use of additive animations. */ -public func coreAnimation(_ spring: SpringShadow) -> (MotionObservable) where T: Subtractable { +public func coreAnimation(_ spring: SpringShadow) -> (MotionObservable) { let initialVelocityStream = spring.initialVelocity.asStream() return MotionObservable { observer in var animationKeys: [String] = [] diff --git a/src/systems/coreAnimationTweenToStream.swift b/src/systems/coreAnimationTweenToStream.swift index 5e2f50a..43af0b8 100644 --- a/src/systems/coreAnimationTweenToStream.swift +++ b/src/systems/coreAnimationTweenToStream.swift @@ -67,7 +67,7 @@ private func streamFromTween(_ tween: TweenShadow, configureEvent: @escapi } animation.beginTime = CFTimeInterval(tween.delay.value) if tween.delay.value > 0 { - animation.fillMode = kCAFillModeBackwards + animation.fillMode = CAMediaTimingFillMode.backwards } animation.duration = CFTimeInterval(duration) animation.repeatCount = Float(tween.repeatCount.value) diff --git a/src/systems/sliderToStream.swift b/src/systems/sliderToStream.swift index 9c63935..49b2484 100644 --- a/src/systems/sliderToStream.swift +++ b/src/systems/sliderToStream.swift @@ -49,7 +49,7 @@ private final class SliderConnection: NSObject { slider = nil } - func sliderDidChange() { + @objc func sliderDidChange() { if let slider = slider { observer.next(CGFloat(slider.value)) } diff --git a/src/transitions/TransitionContextViewRetriever.swift b/src/transitions/TransitionContextViewRetriever.swift index a83333d..8b14097 100644 --- a/src/transitions/TransitionContextViewRetriever.swift +++ b/src/transitions/TransitionContextViewRetriever.swift @@ -34,7 +34,7 @@ public func transitionContextViewRetriever(for viewController: UIViewController) } // Haven't found the view retriever yet, let's search the children. - var queue = viewController.childViewControllers + var queue = viewController.children while let childViewController = queue.first { if let retriever = childViewController as? TransitionContextViewRetriever { @@ -52,7 +52,7 @@ public func transitionContextViewRetriever(for viewController: UIViewController) fallthrough } default: - childViewControllers = childViewController.childViewControllers + childViewControllers = childViewController.children } queue.append(contentsOf: childViewControllers)