brh55 / react-native-masonry

:raised_hands: A pure JS react-native component to render a masonry~ish layout for images with support for dynamic columns, progressive image loading, device rotation, on-press handlers, and headers/captions.
MIT License
1.32k stars 157 forks source link

Can it render views instead images? #59

Open SoldierCorp opened 7 years ago

SoldierCorp commented 7 years ago
brh55 commented 7 years ago

Technically no, the only reason is because rendering a masonry with just views is relatively easy to implement. This repository, however, includes additional code to handle and manage the images to ensure they fit perfectly, which isn't too easy to do.

That's not to say if this a particular use case that is desired, it does fall along the scope

sandrotonon commented 7 years ago

rendering a masonry with just views is relatively easy to implement

So how would you do that?

brh55 commented 7 years ago

As long as it's columns without images, you would just use flexbox (justifyContent: 'space-between' + fixed widths for columns) as intended @glur4k

sandrotonon commented 7 years ago

Thanks for your reply but unfortunately its still not working...

My Code looks like this:

<View style={{
  borderWidth: 1,
  flexDirection: 'row',
  flexWrap: 'wrap',
  justifyContent: 'space-between'
}}>
  {this.props.data.map((entry, index) => (
    <Card
      additionalStyles={{ width: 176 }}
      key={entry.description}
      date={entry.date}
      description={entry.description}
    />
  ))}
</View>

whereas it renders like this: masonry

which is obviously not masonry-ish (the order is correct tho)?

brh55 commented 7 years ago

@glur4k Right on track, the last thing you need is each column needs to be it's own view (set to it's respectable width) containing the list of cards. This avoids the limitations on heights being stretched out to match it's accommodating row. Hopefully that makes sense

sandrotonon commented 7 years ago

@brh55 Yeah but this would require a measurement of the cards height to determine in which column it should render. But since the height of a card is dynamic, I wound have to render all cards to determine their height with the onLayout function. And when this is done, everything would have to be re-rendered in the correct column.

Is this correct?

brh55 commented 7 years ago

@glur4k Yes if you are trying to have even looking columns. Unless order matters then you wouldn't need to do this.

sandrotonon commented 7 years ago

@brh55 I don't exacly know what you mean. Could you provide a code example showing how to achieve what you mean? I would really appreciate this!

Chaimae123 commented 6 years ago

did you find a solution to your problem ? I am facing the same issue !

brh55 commented 6 years ago

I'm trying to split the core column logic into it's own for more general use cases such as video and custom views. It will be a bit of time as I figure out how to integrate it back into this as well.

Nantris commented 5 years ago

@brh55 this project looks amazing. Thanks very much for sharing it.

Is there any update on use with non-images? I'd also like to render just plain views.