Commit deba7ed3 by Daniel Dahan

development: updated delegation methods access and added PageController from PageTabBarController

parent 37086526
......@@ -16,7 +16,7 @@
96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; };
963832421B88DFD80015F710 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* Material.framework */; };
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 */; };
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, ); }; };
......@@ -209,7 +209,7 @@
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>"; };
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>"; };
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; };
......@@ -407,7 +407,7 @@
isa = PBXGroup;
children = (
96BCB79A1CB40DC500C806FE /* TabBar.swift */,
963FBF071D669D14008F8512 /* PageTabBarController.swift */,
963FBF071D669D14008F8512 /* PageController.swift */,
96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */,
96BCB7591CB40DC500C806FE /* BottomTabBar.swift */,
);
......@@ -1057,7 +1057,7 @@
962864621D54111D00690B69 /* JSON.swift in Sources */,
96BCB7C21CB40DC500C806FE /* Device.swift in Sources */,
96BCB7A41CB40DC500C806FE /* CaptureSession.swift in Sources */,
963FBF081D669D14008F8512 /* PageTabBarController.swift in Sources */,
963FBF081D669D14008F8512 /* PageController.swift in Sources */,
963FBEFD1D669510008F8512 /* Snackbar.swift in Sources */,
96BCB7C51CB40DC500C806FE /* MaterialGravity.swift in Sources */,
968C99471D377849000074FF /* Offset.swift in Sources */,
......
......@@ -133,7 +133,7 @@ public protocol CaptureDelegate {
open class Capture: View, UIGestureRecognizerDelegate {
/// A delegation reference.
public weak var delegate: CaptureDelegate?
open weak var delegate: CaptureDelegate?
/// A Timer reference for when recording is enabled.
private var timer: Timer?
......
......@@ -366,7 +366,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
}
/// A delegation property for CaptureSessionDelegate.
public weak var delegate: CaptureSessionDelegate?
open weak var delegate: CaptureSessionDelegate?
/// Initializer.
public override init() {
......
......@@ -43,7 +43,7 @@ public protocol DynamicFontTypeDelegate {
@objc(DynamicFontType)
open class DynamicFontType: NSObject {
/// A weak reference to a DynamicFontTypeDelegate.
public weak var delegate: DynamicFontTypeDelegate?
open weak var delegate: DynamicFontTypeDelegate?
/// Initializer.
public override init() {
......
......@@ -42,7 +42,7 @@ public class MenuView : PulseView {
public private(set) lazy var menu: Menu = Menu()
/// A delegation reference.
public weak var delegate: MenuViewDelegate?
open weak var delegate: MenuViewDelegate?
public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
/**
......
......@@ -179,7 +179,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
A NavigationDrawerControllerDelegate property used to bind
the delegation object.
*/
public weak var delegate: NavigationDrawerControllerDelegate?
open weak var delegate: NavigationDrawerControllerDelegate?
/**
A CGFloat property that sets the animation duration of the
......
......@@ -32,15 +32,15 @@ import UIKit
extension UIViewController {
/**
A convenience property that provides access to the PageTabBarController.
This is the recommended method of accessing the PageTabBarController
A convenience property that provides access to the PageController.
This is the recommended method of accessing the PageController
through child UIViewControllers.
*/
public var pageTabBarController: PageTabBarController? {
public var pageController: PageController? {
var viewController: UIViewController? = self
while nil != viewController {
if viewController is PageTabBarController {
return viewController as? PageTabBarController
if viewController is PageController {
return viewController as? PageController
}
viewController = viewController?.parent
}
......@@ -48,18 +48,32 @@ extension UIViewController {
}
}
@objc(PageTabBarControllerDelegate)
public protocol PageTabBarControllerDelegate {
@objc(PageControllerDelegate)
public protocol PageControllerDelegate {
}
@objc(PageTabBarController)
open class PageTabBarController: RootController {
@objc(PageController)
open class PageController: RootController {
/// Reference to the TabBar.
open internal(set) var tabBar: TabBar!
/// 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
......@@ -99,6 +113,18 @@ open class PageTabBarController: RootController {
prepareTabBar()
}
override func prepareRootViewController() {
super.prepareRootViewController()
guard let v = pageViewController else {
return
}
v.isDoubleSided = false
v.delegate = self
v.dataSource = self
}
/// Prepares the tabBar.
private func prepareTabBar() {
if nil == tabBar {
......@@ -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 {
public internal(set) lazy var fetchResultsDataSource = [String: PhotoLibraryFetchResultDataSource]()
/// A reference to a PhotoLibraryDelegate.
public weak var delegate: PhotoLibraryDelegate?
open weak var delegate: PhotoLibraryDelegate?
/// The current PHAuthorizationStatus.
public var authorizationStatus: PHAuthorizationStatus {
......
......@@ -80,7 +80,7 @@ public class Switch: UIControl {
private var bounceOffset: CGFloat = 3
/// An Optional delegation method.
public weak var delegate: SwitchDelegate?
open weak var delegate: SwitchDelegate?
/// Indicates if the animation should bounce.
@IBInspectable public var bounceable: Bool = true {
......
......@@ -103,7 +103,7 @@ open class TabBar: View {
}
/// A delegation reference.
public weak var delegate: TabBarDelegate?
open weak var delegate: TabBarDelegate?
open override var intrinsicContentSize: CGSize {
return CGSize(width: width, height: 49)
......
......@@ -78,7 +78,7 @@ public class Text: NSObject {
public private(set) var textStorage: TextStorage = TextStorage()
/// Delegation object for pre and post text processing.
public weak var delegate: TextDelegate?
open weak var delegate: TextDelegate?
/// Initializer.
public override init() {
......
......@@ -76,7 +76,7 @@ open class ToolbarController: RootController {
open internal(set) var toolbar: Toolbar!
/// Delegation handler.
public weak var delegate: ToolbarControllerDelegate?
open weak var delegate: ToolbarControllerDelegate?
/// A floating 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