diff --git a/docs/_docs/containers-ascollectionnode.md b/docs/_docs/containers-ascollectionnode.md
index d19074a3a2..e59771e61a 100755
--- a/docs/_docs/containers-ascollectionnode.md
+++ b/docs/_docs/containers-ascollectionnode.md
@@ -22,7 +22,7 @@ nextPage: containers-aspagernode.html
-override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
+override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
@@ -37,7 +37,7 @@ with your choice of **_one_** of the following methods
- (ASCellNode *)collectionNode:(ASCollectionNode *)collectionNode nodeForItemAtIndexPath:(NSIndexPath *)indexPath
-override func collectionNode(collectionNode: ASCollectionNode, nodeForItemAtIndexPath indexPath: NSIndexPath) -> ASCellNode
+override func collectionNode(_ collectionNode: ASCollectionNode, nodeForItemAt indexPath: IndexPath) -> ASCellNode
@@ -54,7 +54,7 @@ or
- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath
-override func collectionNode(collectionNode: ASCollectionNode, nodeBlockForItemAtIndexPath indexPath: NSIndexPath) -> ASCellNodeBlock
+override func collectionNode(_ collectionNode: ASCollectionNode, nodeBlockForItemAt indexPath: IndexPath) -> ASCellNodeBlock
@@ -96,7 +96,7 @@ Consider the following `-collectionNode:nodeBlockForItemAtIndexPath:` method.
-func tableNode(_ collectionNode: ASCollectionNode, nodeBlockForItemAt indexPath: IndexPath) -> ASCellNodeBlock {
+func collectionNode(_ collectionNode: ASCollectionNode, nodeBlockForItemAt indexPath: IndexPath) -> ASCellNodeBlock {
guard photoFeed.count > indexPath.row else { return { ASCellNode() } }
let photoModel = photoFeed[indexPath.row]
@@ -130,13 +130,13 @@ An ASCollectionNode is assigned to be managed by an `ASViewController` in its `-
- (instancetype)init
{
- _flowLayout = [[UICollectionViewFlowLayout alloc] init];
+ _flowLayout = [[UICollectionViewFlowLayout alloc] init];
_collectionNode = [[ASCollectionNode alloc] initWithCollectionViewLayout:_flowLayout];
self = [super initWithNode:_collectionNode];
if (self) {
- _flowLayout.minimumInteritemSpacing = 1;
- _flowLayout.minimumLineSpacing = 1;
+ _flowLayout.minimumInteritemSpacing = 1;
+ _flowLayout.minimumLineSpacing = 1;
}
return self;
@@ -145,13 +145,13 @@ An ASCollectionNode is assigned to be managed by an `ASViewController` in its `-
init() {
- flowLayout = UICollectionViewFlowLayout()
+ flowLayout = UICollectionViewFlowLayout()
collectionNode = ASCollectionNode(collectionViewLayout: flowLayout)
super.init(node: collectionNode)
- flowLayout.minimumInteritemSpacing = 1
- flowLayout.minimumLineSpacing = 1
+ flowLayout.minimumInteritemSpacing = 1
+ flowLayout.minimumLineSpacing = 1
}
@@ -178,7 +178,7 @@ The `LocationCollectionNodeController` above accesses the `ASCollectionView` dir
{
[super viewDidLoad];
- _collectionNode.delegate = self;
+ _collectionNode.delegate = self;
_collectionNode.dataSource = self;
_collectionNode.view.allowsSelection = NO;
_collectionNode.view.backgroundColor = [UIColor whiteColor];
@@ -189,10 +189,10 @@ The `LocationCollectionNodeController` above accesses the `ASCollectionView` dir
override func viewDidLoad() {
super.viewDidLoad()
- collectionNode.delegate = self
+ collectionNode.delegate = self
collectionNode.dataSource = self
collectionNode.view.allowsSelection = false
- collectionNode.view.backgroundColor = UIColor.whiteColor()
+ collectionNode.view.backgroundColor = .white
}
diff --git a/docs/_docs/containers-aspagernode.md b/docs/_docs/containers-aspagernode.md
index 31b6e091a4..f538983ee0 100755
--- a/docs/_docs/containers-aspagernode.md
+++ b/docs/_docs/containers-aspagernode.md
@@ -20,7 +20,7 @@ The main dataSource methods are:
-func numberOfPagesInPagerNode(pagerNode: ASPagerNode!) -> Int
+func numberOfPages(in pagerNode: ASPagerNode) -> Int
@@ -35,7 +35,7 @@ and
-func pagerNode(pagerNode: ASPagerNode!, nodeAtIndex index: Int) -> ASCellNode!
+func pagerNode(_ pagerNode: ASPagerNode, nodeAt index: Int) -> ASCellNode
@@ -50,7 +50,7 @@ or
-func pagerNode(pagerNode: ASPagerNode!, nodeBlockAtIndex index: Int) -> ASCellNodeBlock!
+func pagerNode(_ pagerNode: ASPagerNode, nodeBlockAt index: Int) -> ASCellNodeBlock
@@ -86,8 +86,8 @@ In the example below, you can see how the index is used to access the photo mode
-func pagerNode(pagerNode: ASPagerNode!, nodeBlockAtIndex index: Int) -> ASCellNodeBlock! {
- guard photoFeed.count > index else { return nil }
+func pagerNode(_ pagerNode: ASPagerNode, nodeBlockAt index: Int) -> ASCellNodeBlock {
+ guard photoFeed.count > index else { return { ASCellNode() } }
let photoModel = photoFeed[index]
let cellNodeBlock = { () -> ASCellNode in
@@ -123,8 +123,8 @@ One especially useful pattern is to return an `ASCellNode` that is initialized w
-func pagerNode(pagerNode: ASPagerNode!, nodeAtIndex index: Int) -> ASCellNode! {
- guard animals.count > index else { return nil }
+func pagerNode(_ pagerNode: ASPagerNode, nodeAt index: Int) -> ASCellNode {
+ guard animals.count > index else { return ASCellNode() }
let animal = animals[index]
let node = ASCellNode(viewControllerBlock: { () -> UIViewController in
diff --git a/docs/_docs/containers-asviewcontroller.md b/docs/_docs/containers-asviewcontroller.md
index 53f91a7843..f3a5d8e5d3 100755
--- a/docs/_docs/containers-asviewcontroller.md
+++ b/docs/_docs/containers-asviewcontroller.md
@@ -45,18 +45,16 @@ This table node is assigned to the `ASViewController` in its `-initWithNode:` de
-func initWithModel(models: Array<Model>) {
- let tableNode = ASTableNode(style:.Plain)
+init(models: [Model]) {
+ let tableNode = ASTableNode(style: .plain)
- super.initWithNode(tableNode)
+ super.init(node: tableNode)
- self.models = models
-
- self.tableNode = tableNode
- self.tableNode.delegate = self
- self.tableNode.dataSource = self
-
- return self
+ self.models = models
+
+ self.tableNode = tableNode
+ self.tableNode.delegate = self
+ self.tableNode.dataSource = self
}
diff --git a/docs/_docs/editable-text-node.md b/docs/_docs/editable-text-node.md
index 034291953d..a1fccd44a4 100755
--- a/docs/_docs/editable-text-node.md
+++ b/docs/_docs/editable-text-node.md
@@ -69,8 +69,8 @@ editableTextNode.typingAttributes = @{NSForegroundColorAttributeName: [UIColor b
-editableTextNode.typingAttributes = [NSForegroundColorAttributeName: UIColor.blueColor(),
- NSBackgroundColorAttributeName: UIColor.redColor()]
+editableTextNode.typingAttributes = [NSForegroundColorAttributeName: UIColor.blue,
+ NSBackgroundColorAttributeName: UIColor.red]
diff --git a/docs/_docs/image-node.md b/docs/_docs/image-node.md
index 4067aba045..872393b70c 100755
--- a/docs/_docs/image-node.md
+++ b/docs/_docs/image-node.md
@@ -27,7 +27,7 @@ imageNode.contentMode = UIViewContentModeScaleAspectFill;
let imageNode = ASImageNode()
imageNode.image = UIImage(named: "someImage")
-imageNode.contentMode = .ScaleAspectFill
+imageNode.contentMode = .scaleAspectFill
diff --git a/docs/_docs/layout2-api-sizing.md b/docs/_docs/layout2-api-sizing.md
index 1a52caf419..1332dfe962 100755
--- a/docs/_docs/layout2-api-sizing.md
+++ b/docs/_docs/layout2-api-sizing.md
@@ -27,14 +27,20 @@ ASDimensionMake(@"50%");
ASDimensionMakeWithFraction(0.5);
// dimension returned in points
-ASDimensionMake(@"70pt")
+ASDimensionMake(@"70pt");
ASDimensionMake(70);
ASDimensionMakeWithPoints(70);
+// dimension returned is relative (%)
+ASDimensionMake("50%")
+ASDimensionMakeWithFraction(0.5)
+
+// dimension returned in points
+ASDimensionMake("70pt")
+ASDimensionMake(70)
+ASDimensionMakeWithPoints(70)
-
-
### Example using `ASDimension`
@@ -59,9 +65,11 @@ self.rightStack.style.flexBasis = ASDimensionMake(@"60%");
[horizontalStack setChildren:@[self.leftStack, self.rightStack]];
+self.leftStack.style.flexBasis = ASDimensionMake("40%")
+self.rightStack.style.flexBasis = ASDimensionMake("60%")
+
+horizontalStack.children = [self.leftStack, self.rightStack]]
-
-
## Sizes (`CGSize`, `ASLayoutSize`)
@@ -77,6 +85,7 @@ self.rightStack.style.flexBasis = ASDimensionMake(@"60%");
ASLayoutSizeMake(ASDimension width, ASDimension height);
+ASLayoutSizeMake(_ width: ASDimension, _ height: ASDimension)
@@ -99,6 +108,12 @@ ASDimension height = ASDimensionMake(@"50%");
layoutElement.style.preferredLayoutSize = ASLayoutSizeMake(width, height);
+// Dimension type "Auto" indicates that the layout element may
+// be resolved in whatever way makes most sense given the circumstances
+let width = ASDimensionMake(.auto, 0)
+let height = ASDimensionMake("50%")
+
+layoutElement.style.preferredLayoutSize = ASLayoutSizeMake(width, height)
@@ -116,6 +131,7 @@ If you do not need relative values, you can set the layout element's `.preferred
layoutElement.style.preferredSize = CGSizeMake(30, 160);
+layoutElement.style.preferredSize = CGSize(width: 30, height: 60)
@@ -139,6 +155,13 @@ layoutElement.style.minHeight = ASDimensionMake(@"50%");
layoutElement.style.maxHeight = ASDimensionMake(@"50%");
+layoutElement.style.width = ASDimensionMake("50%")
+layoutElement.style.minWidth = ASDimensionMake("50%")
+layoutElement.style.maxWidth = ASDimensionMake("50%")
+
+layoutElement.style.height = ASDimensionMake("50%")
+layoutElement.style.minHeight = ASDimensionMake("50%")
+layoutElement.style.maxHeight = ASDimensionMake("50%")
@@ -159,6 +182,7 @@ layoutElement.style.maxHeight = ASDimensionMake(@"50%");
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize;
+func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec
diff --git a/docs/_docs/layout2-layoutspec-types.md b/docs/_docs/layout2-layoutspec-types.md
index 5c753bd491..0c9be6b2d3 100755
--- a/docs/_docs/layout2-layoutspec-types.md
+++ b/docs/_docs/layout2-layoutspec-types.md
@@ -275,7 +275,7 @@ If the center spec's width or height is unconstrained, it shrinks to the size of
{
ASStaticSizeDisplayNode *subnode = ASDisplayNodeWithBackgroundColor([UIColor greenColor], CGSizeMake(70, 100));
return [ASCenterLayoutSpec centerLayoutSpecWithCenteringOptions:ASCenterLayoutSpecCenteringXY
- sizingOptions:ASRelativeLayoutSpecSizingOptionDefault
+ sizingOptions:ASCenterLayoutSpecSizingOptionDefault
child:subnode]
}
diff --git a/docs/_docs/map-node.md b/docs/_docs/map-node.md
index 6ea77387ae..6245306193 100755
--- a/docs/_docs/map-node.md
+++ b/docs/_docs/map-node.md
@@ -18,7 +18,7 @@ Let's say you'd like to show a snapshot of San Francisco. All you need are the
ASMapNode *mapNode = [[ASMapNode alloc] init];
-mapNode.preferredFrameSize = CGSizeMake(300.0, 300.0);
+mapNode.style.preferredSize = CGSizeMake(300.0, 300.0);
// San Francisco
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(37.7749, -122.4194);
@@ -29,7 +29,7 @@ mapNode.region = MKCoordinateRegionMakeWithDistance(coord, 20000, 20000);
let mapNode = ASMapNode()
-mapNode.preferredFrameSize = CGSize(width: 300.0, height: 300.0)
+mapNode.style.preferredSize = CGSize(width: 300.0, height: 300.0)
// San Francisco
let coord = CLLocationCoordinate2DMake(37.7749, -122.4194)
@@ -71,7 +71,7 @@ mapNode.options = options;
let options = MKMapSnapshotOptions()
-options.mapType = .Satellite
+options.mapType = .satellite
options.region = MKCoordinateRegionMakeWithDistance(coord, 20000, 20000)
mapNode.options = options
diff --git a/docs/_docs/multiplex-image-node.md b/docs/_docs/multiplex-image-node.md
index 16beda7a36..d219becb80 100755
--- a/docs/_docs/multiplex-image-node.md
+++ b/docs/_docs/multiplex-image-node.md
@@ -37,7 +37,7 @@ Then, assign an array of keys to the property `imageIdentifiers`. This list sho
init(urls: [String: NSURL]) {
imageURLs = urls
- multiplexImageNode = ASMultiplexImageNode(cache: nil, downloader: ASBasicImageDownloader.sharedImageDownloader())
+ multiplexImageNode = ASMultiplexImageNode(cache: nil, downloader: ASBasicImageDownloader.shared())
multiplexImageNode.downloadsIntermediateImages = true
multiplexImageNode.imageIdentifiers = ["original", "medium", "thumb" ]
@@ -67,7 +67,7 @@ Then, if you've set up a simple dictionary that holds the keys you provided earl
-func multiplexImageNode(imageNode: ASMultiplexImageNode, URLForImageIdentifier imageIdentifier: ASImageIdentifier) -> NSURL? {
+func multiplexImageNode(_ imageNode: ASMultiplexImageNode, urlForImageIdentifier imageIdentifier: ASImageIdentifier) -> URL? {
return imageURLs[imageIdentifier]
}
@@ -96,11 +96,11 @@ For example, in the case that you want to react to the fact that a new image arr
-func multiplexImageNode(imageNode: ASMultiplexImageNode,
- didUpdateImage image: UIImage?,
- withIdentifier imageIdentifier: ASImageIdentifier?,
- fromImage previousImage: UIImage?,
- withIdentifier previousImageIdentifier: ASImageIdentifier?) {
+func multiplexImageNode(_ imageNode: ASMultiplexImageNode,
+ didUpdate image: UIImage?,
+ withIdentifier imageIdentifier: ASImageIdentifier?,
+ from previousImage: UIImage?,
+ withIdentifier previousImageIdentifier: ASImageIdentifier?) {
// this is optional, in case you want to react to the fact that a new image came in
}
diff --git a/docs/_docs/network-image-node.md b/docs/_docs/network-image-node.md
index 46427d6440..2753afe3ed 100755
--- a/docs/_docs/network-image-node.md
+++ b/docs/_docs/network-image-node.md
@@ -19,7 +19,7 @@ imageNode.URL = [NSURL URLWithString:@"https://someurl.com/image_uri"];
let imageNode = ASNetworkImageNode()
-imageNode.URL = NSURL(string: "https://someurl.com/image_uri")
+imageNode.url = URL(string: "https://someurl.com/image_uri")
@@ -39,15 +39,15 @@ If you have a standard size you want the image node's frame size to be you can u
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constraint
{
- imageNode.preferredFrameSize = CGSizeMake(100, 200);
+ imageNode.style.preferredSize = CGSizeMake(100, 200);
...
return finalLayoutSpec;
}
-override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec {
- imageNode.preferredFrameSize = CGSize(width: 100, height: 200)
+override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
+ imageNode.style.preferredSize = CGSize(width: 100, height: 200)
...
return finalLayoutSpec
}
@@ -74,7 +74,7 @@ This is also a perfect place to use `ASRatioLayoutSpec`. Instead of assigning a
-override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec {
+override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
let ratio: CGFloat = 3.0/1.0
let imageRatioSpec = ASRatioLayoutSpec(ratio:ratio, child:self.imageNode)
...
diff --git a/docs/_docs/video-node.md b/docs/_docs/video-node.md
index 699952d1ef..6a81074a85 100755
--- a/docs/_docs/video-node.md
+++ b/docs/_docs/video-node.md
@@ -28,7 +28,7 @@ videoNode.asset = asset;
let videoNode = ASVideoNode()
-let asset = AVAsset(URL: NSURL(string: "http://www.w3schools.com/html/mov_bbb.mp4"))
+let asset = AVAsset(url: URL(string: "http://www.w3schools.com/html/mov_bbb.mp4")!)
videoNode.asset = asset
@@ -78,7 +78,7 @@ There are a ton of delegate methods available to you that allow you to react to
- (void)videoNode:(ASVideoNode *)videoNode willChangePlayerState:(ASVideoNodePlayerState)state toState:(ASVideoNodePlayerState)toState;
-videoNode(videoNode:willChangePlayerState:toState:)
+videoNode(_:willChange:to:)