-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly insert/delete items #159
Conversation
@@ -346,8 +316,8 @@ extension BrickFlowLayout { | |||
} | |||
|
|||
var attributes: [UICollectionViewLayoutAttributes] = [] | |||
for (_, section) in sections { | |||
attributes += section.layoutAttributesForElementsInRect(rect, with: zIndexer) | |||
for (sectionIndex, section) in sections { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use sections.forEach { ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic has a reference to to self
(_collectionView
& zIndexer
)
Source/Layout/BrickFlowLayout.swift
Outdated
isUpdating = true | ||
if (insertedIndexPaths.count + deletedIndexPaths.count) > 0 { | ||
zIndexer.reset(for: self) | ||
for (sectionIndex, section) in sections! { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change force unwrap to an if let
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's OK to force unwrap sections. Without them being initialized, there wouldn't be any insert/delete possible
I've added a comment to describe this
Source/Cells/BrickCell.swift
Outdated
@@ -206,8 +206,17 @@ open class BrickCell: BaseBrickCell { | |||
|
|||
let preferred = layoutAttributes.copy() as! UICollectionViewLayoutAttributes | |||
|
|||
let size = CGSize(width: layoutAttributes.frame.width, height: self.heightForBrickView(withWidth: layoutAttributes.frame.width)) | |||
preferred.frame.size = size | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
The items that are inserted/deleted will now be properly placed in the correct atttributes location, so that the animations make much more sense Fixes #158
7bb3d6d
to
06d8448
Compare
The items that are inserted/deleted will now be properly placed in the correct atttributes location, so that the animations make much more sense
Fixes #158