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

#1405 Multiline Cell component #1417

Merged
merged 2 commits into from
Oct 21, 2019
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
27 changes: 16 additions & 11 deletions src/widgets/DataTable/Cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,31 @@ import { getAdjustedStyle } from './utilities';
* @param {Object} textStyle Style object for the inner Text
* @param {Number} width optional flex property to inject into styles.
* @param {Bool} isLastCell Indicator for if this cell is the last
* @param {Number} maxLiens Maximum number of lines for the Text component
* in a row. Removing the borderRight if true.
*/
const Cell = React.memo(({ value, textStyle, viewStyle, width, isLastCell, debug }) => {
if (debug) console.log(`- Cell: ${value}`);
const internalViewStyle = getAdjustedStyle(viewStyle, width, isLastCell);
const Cell = React.memo(
({ value, textStyle, viewStyle, width, isLastCell, numberOfLines, debug }) => {
if (debug) console.log(`- Cell: ${value}`);
const internalViewStyle = getAdjustedStyle(viewStyle, width, isLastCell);

return (
<View style={internalViewStyle}>
<Text ellipsizeMode="tail" numberOfLines={1} style={textStyle}>
{value}
</Text>
</View>
);
});
return (
<View style={internalViewStyle}>
<Text ellipsizeMode="tail" numberOfLines={numberOfLines} style={textStyle}>
{value}
</Text>
</View>
);
}
);

Cell.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
textStyle: PropTypes.object,
viewStyle: PropTypes.object,
width: PropTypes.number,
isLastCell: PropTypes.bool,
numberOfLines: PropTypes.number,
debug: PropTypes.bool,
};

Expand All @@ -43,6 +47,7 @@ Cell.defaultProps = {
viewStyle: {},
width: 0,
isLastCell: false,
numberOfLines: 2,
debug: false,
};

Expand Down