Commit 659e264b by Daniel Dahan

updating example App

parent 3cd654d4
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */; }; 9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */; };
9663F9521C7A751D00AF0965 /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* FeedViewController.swift */; }; 9663F9521C7A751D00AF0965 /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* FeedViewController.swift */; };
96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */; }; 96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */; };
96FC37D31C8CE1290040A569 /* MessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96FC37D21C8CE1290040A569 /* MessagesViewController.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -52,7 +51,6 @@ ...@@ -52,7 +51,6 @@
9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppRightViewController.swift; sourceTree = "<group>"; }; 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppRightViewController.swift; sourceTree = "<group>"; };
9663F9511C7A751D00AF0965 /* FeedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; }; 9663F9511C7A751D00AF0965 /* FeedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; };
96CC08871C7FEBD60034FF84 /* InboxViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InboxViewController.swift; sourceTree = "<group>"; }; 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InboxViewController.swift; sourceTree = "<group>"; };
96FC37D21C8CE1290040A569 /* MessagesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessagesViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -96,7 +94,6 @@ ...@@ -96,7 +94,6 @@
9663F9331C7A744600AF0965 /* SearchListViewController.swift */, 9663F9331C7A744600AF0965 /* SearchListViewController.swift */,
9663F9511C7A751D00AF0965 /* FeedViewController.swift */, 9663F9511C7A751D00AF0965 /* FeedViewController.swift */,
96CC08871C7FEBD60034FF84 /* InboxViewController.swift */, 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */,
96FC37D21C8CE1290040A569 /* MessagesViewController.swift */,
9663F9381C7A744600AF0965 /* Assets.xcassets */, 9663F9381C7A744600AF0965 /* Assets.xcassets */,
9663F93A1C7A744600AF0965 /* LaunchScreen.storyboard */, 9663F93A1C7A744600AF0965 /* LaunchScreen.storyboard */,
9663F93D1C7A744600AF0965 /* Info.plist */, 9663F93D1C7A744600AF0965 /* Info.plist */,
...@@ -175,7 +172,6 @@ ...@@ -175,7 +172,6 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96FC37D31C8CE1290040A569 /* MessagesViewController.swift in Sources */,
9663F94A1C7A74B500AF0965 /* AppSearchBarViewController.swift in Sources */, 9663F94A1C7A74B500AF0965 /* AppSearchBarViewController.swift in Sources */,
96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */, 96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */,
9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */, 9663F9501C7A74FC00AF0965 /* AppRightViewController.swift in Sources */,
......
...@@ -87,7 +87,7 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -87,7 +87,7 @@ class AppSearchBarViewController: SearchBarViewController {
clearButton.setImage(image, forState: .Highlighted) clearButton.setImage(image, forState: .Highlighted)
// Back button. // Back button.
image = UIImage(named: "ic_arrow_back_white")?.imageWithRenderingMode(.AlwaysTemplate) image = MaterialIcon.arrowDownward
let backButton: FlatButton = FlatButton() let backButton: FlatButton = FlatButton()
backButton.pulseScale = false backButton.pulseScale = false
backButton.pulseColor = MaterialColor.grey.darken4 backButton.pulseColor = MaterialColor.grey.darken4
...@@ -114,8 +114,7 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -114,8 +114,7 @@ class AppSearchBarViewController: SearchBarViewController {
searchBarView.textField.delegate = self searchBarView.textField.delegate = self
searchBarView.clearButton = clearButton searchBarView.clearButton = clearButton
searchBarView.leftControls = [backButton] searchBarView.rightControls = [backButton]
searchBarView.rightControls = [moreButton]
} }
} }
......
...@@ -52,6 +52,12 @@ class FeedViewController: UIViewController { ...@@ -52,6 +52,12 @@ class FeedViewController: UIViewController {
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
sideNavigationViewController?.enabled = true sideNavigationViewController?.enabled = true
if let navigationbar: NavigationBar = navigationController?.navigationBar as? NavigationBar {
navigationbar.statusBarStyle = .LightContent
navigationbar.backgroundColor = MaterialColor.blue.base
navigationbar.backButton.tintColor = MaterialColor.white
}
} }
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
...@@ -66,7 +72,11 @@ class FeedViewController: UIViewController { ...@@ -66,7 +72,11 @@ class FeedViewController: UIViewController {
/// Handler for searchButton. /// Handler for searchButton.
internal func handleSearchButton() { internal func handleSearchButton() {
presentViewController(AppSearchBarViewController(mainViewController: SearchListViewController()), animated: true, completion: nil) let vc: AppSearchBarViewController = AppSearchBarViewController(mainViewController: SearchListViewController())
navigationController?.modalPresentationStyle = .Popover
navigationController?.presentViewController(vc, animated: true, completion: nil)
} }
/// Prepares view. /// Prepares view.
......
...@@ -175,9 +175,4 @@ extension InboxViewController: UITableViewDelegate { ...@@ -175,9 +175,4 @@ extension InboxViewController: UITableViewDelegate {
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 48 return 48
} }
/// Did select table.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
navigationController?.pushViewController(MessagesViewController(), animated: true)
}
} }
/*
* 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 Material 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
private struct Item {
var text: String
var detail: String
var image: UIImage?
}
class MessagesViewController: UIViewController {
/// A tableView used to display Bond entries.
private let tableView: UITableView = UITableView()
/// A list of all the Author Bond types.
private var items: Array<Item> = Array<Item>()
override func viewDidLoad() {
super.viewDidLoad()
prepareItems()
prepareView()
prepareTableView()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
sideNavigationViewController?.enabled = false
}
/**
Handles the search button click, which opens the
SideNavigationViewController.
*/
func handleSearchButton() {
sideNavigationViewController?.openRightView()
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.white
let titleLabel: UILabel = UILabel()
titleLabel.text = "Messages"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
let detailLabel: UILabel = UILabel()
detailLabel.text = "\(items.count) Messages"
detailLabel.textAlignment = .Left
detailLabel.textColor = MaterialColor.white
let image: UIImage? = UIImage(named: "ic_share_white")
let shareButton: FlatButton = FlatButton()
shareButton.pulseScale = false
shareButton.pulseColor = MaterialColor.white
shareButton.setImage(image, forState: .Normal)
shareButton.setImage(image, forState: .Highlighted)
navigationItem.titleLabel = titleLabel
navigationItem.detailLabel = detailLabel
navigationItem.rightControls = [shareButton]
}
/// Prepares the items Array.
private func prepareItems() {
items.append(Item(text: "Summer BBQ", detail: "Wish I could come, but I am out of town this weekend.", image: UIImage(named: "Profile1")))
items.append(Item(text: "Birthday gift", detail: "Have any ideas about what we should get Heidi for her birthday?", image: UIImage(named: "Profile2")))
items.append(Item(text: "Brunch this weekend?", detail: "I'll be in your neighborhood doing errands this weekend.", image: UIImage(named: "Profile3")))
items.append(Item(text: "Giants game", detail: "Are we on this weekend for the game?", image: UIImage(named: "Profile4")))
items.append(Item(text: "Recipe to try", detail: "We should eat this: Squash, Corn and tomatillo Tacos.", image: UIImage(named: "Profile5")))
items.append(Item(text: "Interview", detail: "The candidate will be arriving at 11:30, are you free?", image: UIImage(named: "Profile6")))
items.append(Item(text: "Book recommendation", detail: "I found the book title, Surely You’re Joking, Mr. Feynman!", image: UIImage(named: "Profile7")))
items.append(Item(text: "Oui oui", detail: "Do you have Paris recommendations? Have you ever been?", image: UIImage(named: "Profile8")))
}
/// Prepares the tableView.
private func prepareTableView() {
tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "MaterialTableViewCell")
tableView.dataSource = self
tableView.delegate = self
// Use MaterialLayout to easily align the tableView.
view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: tableView)
}
}
/// TableViewDataSource methods.
extension MessagesViewController: UITableViewDataSource {
/// Determines the number of rows in the tableView.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count;
}
/// Returns the number of sections.
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
/// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: MaterialTableViewCell = MaterialTableViewCell(style: .Subtitle, reuseIdentifier: "MaterialTableViewCell")
let item: Item = items[indexPath.row]
cell.selectionStyle = .None
cell.textLabel!.text = item.text
cell.textLabel!.font = RobotoFont.regular
cell.detailTextLabel!.text = item.detail
cell.detailTextLabel!.font = RobotoFont.regular
cell.detailTextLabel!.textColor = MaterialColor.grey.darken1
cell.imageView!.image = item.image?.resize(toWidth: 40)
cell.imageView!.layer.cornerRadius = 20
return cell
}
/// Prepares the header within the tableView.
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = UIView(frame: CGRectMake(0, 0, view.bounds.width, 48))
header.backgroundColor = MaterialColor.white
let label: UILabel = UILabel()
label.font = RobotoFont.medium
label.textColor = MaterialColor.grey.darken1
label.text = "Today"
header.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(header, child: label, left: 24)
return header
}
}
/// UITableViewDelegate methods.
extension MessagesViewController: UITableViewDelegate {
/// Sets the tableView cell height.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 80
}
/// Sets the tableView header height.
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 48
}
}
...@@ -38,6 +38,9 @@ private struct Item { ...@@ -38,6 +38,9 @@ private struct Item {
} }
class SearchListViewController: UIViewController { class SearchListViewController: UIViewController {
/// TextField for search.
private let textField: TextField = TextField()
/// A tableView used to display Bond entries. /// A tableView used to display Bond entries.
private let tableView: UITableView = UITableView() private let tableView: UITableView = UITableView()
...@@ -51,6 +54,15 @@ class SearchListViewController: UIViewController { ...@@ -51,6 +54,15 @@ class SearchListViewController: UIViewController {
prepareTableView() prepareTableView()
} }
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
textField.resignFirstResponder()
}
/** /**
Handles the search button click, which opens the Handles the search button click, which opens the
SideNavigationViewController. SideNavigationViewController.
...@@ -62,6 +74,30 @@ class SearchListViewController: UIViewController { ...@@ -62,6 +74,30 @@ class SearchListViewController: UIViewController {
/// Prepares view. /// Prepares view.
private func prepareView() { private func prepareView() {
view.backgroundColor = MaterialColor.white view.backgroundColor = MaterialColor.white
let image: UIImage? = MaterialIcon.close
let clearButton: FlatButton = FlatButton()
clearButton.pulseScale = false
clearButton.pulseColor = MaterialColor.grey.darken4
clearButton.tintColor = MaterialColor.grey.darken4
clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted)
textField.backgroundColor = nil
textField.placeholder = "Search"
textField.placeholderTextColor = MaterialColor.grey.darken4
textField.font = RobotoFont.regularWithSize(20)
textField.tintColor = MaterialColor.grey.darken4
textField.clearButton = clearButton
navigationItem.detailView = textField
if let navigationbar: NavigationBar = navigationController?.navigationBar as? NavigationBar {
navigationbar.statusBarStyle = .Default
navigationbar.backgroundColor = MaterialColor.white
navigationbar.backButton.tintColor = MaterialColor.grey.darken4
}
} }
/// Prepares the items Array. /// Prepares the items Array.
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
96A71F451C74ABCB00C0C4AE /* MaterialBorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F441C74ABCB00C0C4AE /* MaterialBorder.swift */; }; 96A71F451C74ABCB00C0C4AE /* MaterialBorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F441C74ABCB00C0C4AE /* MaterialBorder.swift */; };
96A71FB31C764E3200C0C4AE /* StatusBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FB21C764E3200C0C4AE /* StatusBarView.swift */; }; 96A71FB31C764E3200C0C4AE /* StatusBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FB21C764E3200C0C4AE /* StatusBarView.swift */; };
96A71FB61C7651AA00C0C4AE /* ControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FB01C7649F800C0C4AE /* ControlView.swift */; }; 96A71FB61C7651AA00C0C4AE /* ControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FB01C7649F800C0C4AE /* ControlView.swift */; };
96BE340F1C8E68EF007D02BE /* MaterialIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BE340E1C8E68EF007D02BE /* MaterialIcon.swift */; };
96CC08311C7CCB7C0034FF84 /* MaterialBorder.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96A71F441C74ABCB00C0C4AE /* MaterialBorder.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96CC08311C7CCB7C0034FF84 /* MaterialBorder.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96A71F441C74ABCB00C0C4AE /* MaterialBorder.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96CC08321C7CCB7C0034FF84 /* MenuViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9626C2DD1C795017007CA8E0 /* MenuViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96CC08321C7CCB7C0034FF84 /* MenuViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9626C2DD1C795017007CA8E0 /* MenuViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96CC08331C7CCB7C0034FF84 /* MaterialSwitch.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96A71EC61C6FFF0500C0C4AE /* MaterialSwitch.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 96CC08331C7CCB7C0034FF84 /* MaterialSwitch.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96A71EC61C6FFF0500C0C4AE /* MaterialSwitch.swift */; settings = {ATTRIBUTES = (Public, ); }; };
...@@ -185,6 +186,7 @@ ...@@ -185,6 +186,7 @@
96A71F441C74ABCB00C0C4AE /* MaterialBorder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialBorder.swift; sourceTree = "<group>"; }; 96A71F441C74ABCB00C0C4AE /* MaterialBorder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialBorder.swift; sourceTree = "<group>"; };
96A71FB01C7649F800C0C4AE /* ControlView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlView.swift; sourceTree = "<group>"; }; 96A71FB01C7649F800C0C4AE /* ControlView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlView.swift; sourceTree = "<group>"; };
96A71FB21C764E3200C0C4AE /* StatusBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarView.swift; sourceTree = "<group>"; }; 96A71FB21C764E3200C0C4AE /* StatusBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarView.swift; sourceTree = "<group>"; };
96BE340E1C8E68EF007D02BE /* MaterialIcon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialIcon.swift; sourceTree = "<group>"; };
96CC083C1C7CF9D40034FF84 /* StatusBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarViewController.swift; sourceTree = "<group>"; }; 96CC083C1C7CF9D40034FF84 /* StatusBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarViewController.swift; sourceTree = "<group>"; };
96CC088B1C7FEC170034FF84 /* MaterialCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionView.swift; sourceTree = "<group>"; }; 96CC088B1C7FEC170034FF84 /* MaterialCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionView.swift; sourceTree = "<group>"; };
96CC088C1C7FEC170034FF84 /* MaterialCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionViewCell.swift; sourceTree = "<group>"; }; 96CC088C1C7FEC170034FF84 /* MaterialCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionViewCell.swift; sourceTree = "<group>"; };
...@@ -349,6 +351,14 @@ ...@@ -349,6 +351,14 @@
name = Switch; name = Switch;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
96BE340D1C8E68BB007D02BE /* Icon */ = {
isa = PBXGroup;
children = (
96BE340E1C8E68EF007D02BE /* MaterialIcon.swift */,
);
name = Icon;
sourceTree = "<group>";
};
96CC08561C7E0EC00034FF84 /* ControlView */ = { 96CC08561C7E0EC00034FF84 /* ControlView */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -376,6 +386,8 @@ ...@@ -376,6 +386,8 @@
96D88BFD1C1328D800B91418 /* LICENSE */, 96D88BFD1C1328D800B91418 /* LICENSE */,
96D88BFC1C1328D800B91418 /* Info.plist */, 96D88BFC1C1328D800B91418 /* Info.plist */,
96D88C091C1328D800B91418 /* Material.h */, 96D88C091C1328D800B91418 /* Material.h */,
96334EF51C8B84660083986B /* Assets.xcassets */,
96BE340D1C8E68BB007D02BE /* Icon */,
96D88C501C132A2C00B91418 /* Extensions */, 96D88C501C132A2C00B91418 /* Extensions */,
96D88C531C132A6900B91418 /* View */, 96D88C531C132A6900B91418 /* View */,
96D88C521C132A5700B91418 /* Layout */, 96D88C521C132A5700B91418 /* Layout */,
...@@ -399,7 +411,6 @@ ...@@ -399,7 +411,6 @@
9626C2DB1C794FBB007CA8E0 /* SearchBar */, 9626C2DB1C794FBB007CA8E0 /* SearchBar */,
9626C2DA1C794FA5007CA8E0 /* NavigationBar */, 9626C2DA1C794FA5007CA8E0 /* NavigationBar */,
9626C2DC1C794FE5007CA8E0 /* SideNavigation */, 9626C2DC1C794FE5007CA8E0 /* SideNavigation */,
96334EF51C8B84660083986B /* Assets.xcassets */,
); );
path = Sources; path = Sources;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -754,6 +765,7 @@ ...@@ -754,6 +765,7 @@
96CC08921C7FEC170034FF84 /* MaterialCollectionView.swift in Sources */, 96CC08921C7FEC170034FF84 /* MaterialCollectionView.swift in Sources */,
96A71EC71C6FFF0500C0C4AE /* MaterialSwitch.swift in Sources */, 96A71EC71C6FFF0500C0C4AE /* MaterialSwitch.swift in Sources */,
96CC08951C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift in Sources */, 96CC08951C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift in Sources */,
96BE340F1C8E68EF007D02BE /* MaterialIcon.swift in Sources */,
96CC08971C7FEC170034FF84 /* MaterialDataSourceItem.swift in Sources */, 96CC08971C7FEC170034FF84 /* MaterialDataSourceItem.swift in Sources */,
96D88C221C1328D800B91418 /* FabButton.swift in Sources */, 96D88C221C1328D800B91418 /* FabButton.swift in Sources */,
96D88C3F1C1328D800B91418 /* RaisedButton.swift in Sources */, 96D88C3F1C1328D800B91418 /* RaisedButton.swift in Sources */,
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_arrow_downward_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_arrow_downward_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_arrow_downward_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_close_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_close_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_close_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
/*
* 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 Material 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
public struct MaterialIcon {
public static let arrowBack: UIImage? = UIImage(named: "ic_arrow_back_white", inBundle: NSBundle(identifier: "io.cosmicmind.Material"), compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate)
public static let arrowDownward: UIImage? = UIImage(named: "ic_arrow_downward_white", inBundle: NSBundle(identifier: "io.cosmicmind.Material"), compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate)
public static let close: UIImage? = UIImage(named: "ic_close_white", inBundle: NSBundle(identifier: "io.cosmicmind.Material"), compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate)
}
...@@ -53,7 +53,7 @@ public class NavigationBar : UINavigationBar { ...@@ -53,7 +53,7 @@ public class NavigationBar : UINavigationBar {
public var backButtonImage: UIImage? { public var backButtonImage: UIImage? {
didSet { didSet {
if nil == backButtonImage { if nil == backButtonImage {
backButtonImage = UIImage(named: "ic_arrow_back_white", inBundle: NSBundle(identifier: "io.cosmicmind.Material"), compatibleWithTraitCollection: nil) backButtonImage = MaterialIcon.arrowBack
} }
} }
} }
...@@ -275,19 +275,30 @@ public class NavigationBar : UINavigationBar { ...@@ -275,19 +275,30 @@ public class NavigationBar : UINavigationBar {
// TitleView alignment. // TitleView alignment.
if let t: UILabel = item.titleLabel { if let t: UILabel = item.titleLabel {
t.grid.rows = 1 t.grid.rows = 1
item.titleView!.addSubview(t) item.titleView!.addSubview(t)
item.titleView!.grid.views?.append(t) item.titleView!.grid.views?.append(t)
if let d: UILabel = item.detailLabel { if let d: UILabel = item.detailLabel {
d.grid.rows = 1 d.grid.rows = 1
d.font = d.font.fontWithSize(12) d.font = d.font.fontWithSize(12)
t.font = t.font.fontWithSize(17) t.font = t.font.fontWithSize(17)
item.titleView!.addSubview(d) item.titleView!.addSubview(d)
item.titleView!.grid.views?.append(d)
item.titleView!.grid.axis.rows = 2 item.titleView!.grid.axis.rows = 2
item.titleView!.grid.views?.append(d)
} else { } else {
t.font = t.font?.fontWithSize(20) t.font = t.font?.fontWithSize(20)
item.titleView!.grid.axis.rows = 1 item.titleView!.grid.axis.rows = 1
} }
} else if let d: UIView = item.detailView {
d.grid.rows = 1
item.titleView!.addSubview(d)
item.titleView!.grid.axis.rows = 1
item.titleView!.grid.views?.append(d)
} }
// rightControls // rightControls
...@@ -341,6 +352,9 @@ public class NavigationItem { ...@@ -341,6 +352,9 @@ public class NavigationItem {
/// Inset. /// Inset.
public var inset: CGFloat = -16 public var inset: CGFloat = -16
/// Detail View.
public var detailView: UIView?
/// Title label. /// Title label.
public var titleLabel: UILabel? public var titleLabel: UILabel?
...@@ -377,6 +391,16 @@ public extension UINavigationItem { ...@@ -377,6 +391,16 @@ public extension UINavigationItem {
} }
} }
/// Detail View.
public var detailView: UIView? {
get {
return item.detailView
}
set(value) {
item.detailView = value
}
}
/// Title Label. /// Title Label.
public var titleLabel: UILabel? { public var titleLabel: UILabel? {
get { get {
......
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