-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
ListView Grid/Custom Layouts #1276
Comments
I know this isn't a complete replacement for ListView, but to make a Pinterest like grid (or any grid), you just render a bunch of items in a ScrollView with the style properties flexWrap set to wrap and flexDirection set to row. ScrollView has an onScroll prop that you can use to emulate most of the features of ListView if you need them. |
What are you looking for that styling a ListView in the way described in that StackOverflow doesn't handle? |
You could also fork ListView and rendering rows by appending to two different columns (assuming you need the perf and other features of ListView, otherwise just use a ScrollView). |
@syousif94 @rxb thank you for your answer; obviously the StackOverflow example is a valid solution if the intention is to leave the that being said, the example is very not trivial, as you can see in the example description
IMO, most new comers to the project would find it difficult to implement a grid view, without any changes to the interface or the official docs. @sahrens |
@yelled3 - If you'd like to add an example to the docs that would be awesome! Layout is an interesting idea but ListView already needs some other work related to perf so this would be lower priority. A community module for this would be so fantastic though! Ping me on irc or twitter @notbrent if you need a hand with it |
@brentvatne thanks - will do :-) |
@brentvatne I created an example repo: where should I include this? in the ListView docs? add as a subfolder to |
@yelled3 - you could add it as an additional example in the UIExplorer 😄 |
@yelled3 Cool stuff - note that A) this would be much harder to do if ListView was backed by UITableView, and B) Pinterest layouts (re @syousif94) are a bit more complex since the elements are different heights, so you can't just use flex wrap. |
@brentvatne take a look: #1668
@shayne then perhaps it should be backed by UICollectionView - this way it can support custom layouts (like Pinterest layout) also, is wrapping UITableView on the project's roadmap? |
Summary: On @brentvatne suggestion: facebook#1276 (comment) I imported my Grid Layout example (https://github.com/yelled3/react-native-grid-example) into UIExplorer. ![demo-grid](https://cloud.githubusercontent.com/assets/818124/8229685/c4325dd4-15c1-11e5-8817-cdf270ab1003.gif) Closes facebook#1668 Github Author: Adam Farhi <[email protected]>
+1 |
I was looking into
ListView
docs and wanted to learn how to render different kind of layouts (aside from a simple table rows layout)this seems like a fairly common use case for native apps.
I'm aware of https://github.com/lucholaf/react-native-grid-view but I think this is not the way to go and it still bounds you to a row layout (with more cells per row)
the only other reference I found was:
http://stackoverflow.com/questions/29394297/listview-grid-in-react-native/29395686#29395686
which looks like a good starting point.
I was thinking maybe there's a way to implement an equivalent to
UICollectionViewFlowLayout
or a custom
UICollectionViewLayout
which will allow for more flexible layouts, such as Pinterest-like layouts.i'm not 100% about a good interface for this, perhaps something like:
or maybe just subclass ListView with
GridListView
which does about the same internally.thoughts?
The text was updated successfully, but these errors were encountered: