Upgrade sample project to use bulk update API.

Summary: Using the newer/recommended API in the sample project. #accept2ship

Reviewed By: emilsjolander

Differential Revision: D4698936

fbshipit-source-id: 07b61df897524cd38390ba48dfa2a2e10942329b
This commit is contained in:
Dustin Shahidehpour
2017-03-13 12:07:19 -07:00
committed by Facebook Github Bot
parent 6ab3984bba
commit 11052053d8
4 changed files with 66 additions and 46 deletions

View File

@@ -4,9 +4,9 @@ PODS:
- IGListKit/Default (2.1.0): - IGListKit/Default (2.1.0):
- IGListKit/Diffing - IGListKit/Diffing
- IGListKit/Diffing (2.1.0) - IGListKit/Diffing (2.1.0)
- Yoga (1.2.0) - Yoga (1.3.0)
- YogaKit (1.2.0): - YogaKit (1.3.0):
- Yoga (~> 1.2) - Yoga (~> 1.3)
DEPENDENCIES: DEPENDENCIES:
- IGListKit (~> 2.1.0) - IGListKit (~> 2.1.0)
@@ -18,8 +18,8 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
IGListKit: b826c68ef7a4ae1626c09d4d3e1ea7a169e6c36e IGListKit: b826c68ef7a4ae1626c09d4d3e1ea7a169e6c36e
Yoga: 20fc010c282cc5f3c27ce512de1329cd1e72b077 Yoga: 2ed1d7accfef3610a67f58c0cf101a0662137f2c
YogaKit: 72d5c8a806dc5cf2aa50c93a6dd88913cdbec6fe YogaKit: cddeccc6a8d2aff563e4c738d3bddb290a6de4cb
PODFILE CHECKSUM: 216f8e7127767709e0e43f3711208d238fa5c404 PODFILE CHECKSUM: 216f8e7127767709e0e43f3711208d238fa5c404

View File

@@ -15,32 +15,38 @@ final class BasicViewController: UIViewController {
let root = self.view! let root = self.view!
root.backgroundColor = .white root.backgroundColor = .white
root.yoga.isEnabled = true root.configureLayout { (layout) in
root.yoga.width = containerSize.width layout.isEnabled = true
root.yoga.height = containerSize.height layout.width = containerSize.width
root.yoga.alignItems = .center layout.height = containerSize.height
root.yoga.justifyContent = .center layout.alignItems = .center
layout.justifyContent = .center
}
let child1 = UIView() let child1 = UIView()
child1.backgroundColor = .blue child1.backgroundColor = .blue
child1.yoga.isEnabled = true child1.configureLayout { (layout) in
child1.yoga.width = 100 layout.isEnabled = true
child1.yoga.height = 10 layout.width = 100
child1.yoga.marginBottom = 25 layout.height = 10
layout.marginBottom = 25
}
root.addSubview(child1) root.addSubview(child1)
let child2 = UIView() let child2 = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
child2.yoga.isEnabled = true
child2.yoga.alignSelf = .flexEnd
child2.backgroundColor = .green child2.backgroundColor = .green
child2.frame = CGRect(x: 0, y: 0, width: 200, height: 100) child2.configureLayout { (layout) in
layout.isEnabled = true
layout.alignSelf = .flexEnd
}
root.addSubview(child2) root.addSubview(child2)
let child3 = UIView() let child3 = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
child3.yoga.isEnabled = true
child3.yoga.alignSelf = .flexStart
child3.backgroundColor = .yellow child3.backgroundColor = .yellow
child3.frame = CGRect(x: 0, y: 0, width: 100, height: 100) child3.configureLayout { (layout) in
layout.isEnabled = true
layout.alignSelf = .flexStart
}
root.addSubview(child3) root.addSubview(child3)
root.yoga.applyLayout(preservingOrigin: true) root.yoga.applyLayout(preservingOrigin: true)

View File

@@ -17,40 +17,50 @@ final class LayoutInclusionViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
let root = self.view! let root = self.view!
root.backgroundColor = .white root.backgroundColor = .white
root.yoga.isEnabled = true root.configureLayout { (layout) in
root.yoga.flexDirection = .column layout.isEnabled = true
root.yoga.justifyContent = .spaceAround layout.flexDirection = .column
layout.justifyContent = .spaceAround
}
contentView.backgroundColor = .clear contentView.backgroundColor = .clear
contentView.layer.borderColor = UIColor.lightGray.cgColor contentView.layer.borderColor = UIColor.lightGray.cgColor
contentView.layer.borderWidth = 1.0 contentView.layer.borderWidth = 1.0
contentView.yoga.isEnabled = true contentView.configureLayout { (layout) in
contentView.yoga.height = 300 layout.isEnabled = true
contentView.yoga.width = self.view.bounds.size.width layout.height = 300
contentView.yoga.flexDirection = .row layout.width = self.view.bounds.size.width
contentView.yoga.justifyContent = .center layout.flexDirection = .row
contentView.yoga.paddingHorizontal = 25 layout.justifyContent = .center
layout.paddingHorizontal = 25
}
self.view.addSubview(contentView) self.view.addSubview(contentView)
let redView = UIView(frame: .zero) let redView = UIView(frame: .zero)
redView.backgroundColor = .red redView.backgroundColor = .red
redView.yoga.isEnabled = true redView.configureLayout { (layout) in
redView.yoga.flexGrow = 1 layout.isEnabled = true
redView.yoga.flexShrink = 1 layout.flexGrow = 1
layout.flexShrink = 1
}
contentView.addSubview(redView) contentView.addSubview(redView)
disappearingView.backgroundColor = .blue disappearingView.backgroundColor = .blue
disappearingView.yoga.isEnabled = true disappearingView.configureLayout { (layout) in
disappearingView.yoga.flexGrow = 1 layout.isEnabled = true
layout.flexGrow = 1
}
contentView.addSubview(disappearingView) contentView.addSubview(disappearingView)
button.setTitle("Add Blue View", for: UIControlState.selected) button.setTitle("Add Blue View", for: UIControlState.selected)
button.setTitle("Remove Blue View", for: UIControlState.normal) button.setTitle("Remove Blue View", for: UIControlState.normal)
button.addTarget(self, action: #selector(buttonWasTapped), for: UIControlEvents.touchUpInside) button.addTarget(self, action: #selector(buttonWasTapped), for: UIControlEvents.touchUpInside)
button.yoga.isEnabled = true button.configureLayout { (layout) in
button.yoga.height = 300 layout.isEnabled = true
button.yoga.width = 300 layout.height = 300
button.yoga.alignSelf = .center layout.width = 300
layout.alignSelf = .center
}
root.addSubview(button) root.addSubview(button)
root.yoga.applyLayout(preservingOrigin: false) root.yoga.applyLayout(preservingOrigin: false)

View File

@@ -15,9 +15,11 @@ final class SingleLabelCollectionCell: UICollectionViewCell {
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
contentView.yoga.isEnabled = true contentView.configureLayout { (layout) in
contentView.yoga.flexDirection = .column layout.isEnabled = true
contentView.yoga.justifyContent = .flexEnd layout.flexDirection = .column
layout.justifyContent = .flexEnd
}
label.textAlignment = .center label.textAlignment = .center
label.numberOfLines = 1 label.numberOfLines = 1
@@ -26,9 +28,11 @@ final class SingleLabelCollectionCell: UICollectionViewCell {
let border = UIView(frame: .zero) let border = UIView(frame: .zero)
border.backgroundColor = .lightGray border.backgroundColor = .lightGray
border.yoga.isEnabled = true border.configureLayout { (layout) in
border.yoga.height = 0.5 layout.isEnabled = true
border.yoga.marginHorizontal = 25 layout.height = 0.5
layout.marginHorizontal = 25
}
contentView.addSubview(border) contentView.addSubview(border)
} }