Commit 0b16cde6 by Daniel Dahan

development: updated NavigationDrawerController project for issue-546

parent f42f9356
...@@ -57,17 +57,14 @@ class ViewController: UIViewController { ...@@ -57,17 +57,14 @@ class ViewController: UIViewController {
private func prepareMenuButton() { private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.white) menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.white)
menuButton.pulseColor = Color.white
} }
private func prepareFavoriteButton() { private func prepareFavoriteButton() {
favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.white) favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.white)
favoriteButton.pulseColor = Color.white
} }
private func prepareShareButton() { private func prepareShareButton() {
shareButton = IconButton(image: Icon.cm.share, tintColor: Color.white) shareButton = IconButton(image: Icon.cm.share, tintColor: Color.white)
shareButton.pulseColor = Color.white
} }
private func prepareBar() { private func prepareBar() {
......
...@@ -77,7 +77,6 @@ class ViewController: UIViewController { ...@@ -77,7 +77,6 @@ class ViewController: UIViewController {
private func prepareRaisedButton() { private func prepareRaisedButton() {
let button = RaisedButton(title: "Raised Button", titleColor: Color.white) let button = RaisedButton(title: "Raised Button", titleColor: Color.white)
button.pulseColor = Color.white
button.backgroundColor = Color.blue.base button.backgroundColor = Color.blue.base
view.layout(button) view.layout(button)
......
...@@ -84,7 +84,6 @@ public class ViewController: UIViewController { ...@@ -84,7 +84,6 @@ public class ViewController: UIViewController {
captureButton = FabButton() captureButton = FabButton()
captureButton.width = 72 captureButton.width = 72
captureButton.height = 72 captureButton.height = 72
captureButton.pulseColor = Color.white
captureButton.backgroundColor = Color.red.darken1.withAlphaComponent(0.3) captureButton.backgroundColor = Color.red.darken1.withAlphaComponent(0.3)
captureButton.borderColor = Color.white captureButton.borderColor = Color.white
captureButton.borderWidthPreset = .border3 captureButton.borderWidthPreset = .border3
......
...@@ -57,17 +57,14 @@ class RootViewController: UIViewController { ...@@ -57,17 +57,14 @@ class RootViewController: UIViewController {
private func prepareMenuButton() { private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.white) menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.white)
menuButton.pulseColor = Color.white
} }
private func prepareStarButton() { private func prepareStarButton() {
starButton = IconButton(image: Icon.cm.star, tintColor: Color.white) starButton = IconButton(image: Icon.cm.star, tintColor: Color.white)
starButton.pulseColor = Color.white
} }
private func prepareSearchButton() { private func prepareSearchButton() {
searchButton = IconButton(image: Icon.cm.search, tintColor: Color.white) searchButton = IconButton(image: Icon.cm.search, tintColor: Color.white)
searchButton.pulseColor = Color.white
} }
private func prepareNavigationItem() { private func prepareNavigationItem() {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
96784E8E1D8FFEC80061C06C /* RightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784E8D1D8FFEC80061C06C /* RightViewController.swift */; }; 96784E8E1D8FFEC80061C06C /* RightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784E8D1D8FFEC80061C06C /* RightViewController.swift */; };
96784E901D8FFEEF0061C06C /* AppNavigationDrawerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784E8F1D8FFEEF0061C06C /* AppNavigationDrawerController.swift */; }; 96784E901D8FFEEF0061C06C /* AppNavigationDrawerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96784E8F1D8FFEEF0061C06C /* AppNavigationDrawerController.swift */; };
968948791DA995C400DA9FD9 /* AppToolbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968948781DA995C400DA9FD9 /* AppToolbarController.swift */; }; 968948791DA995C400DA9FD9 /* AppToolbarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968948781DA995C400DA9FD9 /* AppToolbarController.swift */; };
9689487E1DAA92A200DA9FD9 /* TransitionedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9689487D1DAA92A200DA9FD9 /* TransitionedViewController.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -41,6 +42,7 @@ ...@@ -41,6 +42,7 @@
96784E8D1D8FFEC80061C06C /* RightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RightViewController.swift; sourceTree = "<group>"; }; 96784E8D1D8FFEC80061C06C /* RightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RightViewController.swift; sourceTree = "<group>"; };
96784E8F1D8FFEEF0061C06C /* AppNavigationDrawerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppNavigationDrawerController.swift; sourceTree = "<group>"; }; 96784E8F1D8FFEEF0061C06C /* AppNavigationDrawerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppNavigationDrawerController.swift; sourceTree = "<group>"; };
968948781DA995C400DA9FD9 /* AppToolbarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppToolbarController.swift; sourceTree = "<group>"; }; 968948781DA995C400DA9FD9 /* AppToolbarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppToolbarController.swift; sourceTree = "<group>"; };
9689487D1DAA92A200DA9FD9 /* TransitionedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransitionedViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -77,6 +79,7 @@ ...@@ -77,6 +79,7 @@
96784E8F1D8FFEEF0061C06C /* AppNavigationDrawerController.swift */, 96784E8F1D8FFEEF0061C06C /* AppNavigationDrawerController.swift */,
968948781DA995C400DA9FD9 /* AppToolbarController.swift */, 968948781DA995C400DA9FD9 /* AppToolbarController.swift */,
96784E781D8FFE230061C06C /* RootViewController.swift */, 96784E781D8FFE230061C06C /* RootViewController.swift */,
9689487D1DAA92A200DA9FD9 /* TransitionedViewController.swift */,
96784E8B1D8FFEA10061C06C /* LeftViewController.swift */, 96784E8B1D8FFEA10061C06C /* LeftViewController.swift */,
96784E8D1D8FFEC80061C06C /* RightViewController.swift */, 96784E8D1D8FFEC80061C06C /* RightViewController.swift */,
96784E7D1D8FFE230061C06C /* Assets.xcassets */, 96784E7D1D8FFE230061C06C /* Assets.xcassets */,
...@@ -162,6 +165,7 @@ ...@@ -162,6 +165,7 @@
968948791DA995C400DA9FD9 /* AppToolbarController.swift in Sources */, 968948791DA995C400DA9FD9 /* AppToolbarController.swift in Sources */,
96784E8E1D8FFEC80061C06C /* RightViewController.swift in Sources */, 96784E8E1D8FFEC80061C06C /* RightViewController.swift in Sources */,
96784E901D8FFEEF0061C06C /* AppNavigationDrawerController.swift in Sources */, 96784E901D8FFEEF0061C06C /* AppNavigationDrawerController.swift in Sources */,
9689487E1DAA92A200DA9FD9 /* TransitionedViewController.swift in Sources */,
96784E791D8FFE230061C06C /* RootViewController.swift in Sources */, 96784E791D8FFE230061C06C /* RootViewController.swift in Sources */,
96784E771D8FFE230061C06C /* AppDelegate.swift in Sources */, 96784E771D8FFE230061C06C /* AppDelegate.swift in Sources */,
); );
......
...@@ -32,9 +32,47 @@ import UIKit ...@@ -32,9 +32,47 @@ import UIKit
import Material import Material
class AppToolbarController: ToolbarController { class AppToolbarController: ToolbarController {
open override func prepare() { private var menuButton: IconButton!
private var switchControl: Switch!
private var moreButton: IconButton!
override func prepare() {
super.prepare() super.prepare()
statusBarStyle = .default statusBarStyle = .default
prepareMenuButton()
prepareSwitch()
prepareMoreButton()
prepareToolbar()
}
@objc
internal func handleMenuButton() {
navigationDrawerController?.toggleLeftView()
}
@objc
internal func handleMoreButton() {
navigationDrawerController?.toggleRightView()
}
private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.blue.base)
menuButton.addTarget(self, action: #selector(handleMenuButton), for: .touchUpInside)
}
private func prepareSwitch() {
switchControl = Switch(state: .off, style: .light, size: .small)
}
private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreVertical, tintColor: Color.blue.base)
moreButton.addTarget(self, action: #selector(handleMoreButton), for: .touchUpInside)
}
private func prepareToolbar() {
toolbar.leftViews = [menuButton]
toolbar.rightViews = [switchControl, moreButton]
} }
} }
...@@ -32,8 +32,32 @@ import UIKit ...@@ -32,8 +32,32 @@ import UIKit
import Material import Material
class LeftViewController: UIViewController { class LeftViewController: UIViewController {
private var transitionButton: FlatButton!
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = Color.blue.base
prepareTransitionButton()
}
@objc
internal func handleTransitionButton() {
// Transition the entire NavigationDrawer rootViewController.
// navigationDrawerController?.transition(to: TransitionedViewController(), completion: closeNavigationDrawer)
// Transition the ToolbarController rootViewController that is in the NavigationDrawer rootViewController.
(navigationDrawerController?.rootViewController as? ToolbarController)?.transition(to: TransitionedViewController(), completion: closeNavigationDrawer)
}
internal func closeNavigationDrawer(result: Bool) {
navigationDrawerController?.closeLeftView()
}
private func prepareTransitionButton() {
transitionButton = FlatButton(title: "Transition VC", titleColor: Color.white)
transitionButton.addTarget(self, action: #selector(handleTransitionButton), for: .touchUpInside)
view.layout(transitionButton).horizontally().center()
} }
} }
...@@ -32,8 +32,32 @@ import UIKit ...@@ -32,8 +32,32 @@ import UIKit
import Material import Material
class RightViewController: UIViewController { class RightViewController: UIViewController {
private var rootButton: FlatButton!
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.blue.base view.backgroundColor = Color.blue.base
prepareRootButton()
}
@objc
internal func handleTransitionButton() {
// Transition the entire NavigationDrawer rootViewController.
// navigationDrawerController?.transition(to: RootViewController(), completion: closeNavigationDrawer)
// Transition the ToolbarController rootViewController that is in the NavigationDrawer rootViewController.
(navigationDrawerController?.rootViewController as? ToolbarController)?.transition(to: RootViewController(), completion: closeNavigationDrawer)
}
internal func closeNavigationDrawer(result: Bool) {
navigationDrawerController?.closeRightView()
}
private func prepareRootButton() {
rootButton = FlatButton(title: "Root VC", titleColor: Color.white)
rootButton.addTarget(self, action: #selector(handleTransitionButton), for: .touchUpInside)
view.layout(rootButton).horizontally().center()
} }
} }
...@@ -32,62 +32,19 @@ import UIKit ...@@ -32,62 +32,19 @@ import UIKit
import Material import Material
class RootViewController: UIViewController { class RootViewController: UIViewController {
/// Toolbar buttons.
private var menuButton: IconButton!
private var switchControl: Switch!
private var moreButton: IconButton!
open override func viewDidLoad() { open override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Color.white view.backgroundColor = Color.white
}
open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
prepareMenuButton()
prepareSwitch()
prepareMoreButton()
prepareToolbar() prepareToolbar()
} }
@objc
internal func handleMenuButton() {
navigationDrawerController?.toggleLeftView()
}
@objc
internal func handleMoreButton() {
navigationDrawerController?.toggleRightView()
}
private func prepareMenuButton() {
menuButton = IconButton(image: Icon.cm.menu, tintColor: Color.blue.base)
menuButton.addTarget(self, action: #selector(handleMenuButton), for: .touchUpInside)
}
private func prepareSwitch() {
switchControl = Switch(state: .off, style: .light, size: .small)
}
private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreVertical, tintColor: Color.blue.base)
moreButton.addTarget(self, action: #selector(handleMoreButton), for: .touchUpInside)
}
private func prepareToolbar() { private func prepareToolbar() {
guard let tc = toolbarController else { guard let tc = toolbarController else {
return return
} }
tc.toolbar.title = "Marterial" tc.toolbar.title = "Marterial"
// tc.toolbar.titleLabel.textAlignment = .left
tc.toolbar.detail = "Build Beautiful Software" tc.toolbar.detail = "Build Beautiful Software"
// tc.toolbar.detailLabel.textAlignment = .left
tc.toolbar.leftViews = [menuButton]
tc.toolbar.rightViews = [switchControl, moreButton]
} }
} }
/*
* 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 TransitionedViewController: UIViewController {
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.purple.base
prepareToolbar()
}
private func prepareToolbar() {
guard let tc = toolbarController else {
return
}
tc.toolbar.title = "Transitioned"
tc.toolbar.detail = "View Controller"
}
}
...@@ -32,7 +32,6 @@ import UIKit ...@@ -32,7 +32,6 @@ import UIKit
import Material import Material
class RootViewController: UIViewController { class RootViewController: UIViewController {
/// Toolbar buttons.
private var menuButton: IconButton! private var menuButton: IconButton!
private var starButton: IconButton! private var starButton: IconButton!
private var searchButton: IconButton! private var searchButton: IconButton!
......
...@@ -43,7 +43,6 @@ class ViewController: UIViewController { ...@@ -43,7 +43,6 @@ class ViewController: UIViewController {
private func prepareFabButton() { private func prepareFabButton() {
fabButton.image = Icon.cm.add fabButton.image = Icon.cm.add
fabButton.pulseColor = Color.white
} }
private func prepareIconButton() { private func prepareIconButton() {
......
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Material' s.name = 'Material'
s.version = '2.1.1' s.version = '2.1.2'
s.license = 'BSD-3-Clause' s.license = 'BSD-3-Clause'
s.summary = 'Material is an animation and graphics framework that is used to create beautiful applications.' s.summary = 'Material is an animation and graphics framework that is used to create beautiful applications.'
s.homepage = 'http://cosmicmind.io' s.homepage = 'http://cosmicmind.io'
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>2.1.1</string> <string>2.1.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -43,7 +43,6 @@ open class FabButton: Button { ...@@ -43,7 +43,6 @@ open class FabButton: Button {
depthPreset = .depth1 depthPreset = .depth1
shapePreset = .circle shapePreset = .circle
pulseAnimation = .centerWithBacking pulseAnimation = .centerWithBacking
pulseColor = Color.white
tintColor = Color.white tintColor = Color.white
backgroundColor = Color.red.base backgroundColor = Color.red.base
} }
......
...@@ -35,7 +35,7 @@ internal struct Pulse { ...@@ -35,7 +35,7 @@ internal struct Pulse {
internal lazy var layers = [CAShapeLayer]() internal lazy var layers = [CAShapeLayer]()
/// A UIColor. /// A UIColor.
internal var color = Color.grey.base internal var color = Color.white
/// A reference to the PulseAnimation. /// A reference to the PulseAnimation.
internal var animation = PulseAnimation.pointWithBacking internal var animation = PulseAnimation.pointWithBacking
......
...@@ -121,7 +121,7 @@ open class RootController: UIViewController { ...@@ -121,7 +121,7 @@ open class RootController: UIViewController {
to: viewController, to: viewController,
duration: duration, duration: duration,
options: options, options: options,
animations: animations) { [weak self, completion = completion] (result: Bool) in animations: animations) { [weak self, viewController = viewController, completion = completion] (result) in
guard let s = self else { guard let s = self else {
return return
} }
......
...@@ -452,8 +452,7 @@ open class Switch: UIControl { ...@@ -452,8 +452,7 @@ open class Switch: UIControl {
/// Prepares the button. /// Prepares the button.
private func prepareButton() { private func prepareButton() {
button.pulseColor = Color.white button.addTarget(self, action: #selector(handleTouchUpInside), for: .touchUpInside)
button.addTarget(self, action: #selector(handleTouchUpInside), for: .touchUpInside)
button.addTarget(self, action: #selector(handleTouchDragInside), for: .touchDragInside) button.addTarget(self, action: #selector(handleTouchDragInside), for: .touchDragInside)
button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled), for: .touchCancel) button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled), for: .touchCancel)
button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled), for: .touchUpOutside) button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled), for: .touchUpOutside)
......
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