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,8 +50,36 @@ 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
......@@ -98,28 +126,4 @@ open class MenuController: RootController {
}
}
}
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 EventKit
@objc(RemindersAuthorizationStatus)
public enum RemindersAuthorizationStatus: Int {
case authorized
case denied
}
@objc(RemindersDelegate)
public protocol RemindersDelegate {
/**
A delegation method that is executed when the Reminder status is updated.
- Parameter reminders: A reference to the Reminder.
- Parameter status: A reference to the ReminderAuthorizationStatus.
*/
@objc
optional func reminders(reminders: Reminders, status: RemindersAuthorizationStatus)
/**
A delegation method that is executed when Reminders is authorized.
- Parameter reminders: A reference to the Reminders.
*/
@objc
optional func reminders(authorized reminders: Reminders)
/**
A delegation method that is executed when Reminders is denied.
- Parameter reminders: A reference to the Reminders.
*/
@objc
optional func reminders(denied reminders: Reminders)
/**
A delegation method that is executed when a new Reminders list is created
- Parameter reminders: A reference to the Reminders.
- Parameter list: A reference to the calendar created
- Parameter created: A boolean describing if the operation succeeded or not.
*/
@objc
optional func reminders(reminders: Reminders, list: EKCalendar, created: Bool)
/**
A delegation method that is executed when a new Reminders list is created
- Parameter reminders: A reference to the Reminder.
- Parameter list: A reference to the calendar created
- Parameter deleted: A boolean describing if the operation succeeded or not.
*/
@objc
optional func reminders(reminders: Reminders, list: EKCalendar, deleted: Bool)
/**
A delegation method that is executed when a new Reminders list is created
- Parameter reminders: A reference to the Reminder.
- Parameter created: A boolean describing if the operation succeeded or not.
*/
@objc
optional func reminders(reminders: Reminders, created: Bool)
/**
A delegation method that is executed when a new Reminders list is created
- Parameter reminders: A reference to the Reminder.
- Parameter deleted: A boolean describing if the operation succeeded or not.
*/
@objc
optional func reminders(reminders: Reminders, deleted: Bool)
}
@objc(Reminders)
open class Reminders: NSObject {
/// The current ReminderAuthorizationStatus.
public var authorizationStatus: RemindersAuthorizationStatus {
return .authorized == EKEventStore.authorizationStatus(for: .reminder) ? .authorized : .denied
}
/// A reference to the eventStore.
internal lazy var eventStore = EKEventStore()
/// A reference to a RemindersDelegate.
open weak var delegate: RemindersDelegate?
open func requestAuthorization(_ completion: (@escaping (RemindersAuthorizationStatus) -> Void)? = nil) {
eventStore.requestAccess(to: .reminder) { [weak self, completion = completion] (permission, _) in
DispatchQueue.main.async { [weak self, completion = completion] in
guard let s = self else {
return
}
if permission {
s.delegate?.reminders?(reminders: s, status: .authorized)
s.delegate?.reminders?(authorized: s)
completion?(.authorized)
} else {
s.delegate?.reminders?(reminders: s, status: .denied)
s.delegate?.reminders?(denied: s)
completion?(.denied)
}
}
}
}
}
// List CRUD operations
extension Reminders {
/**
A method for creating new Reminder lists
- Parameter list title: the name of the list
- Parameter completion: optional completion call back
*/
public func create(list title: String, completion: (@escaping (Bool, Error?) -> Void)? = nil) {
DispatchQueue.global(qos: .default).async { [weak self, completion = completion] in
guard let s = self else {
return
}
let list = EKCalendar(for: .reminder, eventStore: s.eventStore)
list.title = title
for source in s.eventStore.sources {
if .local == source.sourceType {
list.source = source
var created = false
var error: Error?
do {
try s.eventStore.saveCalendar(list, commit: true)
created = true
} catch let e {
error = e
}
DispatchQueue.main.async { [weak self, completion = completion] in
guard let s = self else {
return
}
s.delegate?.reminders?(reminders: s, list: list, created: created)
completion?(created, error)
}
}
}
}
}
/**
A method for deleting existing Reminder lists
- Parameter list identifier: the name of the list
- Parameter completion: optional completion call back
*/
public func delete(list identifier: String, completion: (@escaping (Bool, Error?) -> Void)? = nil) {
DispatchQueue.global(qos: .default).async { [weak self, completion = completion] in
guard let s = self else {
return
}
guard let list = s.eventStore.calendar(withIdentifier: identifier) else {
return
}
var deleted = false
var error: Error?
do {
try s.eventStore.removeCalendar(list, commit: true)
deleted = true
} catch let e {
error = e
}
DispatchQueue.main.async { [weak self, completion = completion] in
guard let s = self else {
return
}
s.delegate?.reminders?(reminders: s, list: list, deleted: deleted)
completion?(deleted, error)
}
}
}
/**
A method for retrieving reminder lists
- Parameter completion: completion call back
*/
public func fetchLists(completion: ([EKCalendar]) -> Void) {
completion(eventStore.calendars(for: .reminder))
}
}
// Reminder list CRUD operations
extension Reminders {
/**
A method for retrieving reminders from an optionally existing list.
if the list does not exist the reminders will be retrieved from the default reminders list
- Parameter list: An optional EKCalendar.
- Parameter completion: completion call back
*/
public func fetchReminders(list: EKCalendar, completion: @escaping ([EKReminder]) -> Void) {
var lists = [EKCalendar]()
lists.append(list)
eventStore.fetchReminders(matching: eventStore.predicateForReminders(in: lists), completion: { [completion = completion] (reminders) in
DispatchQueue.main.async { [completion = completion] in
completion(reminders ?? [])
}
})
}
// FIX ME: Should we use the calendar identifier here instead of the title for finding the right cal?
/**
A method for adding a new reminder to an optionally existing list.
if the list does not exist it will be added to the default reminders list.
- Parameter completion: optional completion call back
*/
public func create(title: String, dateComponents: DateComponents, in list: EKCalendar? = nil, completion: (@escaping (Error?) -> Void)? = nil) {
var reminderCal = [EKCalendar]()
if list != nil {
fetchLists(completion: { (calendars) in
for calendar in calendars {
if calendar.title == list!.title {
reminderCal.append(calendar)
}
}
})
}
let reminder = EKReminder(eventStore: eventStore)
reminder.title = title
reminder.dueDateComponents = dateComponents
reminder.calendar = reminderCal.last!
var created: Bool = false
var error: Error?
do {
try eventStore.save(reminder, commit: true)
created = true
} catch let e {
error = e
}
DispatchQueue.main.async { [weak self] in
guard let s = self else {
return
}
s.delegate?.reminders?(reminders: s, created: created)
if let c = completion {
c(error)
}
}
}
// FIX ME: Should we use the calendar identifier here instead of the title for finding the right cal?
/**
A method for adding a new reminder to an optionally existing list.
if the list does not exist it will be added to the default reminders list.
- Parameter completion: optional completion call back
*/
public func delete(reminder: EKReminder, completion: (@escaping (Error?) -> Void)? = nil) {
var deleted: Bool = false
var error: Error?
do {
try eventStore.remove(reminder, commit: true)
deleted = true
} catch let e {
error = e
}
DispatchQueue.main.async { [weak self] in
guard let s = self else {
return
}
s.delegate?.reminders?(reminders: s, deleted: deleted)
if let c = completion {
c(error)
}
}
}
}
/*
* 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,6 +62,7 @@ public protocol SearchBarDelegate {
open class SearchBar: Bar {
/// The UITextField for the searchBar.
@IBInspectable
open let textField = UITextField()
/// Reference to the clearButton.
......
......@@ -61,6 +61,7 @@ open class SearchBarController: StatusBarController {
}
/// Reference to the SearchBar.
@IBInspectable
open let searchBar = SearchBar()
open override func layoutSubviews() {
......
......@@ -102,9 +102,11 @@ open class StatusBarController: RootController {
super.prepare()
prepareStatusBar()
}
}
extension StatusBarController {
/// Prepares the statusBar.
private func prepareStatusBar() {
fileprivate func prepareStatusBar() {
statusBar.backgroundColor = .white
statusBar.height = 20
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