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

LayoutProvider and item #70

Closed
sm2017 opened this issue Nov 12, 2017 · 1 comment
Closed

LayoutProvider and item #70

sm2017 opened this issue Nov 12, 2017 · 1 comment

Comments

@sm2017
Copy link

sm2017 commented Nov 12, 2017

I have an use case that LayoutProvider must pass me item to calculate dim.width and dim.height

like the following code

 this._layoutProvider = new LayoutProvider(
            index => {
                if (index % 3 === 0) {
                    return ViewTypes.FULL;
                } else if (index % 3 === 1) {
                    return ViewTypes.HALF_LEFT;
                } else {
                    return ViewTypes.HALF_RIGHT;
                }
            },
            (type, dim , item) => {
                  dim.width = item.width();
                  dim.height = item.height();
            }
        );

(type, dim , item) => {} OR (type, dim , index) => {} is good

@naqvitalha
Copy link
Collaborator

Layout provider is anyway a class. It would be very simple to grab reference to the data provider here. You already have the index. To get data use item = dataProvider.getDataForIndex(i) leaving out data here was a conscious design decision.

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

No branches or pull requests

2 participants