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

Compute item height via column number property. #61

Merged
merged 1 commit into from
Jul 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions components/grid/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export default class Grid extends React.Component<GridProps, any> {
itemStyle: {},
};

getFlexItemStyle() {
getFlexItemStyle(columnNum: number) {
return {
height: Dimensions.get('window').width / 4,
borderRightWidth: this.props.hasLine ? 1 : 0,
height: Dimensions.get('window').width / columnNum,
borderRightWidth: this.props.hasLine ? StyleSheet.hairlineWidth : 0,
};
}

Expand Down Expand Up @@ -74,7 +74,7 @@ export default class Grid extends React.Component<GridProps, any> {
</Flex>
));

const flexItemStyle = this.getFlexItemStyle();
const flexItemStyle = this.getFlexItemStyle(columnNum);
const rowsArr: any[] = [];

for (let i = 0; i < rowCount; i++) {
Expand All @@ -89,7 +89,7 @@ export default class Grid extends React.Component<GridProps, any> {
style={[
styles.grayBorderBox,
flexItemStyle,
{ borderLeftWidth: hasLine && j === 0 ? 1 : 0 },
{ borderLeftWidth: hasLine && j === 0 ? StyleSheet.hairlineWidth : 0 },
customItemStyle,
]}
onPress={() => onClick(el, dataIndex)}
Expand All @@ -104,8 +104,8 @@ export default class Grid extends React.Component<GridProps, any> {
}
}
const boxBorderStyle = {
borderTopWidth: hasLine && i === 0 ? 1 : 0,
borderBottomWidth: hasLine ? 1 : 0,
borderTopWidth: hasLine && i === 0 ? StyleSheet.hairlineWidth : 0,
borderBottomWidth: hasLine ? StyleSheet.hairlineWidth : 0,
};
rowsArr.push(
<Flex key={i} style={[styles.grayBorderBox, boxBorderStyle]}>
Expand Down Expand Up @@ -138,7 +138,7 @@ export default class Grid extends React.Component<GridProps, any> {
key={rowIndex}
style={[
styles.grayBorderBox,
{ borderBottomWidth: hasLine ? 1 : 0 },
{ borderBottomWidth: hasLine ? StyleSheet.hairlineWidth : 0 },
]}
>
{res}
Expand All @@ -151,7 +151,7 @@ export default class Grid extends React.Component<GridProps, any> {
key={pageIndex}
style={[
styles.grayBorderBox,
{ borderTopWidth: hasLine && pageIndex !== 0 ? 1 : 0 },
{ borderTopWidth: hasLine && pageIndex !== 0 ? StyleSheet.hairlineWidth : 0 },
]}
>
{pageRows}
Expand Down