Skip to content

Commit

Permalink
fix(MD-4210): check for image type in text when in viewdata
Browse files Browse the repository at this point in the history
  • Loading branch information
vcellu authored and enell committed Mar 23, 2023
1 parent f58aec6 commit 3abcb5a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,15 @@ public void setCellData(DataCell cell, DataRow row, DataColumn column) {
cell.cellForegroundColor = Color.BLACK;
tableView.cellContentStyle.color = Color.BLACK;
}


cell.setIsDataView(isDataView);
if(cell.indicator != null && cell.type.compareTo("miniChart") != 0) {
buildSpannableText();
} else {
if(column.representation != null && column.representation.type.compareTo("image") == 0) {
cell.qText = getImageLabel(cell, row, column);
}
setText(cell.qText);
textWrapper.countWords(cell.qText);
}
Expand All @@ -162,6 +167,22 @@ public void setCellData(DataCell cell, DataRow row, DataColumn column) {
setupUrl();
}
}

private String getImageLabel(DataCell cell, DataRow row, DataColumn column) {
if(column.representation != null && column.stylingInfo != null) {
int index = column.stylingInfo.indexOf("imageLabel");
if(index == -1) {
index = column.stylingInfo.indexOf("imageUrl");
}
if(index != -1 && cell.qAttrExpValues != null) {
qValue value = cell.qAttrExpValues.values.get(index);
if(value != null) {
return value.qText;
}
}
}
return "";
}

private void buildSpannableText() {
int textColor = cell.indicator.applySegmentColors ? cell.indicator.color : TableTheme.defaultTextColor;
Expand Down
3 changes: 3 additions & 0 deletions ios/DataCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ class DataCellView: UICollectionViewCell, ExpandedCellProtocol {
} else if representation.type == "url" {
let index = col.stylingInfo?.firstIndex(of: "url")
label.setupUrl(col, cell: element, index: index)
} else if representation.type == "image" {
// can fall down here if view data
label.setImageLabel(col, cell: element)
} else {
label.text = element.qText
label.textColor = getForegroundColor(col: col, element: element, withStyle: styleInfo[index])
Expand Down
17 changes: 17 additions & 0 deletions ios/PaddedLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,23 @@ class PaddedLabel: UILabel, SelectionsListener, ConstraintCellProtocol {
}
}
}

func setImageLabel(_ col: DataColumn, cell: DataCell) {
if(setLabelFromStyle(style: "imageLabel", col: col, cell: cell)) {
return;
}
let _ = setLabelFromStyle(style: "imageUrl", col: col, cell: cell)
}

func setLabelFromStyle(style: String, col: DataColumn, cell: DataCell) -> Bool {
if let imageIndex = col.stylingInfo?.firstIndex(of: style) {
if let text = cell.qAttrExps?.qValues?[imageIndex].qText {
self.text = text
return true
}
}
return false
}

func setAttributedText(_ t: String, withIcon: UniChar, element: DataCell, isDataView: Bool) {
var iconColor = UIColor.black// self.textColor;
Expand Down

0 comments on commit 3abcb5a

Please sign in to comment.