Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions LayoutFrameworkBenchmark.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
TargetAttributes = {
24661CFB1F4EFFF5002CB883 = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = 385YL4KG69;
DevelopmentTeam = 4Q596JWQC5;
LastSwiftMigration = 0920;
ProvisioningStyle = Automatic;
};
Expand Down Expand Up @@ -481,7 +481,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 385YL4KG69;
DEVELOPMENT_TEAM = 4Q596JWQC5;
INFOPLIST_FILE = LayoutFrameworkBenchmark/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.lucdion.LayoutFrameworkBenchmark;
Expand All @@ -498,7 +498,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 385YL4KG69;
DEVELOPMENT_TEAM = 4Q596JWQC5;
INFOPLIST_FILE = LayoutFrameworkBenchmark/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.lucdion.LayoutFrameworkBenchmark;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,25 @@ class MiniProfileView: UIView {
return i
}()

let posterNameLabel: UILabel = UILabel()
let posterNameLabel: UILabel = {
let l = UILabel()
l.backgroundColor = UIColor.yellow
return l
}()

let posterHeadlineLabel: UILabel = {
let l = UILabel()
l.numberOfLines = 3
l.backgroundColor = UIColor.yellow
return l
}()

let posterTimeLabel: UILabel = {
let l = UILabel()
l.backgroundColor = UIColor.yellow
return l
}()

let posterTimeLabel: UILabel = UILabel()
let posterCommentLabel: UILabel = UILabel()

init() {
Expand Down Expand Up @@ -176,14 +186,14 @@ class SocialActionsView: UIView {
let likeLabel: UILabel = {
let l = UILabel()
l.text = "Like"
l.backgroundColor = UIColor(red: 0, green: 0.9, blue: 0, alpha: 1)
l.backgroundColor = .green
return l
}()

let commentLabel: UILabel = {
let l = UILabel()
l.text = "Comment"
l.backgroundColor = UIColor(red: 0, green: 1.0, blue: 0, alpha: 1)
l.backgroundColor = .green
l.textAlignment = .center
return l
}()
Expand All @@ -192,7 +202,7 @@ class SocialActionsView: UIView {
let l = UILabel()
l.text = "Share"
l.textAlignment = .right
l.backgroundColor = UIColor(red: 0, green: 0.8, blue: 0, alpha: 1)
l.backgroundColor = .green
return l
}()

Expand Down Expand Up @@ -235,7 +245,6 @@ class TopBarView: UIView {

init() {
super.init(frame: .zero)
backgroundColor = UIColor.blue
let views: [String: UIView] = ["actionLabel": actionLabel, "optionsLabel": optionsLabel]
addAutoLayoutSubviews(views)
addConstraints(withVisualFormat: "H:|-0-[actionLabel]-0-[optionsLabel]-0-|", views: views)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class FeedItemLayoutKitView: UIView, DataBinder {
func setData(_ data: FeedItemData) {
let posterProfile = ProfileCardLayout(
name: data.posterName,
connectionDegree: "2nd",
headline: data.posterHeadline,
timestamp: data.posterTimestamp,
profileImageName: "50x50.png")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import LayoutKit

open class ProfileCardLayout: StackLayout<UIView> {

public init(name: String, connectionDegree: String, headline: String, timestamp: String, profileImageName: String) {
public init(name: String, headline: String, timestamp: String, profileImageName: String) {
let labelConfig = { (label: UILabel) in
label.backgroundColor = UIColor.yellow
}
Expand All @@ -21,9 +21,6 @@ open class ProfileCardLayout: StackLayout<UIView> {
spacing: 4,
sublayouts: [
LabelLayout(text: name, viewReuseId: "name", config: labelConfig),
LabelLayout(text: connectionDegree, viewReuseId: "connectionDegree", config: { label in
label.backgroundColor = UIColor.gray
}),
]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import UIKit

/// A LinkedIn feed item that is implemented with manual layout code.
class FeedItemManualView: UIView, DataBinder {
let hMargin: CGFloat = 8

let actionLabel: UILabel = {
let l = UILabel()
l.backgroundColor = UIColor.blue
return l
}()

Expand All @@ -33,15 +33,24 @@ class FeedItemManualView: UIView, DataBinder {
return i
}()

let posterNameLabel: UILabel = UILabel()
let posterNameLabel: UILabel = {
let l = UILabel()
l.backgroundColor = UIColor.yellow
return l
}()

let posterHeadlineLabel: UILabel = {
let l = UILabel()
l.numberOfLines = 3
l.backgroundColor = UIColor.yellow
return l
}()

let posterTimeLabel: UILabel = {
let l = UILabel()
l.backgroundColor = UIColor.yellow
return l
}()

let posterTimeLabel: UILabel = UILabel()
let posterCommentLabel: UILabel = UILabel()

let contentImageView: UIImageView = {
Expand All @@ -57,23 +66,23 @@ class FeedItemManualView: UIView, DataBinder {

let likeLabel: UILabel = {
let l = UILabel()
l.backgroundColor = UIColor(red: 0, green: 0.9, blue: 0, alpha: 1)
l.backgroundColor = .green
l.text = "Like"
return l
}()

let commentLabel: UILabel = {
let l = UILabel()
l.text = "Comment"
l.backgroundColor = UIColor(red: 0, green: 1.0, blue: 0, alpha: 1)
l.backgroundColor = .green
l.textAlignment = .center
return l
}()

let shareLabel: UILabel = {
let l = UILabel()
l.text = "Share"
l.backgroundColor = UIColor(red: 0, green: 0.8, blue: 0, alpha: 1)
l.backgroundColor = .green
l.textAlignment = .right
return l
}()
Expand Down Expand Up @@ -112,9 +121,16 @@ class FeedItemManualView: UIView, DataBinder {

func setData(_ data: FeedItemData) {
actionLabel.text = data.actionText

posterNameLabel.text = data.posterName
posterNameLabel.sizeToFit()

posterHeadlineLabel.text = data.posterHeadline
posterHeadlineLabel.sizeToFit()

posterTimeLabel.text = data.posterTimestamp
posterTimeLabel.sizeToFit()

posterCommentLabel.text = data.posterComment
contentTitleLabel.text = data.contentTitle
contentDomainLabel.text = data.contentDomain
Expand All @@ -124,57 +140,59 @@ class FeedItemManualView: UIView, DataBinder {

override func layoutSubviews() {
super.layoutSubviews()
optionsLabel.frame = CGRect(x: bounds.width-optionsLabel.frame.width, y: 0, width: optionsLabel.frame.width, height: optionsLabel.frame.height)
actionLabel.frame = CGRect(x: 0, y: 0, width: bounds.width-optionsLabel.frame.width, height: 0)

let vMargin: CGFloat = 4
let spacing: CGFloat = 1

optionsLabel.frame = CGRect(x: bounds.width-optionsLabel.frame.width - hMargin, y: hMargin, width: optionsLabel.frame.width, height: optionsLabel.frame.height)
actionLabel.frame = CGRect(x: hMargin, y: hMargin, width: bounds.width-optionsLabel.frame.width, height: 0)
actionLabel.sizeToFit()

posterImageView.frame = CGRect(x: 0, y: actionLabel.frame.bottom, width: posterImageView.frame.width, height: 0)
posterImageView.frame = CGRect(x: hMargin, y: actionLabel.frame.bottom + 10, width: posterImageView.frame.width, height: 0)
posterImageView.sizeToFit()

let contentInsets = UIEdgeInsets(top: 0, left: 1, bottom: 2, right: 3)
let posterLabelWidth = bounds.width-posterImageView.frame.width - contentInsets.left - contentInsets.right
posterNameLabel.frame = CGRect(x: posterImageView.frame.right + contentInsets.left, y: posterImageView.frame.origin.y + contentInsets.top, width: posterLabelWidth, height: 0)
posterNameLabel.sizeToFit()
let contentInsets = UIEdgeInsets(top: -10, left: 2, bottom: 2, right: 3)
posterNameLabel.frame = CGRect(x: posterImageView.frame.right + contentInsets.left, y: posterImageView.frame.origin.y + contentInsets.top, width: posterNameLabel.frame.width, height: posterNameLabel.frame.height)

let spacing: CGFloat = 1
posterHeadlineLabel.frame = CGRect(x: posterImageView.frame.right + contentInsets.left, y: posterNameLabel.frame.bottom + spacing, width: posterLabelWidth, height: 0)
posterHeadlineLabel.sizeToFit()
posterHeadlineLabel.frame = CGRect(x: posterImageView.frame.right + contentInsets.left, y: posterNameLabel.frame.bottom + spacing, width: posterHeadlineLabel.frame.width, height: posterHeadlineLabel.frame.height)

posterTimeLabel.frame = CGRect(x: posterImageView.frame.right + contentInsets.left, y: posterHeadlineLabel.frame.bottom + spacing, width: posterLabelWidth, height: 0)
posterTimeLabel.sizeToFit()
posterTimeLabel.frame = CGRect(x: posterImageView.frame.right + contentInsets.left, y: posterHeadlineLabel.frame.bottom + spacing, width: posterTimeLabel.frame.width, height: posterTimeLabel.frame.height)

posterCommentLabel.frame = CGRect(x: 0, y: max(posterImageView.frame.bottom, posterTimeLabel.frame.bottom + contentInsets.bottom), width: frame.width, height: 0)
posterCommentLabel.frame = CGRect(x: hMargin, y: max(posterImageView.frame.bottom, posterTimeLabel.frame.bottom + contentInsets.bottom), width: frame.width, height: 0)
posterCommentLabel.sizeToFit()

contentImageView.frame = CGRect(x: frame.width/2 - contentImageView.frame.width/2, y: posterCommentLabel.frame.bottom, width: frame.width, height: 0)
contentImageView.frame = CGRect(x: hMargin, y: posterCommentLabel.frame.bottom, width: frame.width, height: 0)
contentImageView.sizeToFit()

contentTitleLabel.frame = CGRect(x: 0, y: contentImageView.frame.bottom, width: frame.width, height: 0)
contentTitleLabel.frame = CGRect(x: hMargin, y: contentImageView.frame.bottom, width: frame.width, height: 0)
contentTitleLabel.sizeToFit()

contentDomainLabel.frame = CGRect(x: 0, y: contentTitleLabel.frame.bottom, width: frame.width, height: 0)
contentDomainLabel.frame = CGRect(x: hMargin, y: contentTitleLabel.frame.bottom, width: frame.width, height: 0)
contentDomainLabel.sizeToFit()

likeLabel.frame = CGRect(x: 0, y: contentDomainLabel.frame.bottom, width: 0, height: 0)
likeLabel.frame = CGRect(x: hMargin, y: contentDomainLabel.frame.bottom + vMargin, width: 0, height: 0)
likeLabel.sizeToFit()

commentLabel.sizeToFit()
commentLabel.frame = CGRect(x: frame.width/2-commentLabel.frame.width/2, y: contentDomainLabel.frame.bottom, width: commentLabel.frame.width, height: commentLabel.frame.height)
commentLabel.frame = CGRect(x: frame.width / 2 - commentLabel.frame.width / 2, y: contentDomainLabel.frame.bottom + vMargin, width: commentLabel.frame.width, height: commentLabel.frame.height)

shareLabel.sizeToFit()
shareLabel.frame = CGRect(x: frame.width-shareLabel.frame.width, y: contentDomainLabel.frame.bottom, width: shareLabel.frame.width, height: shareLabel.frame.height)
shareLabel.frame = CGRect(x: frame.width - shareLabel.frame.width - hMargin, y: contentDomainLabel.frame.bottom + vMargin, width: shareLabel.frame.width, height: shareLabel.frame.height)

actorImageView.frame = CGRect(x: 0, y: likeLabel.frame.bottom, width: 0, height: 0)
actorImageView.frame = CGRect(x: hMargin, y: likeLabel.frame.bottom + vMargin, width: 0, height: 0)
actorImageView.sizeToFit()

actorCommentLabel.frame = CGRect(x: actorImageView.frame.right, y: likeLabel.frame.bottom, width: frame.width-actorImageView.frame.width, height: 0)
actorCommentLabel.frame = CGRect(x: actorImageView.frame.right + vMargin,
y: actorImageView.frame.minY + (actorImageView.frame.height - actorCommentLabel.frame.height) / 2,
width: frame.width-actorImageView.frame.width,
height: 0)
actorCommentLabel.sizeToFit()
}

override func sizeThatFits(_ size: CGSize) -> CGSize {
frame = CGRect(x: 0, y: 0, width: size.width, height: size.height)
layoutSubviews()
return CGSize(width: size.width, height: max(actorImageView.frame.bottom, actorCommentLabel.frame.bottom))
return CGSize(width: size.width, height: max(actorImageView.frame.bottom, actorCommentLabel.frame.bottom) + hMargin)
}

override var intrinsicContentSize: CGSize {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class NKFrameLayoutKitView: UIView, DataBinder {

let actionLabel: UILabel = {
let l = UILabel()
l.backgroundColor = UIColor.blue
return l
}()

Expand All @@ -33,15 +32,24 @@ class NKFrameLayoutKitView: UIView, DataBinder {
return i
}()

let posterNameLabel: UILabel = UILabel()
let posterNameLabel: UILabel = {
let l = UILabel()
l.backgroundColor = UIColor.yellow
return l
}()

let posterHeadlineLabel: UILabel = {
let l = UILabel()
l.numberOfLines = 3
return l
}()

let posterTimeLabel: UILabel = UILabel()
let posterTimeLabel: UILabel = {
let l = UILabel()
l.backgroundColor = UIColor.yellow
return l
}()

let posterCommentLabel: UILabel = UILabel()

let contentImageView: UIImageView = {
Expand All @@ -56,23 +64,23 @@ class NKFrameLayoutKitView: UIView, DataBinder {

let likeLabel: UILabel = {
let l = UILabel()
l.backgroundColor = UIColor(red: 0, green: 0.9, blue: 0, alpha: 1)
l.backgroundColor = .green
l.text = "Like"
return l
}()

let commentLabel: UILabel = {
let l = UILabel()
l.text = "Comment"
l.backgroundColor = UIColor(red: 0, green: 1.0, blue: 0, alpha: 1)
l.backgroundColor = .green
l.textAlignment = .center
return l
}()

let shareLabel: UILabel = {
let l = UILabel()
l.text = "Share"
l.backgroundColor = UIColor(red: 0, green: 0.8, blue: 0, alpha: 1)
l.backgroundColor = .green
l.textAlignment = .right
return l
}()
Expand Down
Loading