Bk/refactor model state batch updates#145
Merged
bryankeller merged 2 commits intomasterfrom Oct 30, 2025
Merged
Conversation
Also update min iOS version to iOS 12
brynbodayle
reviewed
Oct 30, 2025
| inSectionAtIndex: indexPath.section) | ||
| else { | ||
| // On iOS 9, `layoutAttributesForItem(at:)` can be invoked for an index path of a new item | ||
| // before the layout is notified of this new item (through either `prepare` or |
Contributor
There was a problem hiding this comment.
should we go ahead and clean up these comments referencing unsupported versions?
Contributor
Author
There was a problem hiding this comment.
Ah yeah, good idea, I can remove the comment in the next PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
This refactors how MagazineLayout tracks layout state when batch updates are happening. Previously, the
ModelStatewould store the current and previous section + item models. Many of theModelState's functions took aBatchUpdateStageparameter, allowingMagazineLayoutto ask for layout information for the.beforeUpdatesand.afterUpdatesstage.Rather than complicating all of these functions and having them handle the before and after updates stage, we can simply make a copy of the entire
ModelStatewhen batch updates occur, and store it asmodelStateBeforeBatchUpdates. This simplifies the signatures and implementations of many functions in theModelState, as they only need to operate on the section and item models that they know about.This also bumps the minimum iOS version to iOS 12, allowing us to remove some workarounds.
This is the first major step toward tracking a full layout "snapshot" when batch updates occur, which will simplify target-content-offset-related logic, and some other layout-metric-related logic as well. I created a prototype layout to test some of these ideas, and since they proved successful, I'm bring these ideas over to MagazineLayout.
How Has This Been Tested
Types of changes
Checklist