Commit 735947b5 by Daniel Dahan

development: updates to Controller types to make them inspectable

parent e5dab721
......@@ -7,6 +7,31 @@
objects = {
/* Begin PBXBuildFile section */
9617B0741DFCA74500410F8F /* Reminders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9617B0731DFCA74500410F8F /* Reminders.swift */; };
9617B07A1DFCA80A00410F8F /* RemindersController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9617B0791DFCA80A00410F8F /* RemindersController.swift */; };
9617B07B1DFCA8CF00410F8F /* Reminders.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9617B0731DFCA74500410F8F /* Reminders.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B07C1DFCA8CF00410F8F /* RemindersController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9617B0791DFCA80A00410F8F /* RemindersController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B07D1DFCA8CF00410F8F /* Application.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961E6BDE1DDA2A95004E6C93 /* Application.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B07E1DFCA8CF00410F8F /* Card.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB75D1CB40DC500C806FE /* Card.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B07F1DFCA8CF00410F8F /* ImageCard.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7621CB40DC500C806FE /* ImageCard.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0801DFCA8CF00410F8F /* PresenterCard.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0811DFCA8CF00410F8F /* Capture.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B0D1DBE6AF600DA84DB /* Capture.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0821DFCA8CF00410F8F /* CapturePreview.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B0F1DBE6AF600DA84DB /* CapturePreview.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0831DFCA8CF00410F8F /* CaptureController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B0E1DBE6AF600DA84DB /* CaptureController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0841DFCA8CF00410F8F /* Editor.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961DED451DCC40C500F425B6 /* Editor.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0851DFCA8CF00410F8F /* EditorController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961DED4A1DCC546100F425B6 /* EditorController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0861DFCA8CF00410F8F /* HeightPreset.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9626CB9A1DAD3D1D003E2611 /* HeightPreset.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0871DFCA8CF00410F8F /* PageTabBarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963FBF071D669D14008F8512 /* PageTabBarController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0881DFCA8CF00410F8F /* PhotoLibrary.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B161DBE6B1800DA84DB /* PhotoLibrary.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0891DFCA8CF00410F8F /* PhotoLibraryController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96717B171DBE6B1800DA84DB /* PhotoLibraryController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B08A1DFCA8CF00410F8F /* Display.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9626CA961DAB53A8003E2611 /* Display.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B08B1DFCA8CF00410F8F /* Screen.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961E6BE11DDA2AF3004E6C93 /* Screen.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B08C1DFCA8CF00410F8F /* SearchBar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7951CB40DC500C806FE /* SearchBar.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B08D1DFCA8CF00410F8F /* SearchBarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7961CB40DC500C806FE /* SearchBarController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B08E1DFCA8CF00410F8F /* TabBar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB79A1CB40DC500C806FE /* TabBar.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B08F1DFCA8CF00410F8F /* CharacterAttribute.swift in Headers */ = {isa = PBXBuildFile; fileRef = 961276621DCD8B1800A7D920 /* CharacterAttribute.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0901DFCA8CF00410F8F /* Toolbar.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB79F1CB40DC500C806FE /* Toolbar.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9617B0911DFCA8CF00410F8F /* ToolbarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7A01CB40DC500C806FE /* ToolbarController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
961E6BDF1DDA2A95004E6C93 /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961E6BDE1DDA2A95004E6C93 /* Application.swift */; };
961E6BE21DDA2AF3004E6C93 /* Screen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961E6BE11DDA2AF3004E6C93 /* Screen.swift */; };
96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; };
......@@ -198,6 +223,8 @@
/* Begin PBXFileReference section */
961276621DCD8B1800A7D920 /* CharacterAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CharacterAttribute.swift; sourceTree = "<group>"; };
9617B0731DFCA74500410F8F /* Reminders.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Reminders.swift; path = Reminders/Reminders.swift; sourceTree = "<group>"; };
9617B0791DFCA80A00410F8F /* RemindersController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemindersController.swift; sourceTree = "<group>"; };
961DED451DCC40C500F425B6 /* Editor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Editor.swift; sourceTree = "<group>"; };
961DED4A1DCC546100F425B6 /* EditorController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditorController.swift; sourceTree = "<group>"; };
961E6BDE1DDA2A95004E6C93 /* Application.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Application.swift; sourceTree = "<group>"; };
......@@ -352,6 +379,15 @@
name = TextField;
sourceTree = "<group>";
};
9617B0721DFCA71C00410F8F /* Reminders */ = {
isa = PBXGroup;
children = (
9617B0731DFCA74500410F8F /* Reminders.swift */,
9617B0791DFCA80A00410F8F /* RemindersController.swift */,
);
name = Reminders;
sourceTree = "<group>";
};
961DED441DCC40AC00F425B6 /* Editor */ = {
isa = PBXGroup;
children = (
......@@ -571,6 +607,7 @@
96BCB7571CB40DC500C806FE /* iOS */ = {
isa = PBXGroup;
children = (
9617B0721DFCA71C00410F8F /* Reminders */,
961E6BDD1DDA2A7E004E6C93 /* Application */,
96264BE41D833C8400576F37 /* Bar */,
962DDD081D6FBBD0001C307C /* BottomTabBar */,
......@@ -876,6 +913,29 @@
9697F7C51D8F2573004741EC /* MenuItem.swift in Headers */,
9697F7CB1D8F2573004741EC /* Snackbar.swift in Headers */,
9697F7CC1D8F2573004741EC /* SnackbarController.swift in Headers */,
9617B07B1DFCA8CF00410F8F /* Reminders.swift in Headers */,
9617B07C1DFCA8CF00410F8F /* RemindersController.swift in Headers */,
9617B07D1DFCA8CF00410F8F /* Application.swift in Headers */,
9617B07E1DFCA8CF00410F8F /* Card.swift in Headers */,
9617B07F1DFCA8CF00410F8F /* ImageCard.swift in Headers */,
9617B0801DFCA8CF00410F8F /* PresenterCard.swift in Headers */,
9617B0811DFCA8CF00410F8F /* Capture.swift in Headers */,
9617B0821DFCA8CF00410F8F /* CapturePreview.swift in Headers */,
9617B0831DFCA8CF00410F8F /* CaptureController.swift in Headers */,
9617B0841DFCA8CF00410F8F /* Editor.swift in Headers */,
9617B0851DFCA8CF00410F8F /* EditorController.swift in Headers */,
9617B0861DFCA8CF00410F8F /* HeightPreset.swift in Headers */,
9617B0871DFCA8CF00410F8F /* PageTabBarController.swift in Headers */,
9617B0881DFCA8CF00410F8F /* PhotoLibrary.swift in Headers */,
9617B0891DFCA8CF00410F8F /* PhotoLibraryController.swift in Headers */,
9617B08A1DFCA8CF00410F8F /* Display.swift in Headers */,
9617B08B1DFCA8CF00410F8F /* Screen.swift in Headers */,
9617B08C1DFCA8CF00410F8F /* SearchBar.swift in Headers */,
9617B08D1DFCA8CF00410F8F /* SearchBarController.swift in Headers */,
9617B08E1DFCA8CF00410F8F /* TabBar.swift in Headers */,
9617B08F1DFCA8CF00410F8F /* CharacterAttribute.swift in Headers */,
9617B0901DFCA8CF00410F8F /* Toolbar.swift in Headers */,
9617B0911DFCA8CF00410F8F /* ToolbarController.swift in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1116,6 +1176,7 @@
965E80EA1DD4C55200D61E4B /* Material+UIFont.swift in Sources */,
965E80EB1DD4C55200D61E4B /* Material+UIImage.swift in Sources */,
965E80EC1DD4C55200D61E4B /* Material+Array.swift in Sources */,
9617B07A1DFCA80A00410F8F /* RemindersController.swift in Sources */,
965E80ED1DD4C55200D61E4B /* Material+UIWindow.swift in Sources */,
965E80E41DD4C53300D61E4B /* PulseView.swift in Sources */,
965E80E51DD4C53300D61E4B /* MotionPulse.swift in Sources */,
......@@ -1136,6 +1197,7 @@
965E80D31DD4C50600D61E4B /* Device.swift in Sources */,
965E80FD1DD4D59500D61E4B /* Toolbar.swift in Sources */,
965E80D41DD4C50600D61E4B /* Divider.swift in Sources */,
9617B0741DFCA74500410F8F /* Reminders.swift in Sources */,
965E80D51DD4C50600D61E4B /* Grid.swift in Sources */,
965E80D61DD4C50600D61E4B /* HeightPreset.swift in Sources */,
961E6BDF1DDA2A95004E6C93 /* Application.swift in Sources */,
......
......@@ -78,20 +78,22 @@ open class CaptureController: ToolbarController {
prepareToolbar()
prepareCapture()
}
}
extension CaptureController {
/// Prepares the statusBar.
private func prepareStatusBar() {
fileprivate func prepareStatusBar() {
statusBar.backgroundColor = .clear
}
/// Prepares the toolbar.
private func prepareToolbar() {
fileprivate func prepareToolbar() {
toolbar.backgroundColor = .clear
toolbar.depthPreset = .none
}
/// Prepares capture.
private func prepareCapture() {
fileprivate func prepareCapture() {
capture.delegate = self
capture.flashMode = .auto
}
......
......@@ -50,16 +50,44 @@ extension UIViewController {
open class MenuController: RootController {
/// Reference to the MenuView.
@IBInspectable
open let menu = Menu()
open override func layoutSubviews() {
super.layoutSubviews()
rootViewController.view.frame = view.bounds
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() {
super.prepare()
prepareMenu()
}
}
extension MenuController {
/// Prepares the Menu.
fileprivate func prepareMenu() {
menu.zPosition = 1000
view.addSubview(menu)
}
}
extension MenuController {
/**
Opens the menu with a callback.
- Parameter completion: An Optional callback that is executed when
all menu items have been opened.
*/
open func openMenu(completion: ((UIView) -> Void)? = nil) {
if true == isUserInteractionEnabled {
isUserInteractionEnabled = false
open func openMenu(completion: ((UIView) -> Void)? = nil) {
if true == isUserInteractionEnabled {
isUserInteractionEnabled = false
UIView.animate(withDuration: 0.15, animations: { [weak self] in
guard let s = self else {
return
......@@ -69,16 +97,16 @@ open class MenuController: RootController {
menu.open { [completion = completion] (view) in
completion?(view)
}
}
}
}
}
/**
Opens the menu with a callback.
- Parameter completion: An Optional callback that is executed when
all menu items have been closed.
*/
open func closeMenu(completion: ((UIView) -> Void)? = nil) {
if false == isUserInteractionEnabled {
if false == isUserInteractionEnabled {
UIView.animate(withDuration: 0.15, animations: { [weak self] in
guard let s = self else {
return
......@@ -96,30 +124,6 @@ open class MenuController: RootController {
s.isUserInteractionEnabled = true
}
}
}
}
open override func layoutSubviews() {
super.layoutSubviews()
rootViewController.view.frame = view.bounds
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() {
super.prepare()
prepareMenuView()
}
/// Prepares the MenuView.
private func prepareMenuView() {
menu.zPosition = 1000
view.addSubview(menu)
}
}
}
}
......@@ -101,6 +101,7 @@ public protocol PageTabBarControllerDelegate {
@objc(PageTabBarController)
open class PageTabBarController: RootController {
/// Reference to the PageTabBar.
@IBInspectable
open let pageTabBar = PageTabBar()
/// A boolean that indicates whether bounce is enabled.
......
......@@ -70,9 +70,11 @@ open class PhotoLibraryController: UIViewController {
view.contentScaleFactor = Screen.scale
preparePhotoLibrary()
}
}
extension PhotoLibraryController {
/// Prepares the photoLibrary.
private func preparePhotoLibrary() {
fileprivate func preparePhotoLibrary() {
photoLibrary.delegate = self
}
}
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* 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
extension UIViewController {
/**
A convenience property that provides access to the RemindersController.
This is the recommended method of accessing the RemindersController
through child UIViewControllers.
*/
public var remindersController: RemindersController? {
var viewController: UIViewController? = self
while nil != viewController {
if viewController is RemindersController {
return viewController as? RemindersController
}
viewController = viewController?.parent
}
return nil
}
}
open class RemindersController: UIViewController {
/// A reference to a Reminder.
open let reminders = Reminders()
open override func viewDidLoad() {
super.viewDidLoad()
prepareView()
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
open func prepare() {
view.clipsToBounds = true
view.backgroundColor = Color.white
view.contentScaleFactor = Device.scale
prepareReminders()
}
}
extension RemindersController {
/// Prepares the reminders.
fileprivate func prepareReminders() {
reminders.delegate = self
}
}
extension RemindersController: RemindersDelegate {}
......@@ -62,7 +62,8 @@ public protocol SearchBarDelegate {
open class SearchBar: Bar {
/// The UITextField for the searchBar.
open let textField = UITextField()
@IBInspectable
open let textField = UITextField()
/// Reference to the clearButton.
open fileprivate(set) var clearButton: IconButton!
......
......@@ -61,6 +61,7 @@ open class SearchBarController: StatusBarController {
}
/// Reference to the SearchBar.
@IBInspectable
open let searchBar = SearchBar()
open override func layoutSubviews() {
......
......@@ -102,11 +102,13 @@ open class StatusBarController: RootController {
super.prepare()
prepareStatusBar()
}
/// Prepares the statusBar.
private func prepareStatusBar() {
statusBar.backgroundColor = .white
}
extension StatusBarController {
/// Prepares the statusBar.
fileprivate func prepareStatusBar() {
statusBar.backgroundColor = .white
statusBar.height = 20
view.addSubview(statusBar)
}
view.addSubview(statusBar)
}
}
......@@ -81,7 +81,8 @@ open class ToolbarController: StatusBarController {
}
/// Reference to the Toolbar.
open fileprivate(set) var toolbar = Toolbar()
@IBInspectable
open let toolbar = Toolbar()
/// Internal reference to the floatingViewController.
private var internalFloatingViewController: 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