Commit 42e6257c by Daniel Dahan

development: updated remaining example projects for HeightPreset

parent da92a778
......@@ -32,7 +32,6 @@ import UIKit
import Material
class ViewController: UIViewController {
/// A reference to the Layer.
private var layer: Layer!
override func viewDidLoad() {
......
......@@ -7,7 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
9640ED151DAE115D0085CDA1 /* AppStatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9640ED141DAE115D0085CDA1 /* AppStatusBarController.swift */; };
96CC49CD1D8DD984002CAB55 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC49CC1D8DD984002CAB55 /* AppDelegate.swift */; };
96CC49CF1D8DD984002CAB55 /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC49CE1D8DD984002CAB55 /* RootViewController.swift */; };
96CC49D41D8DD984002CAB55 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96CC49D31D8DD984002CAB55 /* Assets.xcassets */; };
......@@ -30,7 +29,6 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
9640ED141DAE115D0085CDA1 /* AppStatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppStatusBarController.swift; sourceTree = "<group>"; };
96CC49C91D8DD984002CAB55 /* NavigationController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavigationController.app; sourceTree = BUILT_PRODUCTS_DIR; };
96CC49CC1D8DD984002CAB55 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96CC49CE1D8DD984002CAB55 /* RootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = "<group>"; };
......@@ -72,7 +70,6 @@
isa = PBXGroup;
children = (
96CC49CC1D8DD984002CAB55 /* AppDelegate.swift */,
9640ED141DAE115D0085CDA1 /* AppStatusBarController.swift */,
96CC49DE1D8DD9E8002CAB55 /* AppNavigationController.swift */,
96CC49CE1D8DD984002CAB55 /* RootViewController.swift */,
96CC49E41D8DDF61002CAB55 /* NextViewController.swift */,
......@@ -155,7 +152,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9640ED151DAE115D0085CDA1 /* AppStatusBarController.swift in Sources */,
96CC49DF1D8DD9E8002CAB55 /* AppNavigationController.swift in Sources */,
96CC49E51D8DDF61002CAB55 /* NextViewController.swift in Sources */,
96CC49CF1D8DD984002CAB55 /* RootViewController.swift in Sources */,
......
......@@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationDidFinishLaunching(_ application: UIApplication) {
window = UIWindow(frame: Device.bounds)
window!.rootViewController = AppStatusBarController(rootViewController: AppNavigationController(rootViewController: RootViewController()))
window!.rootViewController = AppNavigationController(rootViewController: RootViewController())
window!.makeKeyAndVisible()
}
}
......
/*
* 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
import Material
class AppStatusBarController: StatusBarController {
open override func prepare() {
super.prepare()
statusBarStyle = .default
statusBar.backgroundColor = .white
}
}
......@@ -43,6 +43,7 @@ class AppToolbarController: ToolbarController {
prepareMenuButton()
prepareSwitch()
prepareMoreButton()
prepareStatusBar()
prepareToolbar()
}
......@@ -70,6 +71,13 @@ class AppToolbarController: ToolbarController {
moreButton.addTarget(self, action: #selector(handleMoreButton), for: .touchUpInside)
}
private func prepareStatusBar() {
statusBarStyle = .lightContent
// Access the statusBar.
// statusBar.backgroundColor = Color.green.base
}
private func prepareToolbar() {
toolbar.leftViews = [menuButton]
toolbar.rightViews = [switchControl, moreButton]
......
......@@ -56,6 +56,7 @@ class LeftViewController: UIViewController {
private func prepareTransitionButton() {
transitionButton = FlatButton(title: "Transition VC", titleColor: .white)
transitionButton.pulseColor = .white
transitionButton.addTarget(self, action: #selector(handleTransitionButton), for: .touchUpInside)
view.layout(transitionButton).horizontally().center()
......
......@@ -42,7 +42,7 @@ class RightViewController: UIViewController {
}
@objc
internal func handleTransitionButton() {
internal func handleRootButton() {
// Transition the entire NavigationDrawer rootViewController.
// navigationDrawerController?.transition(to: RootViewController(), completion: closeNavigationDrawer)
......@@ -56,7 +56,8 @@ class RightViewController: UIViewController {
private func prepareRootButton() {
rootButton = FlatButton(title: "Root VC", titleColor: .white)
rootButton.addTarget(self, action: #selector(handleTransitionButton), for: .touchUpInside)
rootButton.pulseColor = .white
rootButton.addTarget(self, action: #selector(handleRootButton), for: .touchUpInside)
view.layout(rootButton).horizontally().center()
}
......
......@@ -34,7 +34,8 @@ import Material
class RootViewController: UIViewController {
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
view.backgroundColor = Color.grey.lighten5
prepareToolbar()
}
......
......@@ -55,7 +55,7 @@ class AppSearchBarController: SearchBarController {
statusBarStyle = .lightContent
// Access the statusBar.
// statusBar.backgroundColor = .green
// statusBar.backgroundColor = Color.green.base
}
private func prepareSearchBar() {
......
......@@ -34,7 +34,13 @@ import Material
class AppStatusBarController: StatusBarController {
open override func prepare() {
super.prepare()
statusBarStyle = .default
prepareStatusBar()
}
private func prepareStatusBar() {
statusBarStyle = .lightContent
statusBar.backgroundColor = Color.blue.base
}
}
......@@ -32,10 +32,7 @@ import UIKit
import Material
class ViewController: UIViewController {
/// Buttons for the TabBar.
private lazy var buttons = [Button]()
/// A reference to the TabBar.
private var tabBar: TabBar!
override func viewDidLoad() {
......@@ -62,6 +59,7 @@ class ViewController: UIViewController {
private func prepareTabBar() {
tabBar = TabBar()
tabBar.delegate = self
tabBar.dividerColor = Color.grey.lighten3
tabBar.dividerAlignment = .top
......@@ -76,3 +74,13 @@ class ViewController: UIViewController {
}
}
extension ViewController: TabBarDelegate {
func tabBar(tabBar: TabBar, willSelect button: UIButton) {
print("will select")
}
func tabBar(tabBar: TabBar, didSelect button: UIButton) {
print("did select")
}
}
......@@ -87,9 +87,9 @@ class ViewController: UIViewController {
emailField.isClearIconButtonEnabled = true
emailField.delegate = self
emailField.placeholderNormalColor = amber.darken4
emailField.placeholderActiveColor = pink.base
emailField.dividerNormalColor = cyan.base
emailField.placeholderNormalColor = Color.amber.darken4
emailField.placeholderActiveColor = Color.pink.base
emailField.dividerNormalColor = Color.cyan.base
view.addSubview(emailField)
}
......
......@@ -32,17 +32,16 @@ import UIKit
import Material
class ViewController: UIViewController {
/// A reference to the View.
private var logo: View!
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
prepareLogo()
prepareView()
}
private func prepareLogo() {
private func prepareView() {
let d: CGFloat = 100
logo = View()
......
......@@ -39,6 +39,6 @@ class AppBottomNavigationController: BottomNavigationController {
private func prepareTabBar() {
tabBar.depthPreset = .none
tabBar.dividerColor = .grey.lighten3
tabBar.dividerColor = Color.grey.lighten3
}
}
......@@ -39,12 +39,12 @@ class AudioViewController: UIViewController {
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .blue.base
view.backgroundColor = Color.blue.base
}
private func prepareTabBarItem() {
tabBarItem.title = nil
tabBarItem.image = Icon.cm.audioLibrary?.tint(with: .blueGrey.base)
tabBarItem.selectedImage = Icon.cm.audioLibrary?.tint(with: .blue.base)
tabBarItem.image = Icon.cm.audioLibrary?.tint(with: Color.blueGrey.base)
tabBarItem.selectedImage = Icon.cm.audioLibrary?.tint(with: Color.blue.base)
}
}
......@@ -39,12 +39,12 @@ class PhotoViewController: UIViewController {
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .red.base
view.backgroundColor = Color.red.base
}
private func prepareTabBarItem() {
tabBarItem.title = nil
tabBarItem.image = Icon.cm.photoCamera?.tint(with: .blueGrey.base)
tabBarItem.selectedImage = Icon.cm.photoCamera?.tint(with: .blue.base)
tabBarItem.image = Icon.cm.photoCamera?.tint(with: Color.blueGrey.base)
tabBarItem.selectedImage = Icon.cm.photoCamera?.tint(with: Color.blue.base)
}
}
......@@ -39,12 +39,12 @@ class RemindersViewController: UIViewController {
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .yellow.base
view.backgroundColor = Color.yellow.base
}
private func prepareTabBarItem() {
tabBarItem.title = nil
tabBarItem.image = Icon.cm.bell?.tint(with: .blueGrey.base)
tabBarItem.selectedImage = Icon.cm.bell?.tint(with: .blue.base)
tabBarItem.image = Icon.cm.bell?.tint(with: Color.blueGrey.base)
tabBarItem.selectedImage = Icon.cm.bell?.tint(with: Color.blue.base)
}
}
......@@ -39,12 +39,12 @@ class SearchViewController: UIViewController {
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .blueGrey.base
view.backgroundColor = Color.blueGrey.base
}
private func prepareTabBarItem() {
tabBarItem.title = nil
tabBarItem.image = Icon.cm.search?.tint(with: .blueGrey.base)
tabBarItem.selectedImage = Icon.cm.search?.tint(with: .blue.base)
tabBarItem.image = Icon.cm.search?.tint(with: Color.blueGrey.base)
tabBarItem.selectedImage = Icon.cm.search?.tint(with: Color.blue.base)
}
}
......@@ -34,7 +34,12 @@ import Material
class AppNavigationController: NavigationController {
open override func prepare() {
super.prepare()
statusBarStyle = .default
guard let v = navigationBar as? NavigationBar else {
return
}
v.depthPreset = .none
v.dividerColor = Color.grey.lighten3
}
}
......@@ -34,7 +34,7 @@ import Material
class NextViewController: UIViewController {
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.grey.base
view.backgroundColor = Color.grey.lighten5
prepareNavigationItem()
}
......@@ -43,7 +43,8 @@ class NextViewController: UIViewController {
navigationItem.title = "Title"
navigationItem.detail = "Detail Description"
navigationItem.backButton.tintColor = Color.blue.base
// Access the back button.
// navigationItem.backButton.tintColor = .white
}
}
......@@ -42,7 +42,7 @@ class RootViewController: UIViewController {
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1
view.backgroundColor = Color.grey.lighten5
prepareMenuButton()
prepareStarButton()
......@@ -77,6 +77,7 @@ class RootViewController: UIViewController {
private func prepareNextButton() {
nextButton = FlatButton()
nextButton.pulseAnimation = .none
nextButton.addTarget(self, action: #selector(handleNextButton), for: .touchUpInside)
view.layout(nextButton).edges()
}
......
......@@ -32,9 +32,35 @@ import UIKit
import Material
class AppSearchBarController: SearchBarController {
private var menuButton: IconButton!
private var moreButton: IconButton!
open override func prepare() {
super.prepare()
statusBarStyle = .default
prepareMenuButton()
prepareMoreButton()
prepareStatusBar()
prepareSearchBar()
}
private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu)
}
private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreVertical)
}
private func prepareStatusBar() {
statusBarStyle = .lightContent
// Access the statusBar.
// statusBar.backgroundColor = Color.green.base
}
private func prepareSearchBar() {
searchBar.leftViews = [menuButton]
searchBar.rightViews = [moreButton]
}
}
......@@ -32,37 +32,18 @@ import UIKit
import Material
class RootViewController: UIViewController {
private var menuButton: IconButton!
private var moreButton: IconButton!
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.grey.lighten1
}
open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
view.backgroundColor = Color.grey.lighten5
prepareMenuButton()
prepareMoreButton()
prepareSearchBar()
}
private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu)
}
private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreVertical)
}
private func prepareSearchBar() {
guard let sc = searchBarController else {
return
}
sc.searchBar.leftViews = [menuButton]
sc.searchBar.rightViews = [moreButton]
// Access the searchBar.
// guard let searchBar = searchBarController?.searchBar else {
// return
// }
}
}
......@@ -39,19 +39,19 @@ class AppSnackbarController: SnackbarController {
}
extension AppSnackbarController: SnackbarControllerDelegate {
func snackbarControllerWillShow(snackbarController: SnackbarController) {
print("snackbarControllerWillShow")
func snackbarController(snackbarController: SnackbarController, willShow snackbar: Snackbar) {
print("snackbarController will show")
}
func snackbarControllerWillHide(snackbarController: SnackbarController) {
print("snackbarControllerWillHide")
func snackbarController(snackbarController: SnackbarController, willHide snackbar: Snackbar) {
print("snackbarController will hide")
}
func snackbarControllerDidShow(snackbarController: SnackbarController) {
print("snackbarControllerDidShow")
func snackbarController(snackbarController: SnackbarController, didShow snackbar: Snackbar) {
print("snackbarController did show")
}
func snackbarControllerDidHide(snackbarController: SnackbarController) {
print("snackbarControllerDidHide")
func snackbarController(snackbarController: SnackbarController, didHide snackbar: Snackbar) {
print("snackbarController did hide")
}
}
......@@ -37,12 +37,13 @@ class RootViewController: UIViewController {
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.grey.lighten5
prepareUndoButton()
}
open override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
prepareUndoButton()
prepareSnackbar()
animateSnackbar()
scheduleAnimation()
......@@ -55,12 +56,12 @@ class RootViewController: UIViewController {
}
private func prepareSnackbar() {
guard let sc = snackbarController else {
guard let snackbar = snackbarController?.snackbar else {
return
}
sc.snackbar.text = "Reminder saved."
sc.snackbar.rightViews = [undoButton]
snackbar.text = "Reminder saved."
snackbar.rightViews = [undoButton]
}
private func scheduleAnimation() {
......
......@@ -34,7 +34,13 @@ import Material
class AppStatusBarController: StatusBarController {
open override func prepare() {
super.prepare()
statusBarStyle = .default
prepareStatusBar()
}
private func prepareStatusBar() {
statusBarStyle = .lightContent
statusBar.backgroundColor = Color.blue.base
}
}
......@@ -37,7 +37,7 @@ open class NavigationBar: UINavigationBar {
}
open override var intrinsicContentSize: CGSize {
return CGSize(width: width, height: height)
return CGSize(width: Device.width, height: height)
}
/// A preset wrapper around contentEdgeInsets.
......
......@@ -78,7 +78,7 @@ open class StatusBarController: RootController {
/// Prepares the statusBar.
private func prepareStatusBar() {
statusBar.zPosition = 3000
statusBar.backgroundColor = Color.grey.lighten3
statusBar.backgroundColor = .white
view.layout(statusBar).top().horizontally().height(20)
}
}
......@@ -45,7 +45,7 @@ public protocol TabBarDelegate {
- Parameter button: A UIButton.
*/
@objc
optional func tabBarWillSelectButton(tabBar: TabBar, button: UIButton)
optional func tabBar(tabBar: TabBar, willSelect button: UIButton)
/**
A delegation method that is executed when the button did complete the
......@@ -54,7 +54,7 @@ public protocol TabBarDelegate {
- Parameter button: A UIButton.
*/
@objc
optional func tabBarDidSelectButton(tabBar: TabBar, button: UIButton)
optional func tabBar(tabBar: TabBar, didSelect button: UIButton)
}
open class TabBar: Bar {
......@@ -174,7 +174,7 @@ open class TabBar: Bar {
- Paramater completion: An optional completion block.
*/
open func animate(to button: UIButton, completion: ((UIButton) -> Void)? = nil) {
delegate?.tabBarWillSelectButton?(tabBar: self, button: button)
delegate?.tabBar?(tabBar: self, willSelect: button)
selected = button
isAnimating = true
UIView.animate(withDuration: 0.25, animations: { [weak self, button = button] in
......@@ -188,7 +188,7 @@ open class TabBar: Bar {
return
}
s.isAnimating = false
s.delegate?.tabBarDidSelectButton?(tabBar: s, button: button)
s.delegate?.tabBar?(tabBar: s, didSelect: button)
completion?(button)
}
}
......
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