Commit 2db722d6 by Daniel Dahan

added IBDesignable where appropriate

parent cf9d270f
......@@ -34,6 +34,8 @@
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
......
......@@ -87,7 +87,7 @@ class ItemViewController: UIViewController {
/// Prepares the titleLabel.
private func prepareTitleLabel() {
titleLabel = UILabel()
titleLabel.text = "Recipe"
titleLabel.text = "Item"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
}
......
......@@ -165,7 +165,7 @@ class RecipesViewController: UIViewController {
private func prepareTitleLabel() {
titleLabel = UILabel()
titleLabel.text = "Recipes"
titleLabel.textAlignment = .Left
titleLabel.textAlignment = .Center
titleLabel.textColor = MaterialColor.white
}
......@@ -198,9 +198,10 @@ class RecipesViewController: UIViewController {
/// Prepares the NavigationBar.
private func prepareNavigationBar() {
// navigationItem.title = "Recipes"
navigationItem.titleLabel = titleLabel
navigationItem.leftControls = [menuButton]
navigationItem.rightControls = [switchControl, searchButton]
// navigationItem.leftControls = [menuButton]
// navigationItem.rightControls = [switchControl, searchButton]
}
/// Prepares the tableView.
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9060" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<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="9051"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<scenes>
<!--View Controller-->
......@@ -19,14 +19,12 @@
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XJ3-7l-unK" customClass="ImageCardView" customModule="Material">
<rect key="frame" x="20" y="40" width="560" height="295"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="295" id="KSN-He-8WQ"/>
</constraints>
</view>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="XJ3-7l-unK" secondAttribute="trailing" constant="20" id="NeV-DV-ltW"/>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<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="9529"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<scenes>
<!--View Controller-->
......
......@@ -12,8 +12,6 @@
96212DCB1C1696D000F31053 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96212DC31C1696D000F31053 /* LaunchScreen.storyboard */; };
96212DCC1C1696D000F31053 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96212DC51C1696D000F31053 /* Main.storyboard */; };
96212DCE1C1696D000F31053 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96212DC81C1696D000F31053 /* ViewController.swift */; };
963236151C96578E00282A94 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963236141C96578E00282A94 /* Material.framework */; };
963236161C96578E00282A94 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 963236141C96578E00282A94 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -23,7 +21,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
963236161C96578E00282A94 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -37,7 +34,6 @@
96212DC61C1696D000F31053 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
96212DC71C1696D000F31053 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96212DC81C1696D000F31053 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
963236141C96578E00282A94 /* 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>"; };
9ABEC4EF1C14F08200F6895E /* MaterialPulseView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MaterialPulseView.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
......@@ -46,7 +42,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
963236151C96578E00282A94 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -69,7 +64,6 @@
9ABEC4E61C14F08200F6895E = {
isa = PBXGroup;
children = (
963236141C96578E00282A94 /* Material.framework */,
96212DC01C1696D000F31053 /* MaterialPulseView */,
9ABEC4F01C14F08200F6895E /* Products */,
);
......
......@@ -30,6 +30,7 @@
import UIKit
@IBDesignable
@objc(MaterialButton)
public class MaterialButton : UIButton {
/**
......
......@@ -30,6 +30,7 @@
import UIKit
@IBDesignable
public class MaterialCollectionView : UICollectionView {
/// A preset wrapper around contentInset.
public var contentInsetPreset: MaterialEdgeInset {
......
......@@ -30,6 +30,7 @@
import UIKit
@IBDesignable
@objc(MaterialCollectionViewCell)
public class MaterialCollectionViewCell : UICollectionViewCell {
/**
......
......@@ -30,6 +30,7 @@
import UIKit
@IBDesignable
public class MaterialLabel : UILabel {
/**
:name: layerClass
......
......@@ -54,7 +54,8 @@ public protocol MaterialSwitchDelegate {
func materialSwitchStateChanged(control: MaterialSwitch)
}
public class MaterialSwitch: UIControl {
@IBDesignable
public class MaterialSwitch : UIControl {
/// An internal reference to the switchState public property.
private var internalSwitchState: MaterialSwitchState = .Off
......
......@@ -30,7 +30,8 @@
import UIKit
public class MaterialTableViewCell: UITableViewCell {
@IBDesignable
public class MaterialTableViewCell : UITableViewCell {
/**
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
......
......@@ -30,6 +30,7 @@
import UIKit
@IBDesignable
@objc(MaterialView)
public class MaterialView : UIView {
/**
......
......@@ -48,7 +48,8 @@ public extension UIViewController {
}
}
public class MenuViewController: UIViewController {
@IBDesignable
public class MenuViewController : UIViewController {
/// Reference to the MenuView.
public private(set) lazy var menuView: MenuView = MenuView()
......
......@@ -42,6 +42,7 @@ public extension UINavigationBar {
}
}
@IBDesignable
public class NavigationBar : UINavigationBar {
/// Reference to the backButton.
public private(set) lazy var backButton: FlatButton = FlatButton()
......@@ -253,12 +254,7 @@ public class NavigationBar : UINavigationBar {
public override func layoutSubviews() {
super.layoutSubviews()
if let item: UINavigationItem = topItem {
layoutNavigationItem(item)
}
topItem?.titleView?.grid.reloadLayout()
topItem?.titleView?.backgroundColor = MaterialColor.green.base
}
public override func pushNavigationItem(item: UINavigationItem, animated: Bool) {
......@@ -297,13 +293,13 @@ public class NavigationBar : UINavigationBar {
item.leftBarButtonItems = n.reverse()
}
// If title is empty
if "" == item.title {
if nil == item.titleView {
item.titleView = UIView()
item.titleView!.backgroundColor = nil
item.titleView = UIView(frame: CGRectMake(0, contentInset.top, MaterialDevice.width, h - contentInset.top - contentInset.bottom))
item.titleView!.grid.axis.direction = .Vertical
}
item.titleView!.frame = CGRectMake(0, contentInset.top, MaterialDevice.width < MaterialDevice.height ? MaterialDevice.height : MaterialDevice.width, h - contentInset.top - contentInset.bottom)
item.titleView!.grid.views = []
// TitleView alignment.
......@@ -314,14 +310,17 @@ public class NavigationBar : UINavigationBar {
item.titleView!.grid.views?.append(t)
if 32 >= height || nil == item.detailLabel {
t.font = t.font?.fontWithSize(20)
t.font = t.font?.fontWithSize(17)
item.titleView!.grid.axis.rows = 1
item.detailLabel?.hidden = true
} else if let d: UILabel = item.detailLabel {
d.grid.rows = 1
d.hidden = false
d.font = d.font.fontWithSize(12)
t.font = t.font.fontWithSize(17)
item.titleView!.addSubview(d)
item.titleView!.grid.axis.rows = 2
item.titleView!.grid.views?.append(d)
......@@ -333,6 +332,7 @@ public class NavigationBar : UINavigationBar {
item.titleView!.grid.axis.rows = 1
item.titleView!.grid.views?.append(d)
}
}
// rightControls
if let v: Array<UIControl> = item.rightControls {
......@@ -353,8 +353,6 @@ public class NavigationBar : UINavigationBar {
item.rightBarButtonItems = n.reverse()
}
item.titleView!.grid.reloadLayout()
}
/**
......@@ -384,8 +382,10 @@ public class NavigationBar : UINavigationBar {
/// Prepares the UINavigationItem for layout and sizing.
internal func prepareItem(item: UINavigationItem) {
if nil == item.title {
item.title = ""
}
}
}
/// A memory reference to the NavigationItem instance for UINavigationBar extensions.
......
......@@ -64,7 +64,7 @@ public protocol NavigationBarViewControllerDelegate : MaterialDelegate {
}
@objc(NavigationBarViewController)
public class NavigationBarViewController: StatusBarViewController {
public class NavigationBarViewController : StatusBarViewController {
/// The height of the StatusBar.
@IBInspectable public override var heightForStatusBar: CGFloat {
get {
......
......@@ -30,6 +30,7 @@
import UIKit
@IBDesignable
public class NavigationController : UINavigationController, UIGestureRecognizerDelegate {
/**
An initializer that initializes the object with a NSCoder object.
......@@ -78,6 +79,14 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
}
}
public override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
// Load the initial topItem.
if let v: UINavigationItem = navigationBar.topItem {
(navigationBar as? NavigationBar)?.layoutNavigationItem(v)
}
}
/**
Detects the gesture recognizer being used. This is necessary when using
SideNavigationViewController. It eliminates the conflict in panning.
......
......@@ -48,7 +48,7 @@ public extension UIViewController {
}
}
public class SearchBarViewController: StatusBarViewController {
public class SearchBarViewController : StatusBarViewController {
/// The height of the StatusBar.
@IBInspectable public override var heightForStatusBar: CGFloat {
get {
......
......@@ -111,8 +111,9 @@ public protocol SideNavigationViewControllerDelegate {
optional func sideNavigationStatusBarHiddenState(sideNavigationViewController: SideNavigationViewController, hidden: Bool)
}
@IBDesignable
@objc(SideNavigationViewController)
public class SideNavigationViewController: UIViewController, UIGestureRecognizerDelegate {
public class SideNavigationViewController : UIViewController, UIGestureRecognizerDelegate {
/**
A CGFloat property that is used internally to track
the original (x) position of the container view when panning.
......
......@@ -30,7 +30,8 @@
import UIKit
public class StatusBarViewController: UIViewController {
@IBDesignable
public class StatusBarViewController : UIViewController {
/// The height of the StatusBar.
@IBInspectable public var heightForStatusBar: CGFloat = 20
......
......@@ -32,6 +32,7 @@ import UIKit
public protocol TextFieldDelegate : UITextFieldDelegate {}
@IBDesignable
public class TextField : UITextField {
/**
This property is the same as clipsToBounds. It crops any of the view's
......
......@@ -33,6 +33,7 @@ import UIKit
@objc(TextViewDelegate)
public protocol TextViewDelegate : UITextViewDelegate {}
@IBDesignable
@objc(TextView)
public class TextView: UITextView {
/**
......
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