Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support extension #50

Merged
merged 1 commit into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Motion.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ Pod::Spec.new do |s|
s.ios.source_files = 'Sources/**/*.swift'
s.requires_arc = true
end

end
4 changes: 4 additions & 0 deletions Motion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
96E409AB1F24F7570015A2B5 /* MotionPreprocessor.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96E409621F24F7370015A2B5 /* MotionPreprocessor.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96E409AC1F24F7570015A2B5 /* SourcePreprocessor.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96E409631F24F7370015A2B5 /* SourcePreprocessor.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96E409AD1F24F7570015A2B5 /* TransitionPreprocessor.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96E409641F24F7370015A2B5 /* TransitionPreprocessor.swift */; settings = {ATTRIBUTES = (Public, ); }; };
D4A2ECE521467454003162B4 /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4A2ECE421467454003162B4 /* Application.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -139,6 +140,7 @@
96E409641F24F7370015A2B5 /* TransitionPreprocessor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransitionPreprocessor.swift; sourceTree = "<group>"; };
96E409BB1F24FC210015A2B5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96E409BC1F24FC300015A2B5 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
D4A2ECE421467454003162B4 /* Application.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Application.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXGroup section */
Expand Down Expand Up @@ -181,6 +183,7 @@
96E409BB1F24FC210015A2B5 /* Info.plist */,
96E409BC1F24FC300015A2B5 /* LICENSE */,
96E4094F1F24F7370015A2B5 /* Motion.h */,
D4A2ECE421467454003162B4 /* Application.swift */,
965FE9681FDDA1F20098BDD0 /* MotionViewOrderStrategy.swift */,
96E409511F24F7370015A2B5 /* MotionAnimation.swift */,
96E409521F24F7370015A2B5 /* MotionAnimationState.swift */,
Expand Down Expand Up @@ -373,6 +376,7 @@
96E409761F24F7370015A2B5 /* MotionAnimation.swift in Sources */,
965FE9A31FE4407D0098BDD0 /* MotionTransition+Interactive.swift in Sources */,
96E4096B1F24F7370015A2B5 /* Motion+Array.swift in Sources */,
D4A2ECE521467454003162B4 /* Application.swift in Sources */,
96E409721F24F7370015A2B5 /* Motion+UIViewController.swift in Sources */,
96E4097E1F24F7370015A2B5 /* MotionSnapshotType.swift in Sources */,
965FE9691FDDA1F20098BDD0 /* MotionViewOrderStrategy.swift in Sources */,
Expand Down
44 changes: 44 additions & 0 deletions Sources/Application.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2015 - 2018, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import UIKit


internal class Application {
static var shared: UIApplication {
let sharedSelector = NSSelectorFromString("sharedApplication")
guard UIApplication.responds(to: sharedSelector) else {
fatalError("[Motion: Extensions cannot access Application]")
}

let shared = UIApplication.perform(sharedSelector)
return shared?.takeUnretainedValue() as! UIApplication
}
}
2 changes: 1 addition & 1 deletion Sources/Extensions/Motion+UIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ extension UIViewController {
next.view.window?.addSubview(next.view)

guard let pvc = presentingVC else {
UIApplication.shared.keyWindow?.rootViewController = next
Application.shared.keyWindow?.rootViewController = next
return
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Transition/MotionTransition+Complete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ extension MotionTransition {
if isPresenting != isFinishing, !isContainerController {
// Only happens when present a .overFullScreen view controller.
// bug: http://openradar.appspot.com/radar?id=5320103646199808
UIApplication.shared.keyWindow?.addSubview(isPresenting ? fv : tv)
Application.shared.keyWindow?.addSubview(isPresenting ? fv : tv)
}
}

Expand Down