Spacing in GridView
Look at the left side. How to set spacing between card on GridView like this?

I have follow docs, but I got white separator between card.

I'm not quite sure what is the issue here... Could you please share your code here?
and the screenshot of whole app screen?
This is the main app:
renderRow = (data) => {
return (
<RestaurantCard
key={data.objectId}
data={data}
onPress={() => {
Actions.restaurantDetail({ restaurantId: data.objectId })
}}
/>
)
}
}
render() {
const { restaurants, menus, loading, error } = this.props
const { currentCategory } = this.state
const data = currentCategory === 'restaurant' ? restaurants : menus
return (<GridViewWithError
data={data}
error={error}
columns={2}
renderRow={this.renderRow}
onRefresh={this.handleClickRefresh}
/>)
}
and this below is GridViewWithError component code:
const GridViewWithError = (props) => {
const { data, error, renderRow, columns, ...listViewProps } = props
if (!error) {
const groupedData = GridRow.groupByRows(data, 2)
const renderGroupedRow = (data) => (
<GridRow columns={columns}>
{data.map(renderRow)}
</GridRow>
)
return (
<ListView
data={groupedData}
error={error}
renderRow={renderGroupedRow}
{...listViewProps}
/>
)
}
return (
<Tile styleName='text-centric'>
<Title styleName='md-gutter-top'>Oops! Something is wrong!</Title>
<Subtitle>{error}</Subtitle>
<Button styleName='dark md-gutter-top' onPress={listViewProps.onRefresh}>
<Icon name='refresh' />
<Text>CLICK TO REFRESH</Text>
</Button>
</Tile>
)
}
GridViewWithError.propTypes = {
data: PropTypes.array,
error: PropTypes.string,
columns: PropTypes.number,
renderRow: PropTypes.func.isRequired,
onRefresh: PropTypes.func.isRequired,
}
GridViewWithError.defaultProps = {
columns: 1,
}
export default GridViewWithError
RestaurantCard.js:
export default class RestaurantCard extends Component {
static propTypes = {
data: PropTypes.shape({
objectId: PropTypes.any.isRequired,
name: PropTypes.string.isRequired,
location: PropTypes.string,
tags: PropTypes.array,
image: PropTypes.object,
overallRating: PropTypes.number,
formattedOpeningHours: PropTypes.string,
}),
onPress: PropTypes.func,
}
render() {
const { data, onPress } = this.props
const imageUrl = data.image && data.image.url
const imageSource = imageUrl ?
{ uri: imageUrl } :
{ uri: 'product_placeholder', isStatic: true }
return (
<TouchableHighlight underlayColor="#dddddd" onPress={() => onPress(data)}>
<Card>
<Image styleName='medium-wide' source={imageSource}>
{data.isClosed && (
<Overlay styleName='fill-parent'>
<Text>We're closed</Text>
</Overlay>
)}
<Overlay style={styles.ratingOverlay}>
<Text style={{ color: 'yellow' }}>★ </Text>
<Text>{data.rating.overall || 0}</Text>
</Overlay>
</Image>
<View styleName='content'>
<Subtitle
styleName='bold'
numberOfLines={1}
style={{ marginBottom: 0 }}
>
{data.name}
</Subtitle>
<Caption numberOfLines={1} style={{ marginBottom: 10 }}>
{data.tags.join(' · ')}
</Caption>
<View styleName='horizontal space-between'>
<Caption>3 KM</Caption>
<Caption>{data.formattedOpeningHours}</Caption>
</View>
</View>
</Card>
</TouchableHighlight>
)
}
}
const styles = {
ratingOverlay: {
flex: 1,
flexDirection: 'row',
position: 'absolute',
bottom: 0,
right: 0,
padding: 5,
},
}
and sorry, I can't capture screenshot right now. Because my backend's REST scheme has changed. So I need to finish refactoring my frontend based on JSON scheme. But I just crop the necessary part of screenshot image which I've posted yesterday. The above part is a navbar and the below part is empty (because I just have 2 data so far)
It looks like you have a white background below the list. The cards are probably separated properly, but the background of one of the parent views is white as well, so it looks like the cards are merged together.
You should either wrap the entire screen in the Screen component that should add the correct background, or just add a background to your ListView by using a custom style or styleName. Hope this helps.
Thanks @zrumenjak. Unfortunately I can't test it because I'm not working with related project anymore. So I close this issue & will reopen if somebody have same issue with this.