Commit deba7ed3 by Daniel Dahan

development: updated delegation methods access and added PageController from PageTabBarController

parent 37086526
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; }; 96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; };
963832421B88DFD80015F710 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* Material.framework */; }; 963832421B88DFD80015F710 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* Material.framework */; };
963FBEFD1D669510008F8512 /* Snackbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963FBEFC1D669510008F8512 /* Snackbar.swift */; }; 963FBEFD1D669510008F8512 /* Snackbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963FBEFC1D669510008F8512 /* Snackbar.swift */; };
963FBF081D669D14008F8512 /* PageTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963FBF071D669D14008F8512 /* PageTabBarController.swift */; }; 963FBF081D669D14008F8512 /* PageController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963FBF071D669D14008F8512 /* PageController.swift */; };
9658F2171CD6FA4700B902C1 /* IconButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9658F2161CD6FA4700B902C1 /* IconButton.swift */; }; 9658F2171CD6FA4700B902C1 /* IconButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9658F2161CD6FA4700B902C1 /* IconButton.swift */; };
9660161D1CB2ED6C00AAB661 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 966016131CB2ED6C00AAB661 /* Material.framework */; }; 9660161D1CB2ED6C00AAB661 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 966016131CB2ED6C00AAB661 /* Material.framework */; };
9660162A1CB2F04E00AAB661 /* Material.h in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C091C1328D800B91418 /* Material.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9660162A1CB2F04E00AAB661 /* Material.h in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C091C1328D800B91418 /* Material.h */; settings = {ATTRIBUTES = (Public, ); }; };
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
963832411B88DFD80015F710 /* Material.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Material.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 963832411B88DFD80015F710 /* Material.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Material.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
963832591B88E31A0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 963832591B88E31A0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
963FBEFC1D669510008F8512 /* Snackbar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Snackbar.swift; sourceTree = "<group>"; }; 963FBEFC1D669510008F8512 /* Snackbar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Snackbar.swift; sourceTree = "<group>"; };
963FBF071D669D14008F8512 /* PageTabBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageTabBarController.swift; sourceTree = "<group>"; }; 963FBF071D669D14008F8512 /* PageController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageController.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>"; };
966016131CB2ED6C00AAB661 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 966016131CB2ED6C00AAB661 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9660161C1CB2ED6C00AAB661 /* Material macOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Material macOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 9660161C1CB2ED6C00AAB661 /* Material macOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Material macOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
...@@ -407,7 +407,7 @@ ...@@ -407,7 +407,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96BCB79A1CB40DC500C806FE /* TabBar.swift */, 96BCB79A1CB40DC500C806FE /* TabBar.swift */,
963FBF071D669D14008F8512 /* PageTabBarController.swift */, 963FBF071D669D14008F8512 /* PageController.swift */,
96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */, 96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */,
96BCB7591CB40DC500C806FE /* BottomTabBar.swift */, 96BCB7591CB40DC500C806FE /* BottomTabBar.swift */,
); );
...@@ -1057,7 +1057,7 @@ ...@@ -1057,7 +1057,7 @@
962864621D54111D00690B69 /* JSON.swift in Sources */, 962864621D54111D00690B69 /* JSON.swift in Sources */,
96BCB7C21CB40DC500C806FE /* Device.swift in Sources */, 96BCB7C21CB40DC500C806FE /* Device.swift in Sources */,
96BCB7A41CB40DC500C806FE /* CaptureSession.swift in Sources */, 96BCB7A41CB40DC500C806FE /* CaptureSession.swift in Sources */,
963FBF081D669D14008F8512 /* PageTabBarController.swift in Sources */, 963FBF081D669D14008F8512 /* PageController.swift in Sources */,
963FBEFD1D669510008F8512 /* Snackbar.swift in Sources */, 963FBEFD1D669510008F8512 /* Snackbar.swift in Sources */,
96BCB7C51CB40DC500C806FE /* MaterialGravity.swift in Sources */, 96BCB7C51CB40DC500C806FE /* MaterialGravity.swift in Sources */,
968C99471D377849000074FF /* Offset.swift in Sources */, 968C99471D377849000074FF /* Offset.swift in Sources */,
......
...@@ -133,7 +133,7 @@ public protocol CaptureDelegate { ...@@ -133,7 +133,7 @@ public protocol CaptureDelegate {
open class Capture: View, UIGestureRecognizerDelegate { open class Capture: View, UIGestureRecognizerDelegate {
/// A delegation reference. /// A delegation reference.
public weak var delegate: CaptureDelegate? open weak var delegate: CaptureDelegate?
/// A Timer reference for when recording is enabled. /// A Timer reference for when recording is enabled.
private var timer: Timer? private var timer: Timer?
......
...@@ -366,7 +366,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate { ...@@ -366,7 +366,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
} }
/// A delegation property for CaptureSessionDelegate. /// A delegation property for CaptureSessionDelegate.
public weak var delegate: CaptureSessionDelegate? open weak var delegate: CaptureSessionDelegate?
/// Initializer. /// Initializer.
public override init() { public override init() {
......
...@@ -43,7 +43,7 @@ public protocol DynamicFontTypeDelegate { ...@@ -43,7 +43,7 @@ public protocol DynamicFontTypeDelegate {
@objc(DynamicFontType) @objc(DynamicFontType)
open class DynamicFontType: NSObject { open class DynamicFontType: NSObject {
/// A weak reference to a DynamicFontTypeDelegate. /// A weak reference to a DynamicFontTypeDelegate.
public weak var delegate: DynamicFontTypeDelegate? open weak var delegate: DynamicFontTypeDelegate?
/// Initializer. /// Initializer.
public override init() { public override init() {
......
...@@ -42,7 +42,7 @@ public class MenuView : PulseView { ...@@ -42,7 +42,7 @@ public class MenuView : PulseView {
public private(set) lazy var menu: Menu = Menu() public private(set) lazy var menu: Menu = Menu()
/// A delegation reference. /// A delegation reference.
public weak var delegate: MenuViewDelegate? open weak var delegate: MenuViewDelegate?
public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
/** /**
......
...@@ -179,7 +179,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -179,7 +179,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
A NavigationDrawerControllerDelegate property used to bind A NavigationDrawerControllerDelegate property used to bind
the delegation object. the delegation object.
*/ */
public weak var delegate: NavigationDrawerControllerDelegate? open weak var delegate: NavigationDrawerControllerDelegate?
/** /**
A CGFloat property that sets the animation duration of the A CGFloat property that sets the animation duration of the
......
...@@ -32,15 +32,15 @@ import UIKit ...@@ -32,15 +32,15 @@ import UIKit
extension UIViewController { extension UIViewController {
/** /**
A convenience property that provides access to the PageTabBarController. A convenience property that provides access to the PageController.
This is the recommended method of accessing the PageTabBarController This is the recommended method of accessing the PageController
through child UIViewControllers. through child UIViewControllers.
*/ */
public var pageTabBarController: PageTabBarController? { public var pageController: PageController? {
var viewController: UIViewController? = self var viewController: UIViewController? = self
while nil != viewController { while nil != viewController {
if viewController is PageTabBarController { if viewController is PageController {
return viewController as? PageTabBarController return viewController as? PageController
} }
viewController = viewController?.parent viewController = viewController?.parent
} }
...@@ -48,18 +48,32 @@ extension UIViewController { ...@@ -48,18 +48,32 @@ extension UIViewController {
} }
} }
@objc(PageTabBarControllerDelegate) @objc(PageControllerDelegate)
public protocol PageTabBarControllerDelegate { public protocol PageControllerDelegate {
} }
@objc(PageTabBarController) @objc(PageController)
open class PageTabBarController: RootController { open class PageController: RootController {
/// Reference to the TabBar. /// Reference to the TabBar.
open internal(set) var tabBar: TabBar! open internal(set) var tabBar: TabBar!
/// Delegation handler. /// Delegation handler.
public weak var delegate: PageTabBarControllerDelegate? public weak var delegate: PageControllerDelegate?
/// A reference to the instance when it is a UIPageViewController.
open var pageViewController: UIPageViewController? {
return rootViewController as? UIPageViewController
}
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public override init(rootViewController: UIViewController) {
super.init(rootViewController: UIPageViewController())
pageViewController?.setViewControllers([rootViewController], direction: .forward, animated: true, completion: nil)
}
/** /**
To execute in the order of the layout chain, override this To execute in the order of the layout chain, override this
...@@ -99,6 +113,18 @@ open class PageTabBarController: RootController { ...@@ -99,6 +113,18 @@ open class PageTabBarController: RootController {
prepareTabBar() prepareTabBar()
} }
override func prepareRootViewController() {
super.prepareRootViewController()
guard let v = pageViewController else {
return
}
v.isDoubleSided = false
v.delegate = self
v.dataSource = self
}
/// Prepares the tabBar. /// Prepares the tabBar.
private func prepareTabBar() { private func prepareTabBar() {
if nil == tabBar { if nil == tabBar {
...@@ -108,3 +134,23 @@ open class PageTabBarController: RootController { ...@@ -108,3 +134,23 @@ open class PageTabBarController: RootController {
} }
} }
} }
extension PageController {
open func setViewControllers(_ viewControllers: [UIViewController]?, direction: UIPageViewControllerNavigationDirection, animated: Bool, completion: (@escaping (Bool) -> Swift.Void)? = nil) {
pageViewController?.setViewControllers(viewControllers, direction: direction, animated: animated, completion: completion)
}
}
extension PageController: UIPageViewControllerDelegate {
}
extension PageController: UIPageViewControllerDataSource {
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
return nil
}
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
return nil
}
}
...@@ -176,7 +176,7 @@ public class PhotoLibrary: NSObject { ...@@ -176,7 +176,7 @@ public class PhotoLibrary: NSObject {
public internal(set) lazy var fetchResultsDataSource = [String: PhotoLibraryFetchResultDataSource]() public internal(set) lazy var fetchResultsDataSource = [String: PhotoLibraryFetchResultDataSource]()
/// A reference to a PhotoLibraryDelegate. /// A reference to a PhotoLibraryDelegate.
public weak var delegate: PhotoLibraryDelegate? open weak var delegate: PhotoLibraryDelegate?
/// The current PHAuthorizationStatus. /// The current PHAuthorizationStatus.
public var authorizationStatus: PHAuthorizationStatus { public var authorizationStatus: PHAuthorizationStatus {
......
...@@ -80,7 +80,7 @@ public class Switch: UIControl { ...@@ -80,7 +80,7 @@ public class Switch: UIControl {
private var bounceOffset: CGFloat = 3 private var bounceOffset: CGFloat = 3
/// An Optional delegation method. /// An Optional delegation method.
public weak var delegate: SwitchDelegate? open weak var delegate: SwitchDelegate?
/// Indicates if the animation should bounce. /// Indicates if the animation should bounce.
@IBInspectable public var bounceable: Bool = true { @IBInspectable public var bounceable: Bool = true {
......
...@@ -103,7 +103,7 @@ open class TabBar: View { ...@@ -103,7 +103,7 @@ open class TabBar: View {
} }
/// A delegation reference. /// A delegation reference.
public weak var delegate: TabBarDelegate? open weak var delegate: TabBarDelegate?
open override var intrinsicContentSize: CGSize { open override var intrinsicContentSize: CGSize {
return CGSize(width: width, height: 49) return CGSize(width: width, height: 49)
......
...@@ -78,7 +78,7 @@ public class Text: NSObject { ...@@ -78,7 +78,7 @@ public class Text: NSObject {
public private(set) var textStorage: TextStorage = TextStorage() public private(set) var textStorage: TextStorage = TextStorage()
/// Delegation object for pre and post text processing. /// Delegation object for pre and post text processing.
public weak var delegate: TextDelegate? open weak var delegate: TextDelegate?
/// Initializer. /// Initializer.
public override init() { public override init() {
......
...@@ -76,7 +76,7 @@ open class ToolbarController: RootController { ...@@ -76,7 +76,7 @@ open class ToolbarController: RootController {
open internal(set) var toolbar: Toolbar! open internal(set) var toolbar: Toolbar!
/// Delegation handler. /// Delegation handler.
public weak var delegate: ToolbarControllerDelegate? open weak var delegate: ToolbarControllerDelegate?
/// A floating UIViewController. /// A floating UIViewController.
open var floatingViewController: UIViewController? { open var floatingViewController: UIViewController? {
......
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