From ac4f1ba8d099a264376c555a0efe094ecf29b905 Mon Sep 17 00:00:00 2001 From: Abdurahim Jauzee Date: Mon, 17 Apr 2017 04:24:12 +0300 Subject: [PATCH] Fixed working with UINavigationController --- .travis.yml | 2 +- ElongationPreview.podspec | 2 +- ElongationPreview.xcodeproj/project.pbxproj | 111 ++++++++++++++++++ .../Source/ElongationTransition.swift | 12 +- .../ElongationPreviewUITests.swift | 28 +++++ ElongationPreviewUITests/Info.plist | 22 ++++ 6 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 ElongationPreviewUITests/ElongationPreviewUITests.swift create mode 100644 ElongationPreviewUITests/Info.plist diff --git a/.travis.yml b/.travis.yml index 018b39a..a2c3c2f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,5 @@ osx_image: xcode8 language: objective-c xcode_project: ElongationPreview.xcodeproj -xcode_scheme: ElongationPreview +xcode_scheme: ElongationPreviewDemo xcode_sdk: iphonesimulator diff --git a/ElongationPreview.podspec b/ElongationPreview.podspec index 120e3e7..4c5d6b1 100644 --- a/ElongationPreview.podspec +++ b/ElongationPreview.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'ElongationPreview' - s.version = '1.0.2' + s.version = '1.0.4' s.summary = 'ElongationPreview is an elegant push-pop style view controller.' s.license = 'MIT' s.homepage = 'https://github.com/Ramotion/elongation-preview' diff --git a/ElongationPreview.xcodeproj/project.pbxproj b/ElongationPreview.xcodeproj/project.pbxproj index 8664930..4cf3405 100644 --- a/ElongationPreview.xcodeproj/project.pbxproj +++ b/ElongationPreview.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 9D69D13B1E4EF31C00D38C59 /* UIFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D69D13A1E4EF31C00D38C59 /* UIFont.swift */; }; 9D69D13D1E4F339300D38C59 /* ElongationTransition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D69D13C1E4F339300D38C59 /* ElongationTransition.swift */; }; 9D69D13F1E4F344B00D38C59 /* ElongationDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D69D13E1E4F344B00D38C59 /* ElongationDetailViewController.swift */; }; + 9D873CEB1E7C2A1200826500 /* ElongationPreviewUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D873CEA1E7C2A1200826500 /* ElongationPreviewUITests.swift */; }; 9D8937311E539DDD00FDC29D /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D8937301E539DDD00FDC29D /* DetailViewController.swift */; }; 9DC8E8841E4B3CAD00C04F79 /* UICollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DC8E8821E4B3CAD00C04F79 /* UICollectionView.swift */; }; 9DC8E8851E4B3CAD00C04F79 /* UITableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DC8E8831E4B3CAD00C04F79 /* UITableView.swift */; }; @@ -40,6 +41,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 9D873CED1E7C2A1200826500 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 9DE4FABA1E4B1A02008502A3 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 9DE4FAD11E4B1A15008502A3; + remoteInfo = ElongationPreviewDemo; + }; 9DC8E8971E4B45F300C04F79 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 9DE4FABA1E4B1A02008502A3 /* Project object */; @@ -76,6 +84,9 @@ 9D69D13A1E4EF31C00D38C59 /* UIFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIFont.swift; sourceTree = ""; }; 9D69D13C1E4F339300D38C59 /* ElongationTransition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElongationTransition.swift; sourceTree = ""; }; 9D69D13E1E4F344B00D38C59 /* ElongationDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElongationDetailViewController.swift; sourceTree = ""; }; + 9D873CE81E7C2A1200826500 /* ElongationPreviewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ElongationPreviewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 9D873CEA1E7C2A1200826500 /* ElongationPreviewUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElongationPreviewUITests.swift; sourceTree = ""; }; + 9D873CEC1E7C2A1200826500 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 9D8937301E539DDD00FDC29D /* DetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; }; 9DC8E8821E4B3CAD00C04F79 /* UICollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionView.swift; sourceTree = ""; }; 9DC8E8831E4B3CAD00C04F79 /* UITableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UITableView.swift; sourceTree = ""; }; @@ -99,6 +110,13 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 9D873CE51E7C2A1200826500 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 9DE4FABF1E4B1A02008502A3 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -160,6 +178,15 @@ path = Extensions; sourceTree = ""; }; + 9D873CE91E7C2A1200826500 /* ElongationPreviewUITests */ = { + isa = PBXGroup; + children = ( + 9D873CEA1E7C2A1200826500 /* ElongationPreviewUITests.swift */, + 9D873CEC1E7C2A1200826500 /* Info.plist */, + ); + path = ElongationPreviewUITests; + sourceTree = ""; + }; 9DC8E8811E4B3CAD00C04F79 /* Extensions */ = { isa = PBXGroup; children = ( @@ -206,6 +233,7 @@ children = ( 9DE4FAC51E4B1A02008502A3 /* ElongationPreview */, 9DE4FAD31E4B1A15008502A3 /* ElongationPreviewDemo */, + 9D873CE91E7C2A1200826500 /* ElongationPreviewUITests */, 9DE4FAC41E4B1A02008502A3 /* Products */, ); sourceTree = ""; @@ -215,6 +243,7 @@ children = ( 9DE4FAC31E4B1A02008502A3 /* ElongationPreview.framework */, 9DE4FAD21E4B1A15008502A3 /* ElongationPreviewDemo.app */, + 9D873CE81E7C2A1200826500 /* ElongationPreviewUITests.xctest */, ); name = Products; sourceTree = ""; @@ -289,6 +318,24 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ + 9D873CE71E7C2A1200826500 /* ElongationPreviewUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9D873CF11E7C2A1200826500 /* Build configuration list for PBXNativeTarget "ElongationPreviewUITests" */; + buildPhases = ( + 9D873CE41E7C2A1200826500 /* Sources */, + 9D873CE51E7C2A1200826500 /* Frameworks */, + 9D873CE61E7C2A1200826500 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 9D873CEE1E7C2A1200826500 /* PBXTargetDependency */, + ); + name = ElongationPreviewUITests; + productName = ElongationPreviewUITests; + productReference = 9D873CE81E7C2A1200826500 /* ElongationPreviewUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; 9DE4FAC21E4B1A02008502A3 /* ElongationPreview */ = { isa = PBXNativeTarget; buildConfigurationList = 9DE4FACB1E4B1A02008502A3 /* Build configuration list for PBXNativeTarget "ElongationPreview" */; @@ -336,6 +383,12 @@ LastUpgradeCheck = 0820; ORGANIZATIONNAME = Ramotion; TargetAttributes = { + 9D873CE71E7C2A1200826500 = { + CreatedOnToolsVersion = 8.2.1; + DevelopmentTeam = 2VFCBFYPFW; + ProvisioningStyle = Automatic; + TestTargetID = 9DE4FAD11E4B1A15008502A3; + }; 9DE4FAC21E4B1A02008502A3 = { CreatedOnToolsVersion = 8.2.1; LastSwiftMigration = 0820; @@ -363,11 +416,19 @@ targets = ( 9DE4FAC21E4B1A02008502A3 /* ElongationPreview */, 9DE4FAD11E4B1A15008502A3 /* ElongationPreviewDemo */, + 9D873CE71E7C2A1200826500 /* ElongationPreviewUITests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 9D873CE61E7C2A1200826500 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 9DE4FAC11E4B1A02008502A3 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -393,6 +454,14 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 9D873CE41E7C2A1200826500 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9D873CEB1E7C2A1200826500 /* ElongationPreviewUITests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 9DE4FABE1E4B1A02008502A3 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -429,6 +498,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 9D873CEE1E7C2A1200826500 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 9DE4FAD11E4B1A15008502A3 /* ElongationPreviewDemo */; + targetProxy = 9D873CED1E7C2A1200826500 /* PBXContainerItemProxy */; + }; 9DC8E8981E4B45F300C04F79 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 9DE4FAC21E4B1A02008502A3 /* ElongationPreview */; @@ -456,6 +530,34 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 9D873CEF1E7C2A1200826500 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = 2VFCBFYPFW; + INFOPLIST_FILE = ElongationPreviewUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.ElongationPreviewUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_TARGET_NAME = ElongationPreviewDemo; + }; + name = Debug; + }; + 9D873CF01E7C2A1200826500 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = 2VFCBFYPFW; + INFOPLIST_FILE = ElongationPreviewUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.ElongationPreviewUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_TARGET_NAME = ElongationPreviewDemo; + }; + name = Release; + }; 9DE4FAC91E4B1A02008502A3 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -633,6 +735,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 9D873CF11E7C2A1200826500 /* Build configuration list for PBXNativeTarget "ElongationPreviewUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9D873CEF1E7C2A1200826500 /* Debug */, + 9D873CF01E7C2A1200826500 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 9DE4FABD1E4B1A02008502A3 /* Build configuration list for PBXProject "ElongationPreview" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/ElongationPreview/Source/ElongationTransition.swift b/ElongationPreview/Source/ElongationTransition.swift index 9a9d51a..8b8bee5 100644 --- a/ElongationPreview/Source/ElongationTransition.swift +++ b/ElongationPreview/Source/ElongationTransition.swift @@ -38,7 +38,17 @@ public class ElongationTransition: NSObject { } fileprivate func root(from context: UIViewControllerContextTransitioning) -> ElongationViewController { - return context.viewController(forKey: rootKey) as? ElongationViewController ?? ElongationViewController(nibName: nil, bundle: nil) + let viewController = context.viewController(forKey: rootKey) + + if let navi = viewController as? UINavigationController { + for case let elongationViewController as ElongationViewController in navi.viewControllers { + return elongationViewController + } + } else if let elongationViewController = viewController as? ElongationViewController { + return elongationViewController + } + + fatalError("Can't get `ElongationViewController` from UINavigationController nor from context's viewController itself.") } fileprivate func detail(from context: UIViewControllerContextTransitioning) -> ElongationDetailViewController { diff --git a/ElongationPreviewUITests/ElongationPreviewUITests.swift b/ElongationPreviewUITests/ElongationPreviewUITests.swift new file mode 100644 index 0000000..88325d9 --- /dev/null +++ b/ElongationPreviewUITests/ElongationPreviewUITests.swift @@ -0,0 +1,28 @@ +// +// ElongationPreviewUITests.swift +// ElongationPreviewUITests +// +// Created by Abdurahim Jauzee on 17/03/2017. +// Copyright © 2017 Ramotion. All rights reserved. +// + +import XCTest +@testable import ElongationPreviewDemo + + +class ElongationPreviewUITests: XCTestCase { + + var viewController: UITableViewController! + var detailViewController: UITableViewController! + + override func setUp() { + super.setUp() + continueAfterFailure = false + XCUIApplication().launch() + } + + override func tearDown() { + super.tearDown() + } + +} diff --git a/ElongationPreviewUITests/Info.plist b/ElongationPreviewUITests/Info.plist new file mode 100644 index 0000000..6c6c23c --- /dev/null +++ b/ElongationPreviewUITests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + +