roberthein / BouncyLayout

Make. It. Bounce.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make compatible with IGListKit

otymartin opened this issue · comments

commented

@roberthein
Hey how can I use this with IGListCollectionViewLayout?
Would appreciate some pointers.

I tried subclassing but i get errors

@otymartin IGListCollectionViewLayout is a subclass of UICollectionViewLayout while BouncyLayout is a subclass of UICollectionViewFlowLayout and they are quite different.
In fact @roberthein maybe on second thought BouncyFlowLayout would have been a slightly better name? :)

commented

@alessandro-martin Thanks for the intel :)
@roberthein Any chance of extending support for IGListKist? It appears to be taking over this whole collectionView world.

Hi @alessandro-martin and @otymartin!

I'm looking into this.

I tried to make it work with IGListKit there are some problems : updating an object doesn't refresh its cell, nor change its bounds. It even create a strange gap later in the collectionView that is equal to what the clicked cell should have expanded in height.

On click, the cell should turn red and expand its height to 300px

simulator screen shot 13 mai 2017 a 21 19 01
simulator screen shot 13 mai 2017 a 21 19 17

Not sure if this is because of BouncyLayout or IGListKit, but it works with a normal UICollectionViewFlowLayout.
I'm going to talk about it here : Instagram/IGListKit#459

Please find attach the example I worked on :
BouncyLayout-master.zip

I progressed a bit, I found a way to do it but it's a bit dirty (see delegate method func didSelect(_ style: CellStyle) and it required that I change BouncyLayout class UIDynamicAnimator variable to open. This animator was the guilty one for caching old values and has to be empty manually before each addition/deletion/update of cells. Thanks to section Adding New Rows of https://www.objc.io/issues/5-ios7/collection-views-and-uidynamics/

New code :
BouncyLayout-master.zip

commented

@LivioGama hey so I just tried this. it appears to work nicely except, I lost my grid view.
Previously I had a grid IGListCollectionView with 3 columns but with your BouncyLayout, it reduced to a single column just like your Photos Collection example.

How can I solve that?

Could you perhaps subclass ListCollectionViewLayout instead?

commented

@LivioGama hey dont mean to nudge but still think you can hammer this out, would absolutley love to implement this in my production app🙏

It won't work because IGListKit layout is not a Flow layout like BouncyLayout. Maybe Instagram can make a FlowLayout, or maybe the author of BouncyLayout can make a subclass from IGListCollectionViewLayout to try to make that work. Meantime, I'm not expert enough with collection view layout to put my nose into it

commented

@LivioGama thanks for trying, much appreciated.
@roberthein Would really appreciate support for IGListCollectionViewLayout

When I was looking into this (another great UI component from @roberthein) I saw this issue and wonderd. Hm.. That is strange. IGListKit is still just data driven backing for UICollectionView and BouncyLayout is still just a modular layout for UICollectionView. Why would that not work together? Spoiler. It does :)

https://github.com/heumn/BouncyListKit

What have I done?
Forked IGListKid.
Added BouncyLayout
Opened EmptyViewController
💫 here comes the magic 💫
collectionView.collectionViewLayout = BouncyLayout()

Result:
Bouncy EmptyViewController demo project

Enough joking. If you guys could reproduce your problem in a fork of that project I will gladly help.

It work for simple cases, like a feed with one column. Try a grid of 2 columns.

commented

@heumn Yes I have a grid with 3 columns. This layout turns it on into a single column grid.

Thanks @LivioGama @otymartin. So I guess this is related to #14 ? I will look into it as well :) Works in my usecase (with IGListKit, but seems stranger things are happening with headers and different sections)

Yeah, there are some caching issues here somewhere... I will dig more tomorrow when I have time :)

commented

@heumn that would be wicked awesome if you could make it work with grid IGList layout :)

@otymartin I have this thing called work on weekdays, but I will look into this on Saturday and Sunday :)

commented

@heumn I can respect that. look forward to see what you pull off

This should be fixed in 2.3.0.