Commit 23dde70e by Daniel Dahan

temporary class MTextField added for new TextField

parent a8c2438b
......@@ -125,8 +125,7 @@ extension ViewController: MaterialCollectionViewDataSource {
textField.font = RobotoFont.regularWithSize(20)
textField.textColor = MaterialColor.black
textField.titleLabel = UILabel()
textField.titleLabel!.font = RobotoFont.mediumWithSize(12)
textField.titleLabel.font = RobotoFont.mediumWithSize(12)
textField.titleLabelColor = MaterialColor.grey.base
textField.titleLabelActiveColor = MaterialColor.blue.accent3
......@@ -135,10 +134,8 @@ extension ViewController: MaterialCollectionViewDataSource {
Used to display the error message, which is displayed when
the user presses the 'return' key.
*/
let detailLabel: UILabel = UILabel()
detailLabel.text = "detail text..."
textField.detailLabel = detailLabel
textField.detailLabel!.font = RobotoFont.mediumWithSize(12)
textField.detailLabel.text = "detail text..."
textField.detailLabel.font = RobotoFont.mediumWithSize(12)
textField.detailLabelActiveColor = MaterialColor.red.accent3
// textField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding.
......
......@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
961776711CCE75EB0091B4F3 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 961776701CCE75EB0091B4F3 /* Material.framework */; };
961776721CCE75EB0091B4F3 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 961776701CCE75EB0091B4F3 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
966F57A11C226BAA009185B7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A01C226BAA009185B7 /* AppDelegate.swift */; };
966F57A31C226BAA009185B7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A21C226BAA009185B7 /* ViewController.swift */; };
966F57A81C226BAA009185B7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A71C226BAA009185B7 /* Assets.xcassets */; };
......@@ -20,6 +22,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
961776721CCE75EB0091B4F3 /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
961776701CCE75EB0091B4F3 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-bshwisidfobstlbomegqyybbrygh/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
966F579D1C226BAA009185B7 /* TextField.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TextField.app; sourceTree = BUILT_PRODUCTS_DIR; };
966F57A01C226BAA009185B7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
966F57A21C226BAA009185B7 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
......@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
961776711CCE75EB0091B4F3 /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -49,6 +54,7 @@
966F57941C226BAA009185B7 = {
isa = PBXGroup;
children = (
961776701CCE75EB0091B4F3 /* Material.framework */,
966F579F1C226BAA009185B7 /* TextField */,
966F579E1C226BAA009185B7 /* Products */,
);
......
......@@ -38,8 +38,57 @@ under the TextField.
import UIKit
import Material
//extension TextField {
//
// func setDefaultLabelSpecs(titleColor titleColor: UIColor, detailColor: UIColor) {
// // ref: https://www.google.com/design/spec/components/text-fields.html#text-fields-labels
// // ref: https://www.google.com/design/spec/patterns/errors.html#errors-user-input-errors
// // ref: https://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keylines-touch-target-size
// assert(height == 80, "Height must be 80, based on Material design spec.")
//
// backgroundColor = nil
//
// let derivedDetailLabelHeight: CGFloat = 15
// let paddingAboveAndBelowErrorText: CGFloat = 4
//
// detailLabel.font = RobotoFont.regularWithSize(12)
// detailLabelActiveColor = detailColor
// detailLabelAnimationDistance = lineLayerThickness + paddingAboveAndBelowErrorText
//
// lineLayerActiveColor = titleColor
// lineLayerColor = MaterialColor.darkText.dividers
// lineLayerDistance = 0 - (derivedDetailLabelHeight + (paddingAboveAndBelowErrorText * 2) + lineLayerThickness)
//
// let derivedTitleLabelHeight: CGFloat = 20
// let paddingAboveLabelText: CGFloat = 8
//
// titleLabelActiveColor = lineLayerActiveColor
// titleLabelAnimationDistance = 0 - (derivedTitleLabelHeight + paddingAboveLabelText)
//
// if let clearButton = clearButton {
// let touchTargetHeight: CGFloat = 48
// let spacing = (height - touchTargetHeight) / 2
// let origin = CGPoint(x: width - touchTargetHeight - spacing, y: spacing)
// let size = CGSize(width: touchTargetHeight, height: touchTargetHeight)
//
// clearButton.frame = CGRect(origin: origin, size: size)
//
// clearButton.contentHorizontalAlignment = .Right
//
// // Use PDF for better rendering
// let clearImage = UIImage(named: "Material/Navigation/Close")
// clearButton.setImage(clearImage, forState: .Normal)
// clearButton.setImage(clearImage, forState: .Highlighted)
//
// // Hide it since it bleeds over the lineLayer, and doesn't look good
// // with the horizontal alignment.
// clearButton.pulseOpacity = 0
// }
// }
//}
class ViewController: UIViewController, TextFieldDelegate {
private var nameField: TextField!
private var nameField: MTextField!
private var emailField: TextField!
override func viewDidLoad() {
......@@ -56,14 +105,16 @@ class ViewController: UIViewController, TextFieldDelegate {
/// Prepares the name TextField.
private func prepareNameField() {
nameField = TextField()
nameField = MTextField()
nameField.placeholder = "Name"
nameField.detail = "Error, incorrect password. yy ypp ggg"
nameField.placeholderTextColor = MaterialColor.green.base
view.addSubview(nameField)
nameField.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTop(view, child: nameField, top: 100)
MaterialLayout.alignToParentHorizontally(view, child: nameField, left: 20, right: 20)
print(nameField)
}
/// Prepares the email TextField.
......@@ -73,6 +124,7 @@ class ViewController: UIViewController, TextFieldDelegate {
emailField = TextField(frame: CGRectMake(x, 200, w, 24))
emailField.placeholder = "Email"
emailField.delegate = self
emailField.text = "Hello World"
/*
Used to display the error message, which is displayed when
......
......@@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; };
963832421B88DFD80015F710 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* Material.framework */; };
9658F1E51CD0229D00B902C1 /* MTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9658F1E41CD0229C00B902C1 /* MTextField.swift */; };
9660161D1CB2ED6C00AAB661 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 966016131CB2ED6C00AAB661 /* Material.framework */; };
9660162A1CB2F04E00AAB661 /* Material.h in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C091C1328D800B91418 /* Material.h */; settings = {ATTRIBUTES = (Public, ); }; };
9679CEAB1CC69E080021685B /* Material+UIImage+TintColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9679CEAA1CC69E080021685B /* Material+UIImage+TintColor.swift */; };
......@@ -196,6 +197,7 @@
963832361B88DFD80015F710 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; };
963832411B88DFD80015F710 /* Material.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Material.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
963832591B88E31A0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9658F1E41CD0229C00B902C1 /* MTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MTextField.swift; sourceTree = "<group>"; };
966016131CB2ED6C00AAB661 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9660161C1CB2ED6C00AAB661 /* Material OSX Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Material OSX Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
967887881C9777CB0037F6C9 /* MaterialViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialViewTests.swift; sourceTree = "<group>"; };
......@@ -580,6 +582,7 @@
96BCB79C1CB40DC500C806FE /* TextField.swift */,
96BCB79D1CB40DC500C806FE /* TextStorage.swift */,
96BCB79E1CB40DC500C806FE /* TextView.swift */,
9658F1E41CD0229C00B902C1 /* MTextField.swift */,
);
name = Text;
sourceTree = "<group>";
......@@ -882,6 +885,7 @@
96BCB7D11CB40DC500C806FE /* MaterialSwitch.swift in Sources */,
96BCB7BA1CB40DC500C806FE /* MaterialCollectionView.swift in Sources */,
96BCB7A31CB40DC500C806FE /* CapturePreview.swift in Sources */,
9658F1E51CD0229D00B902C1 /* MTextField.swift in Sources */,
96BCB7BC1CB40DC500C806FE /* MaterialCollectionViewDataSource.swift in Sources */,
96BCB7C71CB40DC500C806FE /* MaterialKeyframeAnimation.swift in Sources */,
96BCB7BE1CB40DC500C806FE /* MaterialCollectionViewLayout.swift in Sources */,
......
......@@ -64,9 +64,7 @@ public func MaterialAnimationFillModeToValue(mode: MaterialAnimationFillMode) ->
public typealias MaterialAnimationDelayCancelBlock = (cancel : Bool) -> Void
public struct MaterialAnimation {
/**
:name: delay
*/
/// Delay helper method.
public static func delay(time: NSTimeInterval, completion: ()-> Void) -> MaterialAnimationDelayCancelBlock? {
func dispatch_later(completion: ()-> Void) {
......@@ -109,7 +107,7 @@ public struct MaterialAnimation {
/**
:name: animateWithDuration
*/
public static func animateWithDuration(duration: CFTimeInterval, animations: (() -> Void), options: UIViewAnimationOptions? = nil, completion: (() -> Void)? = nil) {
public static func animateWithDuration(duration: CFTimeInterval, animations: (() -> Void), completion: (() -> Void)? = nil) {
CATransaction.begin()
CATransaction.setAnimationDuration(duration)
CATransaction.setCompletionBlock(completion)
......@@ -134,9 +132,9 @@ public struct MaterialAnimation {
/**
:name: animateWithDelay
*/
public static func animateWithDelay(delay d: CFTimeInterval, duration: CFTimeInterval, animations: (() -> Void), options: UIViewAnimationOptions? = nil, completion: (() -> Void)? = nil) {
public static func animateWithDelay(delay d: CFTimeInterval, duration: CFTimeInterval, animations: (() -> Void), completion: (() -> Void)? = nil) {
delay(d) {
animateWithDuration(duration, animations: animations, options: options, completion: completion)
animateWithDuration(duration, animations: animations, completion: completion)
}
}
}
......@@ -632,7 +632,7 @@ public class TextField : UITextField {
/// Layout the clearButton.
private func layoutClearButton() {
if 0 < width && 0 < height {
clearButton.frame = CGRectMake(width - height, 0, height, height)
// clearButton.frame = CGRectMake(width - height, 0, height, height)
}
}
......
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