Skip to content
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

Merged
merged 1 commit into from
Jul 17, 2017
Merged

Properly insert/delete items #159

merged 1 commit into from
Jul 17, 2017

Conversation

rubencagnie
Copy link
Contributor

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

@@ -346,8 +316,8 @@ extension BrickFlowLayout {
}

var attributes: [UICollectionViewLayoutAttributes] = []
for (_, section) in sections {
attributes += section.layoutAttributesForElementsInRect(rect, with: zIndexer)
for (sectionIndex, section) in sections {
Copy link
Contributor

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 { ...

Copy link
Contributor Author

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)

isUpdating = true
if (insertedIndexPaths.count + deletedIndexPaths.count) > 0 {
zIndexer.reset(for: self)
for (sectionIndex, section) in sections! {
Copy link
Contributor

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

Copy link
Contributor Author

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

@@ -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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra new line

Copy link
Contributor Author

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
@jay18001 jay18001 merged commit 78582b6 into master Jul 17, 2017
@jay18001 jay18001 deleted the 158-insert-delete-fix branch July 17, 2017 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants