Giter Club home page Giter Club logo

Comments (6)

kzaher avatar kzaher commented on August 15, 2024

Hi @serluca ,

I'm not sure what is the suggestion here.

collectionView(_:layout:referenceSizeForHeaderInSection:) is part of delegate and not data source, so we can't implement this on data source.

I think that RxDelegate should report collectionView(_:layout:referenceSizeForHeaderInSection:) wasn't implemented in case delegate isn't implementing it because it has void return type, so little confused it returns (0, 0). Why do you think it does?

What we could theoretically do is for data source to also implement delegate methods, and then create an extension rx_itemsWithDataSourceAndDelegate.

from rxdatasources.

serluca avatar serluca commented on August 15, 2024

Hi @kzaher,

I know is not part of the data source (I don't know why apple did that, I think it should), the problem here is not RxDelegate is the default UICollectionViewFlowLayoutDelegate that returns CGSizeZero.

I like what you are suggesting here:

What we could theoretically do is for data source to also implement delegate methods, and then create an extension rx_itemsWithDataSourceAndDelegate.

It would be very cool

from rxdatasources.

kzaher avatar kzaher commented on August 15, 2024

Hi @serluca ,

would

What we could theoretically do is for data source to also implement delegate methods, and then create an extension rx_itemsWithDataSourceAndDelegate.

even help in this case. According to this, it sounds like not.

from rxdatasources.

serluca avatar serluca commented on August 15, 2024

Hi @kzaher

What I'm suggesting here is to have a method that looks like

dataSource.supplementaryViewFactory = { (dataSource, collectionView, kind, indexPath) in
}

But for the delegate method collectionView(_:layout:referenceSizeForHeaderInSection:) something like

dataSourceAndDelegate.referenceSizeForHeaderFactory = { { (dataSource, collectionView, section)
}

Having this method, we can customize the header size and keep the same syntax that we use for the dataSource.

Right now my code looks like this (and I think is ugly):

class MyClass {
    func skinCollectionView() {
        dataSource.supplementaryViewFactory = { (dataSource, collectionView, kind, indexPath) in
            ...
        }
    }   
}

extension MyClass : UICollectionViewDelegateFlowLayout {

    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
        ....
        return Size
    }
}

from rxdatasources.

kzaher avatar kzaher commented on August 15, 2024

Can you make a PR?

from rxdatasources.

serluca avatar serluca commented on August 15, 2024

I'll try :)

from rxdatasources.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.