Commit 5f151b22 by Daniel Dahan

issue-157: Fix for TextField not displaying characters that exceeding the height of the frame.

parent e28d9497
......@@ -85,12 +85,12 @@
9642FA1C1C1B50E700022BC6 /* MainViewController.swift */,
9642FA321C1B909700022BC6 /* LeftViewController.swift */,
967585371C569AA9001E4268 /* RightViewController.swift */,
9642FA211C1B50E700022BC6 /* Assets.xcassets */,
9642FA231C1B50E700022BC6 /* LaunchScreen.storyboard */,
9642FA261C1B50E700022BC6 /* Info.plist */,
96A71F261C7275F200C0C4AE /* FeedCollectionView.swift */,
96A71F281C72761700C0C4AE /* FeedCollectionViewLayout.swift */,
96A71F2A1C72766700C0C4AE /* FeedCollectionViewCell.swift */,
9642FA211C1B50E700022BC6 /* Assets.xcassets */,
9642FA231C1B50E700022BC6 /* LaunchScreen.storyboard */,
9642FA261C1B50E700022BC6 /* Info.plist */,
);
path = SideNavigationViewController;
sourceTree = "<group>";
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "AssortmentOfDessert.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "AssortmentOfFood.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "AvocadoIceCream.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "HeartCookies.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "VeganCakeFull.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "VeganHempBalls.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "VeganPieAbove.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -53,7 +53,6 @@ class FeedCollectionView : UICollectionView {
internal func prepareView() {
registerClass(FeedCollectionViewCell.self, forCellWithReuseIdentifier: "FeedCollectionViewCell")
backgroundColor = MaterialColor.clear
contentInset = UIEdgeInsetsMake(0, 0, 0, 0)
showsVerticalScrollIndicator = false
contentInset = UIEdgeInsetsZero
}
}
......@@ -32,7 +32,90 @@ import UIKit
import Material
class FeedCollectionViewCell : UICollectionViewCell {
private var cardView: MaterialPulseView!
let titleLabel: UILabel = UILabel()
let detailLabel: UILabel = UILabel()
let imageView: MaterialView = MaterialView()
override init(frame: CGRect) {
super.init(frame: frame)
prepareView()
}
convenience init() {
self.init(frame: CGRectNull)
prepareView()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func prepareView() {
cardView = MaterialPulseView(frame: CGRectMake(0, 0, bounds.width, 152))
cardView.pulseScale = false
cardView.pulseColor = MaterialColor.blueGrey.base
addSubview(cardView)
var image: UIImage?
imageView.shape = .Circle
imageView.contentsGravity = .ResizeAspectFill
cardView.addSubview(imageView)
let contentView: MaterialView = MaterialView()
contentView.backgroundColor = MaterialColor.clear
cardView.addSubview(contentView)
titleLabel.textColor = MaterialColor.blueGrey.darken4
titleLabel.backgroundColor = MaterialColor.clear
contentView.addSubview(titleLabel)
image = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate)
let moreButton: FlatButton = FlatButton()
moreButton.contentInsetPreset = .None
moreButton.pulseColor = MaterialColor.blueGrey.darken4
moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal)
moreButton.setImage(image, forState: .Highlighted)
contentView.addSubview(moreButton)
detailLabel.numberOfLines = 0
detailLabel.lineBreakMode = .ByTruncatingTail
detailLabel.font = RobotoFont.regularWithSize(12)
detailLabel.textColor = MaterialColor.blueGrey.darken4
detailLabel.backgroundColor = MaterialColor.clear
contentView.addSubview(detailLabel)
cardView.grid.contentInsetPreset = .Square2
imageView.grid.columns = 4
contentView.grid.columns = 8
cardView.grid.views = [
imageView,
contentView
]
titleLabel.grid.rows = 3
titleLabel.grid.columns = 9
moreButton.grid.rows = 3
moreButton.grid.columns = 2
moreButton.grid.offset.columns = 10
detailLabel.grid.rows = 4
detailLabel.grid.offset.rows = 4
contentView.grid.spacing = 8
contentView.grid.axis.inherited = false
contentView.grid.axis.direction = .None
contentView.grid.contentInsetPreset = .Square3
contentView.grid.views = [
titleLabel,
moreButton,
detailLabel
]
}
}
......@@ -33,8 +33,8 @@ import UIKit
class FeedCollectionViewLayout : UICollectionViewLayout {
private var contentSize: CGSize = CGSizeZero
private var layoutItems: Array<(UICollectionViewLayoutAttributes, NSIndexPath)>?
internal var height: CGFloat = 88
internal var offset: CGFloat = 0
internal var height: CGFloat = 152
internal var offset: CGFloat = 1
override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? {
let attributes: UICollectionViewLayoutAttributes = UICollectionViewLayoutAttributes(forCellWithIndexPath: indexPath)
......
......@@ -31,9 +31,6 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
......
......@@ -55,16 +55,11 @@ class LeftViewController: UIViewController {
prepareCells()
prepareProfileView()
prepareTableView()
// Reload the Grid layout.
view.grid.reloadLayout()
}
/// General preparation statements.
private func prepareView() {
view.backgroundColor = MaterialColor.clear
view.grid.axis.direction = .None
view.grid.views = []
}
/// Prepares the items that are displayed within the tableView.
......@@ -79,29 +74,35 @@ class LeftViewController: UIViewController {
/// Prepares profile view.
private func prepareProfileView() {
let imageView: MaterialView = MaterialView()
imageView.image = UIImage(named: "Profile9")?.resize(toWidth: 72)
imageView.shape = .Circle
imageView.borderColor = MaterialColor.white
imageView.borderWidth = 3
view.addSubview(imageView)
let backgroundView: MaterialView = MaterialView()
backgroundView.image = UIImage(named: "MaterialBackground")
let profileView: MaterialView = MaterialView()
profileView.image = UIImage(named: "Profile9")?.resize(toWidth: 72)
profileView.shape = .Circle
profileView.borderColor = MaterialColor.white
profileView.borderWidth = 3
let nameLabel: UILabel = UILabel()
nameLabel.text = "Michael Smith"
nameLabel.textColor = MaterialColor.white
nameLabel.font = RobotoFont.mediumWithSize(18)
view.addSubview(nameLabel)
view.addSubview(backgroundView)
backgroundView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTop(view, child: backgroundView)
MaterialLayout.alignToParentHorizontally(view, child: backgroundView)
MaterialLayout.height(view, child: backgroundView, height: 170)
nameLabel.grid.rows = 1
nameLabel.grid.offset.rows = 3
backgroundView.addSubview(profileView)
profileView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTopLeft(backgroundView, child: profileView, top: 20, left: 20)
MaterialLayout.size(backgroundView, child: profileView, width: 72, height: 72)
view.grid.views?.append(nameLabel)
print(nameLabel.frame.width)
imageView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTopLeft(view, child: imageView, top: (nameLabel.frame.origin.y - 72) / 2 , left: (nameLabel.frame.width - 72) / 2)
MaterialLayout.size(view, child: imageView, width: 72, height: 72)
backgroundView.addSubview(nameLabel)
nameLabel.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromBottom(backgroundView, child: nameLabel, bottom: 20)
MaterialLayout.alignToParentHorizontally(backgroundView, child: nameLabel, left: 20, right: 20)
}
/// Prepares the tableView.
......@@ -111,11 +112,10 @@ class LeftViewController: UIViewController {
tableView.delegate = self
tableView.separatorStyle = .None
// Use MaterialLayout to easily align the tableView.
view.addSubview(tableView)
tableView.grid.rows = 8
tableView.grid.offset.rows = 4
view.grid.views?.append(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: tableView, top: 170)
}
}
......
......@@ -39,7 +39,7 @@ import UIKit
import Material
struct Item {
var text: String
var title: String
var detail: String
var image: UIImage?
}
......@@ -129,20 +129,54 @@ class MainViewController: UIViewController {
/// Prepares the items Array.
private func prepareItems() {
items.append(Item(text: "Summer BBQ", detail: "Wish I could come, but I am out of town this weekend.", image: UIImage(named: "Profile1")))
items.append(Item(text: "Birthday gift", detail: "Have any ideas about what we should get Heidi for her birthday?", image: UIImage(named: "Profile2")))
items.append(Item(text: "Brunch this weekend?", detail: "I'll be in your neighborhood doing errands this weekend.", image: UIImage(named: "Profile3")))
items.append(Item(text: "Giants game", detail: "Are we on this weekend for the game?", image: UIImage(named: "Profile4")))
items.append(Item(text: "Recipe to try", detail: "We should eat this: Squash, Corn and tomatillo Tacos.", image: UIImage(named: "Profile5")))
items.append(Item(text: "Interview", detail: "The candidate will be arriving at 11:30, are you free?", image: UIImage(named: "Profile6")))
items.append(Item(text: "Book recommendation", detail: "I found the book title, Surely You’re Joking, Mr. Feynman!", image: UIImage(named: "Profile7")))
items.append(Item(text: "Oui oui", detail: "Do you have Paris recommendations? Have you ever been?", image: UIImage(named: "Profile8")))
items.append(Item(
title: "Raw Vegan Blackberry Tart!",
detail: "Wish I could come, but I am out of town this weekend.",
image: UIImage(named: "VeganCakeFull")
))
items.append(Item(
title: "Raw Vegan Pumpkin Pie",
detail: "Have any ideas about what we should get Heidi for her birthday?",
image: UIImage(named: "VeganPieAbove")
))
items.append(Item(
title: "Raw Vegan Nutty Sweets!",
detail: "I'll be in your neighborhood doing errands this weekend.",
image: UIImage(named: "VeganHempBalls")
))
items.append(Item(
title: "Avocado Chocolate Cake!",
detail: "Are we on this weekend for the game?",
image: UIImage(named: "AssortmentOfFood")
))
items.append(Item(
title: "Homemade brunch: Crepe Indulgence",
detail: "We should eat this: Squash, Corn and tomatillo Tacos.",
image: UIImage(named: "AssortmentOfDessert")
))
items.append(Item(
title: "Raw Vegan Chocolate Cookies",
detail: "The candidate will be arriving at 11:30, are you free?",
image: UIImage(named: "HeartCookies")
))
items.append(Item(
title: "Homemade Avocado Ice Cream",
detail: "I found the book title, Surely You’re Joking, Mr. Feynman!",
image: UIImage(named: "AvocadoIceCream")
))
}
/// Prepares the tableView.
private func prepareTableView() {
collectionView.delegate = self
collectionView.dataSource = self
collectionView.backgroundColor = MaterialColor.blueGrey.lighten3
view.addSubview(collectionView)
collectionView.translatesAutoresizingMaskIntoConstraints = false
......@@ -176,7 +210,7 @@ class MainViewController: UIViewController {
menuButton.addTarget(self, action: "handleMenuButton", forControlEvents: .TouchUpInside)
// Switch control.
let switchControl: MaterialSwitch = MaterialSwitch()
let switchControl: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent)
// Search button.
image = UIImage(named: "ic_search_white")
......@@ -193,7 +227,7 @@ class MainViewController: UIViewController {
*/
navigationBarView.statusBarStyle = .LightContent
navigationBarView.backgroundColor = MaterialColor.grey.darken4
navigationBarView.backgroundColor = MaterialColor.blue.base
navigationBarView.titleLabel = titleLabel
navigationBarView.detailLabel = detailLabel
navigationBarView.leftControls = [menuButton]
......@@ -250,6 +284,11 @@ extension MainViewController: UICollectionViewDelegate {
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let c: FeedCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("FeedCollectionViewCell", forIndexPath: indexPath) as! FeedCollectionViewCell
let item: Item = items[indexPath.row] as Item
c.titleLabel.text = item.title
c.detailLabel.text = item.detail
c.imageView.image = item.image
return c
}
}
......
......@@ -58,7 +58,7 @@ class RightViewController: UIViewController {
/// General preparation statements.
private func prepareView() {
view.backgroundColor = MaterialColor.blueGrey.darken4
view.backgroundColor = MaterialColor.grey.darken4
}
override func viewWillAppear(animated: Bool) {
......
......@@ -11,6 +11,8 @@
966F57A31C226BAA009185B7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A21C226BAA009185B7 /* ViewController.swift */; };
966F57A81C226BAA009185B7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A71C226BAA009185B7 /* Assets.xcassets */; };
966F57AB1C226BAA009185B7 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A91C226BAA009185B7 /* LaunchScreen.storyboard */; };
96A71F2D1C72B64900C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F2C1C72B64900C0C4AE /* Material.framework */; };
96A71F2E1C72B64900C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F2C1C72B64900C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -20,6 +22,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96A71F2E1C72B64900C0C4AE /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -33,6 +36,7 @@
966F57A71C226BAA009185B7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
966F57AA1C226BAA009185B7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
966F57AC1C226BAA009185B7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96A71F2C1C72B64900C0C4AE /* 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 */
/* Begin PBXFrameworksBuildPhase section */
......@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96A71F2D1C72B64900C0C4AE /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -49,6 +54,7 @@
966F57941C226BAA009185B7 = {
isa = PBXGroup;
children = (
96A71F2C1C72B64900C0C4AE /* Material.framework */,
966F579F1C226BAA009185B7 /* TextField */,
966F579E1C226BAA009185B7 /* Products */,
);
......
......@@ -579,6 +579,8 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
backdropLayer.hidden = true
if let v: MaterialView = leftView {
self.hideDepth(v)
delegate?.sideNavigationViewWillClose?(self, position: .Left)
UIView.animateWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: {
......@@ -586,7 +588,6 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}) { _ in
self.toggleStatusBar()
self.userInteractionEnabled = true
self.hideDepth(v)
self.hideView(v)
self.delegate?.sideNavigationViewDidClose?(self, position: .Left)
}
......@@ -605,6 +606,8 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
backdropLayer.hidden = true
if let v: MaterialView = rightView {
self.hideDepth(v)
delegate?.sideNavigationViewWillClose?(self, position: .Right)
UIView.animateWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: {
......@@ -612,7 +615,6 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}) { _ in
self.toggleStatusBar()
self.userInteractionEnabled = true
self.hideDepth(v)
self.hideView(v)
self.delegate?.sideNavigationViewDidClose?(self, position: .Right)
}
......@@ -647,6 +649,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
toggleStatusBar(true)
showView(v)
hideDepth(v)
delegate?.sideNavigationViewPanDidBegin?(self, point: point, position: .Right)
case .Changed:
......@@ -681,6 +684,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
toggleStatusBar(true)
showView(v)
hideDepth(v)
delegate?.sideNavigationViewPanDidBegin?(self, point: point, position: .Left)
case .Changed:
......
......@@ -334,6 +334,9 @@ public class TextField : UITextField {
}
}
/// A multiplier for the titleLabel and detailLabel frame height.
public private(set) var scale: CGFloat = UIScreen.mainScreen().scale
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
......@@ -529,7 +532,7 @@ public class TextField : UITextField {
v.text = s
}
}
let h: CGFloat = v.font.pointSize
let h: CGFloat = v.font.pointSize * scale
v.frame = CGRectMake(0, -h, bounds.width, h)
v.hidden = false
UIView.animateWithDuration(0.25, animations: { [unowned self] in
......@@ -556,7 +559,7 @@ public class TextField : UITextField {
private func showDetailLabel() {
if let v: UILabel = detailLabel {
if v.hidden {
let h: CGFloat = v.font.pointSize
let h: CGFloat = v.font.pointSize * scale
v.frame = CGRectMake(0, bounds.height + bottomBorderLayerDistance, bounds.width, h)
v.hidden = false
UIView.animateWithDuration(0.25, animations: { [unowned self] in
......
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