Skip to content

Commit

Permalink
Rename the field again to nodeModel (TextureGroup#504)
Browse files Browse the repository at this point in the history
* Rename the field to nodeModel

* A few more instances

* Fix method name
  • Loading branch information
Adlai-Holler authored and bernieperez committed Apr 25, 2018
1 parent 13ed5d1 commit c86ac98
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 66 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- Add -[ASDisplayNode detailedLayoutDescription] property to aid debugging. [Adlai Holler](https://github.com/Adlai-Holler) [#476](https://github.com/TextureGroup/Texture/pull/476)
- Fix an issue that causes calculatedLayoutDidChange being called needlessly. [Huy Nguyen](https://github.com/nguyenhuy) [#490](https://github.com/TextureGroup/Texture/pull/490)
- Negate iOS 11 automatic estimated table row heights. [Christian Selig](https://github.com/christianselig) [#485](https://github.com/TextureGroup/Texture/pull/485)
- Rename ASCellNode.viewModel to ASCellNode.nodeViewModel to reduce collisions with subclass properties implemented by clients. [Adlai Holler](https://github.com/Adlai-Holler) [#499](https://github.com/TextureGroup/Texture/pull/499)
- Rename ASCellNode.viewModel to ASCellNode.nodeModel to reduce collisions with subclass properties implemented by clients. [Adlai Holler](https://github.com/Adlai-Holler) [#504](https://github.com/TextureGroup/Texture/pull/504)
- [Breaking] Add content offset bridging property to ASTableNode and ASCollectionNode. Deprecate related methods in ASTableView and ASCollectionView [Huy Nguyen](https://github.com/nguyenhuy) [#460](https://github.com/TextureGroup/Texture/pull/460)

##2.3.5
Expand Down
6 changes: 3 additions & 3 deletions Source/ASCellNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
*
* This property may be set off the main thread, but this method will never be invoked concurrently on the
*/
@property (atomic, nullable) id nodeViewModel;
@property (atomic, nullable) id nodeModel;

/**
* Asks the node whether it can be updated to the given view model.
* Asks the node whether it can be updated to the given node model.
*
* The default implementation returns YES if the class matches that of the current view-model.
*/
- (BOOL)canUpdateToViewModel:(id)viewModel;
- (BOOL)canUpdateToNodeModel:(id)nodeModel;

/**
* The backing view controller, or @c nil if the node wasn't initialized with backing view controller
Expand Down
4 changes: 2 additions & 2 deletions Source/ASCellNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ - (void)__setHighlightedFromUIKit:(BOOL)highlighted;
}
}

- (BOOL)canUpdateToViewModel:(id)viewModel
- (BOOL)canUpdateToNodeModel:(id)nodeModel
{
return [self.nodeViewModel class] == [viewModel class];
return [self.nodeModel class] == [nodeModel class];
}

- (NSIndexPath *)indexPath
Expand Down
8 changes: 4 additions & 4 deletions Source/ASCollectionNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,15 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable __kindof ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath AS_WARN_UNUSED_RESULT;

/**
* Retrieves the view-model for the item at the given index path, if any.
* Retrieves the node-model for the item at the given index path, if any.
*
* @param indexPath The index path of the requested item.
*
* @return The view-model for the given item, or @c nil if no item exists at the specified path or no view-model was provided.
* @return The node-model for the given item, or @c nil if no item exists at the specified path or no node-model was provided.
*
* @warning This API is beta and subject to change. We'll try to provide an easy migration path.
*/
- (nullable id)viewModelForItemAtIndexPath:(NSIndexPath *)indexPath AS_WARN_UNUSED_RESULT;
- (nullable id)nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath AS_WARN_UNUSED_RESULT;

/**
* Retrieve the index path for the item with the given node.
Expand Down Expand Up @@ -537,7 +537,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An object that contains all the data for this item.
*/
- (nullable id)collectionNode:(ASCollectionNode *)collectionNode viewModelForItemAtIndexPath:(NSIndexPath *)indexPath;
- (nullable id)collectionNode:(ASCollectionNode *)collectionNode nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath;

/**
* Similar to -collectionNode:nodeForItemAtIndexPath:
Expand Down
4 changes: 2 additions & 2 deletions Source/ASCollectionNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -624,10 +624,10 @@ - (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath
return [self.dataController.pendingMap elementForItemAtIndexPath:indexPath].node;
}

- (id)viewModelForItemAtIndexPath:(NSIndexPath *)indexPath
- (id)nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath
{
[self reloadDataInitiallyIfNeeded];
return [self.dataController.pendingMap elementForItemAtIndexPath:indexPath].viewModel;
return [self.dataController.pendingMap elementForItemAtIndexPath:indexPath].nodeModel;
}

- (NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode
Expand Down
10 changes: 5 additions & 5 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ @interface ASCollectionView () <ASRangeControllerDataSource, ASRangeControllerDe
unsigned int collectionViewNumberOfItemsInSection:1;
unsigned int collectionNodeNodeForItem:1;
unsigned int collectionNodeNodeBlockForItem:1;
unsigned int viewModelForItem:1;
unsigned int nodeModelForItem:1;
unsigned int collectionNodeNodeForSupplementaryElement:1;
unsigned int collectionNodeNodeBlockForSupplementaryElement:1;
unsigned int collectionNodeSupplementaryElementKindsInSection:1;
Expand Down Expand Up @@ -431,7 +431,7 @@ - (void)setAsyncDataSource:(id<ASCollectionDataSource>)asyncDataSource
_asyncDataSourceFlags.collectionNodeNodeForSupplementaryElement = [_asyncDataSource respondsToSelector:@selector(collectionNode:nodeForSupplementaryElementOfKind:atIndexPath:)];
_asyncDataSourceFlags.collectionNodeNodeBlockForSupplementaryElement = [_asyncDataSource respondsToSelector:@selector(collectionNode:nodeBlockForSupplementaryElementOfKind:atIndexPath:)];
_asyncDataSourceFlags.collectionNodeSupplementaryElementKindsInSection = [_asyncDataSource respondsToSelector:@selector(collectionNode:supplementaryElementKindsInSection:)];
_asyncDataSourceFlags.viewModelForItem = [_asyncDataSource respondsToSelector:@selector(collectionNode:viewModelForItemAtIndexPath:)];
_asyncDataSourceFlags.nodeModelForItem = [_asyncDataSource respondsToSelector:@selector(collectionNode:nodeModelForItemAtIndexPath:)];

_asyncDataSourceFlags.interop = [_asyncDataSource conformsToProtocol:@protocol(ASCollectionDataSourceInterop)];
if (_asyncDataSourceFlags.interop) {
Expand Down Expand Up @@ -1662,14 +1662,14 @@ - (void)_beginBatchFetching

#pragma mark - ASDataControllerSource

- (id)dataController:(ASDataController *)dataController viewModelForItemAtIndexPath:(NSIndexPath *)indexPath
- (id)dataController:(ASDataController *)dataController nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (!_asyncDataSourceFlags.viewModelForItem) {
if (!_asyncDataSourceFlags.nodeModelForItem) {
return nil;
}

GET_COLLECTIONNODE_OR_RETURN(collectionNode, nil);
return [_asyncDataSource collectionNode:collectionNode viewModelForItemAtIndexPath:indexPath];
return [_asyncDataSource collectionNode:collectionNode nodeModelForItemAtIndexPath:indexPath];
}

- (ASCellNodeBlock)dataController:(ASDataController *)dataController nodeBlockAtIndexPath:(NSIndexPath *)indexPath
Expand Down
2 changes: 1 addition & 1 deletion Source/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ - (void)rangeController:(ASRangeController *)rangeController updateWithChangeSet

#pragma mark - ASDataControllerSource

- (id)dataController:(ASDataController *)dataController viewModelForItemAtIndexPath:(NSIndexPath *)indexPath
- (id)dataController:(ASDataController *)dataController nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath
{
// Not currently supported for tables. Will be added when the collection API stabilizes.
return nil;
Expand Down
4 changes: 2 additions & 2 deletions Source/Details/ASCollectionElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ AS_SUBCLASSING_RESTRICTED
@property (nonatomic, assign) ASSizeRange constrainedSize;
@property (nonatomic, readonly, weak) id<ASRangeManagingNode> owningNode;
@property (nonatomic, assign) ASPrimitiveTraitCollection traitCollection;
@property (nonatomic, readonly, nullable) id viewModel;
@property (nonatomic, readonly, nullable) id nodeModel;

- (instancetype)initWithViewModel:(nullable id)viewModel
- (instancetype)initWithNodeModel:(nullable id)nodeModel
nodeBlock:(ASCellNodeBlock)nodeBlock
supplementaryElementKind:(nullable NSString *)supplementaryElementKind
constrainedSize:(ASSizeRange)constrainedSize
Expand Down
6 changes: 3 additions & 3 deletions Source/Details/ASCollectionElement.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ @implementation ASCollectionElement {
ASCellNode *_node;
}

- (instancetype)initWithViewModel:(id)viewModel
- (instancetype)initWithNodeModel:(id)nodeModel
nodeBlock:(ASCellNodeBlock)nodeBlock
supplementaryElementKind:(NSString *)supplementaryElementKind
constrainedSize:(ASSizeRange)constrainedSize
Expand All @@ -41,7 +41,7 @@ - (instancetype)initWithViewModel:(id)viewModel
NSAssert(nodeBlock != nil, @"Node block must not be nil");
self = [super init];
if (self) {
_viewModel = viewModel;
_nodeModel = nodeModel;
_nodeBlock = nodeBlock;
_supplementaryElementKind = [supplementaryElementKind copy];
_constrainedSize = constrainedSize;
Expand All @@ -64,7 +64,7 @@ - (ASCellNode *)node
node.owningNode = _owningNode;
node.collectionElement = self;
ASTraitCollectionPropagateDown(node, _traitCollection);
node.nodeViewModel = _viewModel;
node.nodeModel = _nodeModel;
_node = node;
}
return _node;
Expand Down
2 changes: 1 addition & 1 deletion Source/Details/ASDataController.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ extern NSString * const ASCollectionInvalidUpdateException;
*/
- (BOOL)dataController:(ASDataController *)dataController presentedSizeForElement:(ASCollectionElement *)element matchesSize:(CGSize)size;

- (nullable id)dataController:(ASDataController *)dataController viewModelForItemAtIndexPath:(NSIndexPath *)indexPath;
- (nullable id)dataController:(ASDataController *)dataController nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath;

@optional

Expand Down
12 changes: 6 additions & 6 deletions Source/Details/ASDataController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -330,18 +330,18 @@ - (void)_insertElementsIntoMap:(ASMutableElementMap *)map
id<ASRangeManagingNode> node = self.node;
for (NSIndexPath *indexPath in indexPaths) {
ASCellNodeBlock nodeBlock;
id viewModel;
id nodeModel;
if (isRowKind) {
viewModel = [dataSource dataController:self viewModelForItemAtIndexPath:indexPath];
nodeModel = [dataSource dataController:self nodeModelForItemAtIndexPath:indexPath];

// Get the prior element and attempt to update the existing cell node.
if (viewModel != nil && !changeSet.includesReloadData) {
if (nodeModel != nil && !changeSet.includesReloadData) {
NSIndexPath *oldIndexPath = [changeSet oldIndexPathForNewIndexPath:indexPath];
if (oldIndexPath != nil) {
ASCollectionElement *oldElement = [previousMap elementForItemAtIndexPath:oldIndexPath];
ASCellNode *oldNode = oldElement.node;
if ([oldNode canUpdateToViewModel:viewModel]) {
// Just wrap the node in a block. The collection element will -setViewModel:
if ([oldNode canUpdateToNodeModel:nodeModel]) {
// Just wrap the node in a block. The collection element will -setNodeModel:
nodeBlock = ^{
return oldNode;
};
Expand All @@ -360,7 +360,7 @@ - (void)_insertElementsIntoMap:(ASMutableElementMap *)map
constrainedSize = [self constrainedSizeForNodeOfKind:kind atIndexPath:indexPath];
}

ASCollectionElement *element = [[ASCollectionElement alloc] initWithViewModel:viewModel
ASCollectionElement *element = [[ASCollectionElement alloc] initWithNodeModel:nodeModel
nodeBlock:nodeBlock
supplementaryElementKind:isRowKind ? nil : kind
constrainedSize:constrainedSize
Expand Down
Loading

0 comments on commit c86ac98

Please sign in to comment.