Skip to content

Commit 144b4ea

Browse files
committed
Styling for Container & Column, and verticalSeparatorWith support
Added support for styling the wrapper container and columns with wrapperStyle and columnWrapperStyle props. Also added support for verticalSeparatorWidth.
1 parent 382d8a4 commit 144b4ea

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/MasonryList.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ export type Props = {
7575
* sure to also set the `refreshing` prop correctly.
7676
*/
7777
onRefresh?: ?Function,
78+
wrapperStyle?: Object,
79+
columnWrapperStyle?: any,
80+
verticalSeparatorWidth?: number,
7881
};
7982
type State = {
8083
columns: Array<Column>,
@@ -113,6 +116,9 @@ export default class MasonryList extends React.Component<Props, State> {
113116
}
114117
return <ScrollView {...props} />;
115118
},
119+
verticalSeparatorWidth: 0,
120+
wrapperStyle: {},
121+
columnWrapperStyle: {},
116122
};
117123

118124
state = _stateFromProps(this.props);
@@ -205,7 +211,18 @@ export default class MasonryList extends React.Component<Props, State> {
205211
return { length: column.heights[rowIndex], offset, index: rowIndex };
206212
};
207213

208-
_renderScrollComponent = () => <FakeScrollView style={styles.column} />;
214+
_renderScrollComponent = columnIndex => {
215+
const { verticalSeparatorWidth, columnWrapperStyle } = this.props;
216+
return (
217+
<FakeScrollView
218+
style={[
219+
styles.column,
220+
{ marginLeft: (columnIndex > 0) ? verticalSeparatorWidth : 0 },
221+
(typeof columnWrapperStyle === 'function') ? columnWrapperStyle(columnIndex) : columnWrapperStyle
222+
]}
223+
/>
224+
);
225+
};
209226

210227
_getItemCount = data => data.length;
211228

@@ -219,6 +236,7 @@ export default class MasonryList extends React.Component<Props, State> {
219236
ListHeaderComponent,
220237
keyExtractor,
221238
onEndReached,
239+
wrapperStyle,
222240
...props
223241
} = this.props;
224242
let headerElement;
@@ -240,7 +258,7 @@ export default class MasonryList extends React.Component<Props, State> {
240258
this._getItemLayout(col.index, index)}
241259
renderItem={({ item, index }) =>
242260
renderItem({ item, index, column: col.index })}
243-
renderScrollComponent={this._renderScrollComponent}
261+
renderScrollComponent={() => this._renderScrollComponent(col.index)}
244262
keyExtractor={keyExtractor}
245263
onEndReached={onEndReached}
246264
onEndReachedThreshold={this.props.onEndReachedThreshold}

0 commit comments

Comments
 (0)