Skip to content

Commit

Permalink
fix: wrapping (#140)
Browse files Browse the repository at this point in the history
Co-authored-by: Vittorio Cellucci <[email protected]>
  • Loading branch information
vcellu and vcellu authored Nov 17, 2022
1 parent 0e4531d commit a9223cf
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
public class CellContentStyle extends HeaderContentStyle {
int rowHeight = 1;
int lineCount = 1;
int themedRowHeight = 1;
CellContentStyle(ReadableMap data) {
super(data);
lineCount = JsonUtils.getInt(data, "rowHeight", 1);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
if(column == null) {
return;
}
layout.height = TableTheme.DefaultRowHeight;

layout.width = column.width;
setLayoutParams(layout);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ public void updateLineHeight(DataColumn column) {
}

int rowHeight = (maxLineCount * tableView.cellContentStyle.lineHeight) + CellView.PADDING_X_2;
tableView.rowHeight = Math.max(tableView.cellContentStyle.rowHeight, rowHeight);
tableView.rowHeight = Math.max(tableView.cellContentStyle.themedRowHeight, rowHeight);
for (int i = 0; i < childCount; i++) {
View view = getChildAt(i);
RowViewHolder viewHolder = (RowViewHolder) getChildViewHolder(view);
viewHolder.updateHeight(rowHeight);
viewHolder.updateHeight(tableView.rowHeight);
}

dataProvider.updateRowHeight(tableView.rowHeight);
Expand All @@ -170,7 +170,8 @@ public boolean testTextWrap() {
maxLines = Math.max(lines, maxLines);
}
if (!firstColumnOnly) {
tableView.rowHeight = (maxLines * tableView.cellContentStyle.lineHeight) + CellView.PADDING_X_2;
int rowHeight = (maxLines * tableView.cellContentStyle.lineHeight) + CellView.PADDING_X_2;
tableView.rowHeight = Math.max(rowHeight, tableView.cellContentStyle.themedRowHeight);
}

tableView.post(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public HeaderViewFactory(List<DataColumn> dataColumns, List<TotalsCell> totalsCe

@RequiresApi(api = Build.VERSION_CODES.Q)
public static HeaderCell buildFixedColumnCell(FrameLayout rootView, DataColumn column, TableView tableView, boolean topPosition) {
int headerHeight = tableView.tableViewFactory.headerView.getMeasuredHeight();
int headerHeight = tableView.headerHeight;
int padding = (int) PixelUtils.dpToPx(16);

HeaderCell fixedFirstHeaderCell = new HeaderCell(rootView.getContext(), column, tableView);
Expand All @@ -87,7 +87,7 @@ public static HeaderCell buildFixedColumnCell(FrameLayout rootView, DataColumn c
}

public static TotalsViewCell buildFixedTotalsCell(TableView tableView, DataColumn column, TotalsCell totalsCell, boolean topPosition) {
int headerHeight = tableView.tableViewFactory.headerView.getMeasuredHeight();
int headerHeight = tableView.headerHeight;
int padding = (int) PixelUtils.dpToPx(16);
TotalsViewCell text = new TotalsViewCell(tableView.getContext(), column, tableView);
text.setTypeface(text.getTypeface(), Typeface.BOLD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public void setData(DataRow dataRow, int rowHeight, CellContentStyle cellContent

if(column.representation.type.equals("image")) {
CellView cellView = (CellView) row.getChildAt(columnIndex);
LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(column.width, rowHeight);
layout.height = rowHeight;
LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(column.width, ViewGroup.LayoutParams.MATCH_PARENT);
layout.width = column.width;
cellView.setLayoutParams(layout);
cellView.setData(cell, dataRow, column);
Expand All @@ -59,7 +58,7 @@ public void setData(DataRow dataRow, int rowHeight, CellContentStyle cellContent
imageView.setAlignment(column);
} else if(column.representation.type.equals("miniChart")) {
CellView cellView = (CellView) row.getChildAt(columnIndex);
LinearLayout.LayoutParams cellViewLayoutParams = new LinearLayout.LayoutParams(column.width, rowHeight);
LinearLayout.LayoutParams cellViewLayoutParams = new LinearLayout.LayoutParams(column.width, ViewGroup.LayoutParams.MATCH_PARENT);
cellView.setLayoutParams(cellViewLayoutParams);

MiniChartView miniChartView = (MiniChartView) cellView.content;
Expand All @@ -70,9 +69,10 @@ public void setData(DataRow dataRow, int rowHeight, CellContentStyle cellContent

RelativeLayout.LayoutParams textViewLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
textView.setLayoutParams(textViewLayoutParams);

LinearLayout.LayoutParams cellViewLayoutParams = new LinearLayout.LayoutParams(column.width, rowHeight);
LinearLayout.LayoutParams cellViewLayoutParams = new LinearLayout.LayoutParams(column.width, ViewGroup.LayoutParams.MATCH_PARENT);
cellViewLayoutParams.gravity = Gravity.TOP;
cellView.setLayoutParams(cellViewLayoutParams);

if(column.representation.type.equals("text")) {
cell.indicator = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public void run() {
}

protected void updateRowHeights() {
tableView.rowHeight = tableView.cellContentStyle.getLineHeight() + CellView.PADDING_X_2;
tableView.cellContentStyle.themedRowHeight = (tableView.cellContentStyle.getLineHeight() * tableView.cellContentStyle.lineCount) + CellView.PADDING_X_2;
tableView.rowHeight = tableView.cellContentStyle.themedRowHeight;
tableView.headerHeight = tableView.headerContentStyle.getLineHeight() + CellView.PADDING_X_2;
tableView.totalsHeight = tableView.cellContentStyle.getLineHeight() + CellView.PADDING_X_2;
}
Expand Down

0 comments on commit a9223cf

Please sign in to comment.