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

Infinum/feature/diffable data source and animators #58

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ZvonimirMedak
Copy link
Contributor

Description

I've added CombineTableDataSourceDelegate, TableDiffableDataSourceDelegate, TableCellAnimator and updated TableCellItem. Updated the Combine paging example with an example animation to show off how you can create your own and use it.

Checklist:

  • [ x ] Have checked there is no same component already in catalog.
  • [ x ] Have created a sufficient example or wrote tests for it.
  • [ x ] Code is structured, well written using standard Swift coding style.
  • [ x ] All public methods and properties have meaningful and concise documentation.
  • [ x ] Used public modifier for all method and properties that could be changed from user of your feature, and private for internal properties.
  • [ x ] Removed any reference to the project that piece of code was created in.
  • [ x ] Reduced the dependencies to minimum.

@ZvonimirMedak ZvonimirMedak self-assigned this Sep 15, 2022
/// and all `TableCelItem` objects (in the `TableSectionItem`) **must** conform to `CellItemIdentifiable`
///
@available(iOS 13.0, *)
public final class TableDiffableDataSourceDelegate: UITableViewDiffableDataSource<AnyHashable, AnyHashable>, UITableViewDelegate {
Copy link
Member

Choose a reason for hiding this comment

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

TBH I would leave it generic.
For supporting different cell types, I would go with crating result builder for cell items 😄
I would rather go with UITableViewDiffableDataSource for iOS13+ than my custom implementation from file ⬆️ 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one is tailored with some publishers we can listen to, as we have with the default TableDataSourceDelegate. What do you mean by leaving it generic? It's constrained to Hashable anyway even with the base implementation. Would love to hear more about the result builder for cell items idea 😄

Choose a reason for hiding this comment

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

I can't figure out what @Truba had here in mind. Maybe that you should not use AnyHashable, instead we should use generic types here like in the definition of NSDiffableDataSourceSnapshot

NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType> : @unchecked Sendable where SectionIdentifierType : Hashable, SectionIdentifierType : Sendable, ItemIdentifierType : Hashable, ItemIdentifierType : Sendable {  }

Regarding result builders, I guess what should be done here is some result builder for sections/items
e.g. something like this

@SectionBuilder
func cellItems(models: SomeModel) -> [TableSectionItem] { 
    MySectionItem {
        for mode in models {
            MyTableCelItem(model: model)
        }
    }
    
    EmptySection(title: "someTitle")
    
    MySection2 {
        if isEnd {
            PageEndItem() 
        } else { 
            LoaderTableItem()
        }  
    }
}

¯_(ツ)_/¯ Something like this

@nikolamajcen
Copy link
Member

I know this is quite old, but can this be revisited? Should we improve and merge this one or close?

@ZvonimirMedak
Copy link
Contributor Author

Hi @nikolamajcen,
this brings enough improvement to be merged at this stage even though all of the comments aren't resolved. To resolve everything it would take a bit more time, and I feel like that it would complicate things without bringing much value.
If you agree, I will find some time to resolve the conflicts and we can merge it

@nikolamajcen
Copy link
Member

Hey @ZvonimirMedak , that's fine. It does not to be instant, but it would be great if you could find someone to resolve this.

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.

5 participants