Commit 6d13b647 by Daniel Dahan

prepare for release

parent 4089aa47
...@@ -81,6 +81,9 @@ ...@@ -81,6 +81,9 @@
location = "group:Storyboards/MaterialPulseView/MaterialPulseView.xcodeproj"> location = "group:Storyboards/MaterialPulseView/MaterialPulseView.xcodeproj">
</FileRef> </FileRef>
<FileRef <FileRef
location = "group:Storyboards/TextField/TextField.xcodeproj">
</FileRef>
<FileRef
location = "group:Storyboards/MaterialButton/MaterialButton.xcodeproj"> location = "group:Storyboards/MaterialButton/MaterialButton.xcodeproj">
</FileRef> </FileRef>
<FileRef <FileRef
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */; }; 9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */; };
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 */; };
96CC08821C7FC0CF0034FF84 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96CC08811C7FC0CF0034FF84 /* Material.framework */; };
96CC08831C7FC0CF0034FF84 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96CC08811C7FC0CF0034FF84 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */; }; 96CC08881C7FEBD60034FF84 /* InboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
...@@ -29,7 +27,6 @@ ...@@ -29,7 +27,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96CC08831C7FC0CF0034FF84 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -49,7 +46,6 @@ ...@@ -49,7 +46,6 @@
9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppLeftViewController.swift; sourceTree = "<group>"; }; 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppLeftViewController.swift; sourceTree = "<group>"; };
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>"; };
96CC08811C7FC0CF0034FF84 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
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>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
...@@ -58,7 +54,6 @@ ...@@ -58,7 +54,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96CC08821C7FC0CF0034FF84 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -68,7 +63,6 @@ ...@@ -68,7 +63,6 @@
9663F9251C7A744500AF0965 = { 9663F9251C7A744500AF0965 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96CC08811C7FC0CF0034FF84 /* Material.framework */,
9663F9301C7A744600AF0965 /* App */, 9663F9301C7A744600AF0965 /* App */,
9663F92F1C7A744600AF0965 /* Products */, 9663F92F1C7A744600AF0965 /* Products */,
); );
...@@ -92,8 +86,8 @@ ...@@ -92,8 +86,8 @@
9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */, 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */,
9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */, 9663F94F1C7A74FC00AF0965 /* AppRightViewController.swift */,
9663F9331C7A744600AF0965 /* SearchListViewController.swift */, 9663F9331C7A744600AF0965 /* SearchListViewController.swift */,
9663F9511C7A751D00AF0965 /* FeedViewController.swift */,
96CC08871C7FEBD60034FF84 /* InboxViewController.swift */, 96CC08871C7FEBD60034FF84 /* InboxViewController.swift */,
9663F9511C7A751D00AF0965 /* FeedViewController.swift */,
9663F9381C7A744600AF0965 /* Assets.xcassets */, 9663F9381C7A744600AF0965 /* Assets.xcassets */,
9663F93A1C7A744600AF0965 /* LaunchScreen.storyboard */, 9663F93A1C7A744600AF0965 /* LaunchScreen.storyboard */,
9663F93D1C7A744600AF0965 /* Info.plist */, 9663F93D1C7A744600AF0965 /* Info.plist */,
......
...@@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch. // Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds) window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = SideNavigationViewController(mainViewController: AppMenuViewController(mainViewController: AppNavigationBarViewController(mainViewController: FeedViewController())), leftViewController: AppLeftViewController(), rightViewController: AppRightViewController()) window!.rootViewController = SideNavigationViewController(mainViewController: AppMenuViewController(mainViewController: AppNavigationBarViewController(mainViewController: InboxViewController())), leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
window!.makeKeyAndVisible() window!.makeKeyAndVisible()
return true return true
} }
......
...@@ -39,7 +39,6 @@ import Material ...@@ -39,7 +39,6 @@ import Material
private struct Item { private struct Item {
var text: String var text: String
var imageName: String var imageName: String
var selected: Bool
} }
class AppLeftViewController: UIViewController { class AppLeftViewController: UIViewController {
...@@ -76,8 +75,8 @@ class AppLeftViewController: UIViewController { ...@@ -76,8 +75,8 @@ class AppLeftViewController: UIViewController {
/// Prepares the items that are displayed within the tableView. /// Prepares the items that are displayed within the tableView.
private func prepareCells() { private func prepareCells() {
items.append(Item(text: "Feed", imageName: "ic_today", selected: true)) items.append(Item(text: "Feed", imageName: "ic_today"))
items.append(Item(text: "Inbox", imageName: "ic_inbox", selected: true)) items.append(Item(text: "Inbox", imageName: "ic_inbox"))
} }
/// Prepares profile view. /// Prepares profile view.
...@@ -134,15 +133,15 @@ extension AppLeftViewController: UITableViewDataSource { ...@@ -134,15 +133,15 @@ extension AppLeftViewController: UITableViewDataSource {
/// Prepares the cells within the tableView. /// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: MaterialTableViewCell = tableView.dequeueReusableCellWithIdentifier("MaterialTableViewCell", forIndexPath: indexPath) as! MaterialTableViewCell let cell: MaterialTableViewCell = tableView.dequeueReusableCellWithIdentifier("MaterialTableViewCell", forIndexPath: indexPath) as! MaterialTableViewCell
cell.backgroundColor = MaterialColor.clear
let item: Item = items[indexPath.row] let item: Item = items[indexPath.row]
cell.textLabel!.text = item.text cell.textLabel!.text = item.text
cell.textLabel!.textColor = MaterialColor.grey.lighten2
cell.textLabel!.font = RobotoFont.medium cell.textLabel!.font = RobotoFont.medium
cell.imageView!.image = UIImage(named: item.imageName)?.imageWithRenderingMode(.AlwaysTemplate) cell.imageView!.image = UIImage(named: item.imageName)?.imageWithRenderingMode(.AlwaysTemplate)
cell.imageView!.tintColor = MaterialColor.grey.lighten2 cell.imageView!.tintColor = MaterialColor.grey.lighten2
cell.backgroundColor = MaterialColor.clear
cell.textLabel!.textColor = item.selected ? MaterialColor.cyan.lighten5 : MaterialColor.grey.lighten3
return cell return cell
} }
...@@ -162,10 +161,25 @@ extension AppLeftViewController: UITableViewDelegate { ...@@ -162,10 +161,25 @@ extension AppLeftViewController: UITableViewDelegate {
func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? { func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? {
let item: Item = items[indexPath.row] let item: Item = items[indexPath.row]
/**
An example of loading a new UIViewController in the AppNavigationBarViewController
if the UIViewController is not already loaded. This is a bit of a tricky example, as
we are diving deeper into the view hierarchy to transition only the mainViewController of the
AppNavigationBarViewController.
Accessing the mainViewController of: SideNavigationViewController -> MenuViewController -> NavigationBarViewController.
*/
if let a: MenuViewController = sideNavigationViewController?.mainViewController as? MenuViewController { if let a: MenuViewController = sideNavigationViewController?.mainViewController as? MenuViewController {
if let b: NavigationBarViewController = a.mainViewController as? NavigationBarViewController { if let b: NavigationBarViewController = a.mainViewController as? NavigationBarViewController {
b.transitionFromMainViewController("Feed" == item.text ? FeedViewController() : InboxViewController(), options: [.TransitionCrossDissolve]) { [weak self] _ in if "Feed" == item.text && !(b.mainViewController is FeedViewController) {
self?.sideNavigationViewController?.closeLeftView() b.transitionFromMainViewController(FeedViewController(), options: [.TransitionCrossDissolve]) { [weak self] _ in
self?.sideNavigationViewController?.closeLeftView()
}
} else if "Inbox" == item.text && !(b.mainViewController is InboxViewController) {
b.transitionFromMainViewController(InboxViewController(), options: [.TransitionCrossDissolve]) { [weak self] _ in
self?.sideNavigationViewController?.closeLeftView()
}
} }
} }
} }
......
...@@ -36,10 +36,9 @@ within a SideNavigationViewController. ...@@ -36,10 +36,9 @@ within a SideNavigationViewController.
import UIKit import UIKit
import Material import Material
private struct Cell { private struct Item {
var text: String var text: String
var imageName: String var imageName: String
var selected: Bool
} }
class AppRightViewController: UIViewController { class AppRightViewController: UIViewController {
...@@ -47,7 +46,7 @@ class AppRightViewController: UIViewController { ...@@ -47,7 +46,7 @@ class AppRightViewController: UIViewController {
private let tableView: UITableView = UITableView() private let tableView: UITableView = UITableView()
/// A list of all the navigation items. /// A list of all the navigation items.
private var items: Array<Cell> = Array<Cell>() private var items: Array<Item> = Array<Item>()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
...@@ -68,12 +67,12 @@ class AppRightViewController: UIViewController { ...@@ -68,12 +67,12 @@ class AppRightViewController: UIViewController {
/// Prepares the items that are displayed within the tableView. /// Prepares the items that are displayed within the tableView.
private func prepareCells() { private func prepareCells() {
items.append(Cell(text: "Inbox", imageName: "ic_inbox", selected: false)) items.append(Item(text: "Inbox", imageName: "ic_inbox"))
items.append(Cell(text: "Feed", imageName: "ic_today", selected: true)) items.append(Item(text: "Feed", imageName: "ic_today"))
items.append(Cell(text: "Bookmarks", imageName: "ic_book", selected: false)) items.append(Item(text: "Bookmarks", imageName: "ic_book"))
items.append(Cell(text: "Work", imageName: "ic_work", selected: false)) items.append(Item(text: "Work", imageName: "ic_work"))
items.append(Cell(text: "Contacts", imageName: "ic_contacts", selected: false)) items.append(Item(text: "Contacts", imageName: "ic_contacts"))
items.append(Cell(text: "Settings", imageName: "ic_settings", selected: false)) items.append(Item(text: "Settings", imageName: "ic_settings"))
} }
/// Prepares the tableView. /// Prepares the tableView.
...@@ -101,15 +100,15 @@ extension AppRightViewController: UITableViewDataSource { ...@@ -101,15 +100,15 @@ extension AppRightViewController: UITableViewDataSource {
/// Prepares the cells within the tableView. /// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: MaterialTableViewCell = tableView.dequeueReusableCellWithIdentifier("MaterialTableViewCell", forIndexPath: indexPath) as! MaterialTableViewCell let cell: MaterialTableViewCell = tableView.dequeueReusableCellWithIdentifier("MaterialTableViewCell", forIndexPath: indexPath) as! MaterialTableViewCell
cell.backgroundColor = MaterialColor.clear
let item: Cell = items[indexPath.row] let item: Item = items[indexPath.row]
cell.textLabel!.text = item.text cell.textLabel!.text = item.text
cell.textLabel!.textColor = MaterialColor.grey.lighten2
cell.textLabel!.font = RobotoFont.medium cell.textLabel!.font = RobotoFont.medium
cell.imageView!.image = UIImage(named: item.imageName)?.imageWithRenderingMode(.AlwaysTemplate) cell.imageView!.image = UIImage(named: item.imageName)?.imageWithRenderingMode(.AlwaysTemplate)
cell.imageView!.tintColor = MaterialColor.grey.lighten2 cell.imageView!.tintColor = MaterialColor.grey.lighten2
cell.backgroundColor = MaterialColor.clear
cell.textLabel!.textColor = item.selected ? MaterialColor.cyan.lighten5 : MaterialColor.grey.lighten3
return cell return cell
} }
......
...@@ -28,11 +28,15 @@ ...@@ -28,11 +28,15 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/*
The following example shows how to dynamically size MaterialCollectionViewCells.
*/
import UIKit import UIKit
import Material import Material
class FeedViewController: UIViewController { class FeedViewController: UIViewController {
private var collectionView: BasicCollectionView = BasicCollectionView() private var collectionView: MaterialCollectionView = MaterialCollectionView()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
...@@ -62,7 +66,12 @@ class FeedViewController: UIViewController { ...@@ -62,7 +66,12 @@ class FeedViewController: UIViewController {
collectionView.delegate = self collectionView.delegate = self
collectionView.spacingPreset = .Spacing1 collectionView.spacingPreset = .Spacing1
collectionView.contentInsetPreset = .Square1 collectionView.contentInsetPreset = .Square1
collectionView.registerClass(MaterialCollectionViewCell.self, forCellWithReuseIdentifier: "MaterialCollectionViewCell")
// To avoid being hidden under the hovering MenuView.
view.addSubview(collectionView) view.addSubview(collectionView)
// collectionView.scrollDirection = .Horizontal // Uncomment to see the horizontal scroll direction.
} }
} }
...@@ -76,7 +85,8 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -76,7 +85,8 @@ extension FeedViewController: MaterialCollectionViewDataSource {
"detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.", "detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.",
"date": "February 26, 2016" "date": "February 26, 2016"
], ],
itemSize: .Small width: 150, // Applied when scrollDirection is .Horizontal
height: 150 // Applied when scrollDirection is .Vertical
), ),
MaterialDataSourceItem( MaterialDataSourceItem(
data: [ data: [
...@@ -84,7 +94,8 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -84,7 +94,8 @@ extension FeedViewController: MaterialCollectionViewDataSource {
"detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.", "detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.",
"date": "February 26, 2016" "date": "February 26, 2016"
], ],
itemSize: .Small width: 250, // Applied when scrollDirection is .Horizontal
height: 250 // Applied when scrollDirection is .Vertical
), ),
MaterialDataSourceItem( MaterialDataSourceItem(
data: [ data: [
...@@ -92,7 +103,8 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -92,7 +103,8 @@ extension FeedViewController: MaterialCollectionViewDataSource {
"detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.", "detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.",
"date": "February 26, 2016" "date": "February 26, 2016"
], ],
itemSize: .Small width: 350, // Applied when scrollDirection is .Horizontal
height: 350 // Applied when scrollDirection is .Vertical
), ),
MaterialDataSourceItem( MaterialDataSourceItem(
data: [ data: [
...@@ -100,7 +112,8 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -100,7 +112,8 @@ extension FeedViewController: MaterialCollectionViewDataSource {
"detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.", "detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.",
"date": "February 26, 2016" "date": "February 26, 2016"
], ],
itemSize: .Small width: 150, // Applied when scrollDirection is .Horizontal
height: 150 // Applied when scrollDirection is .Vertical
), ),
MaterialDataSourceItem( MaterialDataSourceItem(
data: [ data: [
...@@ -108,7 +121,8 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -108,7 +121,8 @@ extension FeedViewController: MaterialCollectionViewDataSource {
"detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.", "detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.",
"date": "February 26, 2016" "date": "February 26, 2016"
], ],
itemSize: .Small width: 250, // Applied when scrollDirection is .Horizontal
height: 250 // Applied when scrollDirection is .Vertical
), ),
MaterialDataSourceItem( MaterialDataSourceItem(
data: [ data: [
...@@ -116,7 +130,8 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -116,7 +130,8 @@ extension FeedViewController: MaterialCollectionViewDataSource {
"detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.", "detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.",
"date": "February 26, 2016" "date": "February 26, 2016"
], ],
itemSize: .Small width: 350, // Applied when scrollDirection is .Horizontal
height: 350 // Applied when scrollDirection is .Vertical
) )
] ]
} }
...@@ -133,70 +148,14 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -133,70 +148,14 @@ extension FeedViewController: MaterialCollectionViewDataSource {
/// Retrieves a UICollectionViewCell. /// Retrieves a UICollectionViewCell.
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let c: BasicCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("BasicCollectionViewCell", forIndexPath: indexPath) as! BasicCollectionViewCell let c: MaterialCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("MaterialCollectionViewCell", forIndexPath: indexPath) as! MaterialCollectionViewCell
let item: MaterialDataSourceItem = items()[indexPath.item]
c.backgroundColor = MaterialColor.grey.darken1
// Set the data for the view objects. // Access the item data property to set data values.
if let data: Dictionary<String, AnyObject> = item.data as? Dictionary<String, AnyObject> { // let item: MaterialDataSourceItem = items()[indexPath.item]
// let data: Dictionary<String, AnyObject>? = item.data as? Dictionary<String, AnyObject>
// Only load the titleLabel if it has not been. // print(data)
if nil == data["title"] {
c.titleLabel = nil
} else if nil == c.titleLabel {
let titleLabel: UILabel = UILabel()
titleLabel.textColor = MaterialColor.grey.darken4
c.titleLabel = titleLabel
}
// Only load the detailLabel if it has not been.
if nil == data["detail"] {
c.detailLabel = nil
} else if nil == c.detailLabel {
let detailLabel: UILabel = UILabel()
detailLabel.numberOfLines = 0
detailLabel.lineBreakMode = .ByTruncatingTail
detailLabel.font = RobotoFont.regularWithSize(12)
detailLabel.textColor = MaterialColor.grey.darken4
c.detailLabel = detailLabel
}
// Only load the controlView if it has not been.
if nil == c.controlView {
c.controlView = ControlView()
c.controlView!.backgroundColor = nil
// Create a date UILabel for the ControlView's contentView.
let date: UILabel = UILabel()
date.font = RobotoFont.regularWithSize(12)
date.textColor = MaterialColor.grey.base
/**
ControlViews have a contentView. In this example, I am using Grid
to maintain its alignment. A ControlView's contentView is inbetween
the leftControls and rightControls.
*/
c.controlView?.contentView.addSubview(date)
c.controlView?.contentView.grid.views = [date]
let image = UIImage(named: "ic_share_white_18pt")?.imageWithRenderingMode(.AlwaysTemplate)
// Share button.
let shareButton: FlatButton = FlatButton()
shareButton.pulseScale = false
shareButton.pulseColor = MaterialColor.grey.lighten1
shareButton.tintColor = MaterialColor.grey.base
shareButton.setImage(image, forState: .Normal)
shareButton.setImage(image, forState: .Highlighted)
c.controlView?.rightControls = [shareButton]
}
c.titleLabel?.text = data["title"] as? String
c.detailLabel?.text = data["detail"] as? String
(c.controlView?.contentView.subviews.first as? UILabel)?.text = data["date"] as? String
c.reloadView()
}
return c return c
} }
......
...@@ -40,8 +40,8 @@ class ViewController: UIViewController { ...@@ -40,8 +40,8 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
prepareView() prepareView()
prepareHorizontalGridViewExample() // prepareHorizontalGridViewExample()
// prepareVerticalGridViewExample() prepareVerticalGridViewExample()
// prepareGridDirectionNoneExample() // prepareGridDirectionNoneExample()
// prepareSmallCardViewExample() // prepareSmallCardViewExample()
// prepareMediumCardViewExample() // prepareMediumCardViewExample()
...@@ -88,15 +88,14 @@ class ViewController: UIViewController { ...@@ -88,15 +88,14 @@ class ViewController: UIViewController {
btn2.grid.rows = 2 btn2.grid.rows = 2
btn3.grid.rows = 2 btn3.grid.rows = 2
//
// view.grid.columns = 9
view.grid.axis.rows = 6 view.grid.axis.rows = 6
view.grid.spacing = 16 view.grid.spacing = 16
view.grid.axis.direction = .Vertical view.grid.axis.direction = .Vertical
view.grid.contentInset.left = 16 view.grid.contentInset.left = 16
view.grid.contentInset.right = 16 view.grid.contentInset.right = 16
view.grid.contentInset.top = 100 view.grid.contentInset.top = 100
// view.grid.contentInset.bottom = 100 view.grid.contentInset.bottom = 100
view.grid.views = [btn2, btn1, btn3] view.grid.views = [btn2, btn1, btn3]
btn2.backgroundColor = MaterialColor.blue.darken1 btn2.backgroundColor = MaterialColor.blue.darken1
...@@ -104,28 +103,6 @@ class ViewController: UIViewController { ...@@ -104,28 +103,6 @@ class ViewController: UIViewController {
for v in view.grid.views! { for v in view.grid.views! {
print(v.frame) print(v.frame)
} }
let menuButton: FabButton = FabButton()
let mb1: FabButton = FabButton()
let mb2: FabButton = FabButton()
let mb3: FabButton = FabButton()
let menuView: MenuView = MenuView()
menuView.addSubview(mb1)
menuView.addSubview(mb2)
menuView.addSubview(mb3)
// Initialize the menu and setup the configuration options.
menuView.menu.direction = .Up
// menuView.menu.baseViewSize = CGSizeMake(56, 56)
menuView.menu.views = [menuButton, mb1, mb2, mb3]
view.addSubview(menuView)
menuView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.size(view, child: menuView, width: 56, height: 56)
MaterialLayout.alignFromBottomLeft(view, child: menuView, bottom: 16, left: (view.bounds.width - 56) / 2)
menuView.backgroundColor = MaterialColor.green.base
} }
/// Prepares the Vertical GridView example. /// Prepares the Vertical GridView example.
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
96A71ED71C6FFF7300C0C4AE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71ED61C6FFF7300C0C4AE /* ViewController.swift */; }; 96A71ED71C6FFF7300C0C4AE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71ED61C6FFF7300C0C4AE /* ViewController.swift */; };
96A71EDC1C6FFF7300C0C4AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A71EDB1C6FFF7300C0C4AE /* Assets.xcassets */; }; 96A71EDC1C6FFF7300C0C4AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A71EDB1C6FFF7300C0C4AE /* Assets.xcassets */; };
96A71EDF1C6FFF7300C0C4AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A71EDD1C6FFF7300C0C4AE /* LaunchScreen.storyboard */; }; 96A71EDF1C6FFF7300C0C4AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A71EDD1C6FFF7300C0C4AE /* LaunchScreen.storyboard */; };
96D527F01C81566500D3BDD1 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96D527EF1C81566500D3BDD1 /* Material.framework */; };
96D527F11C81566500D3BDD1 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96D527EF1C81566500D3BDD1 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -22,7 +20,6 @@ ...@@ -22,7 +20,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96D527F11C81566500D3BDD1 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -36,7 +33,6 @@ ...@@ -36,7 +33,6 @@
96A71EDB1C6FFF7300C0C4AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 96A71EDB1C6FFF7300C0C4AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96A71EDE1C6FFF7300C0C4AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 96A71EDE1C6FFF7300C0C4AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96A71EE01C6FFF7300C0C4AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 96A71EE01C6FFF7300C0C4AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96D527EF1C81566500D3BDD1 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -44,7 +40,6 @@ ...@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96D527F01C81566500D3BDD1 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -54,7 +49,6 @@ ...@@ -54,7 +49,6 @@
96A71EC81C6FFF7300C0C4AE = { 96A71EC81C6FFF7300C0C4AE = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96D527EF1C81566500D3BDD1 /* Material.framework */,
96A71ED31C6FFF7300C0C4AE /* MaterialSwitch */, 96A71ED31C6FFF7300C0C4AE /* MaterialSwitch */,
96A71ED21C6FFF7300C0C4AE /* Products */, 96A71ED21C6FFF7300C0C4AE /* Products */,
); );
......
...@@ -61,9 +61,7 @@ class AppNavigationBarViewController: NavigationBarViewController { ...@@ -61,9 +61,7 @@ class AppNavigationBarViewController: NavigationBarViewController {
/// Toggle SideNavigationViewController left UIViewController. /// Toggle SideNavigationViewController left UIViewController.
internal func handleMenuButton() { internal func handleMenuButton() {
MaterialAnimation.delay(0.75) { [weak self] in transitionFromMainViewController(GreenViewController(), options: [.TransitionCrossDissolve])
self?.transitionFromMainViewController(GreenViewController(), options: [.TransitionCrossDissolve])
}
} }
/// Toggle SideNavigationViewController right UIViewController. /// Toggle SideNavigationViewController right UIViewController.
...@@ -97,7 +95,7 @@ class AppNavigationBarViewController: NavigationBarViewController { ...@@ -97,7 +95,7 @@ class AppNavigationBarViewController: NavigationBarViewController {
// Menu button. // Menu button.
let menuButton: FlatButton = FlatButton() let menuButton: FlatButton = FlatButton()
menuButton.pulseColor = MaterialColor.white menuButton.pulseColor = nil
menuButton.pulseScale = false menuButton.pulseScale = false
menuButton.setImage(image, forState: .Normal) menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted) menuButton.setImage(image, forState: .Highlighted)
...@@ -110,7 +108,7 @@ class AppNavigationBarViewController: NavigationBarViewController { ...@@ -110,7 +108,7 @@ class AppNavigationBarViewController: NavigationBarViewController {
// Search button. // Search button.
image = UIImage(named: "ic_search_white") image = UIImage(named: "ic_search_white")
let searchButton: FlatButton = FlatButton() let searchButton: FlatButton = FlatButton()
searchButton.pulseColor = MaterialColor.white searchButton.pulseColor = nil
searchButton.pulseScale = false searchButton.pulseScale = false
searchButton.setImage(image, forState: .Normal) searchButton.setImage(image, forState: .Normal)
searchButton.setImage(image, forState: .Highlighted) searchButton.setImage(image, forState: .Highlighted)
...@@ -125,11 +123,7 @@ class AppNavigationBarViewController: NavigationBarViewController { ...@@ -125,11 +123,7 @@ class AppNavigationBarViewController: NavigationBarViewController {
extension AppNavigationBarViewController: MaterialSwitchDelegate { extension AppNavigationBarViewController: MaterialSwitchDelegate {
func materialSwitchStateChanged(control: MaterialSwitch) { func materialSwitchStateChanged(control: MaterialSwitch) {
if .Off == control.switchState { transitionFromMainViewController(YellowViewController(), options: [.TransitionCrossDissolve])
MaterialAnimation.delay(0.75) { [weak self] in
self?.transitionFromMainViewController(YellowViewController(), options: [.TransitionCrossDissolve])
}
}
} }
} }
...@@ -48,10 +48,7 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -48,10 +48,7 @@ class AppSearchBarViewController: SearchBarViewController {
if mainViewController is BlueViewController { if mainViewController is BlueViewController {
return return
} }
transitionFromMainViewController(BlueViewController(), options: [.TransitionCrossDissolve])
MaterialAnimation.delay(0.75) { [weak self] in
self?.transitionFromMainViewController(BlueViewController(), options: [.TransitionCrossDissolve])
}
} }
/// Loads the GreenViewController into the searchBarViewControllers mainViewController. /// Loads the GreenViewController into the searchBarViewControllers mainViewController.
...@@ -59,10 +56,7 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -59,10 +56,7 @@ class AppSearchBarViewController: SearchBarViewController {
if mainViewController is GreenViewController { if mainViewController is GreenViewController {
return return
} }
transitionFromMainViewController(GreenViewController(), options: [.TransitionCrossDissolve])
MaterialAnimation.delay(0.75) { [weak self] in
self?.transitionFromMainViewController(GreenViewController(), options: [.TransitionCrossDissolve])
}
} }
/// Loads the YellowViewController into the searchBarViewControllers mainViewController. /// Loads the YellowViewController into the searchBarViewControllers mainViewController.
...@@ -70,11 +64,8 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -70,11 +64,8 @@ class AppSearchBarViewController: SearchBarViewController {
if (mainViewController as? NavigationBarViewController)?.mainViewController is YellowViewController { if (mainViewController as? NavigationBarViewController)?.mainViewController is YellowViewController {
return return
} }
transitionFromMainViewController(YellowViewController(), options: [.TransitionCrossDissolve])
MaterialAnimation.delay(0.75) { [weak self] in searchBarView.textField.resignFirstResponder()
self?.transitionFromMainViewController(YellowViewController(), options: [.TransitionCrossDissolve])
self?.searchBarView.textField.resignFirstResponder()
}
} }
/// Prepares view. /// Prepares view.
...@@ -88,7 +79,7 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -88,7 +79,7 @@ class AppSearchBarViewController: SearchBarViewController {
var image = UIImage(named: "ic_close_white")?.imageWithRenderingMode(.AlwaysTemplate) var image = UIImage(named: "ic_close_white")?.imageWithRenderingMode(.AlwaysTemplate)
let clearButton: FlatButton = FlatButton() let clearButton: FlatButton = FlatButton()
clearButton.pulseColor = MaterialColor.blueGrey.darken4 clearButton.pulseColor = nil
clearButton.pulseScale = false clearButton.pulseScale = false
clearButton.tintColor = MaterialColor.blueGrey.darken4 clearButton.tintColor = MaterialColor.blueGrey.darken4
clearButton.setImage(image, forState: .Normal) clearButton.setImage(image, forState: .Normal)
...@@ -98,7 +89,7 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -98,7 +89,7 @@ class AppSearchBarViewController: SearchBarViewController {
// Back button. // Back button.
image = UIImage(named: "ic_arrow_back_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_arrow_back_white")?.imageWithRenderingMode(.AlwaysTemplate)
let backButton: FlatButton = FlatButton() let backButton: FlatButton = FlatButton()
backButton.pulseColor = MaterialColor.blueGrey.darken4 backButton.pulseColor = nil
backButton.pulseScale = false backButton.pulseScale = false
backButton.tintColor = MaterialColor.blueGrey.darken4 backButton.tintColor = MaterialColor.blueGrey.darken4
backButton.setImage(image, forState: .Normal) backButton.setImage(image, forState: .Normal)
...@@ -108,7 +99,7 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -108,7 +99,7 @@ class AppSearchBarViewController: SearchBarViewController {
// More button. // More button.
image = UIImage(named: "ic_more_horiz_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_more_horiz_white")?.imageWithRenderingMode(.AlwaysTemplate)
let moreButton: FlatButton = FlatButton() let moreButton: FlatButton = FlatButton()
moreButton.pulseColor = MaterialColor.blueGrey.darken4 moreButton.pulseColor = nil
moreButton.pulseScale = false moreButton.pulseScale = false
moreButton.tintColor = MaterialColor.blueGrey.darken4 moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal) moreButton.setImage(image, forState: .Normal)
......
...@@ -76,7 +76,7 @@ class ViewController: UIViewController { ...@@ -76,7 +76,7 @@ class ViewController: UIViewController {
/// Prepares the tableView. /// Prepares the tableView.
private func prepareTableView() { private func prepareTableView() {
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell") tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "Cell")
tableView.dataSource = self tableView.dataSource = self
tableView.delegate = self tableView.delegate = self
} }
...@@ -137,7 +137,7 @@ extension ViewController: UITableViewDataSource { ...@@ -137,7 +137,7 @@ extension ViewController: UITableViewDataSource {
/// Prepares the cells within the tableView. /// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: UITableViewCell = UITableViewCell(style: .Subtitle, reuseIdentifier: "Cell") let cell: MaterialTableViewCell = MaterialTableViewCell(style: .Subtitle, reuseIdentifier: "Cell")
let item: Item = items[indexPath.row] let item: Item = items[indexPath.row]
cell.selectionStyle = .None cell.selectionStyle = .None
......
...@@ -100,7 +100,7 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -100,7 +100,7 @@ class ViewController: UIViewController, TextFieldDelegate {
textField.detailLabel!.text = "Email is incorrect." textField.detailLabel!.text = "Email is incorrect."
textField.detailLabel!.font = RobotoFont.mediumWithSize(12) textField.detailLabel!.font = RobotoFont.mediumWithSize(12)
textField.detailLabelActiveColor = MaterialColor.red.accent3 textField.detailLabelActiveColor = MaterialColor.red.accent3
textField.detailLabelAutoHideEnabled = false // Comment out this line to have automatic hiding. // textField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding.
let image = UIImage(named: "ic_close_white")?.imageWithRenderingMode(.AlwaysTemplate) let image = UIImage(named: "ic_close_white")?.imageWithRenderingMode(.AlwaysTemplate)
......
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:TextField.xcodeproj">
</FileRef>
</Workspace>
...@@ -28,4 +28,41 @@ ...@@ -28,4 +28,41 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public protocol BasicCollectionViewDataSource : MaterialCollectionViewDataSource {} import UIKit
\ No newline at end of file
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
{
"images" : [
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Material-Icon-29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Material-Icon-29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Material-Icon-40@2x-1.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Material-Icon-40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Material-Icon-60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Material-Icon-60@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Material-Icon-29.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Material-Icon-29@2x-1.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Material-Icon-40.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Material-Icon-40@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Material-Icon-76.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Material-Icon-76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Material-Icon-83.5@2x.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="TextField" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="3zW-lR-Siu" customClass="TextField" customModule="Material">
<rect key="frame" x="200" y="41" width="200" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="fUS-ww-GD9" customClass="TextField" customModule="Material">
<rect key="frame" x="200" y="157" width="200" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="fUS-ww-GD9" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="NRT-ra-UCs"/>
<constraint firstItem="3zW-lR-Siu" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="Xbp-rO-2qd"/>
</constraints>
</view>
<connections>
<outlet property="emailField" destination="fUS-ww-GD9" id="p0A-mG-2Qe"/>
<outlet property="nameField" destination="3zW-lR-Siu" id="0GG-AT-RNy"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
/*
* 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.
*/
/*
The following is an example of using a TextField. TextFields offer details
that describe the usage and input results of text. For example, when a
user enters an incorrect email, it is possible to display an error message
under the TextField.
*/
import UIKit
import Material
class ViewController: UIViewController, TextFieldDelegate {
@IBOutlet weak var nameField: TextField!
@IBOutlet weak var emailField: TextField!
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareNameField()
prepareEmailField()
}
/// General preparation statements.
private func prepareView() {
view.backgroundColor = MaterialColor.white
}
/// Prepares the name TextField.
private func prepareNameField() {
nameField.placeholder = "First Name"
nameField.placeholderTextColor = MaterialColor.grey.base
nameField.font = RobotoFont.regularWithSize(20)
nameField.textColor = MaterialColor.black
nameField.borderStyle = .None
nameField.titleLabel = UILabel()
nameField.titleLabel!.font = RobotoFont.mediumWithSize(12)
nameField.titleLabelColor = MaterialColor.grey.base
nameField.titleLabelActiveColor = MaterialColor.blue.accent3
let image = UIImage(named: "ic_close_white")?.imageWithRenderingMode(.AlwaysTemplate)
let clearButton: FlatButton = FlatButton()
clearButton.pulseColor = MaterialColor.grey.base
clearButton.pulseScale = false
clearButton.tintColor = MaterialColor.grey.base
clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted)
nameField.clearButton = clearButton
}
/// Prepares the email TextField.
private func prepareEmailField() {
emailField.delegate = self
emailField.placeholder = "Email"
emailField.placeholderTextColor = MaterialColor.grey.base
emailField.font = RobotoFont.regularWithSize(20)
emailField.textColor = MaterialColor.black
emailField.borderStyle = .None
emailField.titleLabel = UILabel()
emailField.titleLabel!.font = RobotoFont.mediumWithSize(12)
emailField.titleLabelColor = MaterialColor.grey.base
emailField.titleLabelActiveColor = MaterialColor.blue.accent3
/*
Used to display the error message, which is displayed when
the user presses the 'return' key.
*/
emailField.detailLabel = UILabel()
emailField.detailLabel!.text = "Email is incorrect."
emailField.detailLabel!.font = RobotoFont.mediumWithSize(12)
emailField.detailLabelActiveColor = MaterialColor.red.accent3
// emailField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding.
let image = UIImage(named: "ic_close_white")?.imageWithRenderingMode(.AlwaysTemplate)
let clearButton: FlatButton = FlatButton()
clearButton.pulseColor = MaterialColor.grey.base
clearButton.pulseScale = false
clearButton.tintColor = MaterialColor.grey.base
clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted)
emailField.clearButton = clearButton
}
/// Executed when the 'return' key is pressed when using the emailField.
func textFieldShouldReturn(textField: UITextField) -> Bool {
(textField as! TextField).detailLabelHidden = 0 == textField.text?.utf16.count
return false
}
}
...@@ -63,11 +63,7 @@ ...@@ -63,11 +63,7 @@
96CC08951C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC088E1C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift */; }; 96CC08951C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC088E1C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift */; };
96CC08961C7FEC170034FF84 /* MaterialCollectionViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC088F1C7FEC170034FF84 /* MaterialCollectionViewLayout.swift */; }; 96CC08961C7FEC170034FF84 /* MaterialCollectionViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC088F1C7FEC170034FF84 /* MaterialCollectionViewLayout.swift */; };
96CC08971C7FEC170034FF84 /* MaterialDataSourceItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08901C7FEC170034FF84 /* MaterialDataSourceItem.swift */; }; 96CC08971C7FEC170034FF84 /* MaterialDataSourceItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08901C7FEC170034FF84 /* MaterialDataSourceItem.swift */; };
96CC08991C80B74F0034FF84 /* BasicCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08981C80B74F0034FF84 /* BasicCollectionViewCell.swift */; };
96CC089B1C80B82E0034FF84 /* BasicCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC089A1C80B82E0034FF84 /* BasicCollectionView.swift */; };
96CC089D1C80B8F70034FF84 /* BasicCollectionViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC089C1C80B8F70034FF84 /* BasicCollectionViewLayout.swift */; };
96CC08A01C80CB180034FF84 /* MaterialSpacing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC089F1C80CB180034FF84 /* MaterialSpacing.swift */; }; 96CC08A01C80CB180034FF84 /* MaterialSpacing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC089F1C80CB180034FF84 /* MaterialSpacing.swift */; };
96D527EE1C8121EF00D3BDD1 /* BasicCollectionViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D527ED1C8121EF00D3BDD1 /* BasicCollectionViewDataSource.swift */; };
96D88C1E1C1328D800B91418 /* CaptureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF51C1328D800B91418 /* CaptureView.swift */; }; 96D88C1E1C1328D800B91418 /* CaptureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF51C1328D800B91418 /* CaptureView.swift */; };
96D88C1F1C1328D800B91418 /* CardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF61C1328D800B91418 /* CardView.swift */; }; 96D88C1F1C1328D800B91418 /* CardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF61C1328D800B91418 /* CardView.swift */; };
96D88C201C1328D800B91418 /* CapturePreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF71C1328D800B91418 /* CapturePreviewView.swift */; }; 96D88C201C1328D800B91418 /* CapturePreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88BF71C1328D800B91418 /* CapturePreviewView.swift */; };
...@@ -181,11 +177,7 @@ ...@@ -181,11 +177,7 @@
96CC088E1C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionViewDelegate.swift; sourceTree = "<group>"; }; 96CC088E1C7FEC170034FF84 /* MaterialCollectionViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionViewDelegate.swift; sourceTree = "<group>"; };
96CC088F1C7FEC170034FF84 /* MaterialCollectionViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionViewLayout.swift; sourceTree = "<group>"; }; 96CC088F1C7FEC170034FF84 /* MaterialCollectionViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialCollectionViewLayout.swift; sourceTree = "<group>"; };
96CC08901C7FEC170034FF84 /* MaterialDataSourceItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialDataSourceItem.swift; sourceTree = "<group>"; }; 96CC08901C7FEC170034FF84 /* MaterialDataSourceItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialDataSourceItem.swift; sourceTree = "<group>"; };
96CC08981C80B74F0034FF84 /* BasicCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicCollectionViewCell.swift; sourceTree = "<group>"; };
96CC089A1C80B82E0034FF84 /* BasicCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicCollectionView.swift; sourceTree = "<group>"; };
96CC089C1C80B8F70034FF84 /* BasicCollectionViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicCollectionViewLayout.swift; sourceTree = "<group>"; };
96CC089F1C80CB180034FF84 /* MaterialSpacing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialSpacing.swift; sourceTree = "<group>"; }; 96CC089F1C80CB180034FF84 /* MaterialSpacing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialSpacing.swift; sourceTree = "<group>"; };
96D527ED1C8121EF00D3BDD1 /* BasicCollectionViewDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicCollectionViewDataSource.swift; sourceTree = "<group>"; };
96D88BF51C1328D800B91418 /* CaptureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaptureView.swift; sourceTree = "<group>"; }; 96D88BF51C1328D800B91418 /* CaptureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaptureView.swift; sourceTree = "<group>"; };
96D88BF61C1328D800B91418 /* CardView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardView.swift; sourceTree = "<group>"; }; 96D88BF61C1328D800B91418 /* CardView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardView.swift; sourceTree = "<group>"; };
96D88BF71C1328D800B91418 /* CapturePreviewView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CapturePreviewView.swift; sourceTree = "<group>"; }; 96D88BF71C1328D800B91418 /* CapturePreviewView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CapturePreviewView.swift; sourceTree = "<group>"; };
...@@ -354,10 +346,6 @@ ...@@ -354,10 +346,6 @@
96CC08891C7FEBE10034FF84 /* CollectionView */ = { 96CC08891C7FEBE10034FF84 /* CollectionView */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96CC08981C80B74F0034FF84 /* BasicCollectionViewCell.swift */,
96CC089A1C80B82E0034FF84 /* BasicCollectionView.swift */,
96CC089C1C80B8F70034FF84 /* BasicCollectionViewLayout.swift */,
96D527ED1C8121EF00D3BDD1 /* BasicCollectionViewDataSource.swift */,
96CC088B1C7FEC170034FF84 /* MaterialCollectionView.swift */, 96CC088B1C7FEC170034FF84 /* MaterialCollectionView.swift */,
96CC088C1C7FEC170034FF84 /* MaterialCollectionViewCell.swift */, 96CC088C1C7FEC170034FF84 /* MaterialCollectionViewCell.swift */,
96CC088D1C7FEC170034FF84 /* MaterialCollectionViewDataSource.swift */, 96CC088D1C7FEC170034FF84 /* MaterialCollectionViewDataSource.swift */,
...@@ -715,8 +703,6 @@ ...@@ -715,8 +703,6 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96D88C3D1C1328D800B91418 /* MaterialView.swift in Sources */, 96D88C3D1C1328D800B91418 /* MaterialView.swift in Sources */,
96CC089D1C80B8F70034FF84 /* BasicCollectionViewLayout.swift in Sources */,
96D527EE1C8121EF00D3BDD1 /* BasicCollectionViewDataSource.swift in Sources */,
960B23481C38480E00E96216 /* TextView.swift in Sources */, 960B23481C38480E00E96216 /* TextView.swift in Sources */,
96D88C291C1328D800B91418 /* MaterialBasicAnimation.swift in Sources */, 96D88C291C1328D800B91418 /* MaterialBasicAnimation.swift in Sources */,
96D88C3A1C1328D800B91418 /* MaterialTextLayer.swift in Sources */, 96D88C3A1C1328D800B91418 /* MaterialTextLayer.swift in Sources */,
...@@ -735,7 +721,6 @@ ...@@ -735,7 +721,6 @@
96D88C351C1328D800B91418 /* MaterialLayout.swift in Sources */, 96D88C351C1328D800B91418 /* MaterialLayout.swift in Sources */,
96D88C2F1C1328D800B91418 /* MaterialGravity.swift in Sources */, 96D88C2F1C1328D800B91418 /* MaterialGravity.swift in Sources */,
96D88C231C1328D800B91418 /* FlatButton.swift in Sources */, 96D88C231C1328D800B91418 /* FlatButton.swift in Sources */,
96CC089B1C80B82E0034FF84 /* BasicCollectionView.swift in Sources */,
966F57B81C226D75009185B7 /* TextField.swift in Sources */, 966F57B81C226D75009185B7 /* TextField.swift in Sources */,
96DBA7361C61198400844821 /* Material+UIImage+Color.swift in Sources */, 96DBA7361C61198400844821 /* Material+UIImage+Color.swift in Sources */,
96CC08931C7FEC170034FF84 /* MaterialCollectionViewCell.swift in Sources */, 96CC08931C7FEC170034FF84 /* MaterialCollectionViewCell.swift in Sources */,
...@@ -748,7 +733,6 @@ ...@@ -748,7 +733,6 @@
96D88C221C1328D800B91418 /* FabButton.swift in Sources */, 96D88C221C1328D800B91418 /* FabButton.swift in Sources */,
96D88C3F1C1328D800B91418 /* RaisedButton.swift in Sources */, 96D88C3F1C1328D800B91418 /* RaisedButton.swift in Sources */,
65FDC2EB1C66858A00103AC2 /* Menu.swift in Sources */, 65FDC2EB1C66858A00103AC2 /* Menu.swift in Sources */,
96CC08991C80B74F0034FF84 /* BasicCollectionViewCell.swift in Sources */,
960B23311C383EAA00E96216 /* Material+UIImage+PhotoLibrary.swift in Sources */, 960B23311C383EAA00E96216 /* Material+UIImage+PhotoLibrary.swift in Sources */,
960B23321C383EAA00E96216 /* Material+UIImage+Resize.swift in Sources */, 960B23321C383EAA00E96216 /* Material+UIImage+Resize.swift in Sources */,
96D88C3C1C1328D800B91418 /* MaterialTransitionAnimation.swift in Sources */, 96D88C3C1C1328D800B91418 /* MaterialTransitionAnimation.swift in Sources */,
......
/*
* 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 class BasicCollectionView : MaterialCollectionView {
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
/**
An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame.
*/
public override init(frame: CGRect) {
super.init(frame: frame, collectionViewLayout: BasicCollectionViewLayout())
prepareView()
}
/// A convenience initializer that initializes the object.
public convenience init() {
self.init(frame: CGRectNull)
}
/**
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.
*/
public override func prepareView() {
backgroundColor = MaterialColor.clear
contentInset = UIEdgeInsetsZero
registerClass(BasicCollectionViewCell.self, forCellWithReuseIdentifier: "BasicCollectionViewCell")
}
}
/*
* 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 enum BasicCollectionViewCellSize {
case Small
case Default
case Large
}
public class BasicCollectionViewCell : MaterialCollectionViewCell {
/// An Optional title UILabel.
public var titleLabel: UILabel? {
didSet {
reloadView()
}
}
/// An Optional detail UILabel.
public var detailLabel: UILabel? {
didSet {
reloadView()
}
}
/// An Optional ControlView.
public var controlView: ControlView? {
didSet {
reloadView()
}
}
/**
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.
*/
public override func prepareView() {
super.prepareView()
spacingPreset = .Spacing2
contentInsetPreset = .Square3
backgroundColor = MaterialColor.white
}
/// Reloads the view.
public func reloadView() {
for v in contentView.subviews {
v.removeFromSuperview()
}
var a: Int = 0
var b: Int = 0
var c: Int = 0
switch height {
case 142:
if nil != titleLabel && nil == detailLabel && nil == controlView {
a = 12
} else if nil == titleLabel && nil != detailLabel && nil == controlView {
b = 12
} else if nil == titleLabel && nil == detailLabel && nil != controlView {
c = 12
} else if nil != titleLabel && nil != detailLabel && nil == controlView {
a = 4
b = 8
} else if nil != titleLabel && nil == detailLabel && nil != controlView {
a = 8
c = 4
} else if nil == titleLabel && nil != detailLabel && nil != controlView {
b = 8
c = 4
} else if nil != titleLabel && nil != detailLabel && nil != controlView {
a = 4
b = 4
c = 4
}
case 192:
if nil != titleLabel && nil == detailLabel && nil == controlView {
a = 12
} else if nil == titleLabel && nil != detailLabel && nil == controlView {
b = 12
} else if nil == titleLabel && nil == detailLabel && nil != controlView {
c = 12
} else if nil != titleLabel && nil != detailLabel && nil == controlView {
a = 3
b = 9
} else if nil != titleLabel && nil == detailLabel && nil != controlView {
a = 9
c = 3
} else if nil == titleLabel && nil != detailLabel && nil != controlView {
b = 9
c = 3
} else if nil != titleLabel && nil != detailLabel && nil != controlView {
a = 3
b = 6
c = 3
}
case 256:
if nil != titleLabel && nil == detailLabel && nil == controlView {
a = 12
} else if nil == titleLabel && nil != detailLabel && nil == controlView {
b = 12
} else if nil == titleLabel && nil == detailLabel && nil != controlView {
c = 12
} else if nil != titleLabel && nil != detailLabel && nil == controlView {
a = 2
b = 10
} else if nil != titleLabel && nil == detailLabel && nil != controlView {
a = 10
c = 2
} else if nil == titleLabel && nil != detailLabel && nil != controlView {
b = 10
c = 2
} else if nil != titleLabel && nil != detailLabel && nil != controlView {
a = 2
b = 8
c = 2
}
default:
return
}
if let v: UILabel = titleLabel {
v.grid.rows = a
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
if let v: UILabel = detailLabel {
v.grid.rows = b
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
if let v: ControlView = controlView {
v.grid.rows = c
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
contentView.grid.views = []
contentView.grid.axis.rows = 12
contentView.grid.axis.direction = .Vertical
controlView?.grid.axis.columns = 0 < width ? Int(width / 48) : 12
grid.views = [
contentView
]
contentView.grid.reloadLayout()
}
}
/*
* 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 class BasicCollectionViewLayout : MaterialCollectionViewLayout {
public override func prepareLayout() {
let dataSource: MaterialCollectionViewDataSource = collectionView!.dataSource as! MaterialCollectionViewDataSource
var items: Array<MaterialDataSourceItem> = dataSource.items()
for var i: Int = items.count - 1; 0 <= i; --i {
var v: MaterialDataSourceItem = items[i]
if let q: MaterialDataSourceItemSize = v.itemSize {
switch q {
case .Small:
v.height = 142
case .Default:
v.height = 192
case .Large:
v.height = 256
}
}
items[i] = v
}
prepareLayoutForItems(items)
}
}
...@@ -30,26 +30,26 @@ ...@@ -30,26 +30,26 @@
import UIKit import UIKit
public enum MaterialDataSourceItemSize {
case Small
case Default
case Large
}
public struct MaterialDataSourceItem { public struct MaterialDataSourceItem {
/// Stores an the data for the item.
public var data: AnyObject? public var data: AnyObject?
public var x: CGFloat?
public var y: CGFloat? /// Width for horizontal scroll direction.
public var width: CGFloat? public var width: CGFloat?
/// Height for vertical scroll direction.
public var height: CGFloat? public var height: CGFloat?
public var itemSize: MaterialDataSourceItemSize?
public init(data: AnyObject? = nil, x: CGFloat? = nil, y: CGFloat? = nil, width: CGFloat? = nil, height: CGFloat? = nil, itemSize: MaterialDataSourceItemSize? = nil) { /**
Initializer.
- Parameter data: A reference to an AnyObject that is associated
with a width or height.
- Parameter width: The width for the horizontal scroll direction.
- Parameter height: The height for the vertical scroll direction.
*/
public init(data: AnyObject? = nil, width: CGFloat? = nil, height: CGFloat? = nil) {
self.data = data self.data = data
self.x = x
self.y = y
self.width = width self.width = width
self.height = height self.height = height
self.itemSize = itemSize
} }
} }
\ No newline at end of file
...@@ -280,7 +280,6 @@ public class MaterialSwitch: UIControl { ...@@ -280,7 +280,6 @@ public class MaterialSwitch: UIControl {
trackLayer = MaterialLayer() trackLayer = MaterialLayer()
button = FabButton() button = FabButton()
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView()
prepareTrack() prepareTrack()
prepareButton() prepareButton()
prepareSwitchSize(.Default) prepareSwitchSize(.Default)
...@@ -298,7 +297,6 @@ public class MaterialSwitch: UIControl { ...@@ -298,7 +297,6 @@ public class MaterialSwitch: UIControl {
trackLayer = MaterialLayer() trackLayer = MaterialLayer()
button = FabButton() button = FabButton()
super.init(frame: CGRectNull) super.init(frame: CGRectNull)
prepareView()
prepareTrack() prepareTrack()
prepareButton() prepareButton()
prepareSwitchSize(size) prepareSwitchSize(size)
...@@ -306,17 +304,6 @@ public class MaterialSwitch: UIControl { ...@@ -306,17 +304,6 @@ public class MaterialSwitch: UIControl {
prepareSwitchState(state) prepareSwitchState(state)
} }
/**
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.
*/
public func prepareView() {
}
public override func willMoveToSuperview(newSuperview: UIView?) { public override func willMoveToSuperview(newSuperview: UIView?) {
super.willMoveToSuperview(newSuperview) super.willMoveToSuperview(newSuperview)
styleForState(internalSwitchState) styleForState(internalSwitchState)
...@@ -357,7 +344,7 @@ public class MaterialSwitch: UIControl { ...@@ -357,7 +344,7 @@ public class MaterialSwitch: UIControl {
- Parameter completion: An Optional completion block. - Parameter completion: An Optional completion block.
*/ */
public func setSwitchState(state: MaterialSwitchState, animated: Bool = true, completion: ((control: MaterialSwitch) -> Void)? = nil) { public func setSwitchState(state: MaterialSwitchState, animated: Bool = true, completion: ((control: MaterialSwitch) -> Void)? = nil) {
if internalSwitchState != state { if enabled && internalSwitchState != state {
internalSwitchState = state internalSwitchState = state
if animated { if animated {
animateToState(state) { [unowned self] _ in animateToState(state) { [unowned self] _ in
...@@ -387,9 +374,7 @@ public class MaterialSwitch: UIControl { ...@@ -387,9 +374,7 @@ public class MaterialSwitch: UIControl {
*/ */
internal func handleTouchUpOutsideOrCanceled(sender: FabButton, event: UIEvent) { internal func handleTouchUpOutsideOrCanceled(sender: FabButton, event: UIEvent) {
if let v: UITouch = event.touchesForView(sender)?.first { if let v: UITouch = event.touchesForView(sender)?.first {
let t: CGPoint = v.previousLocationInView(sender) let q: CGFloat = sender.x + v.locationInView(sender).x - v.previousLocationInView(sender).x
let p: CGPoint = v.locationInView(sender)
let q: CGFloat = sender.x + p.x - t.x
setSwitchState(q > (width - button.width) / 2 ? .On : .Off, animated: true) setSwitchState(q > (width - button.width) / 2 ? .On : .Off, animated: true)
} }
} }
...@@ -401,9 +386,7 @@ public class MaterialSwitch: UIControl { ...@@ -401,9 +386,7 @@ public class MaterialSwitch: UIControl {
*/ */
internal func handleTouchDragInside(sender: FabButton, event: UIEvent) { internal func handleTouchDragInside(sender: FabButton, event: UIEvent) {
if let v = event.touchesForView(sender)?.first { if let v = event.touchesForView(sender)?.first {
let t: CGPoint = v.previousLocationInView(sender) let q: CGFloat = max(min(sender.x + v.locationInView(sender).x - v.previousLocationInView(sender).x, onPosition), offPosition)
let p: CGPoint = v.locationInView(sender)
let q: CGFloat = max(min(sender.x + (p.x - t.x), onPosition), offPosition)
if q != sender.x { if q != sender.x {
sender.x = q sender.x = q
} }
...@@ -412,7 +395,7 @@ public class MaterialSwitch: UIControl { ...@@ -412,7 +395,7 @@ public class MaterialSwitch: UIControl {
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
if true == CGRectContainsPoint(trackLayer.frame, layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)) { if true == CGRectContainsPoint(trackLayer.frame, layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)) {
setSwitchState(.On == internalSwitchState ? .Off : .On) setOn(.On != internalSwitchState, animated: true)
} }
} }
......
...@@ -490,7 +490,6 @@ public class TextField : UITextField { ...@@ -490,7 +490,6 @@ public class TextField : UITextField {
/// Clears the textField text. /// Clears the textField text.
internal func handleClearButton() { internal func handleClearButton() {
text = "" text = ""
sendActionsForControlEvents(.ValueChanged)
} }
/// Ahdnler when text value changed. /// Ahdnler when text value changed.
......
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