Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions Source/ASCollectionNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ - (void)didLoad
[view setContentOffset:contentOffset animated:pendingState.animatesContentOffset];
}

if (pendingState.leadingScreensForBatching != 0) {
view.leadingScreensForBatching = pendingState.leadingScreensForBatching;
}

const auto tuningParametersVector = pendingState->_tuningParameters;
const auto tuningParametersVectorSize = tuningParametersVector.size();
for (NSInteger rangeMode = 0; rangeMode < tuningParametersVectorSize; rangeMode++) {
Expand Down
4 changes: 4 additions & 0 deletions Source/ASTableNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ - (void)didLoad
if (!CGPointEqualToPoint(contentOffset, CGPointZero)) {
[view setContentOffset:contentOffset animated:pendingState.animatesContentOffset];
}

if (pendingState.leadingScreensForBatching != 0) {
view.leadingScreensForBatching = pendingState.leadingScreensForBatching;
}

const auto tuningParametersVector = pendingState->_tuningParameters;
const auto tuningParametersVectorSize = tuningParametersVector.size();
Expand Down
59 changes: 59 additions & 0 deletions Tests/ASCollectionViewTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1299,4 +1299,63 @@ - (void)DISABLED_testThatAutomaticallyManagedSubnodesGetPreloadCallBeforeDisplay

}

- (void)testAllPendingStatePropertiesTransferredToView {
// Create node without loading view
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
ASCollectionNode *node = [[ASCollectionNode alloc] initWithFrame:CGRectZero
collectionViewLayout:layout];

XCTAssertFalse(node.isNodeLoaded, @"View should not be loaded before setting properties");

// Set pending state properties before view loads
node.leadingScreensForBatching = 3.6;
node.inverted = YES;
node.allowsMultipleSelection = YES;
node.alwaysBounceVertical = YES;
node.alwaysBounceHorizontal = YES;
node.pagingEnabled = YES;
node.showsVerticalScrollIndicator = NO;
node.showsHorizontalScrollIndicator = NO;
UIEdgeInsets testInsets = UIEdgeInsetsMake(10, 20, 30, 40);
node.contentInset = testInsets;
CGPoint testOffset = CGPointMake(50, 60);
node.contentOffset = testOffset;
ASCollectionViewTestDelegate *delegate = [[ASCollectionViewTestDelegate alloc] initWithNumberOfSections:10 numberOfItemsInSection:10];
node.delegate = delegate;
ASCollectionViewTestDelegate *dataSource = [[ASCollectionViewTestDelegate alloc] initWithNumberOfSections:20 numberOfItemsInSection:20];
node.dataSource = dataSource;


// Load the view (triggers pending state transfer)
ASCollectionView *view = node.view;

XCTAssertTrue(node.isNodeLoaded, @"View should be loaded after accessing node.view");

// Verify properties were transferred correctly
XCTAssertEqual(view.leadingScreensForBatching, 3.6,
@"leadingScreensForBatching should transfer from pending state");
XCTAssertEqual(view.inverted, YES,
@"inverted should transfer from pending state");
XCTAssertEqual(view.allowsMultipleSelection, YES,
@"allowsMultipleSelection should transfer from pending state");
XCTAssertEqual(view.alwaysBounceVertical, YES,
@"alwaysBounceVertical should transfer from pending state");
XCTAssertEqual(view.alwaysBounceHorizontal, YES,
@"alwaysBounceHorizontal should transfer from pending state");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(view.contentInset, testInsets),
@"contentInset should transfer from pending state");
XCTAssertTrue(CGPointEqualToPoint(view.contentOffset, testOffset),
@"contentOffset should transfer from pending state");
XCTAssertEqual(view.showsVerticalScrollIndicator, NO,
@"showsVerticalScrollIndicator should transfer from pending state");
XCTAssertEqual(view.showsHorizontalScrollIndicator, NO,
@"showsHorizontalScrollIndicator should transfer from pending state");
XCTAssertEqual(view.pagingEnabled, YES,
@"pagingEnabled should transfer from pending state");
XCTAssertEqual(view.asyncDelegate, delegate,
@"delegate should transfer from pending state");
XCTAssertEqual(view.asyncDataSource, dataSource,
@"dataSource should transfer from pending state");
}

@end
53 changes: 53 additions & 0 deletions Tests/ASTableViewTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1049,4 +1049,57 @@ - (void)testTintColorIsPropagatedToTableViewCell
XCTAssertTrue(areColorsEqual);
}

- (void)testAllPendingStatePropertiesTransferredToView {
// Create node without loading view
ASTableNode *node = [[ASTableNode alloc] initWithStyle:UITableViewStylePlain];

XCTAssertFalse(node.isNodeLoaded, @"View should not be loaded before setting properties");

// Set pending state properties before view loads
node.leadingScreensForBatching = 3.6;
node.inverted = YES;
node.allowsSelectionDuringEditing = YES;
node.allowsMultipleSelection = YES;
node.allowsMultipleSelectionDuringEditing = YES;
node.pagingEnabled = YES;
node.automaticallyAdjustsContentOffset = NO;
UIEdgeInsets testInsets = UIEdgeInsetsMake(10, 20, 30, 40);
node.contentInset = testInsets;
CGPoint testOffset = CGPointMake(50, 60);
node.contentOffset = testOffset;
ASTableViewFilledDelegate *delegate = [ASTableViewFilledDelegate new];
node.delegate = delegate;
ASTableViewFilledDataSource *dataSource = [ASTableViewFilledDataSource new];
node.dataSource = dataSource;

// Load the view (triggers pending state transfer)
ASTableView *view = node.view;

XCTAssertTrue(node.isNodeLoaded, @"View should be loaded after accessing node.view");

// Verify properties were transferred correctly
XCTAssertEqual(view.leadingScreensForBatching, 3.6,
@"leadingScreensForBatching should transfer from pending state");
XCTAssertEqual(view.inverted, YES,
@"inverted should transfer from pending state");
XCTAssertEqual(view.allowsSelectionDuringEditing, YES,
@"allowsSelectionDuringEditing should transfer from pending state");
XCTAssertEqual(view.allowsMultipleSelection, YES,
@"allowsMultipleSelection should transfer from pending state");
XCTAssertEqual(view.allowsMultipleSelectionDuringEditing, YES,
@"allowsMultipleSelectionDuringEditing should transfer from pending state");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(view.contentInset, testInsets),
@"contentInset should transfer from pending state");
XCTAssertTrue(CGPointEqualToPoint(view.contentOffset, testOffset),
@"contentOffset should transfer from pending state");
XCTAssertEqual(view.automaticallyAdjustsContentOffset, NO,
@"automaticallyAdjustsContentOffset should transfer from pending state");
XCTAssertEqual(view.pagingEnabled, YES,
@"pagingEnabled should transfer from pending state");
XCTAssertEqual(view.asyncDelegate, delegate,
@"delegate should transfer from pending state");
XCTAssertEqual(view.asyncDataSource, dataSource,
@"dataSource should transfer from pending state");
}

@end