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

Fallback to non-skeleton Header #416

Merged
merged 1 commit into from
Jul 2, 2021
Merged

Fallback to non-skeleton Header #416

merged 1 commit into from
Jul 2, 2021

Conversation

guidev
Copy link
Contributor

@guidev guidev commented Jun 26, 2021

Summary

Sometimes a collectionview's header doesn't need to be 'skeletoned' since it's already ready to be displayed, while the content needs more time to load.

When collectionSkeletonView(_ skeletonView: UICollectionView, supplementaryViewIdentifierOfKind: String, at indexPath: IndexPath) -> ReusableCellIdentifier? returns nil, it's best if we fallback to the non-skeleton, original header.

Requirements (place an x in each of the [ ])

Sometimes my collectionview's header doesn't need to be 'skeletoned' while the content does.  

When  collectionSkeletonView(_ skeletonView: UICollectionView, supplementaryViewIdentifierOfKind: String, at indexPath: IndexPath) -> ReusableCellIdentifier? returns nil, it's best if we fallback to the non-skeleton header.
@Juanpe
Copy link
Owner

Juanpe commented Jun 28, 2021

Hi @guidev!

If I understand well, your point is to show the original header when the collection is "skeletoned", isn't it? If so, your code doesn't do that, I mean, the library tries to get the identifier for the header/footer and if it's not defined by the developer, the library will obtain the view from the original data source, then, the view will be "skeletonized".

So, there were some ways to do it:

  1. Set isSkeletonable to false, then the library will get the view but it won't do anything.
  2. Create a new method to prepare the header/footer for the skeleton. Like the library does with the cells:
    func collectionSkeletonView(_ skeletonView: UICollectionView, prepareCellForSkeleton cell: UICollectionViewCell, at indexPath: IndexPath). Using this new method you can set isSkeletonable to false in runtime for whatever header/footer you want.

BTW. I found an error if your collection has headers or footers and you don't implement the method
func collectionSkeletonView(_ skeletonView: UICollectionView, supplementaryViewIdentifierOfKind: String, at indexPath: IndexPath) -> ReusableCellIdentifier?, the app crashes. With your code, if the identifier is not defined, the view will be provided by the original data source. So, we could merge it to solve this corner case. WDYT?

Thanks 🤙

@Juanpe
Copy link
Owner

Juanpe commented Jul 1, 2021

Hi @guidev, could you check the message? I'd like to include the fix asap and if you don't want to do it, no problem, I'll do it :)

Please, let me know 👍🏼

Thanks

@guidev
Copy link
Contributor Author

guidev commented Jul 2, 2021

sounds good

@Juanpe Juanpe merged commit 795fd7d into Juanpe:main Jul 2, 2021
@Juanpe
Copy link
Owner

Juanpe commented Jul 2, 2021

Congratulations! 🎉 This was released as part of SkeletonView 1.21.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants