Commit 0ba48212 by Daniel Dahan

added smart optional variables for TransitionControllers

parent dc110fd1
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
965E81121DD4D5C800D61E4B /* NavigationItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7921CB40DC500C806FE /* NavigationItem.swift */; }; 965E81121DD4D5C800D61E4B /* NavigationItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7921CB40DC500C806FE /* NavigationItem.swift */; };
965E81131DD4D5C800D61E4B /* NavigationDrawerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7971CB40DC500C806FE /* NavigationDrawerController.swift */; }; 965E81131DD4D5C800D61E4B /* NavigationDrawerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7971CB40DC500C806FE /* NavigationDrawerController.swift */; };
965E81161DD4D5C800D61E4B /* DisplayStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626CA961DAB53A8003E2611 /* DisplayStyle.swift */; }; 965E81161DD4D5C800D61E4B /* DisplayStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9626CA961DAB53A8003E2611 /* DisplayStyle.swift */; };
965E81171DD4D5C800D61E4B /* RootController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7991CB40DC500C806FE /* RootController.swift */; }; 965E81171DD4D5C800D61E4B /* TransitionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7991CB40DC500C806FE /* TransitionController.swift */; };
965E81181DD4D5C800D61E4B /* Snackbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963FBEFC1D669510008F8512 /* Snackbar.swift */; }; 965E81181DD4D5C800D61E4B /* Snackbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963FBEFC1D669510008F8512 /* Snackbar.swift */; };
965E81191DD4D5C800D61E4B /* SnackbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961EFC571D738FF600E84652 /* SnackbarController.swift */; }; 965E81191DD4D5C800D61E4B /* SnackbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961EFC571D738FF600E84652 /* SnackbarController.swift */; };
965E811A1DD4D5C800D61E4B /* StatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967A48181D0F425A00B8CEB7 /* StatusBarController.swift */; }; 965E811A1DD4D5C800D61E4B /* StatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967A48181D0F425A00B8CEB7 /* StatusBarController.swift */; };
...@@ -99,7 +99,6 @@ ...@@ -99,7 +99,6 @@
965E81211DD4D5C800D61E4B /* TextStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79D1CB40DC500C806FE /* TextStorage.swift */; }; 965E81211DD4D5C800D61E4B /* TextStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79D1CB40DC500C806FE /* TextStorage.swift */; };
965E81221DD4D5C800D61E4B /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79E1CB40DC500C806FE /* TextView.swift */; }; 965E81221DD4D5C800D61E4B /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB79E1CB40DC500C806FE /* TextView.swift */; };
965E81261DD4D7C800D61E4B /* CharacterAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961276621DCD8B1800A7D920 /* CharacterAttribute.swift */; }; 965E81261DD4D7C800D61E4B /* CharacterAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961276621DCD8B1800A7D920 /* CharacterAttribute.swift */; };
9667A2491F33D5E200C45078 /* Material+UIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9667A2481F33D5E200C45078 /* Material+UIViewController.swift */; };
966C17731F0439F600D3E83C /* Material+MotionAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966C17721F0439F600D3E83C /* Material+MotionAnimation.swift */; }; 966C17731F0439F600D3E83C /* Material+MotionAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966C17721F0439F600D3E83C /* Material+MotionAnimation.swift */; };
9685D5AF1F0F04CB00AFEB79 /* CardCollectionViewCell.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9656895E1F002F16001C656D /* CardCollectionViewCell.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9685D5AF1F0F04CB00AFEB79 /* CardCollectionViewCell.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9656895E1F002F16001C656D /* CardCollectionViewCell.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9685D5B01F0F04CB00AFEB79 /* CardCollectionViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 965689601F002F4C001C656D /* CardCollectionViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9685D5B01F0F04CB00AFEB79 /* CardCollectionViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 965689601F002F4C001C656D /* CardCollectionViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
...@@ -176,7 +175,7 @@ ...@@ -176,7 +175,7 @@
96BCB8371CB4115200C806FE /* Layout.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7811CB40DC500C806FE /* Layout.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8371CB4115200C806FE /* Layout.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7811CB40DC500C806FE /* Layout.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB83B1CB4115200C806FE /* NavigationDrawerController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7971CB40DC500C806FE /* NavigationDrawerController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB83B1CB4115200C806FE /* NavigationDrawerController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7971CB40DC500C806FE /* NavigationDrawerController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB83C1CB4115200C806FE /* Bar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7981CB40DC500C806FE /* Bar.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB83C1CB4115200C806FE /* Bar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7981CB40DC500C806FE /* Bar.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB83D1CB4115200C806FE /* RootController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7991CB40DC500C806FE /* RootController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB83D1CB4115200C806FE /* TransitionController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7991CB40DC500C806FE /* TransitionController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8441CB4115200C806FE /* BottomNavigationController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8441CB4115200C806FE /* BottomNavigationController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8461CB4115200C806FE /* NavigationBar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7901CB40DC500C806FE /* NavigationBar.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8461CB4115200C806FE /* NavigationBar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7901CB40DC500C806FE /* NavigationBar.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8471CB4115200C806FE /* NavigationController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7911CB40DC500C806FE /* NavigationController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCB8471CB4115200C806FE /* NavigationController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7911CB40DC500C806FE /* NavigationController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
...@@ -230,7 +229,6 @@ ...@@ -230,7 +229,6 @@
9656895E1F002F16001C656D /* CardCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardCollectionViewCell.swift; sourceTree = "<group>"; }; 9656895E1F002F16001C656D /* CardCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardCollectionViewCell.swift; sourceTree = "<group>"; };
965689601F002F4C001C656D /* CardCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardCollectionViewController.swift; sourceTree = "<group>"; }; 965689601F002F4C001C656D /* CardCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardCollectionViewController.swift; sourceTree = "<group>"; };
9658F2161CD6FA4700B902C1 /* IconButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IconButton.swift; sourceTree = "<group>"; }; 9658F2161CD6FA4700B902C1 /* IconButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IconButton.swift; sourceTree = "<group>"; };
9667A2481F33D5E200C45078 /* Material+UIViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIViewController.swift"; sourceTree = "<group>"; };
966C17721F0439F600D3E83C /* Material+MotionAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+MotionAnimation.swift"; sourceTree = "<group>"; }; 966C17721F0439F600D3E83C /* Material+MotionAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+MotionAnimation.swift"; sourceTree = "<group>"; };
966ECF291CF4C20100BB0BDF /* CollectionReusableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionReusableView.swift; sourceTree = "<group>"; }; 966ECF291CF4C20100BB0BDF /* CollectionReusableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionReusableView.swift; sourceTree = "<group>"; };
967A48181D0F425A00B8CEB7 /* StatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; }; 967A48181D0F425A00B8CEB7 /* StatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; };
...@@ -316,7 +314,7 @@ ...@@ -316,7 +314,7 @@
96BCB7961CB40DC500C806FE /* SearchBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchBarController.swift; sourceTree = "<group>"; }; 96BCB7961CB40DC500C806FE /* SearchBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchBarController.swift; sourceTree = "<group>"; };
96BCB7971CB40DC500C806FE /* NavigationDrawerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationDrawerController.swift; sourceTree = "<group>"; }; 96BCB7971CB40DC500C806FE /* NavigationDrawerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationDrawerController.swift; sourceTree = "<group>"; };
96BCB7981CB40DC500C806FE /* Bar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bar.swift; sourceTree = "<group>"; }; 96BCB7981CB40DC500C806FE /* Bar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bar.swift; sourceTree = "<group>"; };
96BCB7991CB40DC500C806FE /* RootController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RootController.swift; sourceTree = "<group>"; }; 96BCB7991CB40DC500C806FE /* TransitionController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransitionController.swift; sourceTree = "<group>"; };
96BCB79A1CB40DC500C806FE /* TabBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabBar.swift; sourceTree = "<group>"; }; 96BCB79A1CB40DC500C806FE /* TabBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabBar.swift; sourceTree = "<group>"; };
96BCB79C1CB40DC500C806FE /* TextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = "<group>"; }; 96BCB79C1CB40DC500C806FE /* TextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = "<group>"; };
96BCB79D1CB40DC500C806FE /* TextStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextStorage.swift; sourceTree = "<group>"; }; 96BCB79D1CB40DC500C806FE /* TextStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextStorage.swift; sourceTree = "<group>"; };
...@@ -406,13 +404,13 @@ ...@@ -406,13 +404,13 @@
name = Bar; name = Bar;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
9626CA951DAB5370003E2611 /* Root */ = { 9626CA951DAB5370003E2611 /* Transition */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9626CA961DAB53A8003E2611 /* DisplayStyle.swift */, 9626CA961DAB53A8003E2611 /* DisplayStyle.swift */,
96BCB7991CB40DC500C806FE /* RootController.swift */, 96BCB7991CB40DC500C806FE /* TransitionController.swift */,
); );
name = Root; name = Transition;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
9626CBCC1DADA5F1003E2611 /* Height */ = { 9626CBCC1DADA5F1003E2611 /* Height */ = {
...@@ -645,7 +643,6 @@ ...@@ -645,7 +643,6 @@
96BCB8041CB40F6C00C806FE /* Layout */, 96BCB8041CB40F6C00C806FE /* Layout */,
96BCB8011CB40F1700C806FE /* Navigation */, 96BCB8011CB40F1700C806FE /* Navigation */,
961E6BEF1DDA4B04004E6C93 /* NavigationDrawer */, 961E6BEF1DDA4B04004E6C93 /* NavigationDrawer */,
9626CA951DAB5370003E2611 /* Root */,
961E6BE01DDA2ADD004E6C93 /* Screen */, 961E6BE01DDA2ADD004E6C93 /* Screen */,
963FBF031D6696EF008F8512 /* SearchBar */, 963FBF031D6696EF008F8512 /* SearchBar */,
963FBEFB1D6694E8008F8512 /* Snackbar */, 963FBEFB1D6694E8008F8512 /* Snackbar */,
...@@ -655,6 +652,7 @@ ...@@ -655,6 +652,7 @@
966ECF2B1CF4C21B00BB0BDF /* Table */, 966ECF2B1CF4C21B00BB0BDF /* Table */,
96090B031D9D709E00709CA6 /* Text */, 96090B031D9D709E00709CA6 /* Text */,
963FBF001D66964F008F8512 /* Toolbar */, 963FBF001D66964F008F8512 /* Toolbar */,
9626CA951DAB5370003E2611 /* Transition */,
96BCB8061CB40FD000C806FE /* Type */, 96BCB8061CB40FD000C806FE /* Type */,
96BCB80C1CB410DD00C806FE /* View */, 96BCB80C1CB410DD00C806FE /* View */,
); );
...@@ -786,7 +784,6 @@ ...@@ -786,7 +784,6 @@
96C1C8801D42C62800E6608F /* Material+Array.swift */, 96C1C8801D42C62800E6608F /* Material+Array.swift */,
962864591D53FE3E00690B69 /* Material+UIWindow.swift */, 962864591D53FE3E00690B69 /* Material+UIWindow.swift */,
966C17721F0439F600D3E83C /* Material+MotionAnimation.swift */, 966C17721F0439F600D3E83C /* Material+MotionAnimation.swift */,
9667A2481F33D5E200C45078 /* Material+UIViewController.swift */,
); );
name = Extension; name = Extension;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -870,7 +867,7 @@ ...@@ -870,7 +867,7 @@
96BCB8371CB4115200C806FE /* Layout.swift in Headers */, 96BCB8371CB4115200C806FE /* Layout.swift in Headers */,
96BCB83B1CB4115200C806FE /* NavigationDrawerController.swift in Headers */, 96BCB83B1CB4115200C806FE /* NavigationDrawerController.swift in Headers */,
96BCB83C1CB4115200C806FE /* Bar.swift in Headers */, 96BCB83C1CB4115200C806FE /* Bar.swift in Headers */,
96BCB83D1CB4115200C806FE /* RootController.swift in Headers */, 96BCB83D1CB4115200C806FE /* TransitionController.swift in Headers */,
96BCB8441CB4115200C806FE /* BottomNavigationController.swift in Headers */, 96BCB8441CB4115200C806FE /* BottomNavigationController.swift in Headers */,
96BCB8461CB4115200C806FE /* NavigationBar.swift in Headers */, 96BCB8461CB4115200C806FE /* NavigationBar.swift in Headers */,
96BCB8471CB4115200C806FE /* NavigationController.swift in Headers */, 96BCB8471CB4115200C806FE /* NavigationController.swift in Headers */,
...@@ -1012,7 +1009,6 @@ ...@@ -1012,7 +1009,6 @@
965E81031DD4D5C800D61E4B /* CollectionView.swift in Sources */, 965E81031DD4D5C800D61E4B /* CollectionView.swift in Sources */,
965E81041DD4D5C800D61E4B /* CollectionViewCell.swift in Sources */, 965E81041DD4D5C800D61E4B /* CollectionViewCell.swift in Sources */,
96A180941F2E2B6E006BD69D /* MotionCAAnimation.swift in Sources */, 96A180941F2E2B6E006BD69D /* MotionCAAnimation.swift in Sources */,
9667A2491F33D5E200C45078 /* Material+UIViewController.swift in Sources */,
965E81071DD4D5C800D61E4B /* CollectionViewLayout.swift in Sources */, 965E81071DD4D5C800D61E4B /* CollectionViewLayout.swift in Sources */,
96A180A41F2E2B6E006BD69D /* TransitionPreprocessor.swift in Sources */, 96A180A41F2E2B6E006BD69D /* TransitionPreprocessor.swift in Sources */,
965E81081DD4D5C800D61E4B /* CollectionReusableView.swift in Sources */, 965E81081DD4D5C800D61E4B /* CollectionReusableView.swift in Sources */,
...@@ -1032,7 +1028,7 @@ ...@@ -1032,7 +1028,7 @@
9656895F1F002F16001C656D /* CardCollectionViewCell.swift in Sources */, 9656895F1F002F16001C656D /* CardCollectionViewCell.swift in Sources */,
965E81161DD4D5C800D61E4B /* DisplayStyle.swift in Sources */, 965E81161DD4D5C800D61E4B /* DisplayStyle.swift in Sources */,
96A180931F2E2B6E006BD69D /* MotionAnimationState.swift in Sources */, 96A180931F2E2B6E006BD69D /* MotionAnimationState.swift in Sources */,
965E81171DD4D5C800D61E4B /* RootController.swift in Sources */, 965E81171DD4D5C800D61E4B /* TransitionController.swift in Sources */,
965E81181DD4D5C800D61E4B /* Snackbar.swift in Sources */, 965E81181DD4D5C800D61E4B /* Snackbar.swift in Sources */,
965E81191DD4D5C800D61E4B /* SnackbarController.swift in Sources */, 965E81191DD4D5C800D61E4B /* SnackbarController.swift in Sources */,
96A180801F2E2B6E006BD69D /* MotionAnimatorViewContext.swift in Sources */, 96A180801F2E2B6E006BD69D /* MotionAnimatorViewContext.swift in Sources */,
......
...@@ -31,28 +31,33 @@ ...@@ -31,28 +31,33 @@
import UIKit import UIKit
public struct Application { public struct Application {
/// A reference to the main UIWindow. /// An optional reference to the main UIWindow.
public static var keyWindow: UIWindow? { static var keyWindow: UIWindow? {
return UIApplication.shared.keyWindow return UIApplication.shared.keyWindow
} }
/// A Boolean indicating if the device is in Landscape mode. /// An optional reference to the top most view controller.
public static var isLandscape: Bool { static var rootViewController: UIViewController? {
return keyWindow?.rootViewController
}
/// A boolean indicating if the device is in Landscape mode.
static var isLandscape: Bool {
return UIApplication.shared.statusBarOrientation.isLandscape return UIApplication.shared.statusBarOrientation.isLandscape
} }
/// A Boolean indicating if the device is in Portrait mode. /// A boolean indicating if the device is in Portrait mode.
public static var isPortrait: Bool { static var isPortrait: Bool {
return !isLandscape return !isLandscape
} }
/// The current UIInterfaceOrientation value. /// The current UIInterfaceOrientation value.
public static var orientation: UIInterfaceOrientation { static var orientation: UIInterfaceOrientation {
return UIApplication.shared.statusBarOrientation return UIApplication.shared.statusBarOrientation
} }
/// Retrieves the device status bar style. /// Retrieves the device status bar style.
public static var statusBarStyle: UIStatusBarStyle { static var statusBarStyle: UIStatusBarStyle {
get { get {
return UIApplication.shared.statusBarStyle return UIApplication.shared.statusBarStyle
} }
...@@ -62,7 +67,7 @@ public struct Application { ...@@ -62,7 +67,7 @@ public struct Application {
} }
/// Retrieves the device status bar hidden state. /// Retrieves the device status bar hidden state.
public static var isStatusBarHidden: Bool { static var isStatusBarHidden: Bool {
get { get {
return UIApplication.shared.isStatusBarHidden return UIApplication.shared.isStatusBarHidden
} }
...@@ -75,12 +80,12 @@ public struct Application { ...@@ -75,12 +80,12 @@ public struct Application {
A boolean that indicates based on iPhone rules if the A boolean that indicates based on iPhone rules if the
status bar should be shown. status bar should be shown.
*/ */
public static var shouldStatusBarBeHidden: Bool { static var shouldStatusBarBeHidden: Bool {
return isLandscape && .phone == Device.userInterfaceIdiom return isLandscape && .phone == Device.userInterfaceIdiom
} }
/// A reference to the user interface layout direction. /// A reference to the user interface layout direction.
public static var userInterfaceLayoutDirection: UIUserInterfaceLayoutDirection { static var userInterfaceLayoutDirection: UIUserInterfaceLayoutDirection {
return UIApplication.shared.userInterfaceLayoutDirection return UIApplication.shared.userInterfaceLayoutDirection
} }
} }
...@@ -43,11 +43,11 @@ extension UIViewController { ...@@ -43,11 +43,11 @@ extension UIViewController {
through child UIViewControllers. through child UIViewControllers.
*/ */
public var fabMenuController: FABMenuController? { public var fabMenuController: FABMenuController? {
return findViewControllerType() return traverseViewControllerHierarchyForClassType()
} }
} }
open class FABMenuController: RootController { open class FABMenuController: TransitionController {
/// Reference to the MenuView. /// Reference to the MenuView.
@IBInspectable @IBInspectable
open let fabMenu = FABMenu() open let fabMenu = FABMenu()
......
/*
* Copyright (C) 2015 - 2017, 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 extension UIViewController {
/**
Finds a view controller with a given type based on
the view controller subclass.
- Returns: An optional of type T.
*/
func findViewControllerType<T: UIViewController>() -> T? {
var v: UIViewController? = self
while nil != v {
if v is T {
return v as? T
}
v = v?.parent
}
return nil
}
}
...@@ -43,7 +43,7 @@ extension UIViewController { ...@@ -43,7 +43,7 @@ extension UIViewController {
through child UIViewControllers. through child UIViewControllers.
*/ */
public var navigationDrawerController: NavigationDrawerController? { public var navigationDrawerController: NavigationDrawerController? {
return findViewControllerType() return traverseViewControllerHierarchyForClassType()
} }
} }
...@@ -136,7 +136,7 @@ public protocol NavigationDrawerControllerDelegate { ...@@ -136,7 +136,7 @@ public protocol NavigationDrawerControllerDelegate {
} }
@objc(NavigationDrawerController) @objc(NavigationDrawerController)
open class NavigationDrawerController: RootController { open class NavigationDrawerController: TransitionController {
/** /**
A CGFloat property that is used internally to track A CGFloat property that is used internally to track
the original (x) position of the container view when panning. the original (x) position of the container view when panning.
......
...@@ -37,7 +37,7 @@ public extension UIViewController { ...@@ -37,7 +37,7 @@ public extension UIViewController {
through child UIViewControllers. through child UIViewControllers.
*/ */
var searchBarController: SearchBarController? { var searchBarController: SearchBarController? {
return findViewControllerType() return traverseViewControllerHierarchyForClassType()
} }
} }
......
...@@ -78,11 +78,11 @@ extension UIViewController { ...@@ -78,11 +78,11 @@ extension UIViewController {
through child UIViewControllers. through child UIViewControllers.
*/ */
public var snackbarController: SnackbarController? { public var snackbarController: SnackbarController? {
return findViewControllerType() return traverseViewControllerHierarchyForClassType()
} }
} }
open class SnackbarController: RootController { open class SnackbarController: TransitionController {
/// Reference to the Snackbar. /// Reference to the Snackbar.
open let snackbar = Snackbar() open let snackbar = Snackbar()
......
...@@ -37,11 +37,11 @@ extension UIViewController { ...@@ -37,11 +37,11 @@ extension UIViewController {
through child UIViewControllers. through child UIViewControllers.
*/ */
public var statusBarController: StatusBarController? { public var statusBarController: StatusBarController? {
return findViewControllerType() return traverseViewControllerHierarchyForClassType()
} }
} }
open class StatusBarController: RootController { open class StatusBarController: TransitionController {
/** /**
A Display value to indicate whether or not to A Display value to indicate whether or not to
display the rootViewController to the full view display the rootViewController to the full view
......
...@@ -60,7 +60,7 @@ extension UIViewController { ...@@ -60,7 +60,7 @@ extension UIViewController {
through child UIViewControllers. through child UIViewControllers.
*/ */
public var tabsController: TabsController? { public var tabsController: TabsController? {
return findViewControllerType() return traverseViewControllerHierarchyForClassType()
} }
} }
......
...@@ -37,7 +37,7 @@ public extension UIViewController { ...@@ -37,7 +37,7 @@ public extension UIViewController {
through child UIViewControllers. through child UIViewControllers.
*/ */
var toolbarController: ToolbarController? { var toolbarController: ToolbarController? {
return findViewControllerType() return traverseViewControllerHierarchyForClassType()
} }
} }
......
...@@ -30,7 +30,40 @@ ...@@ -30,7 +30,40 @@
import UIKit import UIKit
open class RootController: UIViewController { internal extension UIViewController {
/**
Finds a view controller with a given type based on
the view controller subclass.
- Returns: An optional of type T.
*/
func traverseViewControllerHierarchyForClassType<T: UIViewController>() -> T? {
var v: UIViewController? = self
while nil != v {
if v is T {
return v as? T
}
v = v?.parent as? TransitionController
}
return Application.rootViewController?.traverseTransitionViewControllerHierarchyForClassType()
}
/**
Retrieves a flattened hierarchy of view controllers for a given type.
- Returns: An Array of type T.
*/
func traverseTransitionViewControllerHierarchyForClassType<T: UIViewController>() -> T? {
if let v = self as? T {
return v
} else if let v = self as? TransitionController {
return v.rootViewController.traverseTransitionViewControllerHierarchyForClassType()
}
return nil
}
}
open class TransitionController: UIViewController {
/** /**
A Boolean property used to enable and disable interactivity A Boolean property used to enable and disable interactivity
with the rootViewController. with the rootViewController.
...@@ -146,7 +179,7 @@ open class RootController: UIViewController { ...@@ -146,7 +179,7 @@ open class RootController: UIViewController {
} }
} }
internal extension RootController { internal extension TransitionController {
/// Prepares the container view. /// Prepares the container view.
func prepareContainer() { func prepareContainer() {
container.frame = view.bounds container.frame = view.bounds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment