Skip to content

Commit

Permalink
Docs: Fix references of ASViewController/ASNavigationController (non-…
Browse files Browse the repository at this point in the history
…existent) to ASDKViewController/ASDKNavigationController (#2072)

* Fix references of ASViewController (non-existent) to ASDKViewController

* More references changes to old ASViewController

* Also update ASNavigationController -> ASDKNavigationController
  • Loading branch information
JoeFerrucci committed Apr 5, 2023
1 parent 2c7ba22 commit e88783e
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 129 deletions.
2 changes: 1 addition & 1 deletion docs/_data/nav_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
- asrunloopqueue
- title: Node Containers
items:
- containers-asviewcontroller
- containers-asdkviewcontroller
- containers-asnodecontroller
- containers-astablenode
- containers-ascollectionnode
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/asrunloopqueue.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: ASRunLoopQueue
layout: docs
permalink: /docs/asrunloopqueue.html
prevPage: asvisibility.html
nextPage: containers-asviewcontroller.html
nextPage: containers-asdkviewcontroller.html
---

Even with main thread work, Texture is able to dramatically reduce its impact on the user experience by way of the rather amazing ASRunLoopQueue.
Expand Down
6 changes: 3 additions & 3 deletions docs/_docs/asvisibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ prevPage: debug-tool-ASRangeController.html
nextPage: asrunloopqueue.html
---

`ASNavigationController` and `ASTabBarController` both implement the `ASVisibility` protocol. These classes can be used even without `ASDisplayNodes`, making them suitable base classes for your inheritance hierarchy. For any child view controllers that are <a href="containers-asviewcontroller.html">`ASViewControllers`</a>, these classes know the exact number of user taps it would take to make the view controller visible (0 if currently visible).
`ASDKNavigationController` and `ASTabBarController` both implement the `ASVisibility` protocol. These classes can be used even without `ASDisplayNodes`, making them suitable base classes for your inheritance hierarchy. For any child view controllers that are <a href="containers-asdkviewcontroller.html">`ASDKViewControllers`</a>, these classes know the exact number of user taps it would take to make the view controller visible (0 if currently visible).

Knowing a view controller’s visibility depth allows view controllers to automatically take appropriate actions as a user approaches or leaves them. Non-default tabs in an app might preload some of their data; a controller 3 levels deep in a navigation stack might progressively free memory for images, text, and fetched data as it gets deeper.

Any container view controller can implement a simple protocol to integrate with the system. For example, `ASNavigationController` will return a visibility depth of it's own `visibilityDepth` + 1 for a view controller that would be revealed by tapping the back button once.
Any container view controller can implement a simple protocol to integrate with the system. For example, `ASDKNavigationController` will return a visibility depth of it's own `visibilityDepth` + 1 for a view controller that would be revealed by tapping the back button once.

You can opt into some of this behavior automatically by enabling `automaticallyAdjustRangeModeBasedOnViewEvents` on `ASViewController`s. With this enabled, if either the view controller or its node conform to `ASRangeControllerUpdateRangeProtocol` (`ASCollectionNode` and `ASTableNode` do by default), the ranges will automatically be decreased as the visibility depth increases to save memory.
You can opt into some of this behavior automatically by enabling `automaticallyAdjustRangeModeBasedOnViewEvents` on `ASDKViewController`s. With this enabled, if either the view controller or its node conform to `ASRangeControllerUpdateRangeProtocol` (`ASCollectionNode` and `ASTableNode` do by default), the ranges will automatically be decreased as the visibility depth increases to save memory.
2 changes: 1 addition & 1 deletion docs/_docs/button-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Let's say you want to add an `ASButtonNode` to the view of one of your existing

The next thing you'll notice is that, if you set titles of various lengths for different control states, the button will dynamically grow and shrink as the title changes. This is because changing the title causes `-setNeedsLayout` to be called on the button. Within a node hierarchy, this makes sense, and will work as expected.

Long story short, use an `ASViewController`.
Long story short, use an `ASDKViewController`.

##### Selected State

Expand Down
4 changes: 2 additions & 2 deletions docs/_docs/cell-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nextPage: button-node.html

### 3 Ways to Party

There are three ways in which you can implement the cells you'll use in your Texture app: subclassing `ASCellNode`, initializing with an existing `ASViewController` or using an existing UIView or `CALayer`.
There are three ways in which you can implement the cells you'll use in your Texture app: subclassing `ASCellNode`, initializing with an existing `ASDKViewController` or using an existing UIView or `CALayer`.

#### Subclassing

Expand All @@ -24,7 +24,7 @@ Most likely, you'll write a few of the following:
- `-layout` -- Also called on the main thread. Layout is complete after the call to super which means you can do any extra tweaking you need to do.


#### Initializing with an `ASViewController`
#### Initializing with an `ASDKViewController`

Say you already have some type of view controller written to display a view in your app. If you want to take that view controller and drop its view in as a cell in one of the scrolling nodes or a pager node its no problem.

Expand Down
8 changes: 4 additions & 4 deletions docs/_docs/containers-ascollectionnode.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ func collectionNode(_ collectionNode: ASCollectionNode, nodeBlockForItemAt index

In the example above, you can see how the index is used to access the photo model before creating the node block.

### Replacing a UICollectionViewController with an ASViewController
### Replacing a UICollectionViewController with an ASDKViewController

Texture does not offer an equivalent to UICollectionViewController. Instead, you can use the flexibility of ASViewController to recreate any type of UI<em>...</em>ViewController.
Texture does not offer an equivalent to UICollectionViewController. Instead, you can use the flexibility of ASDKViewController to recreate any type of UI<em>...</em>ViewController.

Consider, the following ASViewController subclass.
Consider, the following ASDKViewController subclass.

An ASCollectionNode is assigned to be managed by an `ASViewController` in its `-initWithNode:` designated initializer method, thus making it a sort of ASCollectionNodeController.
An ASCollectionNode is assigned to be managed by an `ASDKViewController` in its `-initWithNode:` designated initializer method, thus making it a sort of ASCollectionNodeController.

<div class = "highlight-group">
<span class="language-toggle"><a data-lang="swift" class="swiftButton">Swift</a><a data-lang="objective-c" class = "active objcButton">Objective-C</a></span>
Expand Down
67 changes: 67 additions & 0 deletions docs/_docs/containers-asdkviewcontroller.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: ASDKViewController
layout: docs
permalink: /docs/containers-asdkviewcontroller.html
prevPage: asrunloopqueue.html
nextPage: containers-asnodecontroller.html
---

`ASDKViewController` is a subclass of `UIViewController` that adds several useful features for hosting `ASDisplayNode` hierarchies.

An `ASDKViewController` can be used in place of any `UIViewController` - including within a `UINavigationController`, `UITabBarController` and `UISplitViewController` or as a modal view controller.

Benefits of using an `ASDKViewController`:
<ol>
<li><b>Save Memory</b>. An <code>ASDKViewController</code> that goes off screen will automatically reduce the size of the <a href="intelligent-preloading.html">fetch data</a> and <a href="intelligent-preloading.html">display ranges</a> of any of its children. This is key for memory management in large applications. </li>
<li><b><a href="asvisibility.html"><code>ASVisibility</code></a> Feature</b>. When used in an <code>ASDKNavigationController</code> or <code>ASTabBarController</code>, these classes know the exact number of user taps it would take to make the view controller visible.</li>
</ol>

More features will be added over time, so it is a good idea to base your view controllers off of this class.

## Usage

A `UIViewController` provides a view of its own. An `ASDKViewController` is assigned a node to manage in its designated initializer `-initWithNode:`.

Consider the following `ASDKViewController` subclass, `PhotoFeedNodeController`, from the <a href="https://github.com/texturegroup/texture/tree/master/examples/ASDKgram">ASDKgram example project</a> that would like to use a table node as its managed node.

This table node is assigned to the `ASDKViewController` in its `-initWithNode:` designated initializer method.

<div class = "highlight-group">
<span class="language-toggle"><a data-lang="swift" class="swiftButton">Swift</a><a data-lang="objective-c" class = "active objcButton">Objective-C</a></span>
<div class = "code">
<pre lang="objc" class="objcCode">
- (instancetype)init
{
_tableNode = [[ASTableNode alloc] initWithStyle:UITableViewStylePlain];
self = [super initWithNode:_tableNode];

if (self) {
_tableNode.dataSource = self;
_tableNode.delegate = self;
}

return self;
}
</pre>

<pre lang="swift" class = "swiftCode hidden">
init(models: [Model]) {
let tableNode = ASTableNode(style: .plain)

super.init(node: tableNode)

self.models = models

self.tableNode = tableNode
self.tableNode.delegate = self
self.tableNode.dataSource = self
}
</pre>
</div>
</div>

<br>
<div class = "note">
<b>Conversion Tip</b>: If your app already has a complex view controller hierarchy, it is perfectly fine to have all of them subclass <code>ASDKViewController</code>. That is to say, even if you don't use <code>ASDKViewController</code>'s designated initializer <code>-initWithNode:</code>, and only use the <code>ASDKViewController</code> in the manner of a traditional <code>UIViewController</code>, this will give you the additional node support if you choose to adopt it in different areas your application.
</div>

2 changes: 1 addition & 1 deletion docs/_docs/containers-asnodecontroller.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "ASNodeController <b><i>(Beta)</i></b>"
layout: docs
permalink: /docs/containers-asnodecontroller.html
prevPage: containers-asviewcontroller.html
prevPage: containers-asdkviewcontroller.html
nextPage: containers-astablenode.html
---

Expand Down
16 changes: 8 additions & 8 deletions docs/_docs/containers-aspagernode.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ func pagerNode(_ pagerNode: ASPagerNode, nodeBlockAt index: Int) -> ASCellNodeBl
</div>
</div>

### Using an ASViewController For Optimal Performance
### Using an ASDKViewController For Optimal Performance

One especially useful pattern is to return an `ASCellNode` that is initialized with an existing `UIViewController` or `ASViewController`. For optimal performance, use an `ASViewController`.
One especially useful pattern is to return an `ASCellNode` that is initialized with an existing `UIViewController` or `ASDKViewController`. For optimal performance, use an `ASDKViewController`.

<div class = "highlight-group">
<span class="language-toggle"><a data-lang="swift" class="swiftButton">Swift</a><a data-lang="objective-c" class = "active objcButton">Objective-C</a></span>
Expand Down Expand Up @@ -141,21 +141,21 @@ func pagerNode(_ pagerNode: ASPagerNode, nodeAt index: Int) -> ASCellNode {

In this example, you can see that the node is constructed using the `-initWithViewControllerBlock:` method. It is usually necessary to provide a cell created this way with a `style.preferredSize` so that it can be laid out correctly.

### Use ASPagerNode as root node of an ASViewController
### Use ASPagerNode as root node of an ASDKViewController

#### Log message while popping back in the view controller hierarchy
If you use an `ASPagerNode` embedded in an `ASViewController` in full screen. If you pop back from the view controller hierarchy you will see some error message in the console.
If you use an `ASPagerNode` embedded in an `ASDKViewController` in full screen. If you pop back from the view controller hierarchy you will see some error message in the console.

To resolve the error message set `self.automaticallyAdjustsScrollViewInsets = NO;` in `viewDidLoad` in your `ASViewController` subclass.
To resolve the error message set `self.automaticallyAdjustsScrollViewInsets = NO;` in `viewDidLoad` in your `ASDKViewController` subclass.

#### `navigationBar.translucent` is set to YES
If you have an `ASPagerNode` embedded in an `ASViewController` in full screen and set the `navigationBar.translucent` to `YES`, you will see an error message while pushing the view controller on the view controller stack.
If you have an `ASPagerNode` embedded in an `ASDKViewController` in full screen and set the `navigationBar.translucent` to `YES`, you will see an error message while pushing the view controller on the view controller stack.

To resolve the error message add `[self.pagerNode waitUntilAllUpdatesAreCommitted];` within `- (void)viewWillAppear:(BOOL)animated` in your `ASViewController` subclass.
To resolve the error message add `[self.pagerNode waitUntilAllUpdatesAreCommitted];` within `- (void)viewWillAppear:(BOOL)animated` in your `ASDKViewController` subclass.
Unfortunately the disadvantage of this is that the first measurement pass will block the main thread until it finishes.

#### Some more details about the error messages above
The reason for this error message is that due to the asynchronous nature of Texture, measurement of nodes will happen on a background thread as UIKit will resize the view of the `ASViewController` on on the main thread. The new layout pass has to wait until the old layout pass finishes with an old layout constrained size. Unfortunately while the measurement pass with the old constrained size is still in progress the `ASPagerFlowLayout` that is backing a `ASPagerNode` will print some errors in the console as it expects sizes for nodes already measured with the new constrained size.
The reason for this error message is that due to the asynchronous nature of Texture, measurement of nodes will happen on a background thread as UIKit will resize the view of the `ASDKViewController` on on the main thread. The new layout pass has to wait until the old layout pass finishes with an old layout constrained size. Unfortunately while the measurement pass with the old constrained size is still in progress the `ASPagerFlowLayout` that is backing a `ASPagerNode` will print some errors in the console as it expects sizes for nodes already measured with the new constrained size.

### Sample Apps

Expand Down
8 changes: 4 additions & 4 deletions docs/_docs/containers-astablenode.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ These two methods, need to return either an <a href = "cell-node.html">`ASCellNo

Note that neither of these methods require a reuse mechanism.

### Replacing UITableViewController with ASViewController
### Replacing UITableViewController with ASDKViewController

Texture does not offer an equivalent to `UITableViewController`. Instead, use an `ASViewController` initialized with an `ASTableNode`.
Texture does not offer an equivalent to `UITableViewController`. Instead, use an `ASDKViewController` initialized with an `ASTableNode`.

Consider, again, the `ASViewController` subclass - PhotoFeedNodeController - from the <a href="https://github.com/texturegroup/texture/tree/master/examples/ASDKgram">`ASDKgram sample app`</a> that uses a table node as its managed node.
Consider, again, the `ASDKViewController` subclass - PhotoFeedNodeController - from the <a href="https://github.com/texturegroup/texture/tree/master/examples/ASDKgram">`ASDKgram sample app`</a> that uses a table node as its managed node.

An `ASTableNode` is assigned to be managed by an `ASViewController` in its `-initWithNode:` designated initializer method.
An `ASTableNode` is assigned to be managed by an `ASDKViewController` in its `-initWithNode:` designated initializer method.

<div class = "highlight-group">
<span class="language-toggle"><a data-lang="swift" class="swiftButton">Swift</a><a data-lang="objective-c" class = "active objcButton">Objective-C</a></span>
Expand Down
67 changes: 0 additions & 67 deletions docs/_docs/containers-asviewcontroller.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/_docs/containers-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ It is highly recommended that you use Texture's nodes within a node container. T
<td>in place of UIKit's <code>UITableView</code></td>
</tr>
<tr>
<td><a href = "containers-asviewcontroller.html"><code>ASViewController</code></a></td>
<td><a href = "containers-asdkviewcontroller.html"><code>ASDKViewController</code></a></td>
<td>in place of UIKit's <code>UIViewController</code></td>
</tr>
<tr>
<td><code>ASNavigationController</code></td>
<td><code>ASDKNavigationController</code></td>
<td>in place of UIKit's <code>UINavigationController</code>. Implements the <a href = "asvisibility.html"><code>ASVisibility</code></a> protocol.</td>
</tr>
<tr>
Expand Down
Loading

0 comments on commit e88783e

Please sign in to comment.