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
Support for sections header/footer #9
Comments
Hi Denis, We don't have plans for this feature. This is a very specific UI requirement for your case, but this is why we have ChattoAdditions. Our idea is to have a very light and stable core framework (Chatto) and then have a family of pluggable components in ChattoAdditions so that many different UIs can be implemented. On that basis looks like adding support for viewForSupplementaryElementOfKind would require too many changes in Chatto, potentially affecting several interfaces (DataSource, Decorator, Presenter, ChatItem...). Therefore, the most pragmatic way to implement sticky headers in our framework is to use regular cells. You would need to create a separated CollectionViewLayout in ChattoAdditions and use it in your custom ChatViewController subclass. You would implement your sticky layout there. To achieve that I'd start by making ChatViewController.decoratedChatItems's getter public and use that array to calculate the layout. The ChatViewController will be still creating the layoutModel for the default layout. That can be seen as a waste of work, but it will warm the sizes cache so you will still be very fast calculating the layout in the main thread. Once you get there then we can refactor ChatViewController to allow generic CollectionViewLayout preparation in the background. Hope this helps and we can see a nice PR soon :) Cheers, |
Hello Diego, Thanks for your answer ! Anyway your idea to use regular cells seems really nice, and more simple than the first one. And it will not break things in your framework. But I feel it's more kind of a hack than a native solution, as Apple suggests to use sections and headers to resolve these kind of things. I'm going on holidays tomorrow so I don't know when I will be able to finish this. But I keep you posted. Cheers, |
Hi, |
Hello Diego, I was on holidays so didn't have time to work on it, but I came back yesterday and I finish a first version with section header support. I've added support for supplementaryView and sections (I know it's not your favorite solution but it was the most simple for my skills). Good stuffs:
Bad stuffs:
I think I modified your framework too much and you won't use my work, but maybe it could inspire you for other issues :) I will still work on my fork in the next days/week to improve it. I will try to refactor the code, get rid of the bug, and add support for sound messages (another topic :)). |
Yeah... it looks more or less as I imagined. In my opinion decoration and supplementary views are given by Apple to help us separate responsibilities out of the raw array of data, and have a cleaner code. In my experience, they come as well with some limitations (there's no equivalent to cellForItemAtIndexPath: for supplementary views and it's tricky to refresh them within performBatchUpdates). In Chatto, all this separation of concerns is intended to be done within the Decorator object and the DecorationAttributes. Also, having just one section makes it faster and simpler the calculation of changes for the collection view. Anyway, I'm very happy you were able to get your hands dirty and modify the code, hope you found it clean enough; and thank you for sharing your work! |
Any news on this? What's the state of this? |
@DenisLaboureyras @diegosanchezr I added some demo code of how to add fake header/footer via extra DecoratedChatItem. You can see the code in #58 |
@zwang I noticed, you have avatar's in your pull request. Any chance you would be able to share this? |
@weyert avatar feature has already been merged to latest dev branch. Check it out. :) |
@zwang Sweet! I will wait until Badoo pushed it to the |
@weyert I recommend you to switch to dev branch, as master may not be updated in a while. You can also specify a specific commit in your Podfile |
Hi,
Thanks for your work, your framework seems awesome! And very promising!
I'm currently trying to integrate it in my project, and I have a few questions. The most important for me is do you support sections header? I want to split my messages by day, providing a nice header.
I think you can do it artificially with a new type of message, but it won't stick like headers do.
I think you can achieve that with viewForSupplementaryElementOfKind but I didn't find this kind of code in Chatto.
If you don't plan to support it, I will try to help you implementing it :)
Kind regards,
Denis
The text was updated successfully, but these errors were encountered: