Skip to content

Commit 34de002

Browse files
GianmarcoFolchiGianmarco
andauthored
Fix: Transfer leadingScreensForBatching from pending state on node load (#2130)
* Fix: Transfer leadingScreensForBatching from pending state on node load and add tests * Address PR comments * try to fix build * Adding whitespace to see if builds run * Revert prev commit to check if builds are working --------- Co-authored-by: Gianmarco <[email protected]>
1 parent e696302 commit 34de002

File tree

7 files changed

+118
-3
lines changed

7 files changed

+118
-3
lines changed

.github/workflows/ci-master-only.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
cocoapods-lint:
1010
env:
11-
DEVELOPER_DIR: /Applications/Xcode_16.4.0.app/Contents/Developer
11+
DEVELOPER_DIR: /Applications/Xcode_26.0.1.app/Contents/Developer
1212
name: Verify that podspec lints
1313
runs-on: macos-latest
1414
steps:

.github/workflows/ci-pull-requests-only.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
buildsh:
1010
env:
11-
DEVELOPER_DIR: /Applications/Xcode_16.4.0.app/Contents/Developer
11+
DEVELOPER_DIR: /Applications/Xcode_26.0.1.app/Contents/Developer
1212
strategy:
1313
matrix:
1414
mode: [cocoapods-lint-default-subspecs, cocoapods-lint-other-subspecs]

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [push, pull_request]
55
jobs:
66
buildsh:
77
env:
8-
DEVELOPER_DIR: /Applications/Xcode_16.4.0.app/Contents/Developer
8+
DEVELOPER_DIR: /Applications/Xcode_26.0.1.app/Contents/Developer
99
strategy:
1010
matrix:
1111
mode: [tests, framework, life-without-cocoapods, carthage, examples-pt1, examples-pt2, examples-pt3, examples-pt4]

Source/ASCollectionNode.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ - (instancetype)init
8282
_flags.inverted = NO;
8383
_contentInset = UIEdgeInsetsZero;
8484
_contentOffset = CGPointZero;
85+
_leadingScreensForBatching = 2.0;
8586
_flags.animatesContentOffset = NO;
8687
_flags.showsVerticalScrollIndicator = YES;
8788
_flags.showsHorizontalScrollIndicator = YES;
@@ -323,6 +324,7 @@ - (void)didLoad
323324
view.layoutInspector = pendingState.layoutInspector;
324325
view.showsVerticalScrollIndicator = pendingState.showsVerticalScrollIndicator;
325326
view.showsHorizontalScrollIndicator = pendingState.showsHorizontalScrollIndicator;
327+
view.leadingScreensForBatching = pendingState.leadingScreensForBatching;
326328
#if !TARGET_OS_TV
327329
view.pagingEnabled = pendingState.pagingEnabled;
328330
#endif

Source/ASTableNode.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ - (void)didLoad
163163
view.allowsMultipleSelection = pendingState.allowsMultipleSelection;
164164
view.allowsMultipleSelectionDuringEditing = pendingState.allowsMultipleSelectionDuringEditing;
165165
view.automaticallyAdjustsContentOffset = pendingState.automaticallyAdjustsContentOffset;
166+
view.leadingScreensForBatching = pendingState.leadingScreensForBatching;
166167
#if !TARGET_OS_TV
167168
view.pagingEnabled = pendingState.pagingEnabled;
168169
#endif

Tests/ASCollectionViewTests.mm

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,4 +1299,63 @@ - (void)DISABLED_testThatAutomaticallyManagedSubnodesGetPreloadCallBeforeDisplay
12991299

13001300
}
13011301

1302+
- (void)testAllPendingStatePropertiesTransferredToView {
1303+
// Create node without loading view
1304+
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
1305+
ASCollectionNode *node = [[ASCollectionNode alloc] initWithFrame:CGRectZero
1306+
collectionViewLayout:layout];
1307+
1308+
XCTAssertFalse(node.isNodeLoaded, @"View should not be loaded before setting properties");
1309+
1310+
// Set pending state properties before view loads
1311+
node.leadingScreensForBatching = 3.6;
1312+
node.inverted = YES;
1313+
node.allowsMultipleSelection = YES;
1314+
node.alwaysBounceVertical = YES;
1315+
node.alwaysBounceHorizontal = YES;
1316+
node.pagingEnabled = YES;
1317+
node.showsVerticalScrollIndicator = NO;
1318+
node.showsHorizontalScrollIndicator = NO;
1319+
UIEdgeInsets testInsets = UIEdgeInsetsMake(10, 20, 30, 40);
1320+
node.contentInset = testInsets;
1321+
CGPoint testOffset = CGPointMake(50, 60);
1322+
node.contentOffset = testOffset;
1323+
ASCollectionViewTestDelegate *delegate = [[ASCollectionViewTestDelegate alloc] initWithNumberOfSections:10 numberOfItemsInSection:10];
1324+
node.delegate = delegate;
1325+
ASCollectionViewTestDelegate *dataSource = [[ASCollectionViewTestDelegate alloc] initWithNumberOfSections:20 numberOfItemsInSection:20];
1326+
node.dataSource = dataSource;
1327+
1328+
1329+
// Load the view (triggers pending state transfer)
1330+
ASCollectionView *view = node.view;
1331+
1332+
XCTAssertTrue(node.isNodeLoaded, @"View should be loaded after accessing node.view");
1333+
1334+
// Verify properties were transferred correctly
1335+
XCTAssertEqual(view.leadingScreensForBatching, 3.6,
1336+
@"leadingScreensForBatching should transfer from pending state");
1337+
XCTAssertEqual(view.inverted, YES,
1338+
@"inverted should transfer from pending state");
1339+
XCTAssertEqual(view.allowsMultipleSelection, YES,
1340+
@"allowsMultipleSelection should transfer from pending state");
1341+
XCTAssertEqual(view.alwaysBounceVertical, YES,
1342+
@"alwaysBounceVertical should transfer from pending state");
1343+
XCTAssertEqual(view.alwaysBounceHorizontal, YES,
1344+
@"alwaysBounceHorizontal should transfer from pending state");
1345+
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(view.contentInset, testInsets),
1346+
@"contentInset should transfer from pending state");
1347+
XCTAssertTrue(CGPointEqualToPoint(view.contentOffset, testOffset),
1348+
@"contentOffset should transfer from pending state");
1349+
XCTAssertEqual(view.showsVerticalScrollIndicator, NO,
1350+
@"showsVerticalScrollIndicator should transfer from pending state");
1351+
XCTAssertEqual(view.showsHorizontalScrollIndicator, NO,
1352+
@"showsHorizontalScrollIndicator should transfer from pending state");
1353+
XCTAssertEqual(view.pagingEnabled, YES,
1354+
@"pagingEnabled should transfer from pending state");
1355+
XCTAssertEqual(view.asyncDelegate, delegate,
1356+
@"delegate should transfer from pending state");
1357+
XCTAssertEqual(view.asyncDataSource, dataSource,
1358+
@"dataSource should transfer from pending state");
1359+
}
1360+
13021361
@end

Tests/ASTableViewTests.mm

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,4 +1049,57 @@ - (void)testTintColorIsPropagatedToTableViewCell
10491049
XCTAssertTrue(areColorsEqual);
10501050
}
10511051

1052+
- (void)testAllPendingStatePropertiesTransferredToView {
1053+
// Create node without loading view
1054+
ASTableNode *node = [[ASTableNode alloc] initWithStyle:UITableViewStylePlain];
1055+
1056+
XCTAssertFalse(node.isNodeLoaded, @"View should not be loaded before setting properties");
1057+
1058+
// Set pending state properties before view loads
1059+
node.leadingScreensForBatching = 3.6;
1060+
node.inverted = YES;
1061+
node.allowsSelectionDuringEditing = YES;
1062+
node.allowsMultipleSelection = YES;
1063+
node.allowsMultipleSelectionDuringEditing = YES;
1064+
node.pagingEnabled = YES;
1065+
node.automaticallyAdjustsContentOffset = NO;
1066+
UIEdgeInsets testInsets = UIEdgeInsetsMake(10, 20, 30, 40);
1067+
node.contentInset = testInsets;
1068+
CGPoint testOffset = CGPointMake(50, 60);
1069+
node.contentOffset = testOffset;
1070+
ASTableViewFilledDelegate *delegate = [ASTableViewFilledDelegate new];
1071+
node.delegate = delegate;
1072+
ASTableViewFilledDataSource *dataSource = [ASTableViewFilledDataSource new];
1073+
node.dataSource = dataSource;
1074+
1075+
// Load the view (triggers pending state transfer)
1076+
ASTableView *view = node.view;
1077+
1078+
XCTAssertTrue(node.isNodeLoaded, @"View should be loaded after accessing node.view");
1079+
1080+
// Verify properties were transferred correctly
1081+
XCTAssertEqual(view.leadingScreensForBatching, 3.6,
1082+
@"leadingScreensForBatching should transfer from pending state");
1083+
XCTAssertEqual(view.inverted, YES,
1084+
@"inverted should transfer from pending state");
1085+
XCTAssertEqual(view.allowsSelectionDuringEditing, YES,
1086+
@"allowsSelectionDuringEditing should transfer from pending state");
1087+
XCTAssertEqual(view.allowsMultipleSelection, YES,
1088+
@"allowsMultipleSelection should transfer from pending state");
1089+
XCTAssertEqual(view.allowsMultipleSelectionDuringEditing, YES,
1090+
@"allowsMultipleSelectionDuringEditing should transfer from pending state");
1091+
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(view.contentInset, testInsets),
1092+
@"contentInset should transfer from pending state");
1093+
XCTAssertTrue(CGPointEqualToPoint(view.contentOffset, testOffset),
1094+
@"contentOffset should transfer from pending state");
1095+
XCTAssertEqual(view.automaticallyAdjustsContentOffset, NO,
1096+
@"automaticallyAdjustsContentOffset should transfer from pending state");
1097+
XCTAssertEqual(view.pagingEnabled, YES,
1098+
@"pagingEnabled should transfer from pending state");
1099+
XCTAssertEqual(view.asyncDelegate, delegate,
1100+
@"delegate should transfer from pending state");
1101+
XCTAssertEqual(view.asyncDataSource, dataSource,
1102+
@"dataSource should transfer from pending state");
1103+
}
1104+
10521105
@end

0 commit comments

Comments
 (0)