David PHAM-VAN

Add TableRow decoration

@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 - Implement Linear and Radial gradients in BoxDecoration 5 - Implement Linear and Radial gradients in BoxDecoration
6 - Fix PdfColors.shade() 6 - Fix PdfColors.shade()
7 - Add dashed lines to Decoration Widgets 7 - Add dashed lines to Decoration Widgets
  8 +- Add TableRow decoration
8 9
9 ## 1.6.2 10 ## 1.6.2
10 11
@@ -25,6 +25,7 @@ class TableRow { @@ -25,6 +25,7 @@ class TableRow {
25 this.children, 25 this.children,
26 this.repeat = false, 26 this.repeat = false,
27 this.verticalAlignment, 27 this.verticalAlignment,
  28 + this.decoration,
28 }); 29 });
29 30
30 /// The widgets that comprise the cells in this row. 31 /// The widgets that comprise the cells in this row.
@@ -33,6 +34,8 @@ class TableRow { @@ -33,6 +34,8 @@ class TableRow {
33 /// Repeat this row on all pages 34 /// Repeat this row on all pages
34 final bool repeat; 35 final bool repeat;
35 36
  37 + final BoxDecoration decoration;
  38 +
36 final TableCellVerticalAlignment verticalAlignment; 39 final TableCellVerticalAlignment verticalAlignment;
37 } 40 }
38 41
@@ -424,6 +427,16 @@ class Table extends Widget implements SpanningWidget { @@ -424,6 +427,16 @@ class Table extends Widget implements SpanningWidget {
424 if (index++ < _context.firstLine && !row.repeat) { 427 if (index++ < _context.firstLine && !row.repeat) {
425 continue; 428 continue;
426 } 429 }
  430 +
  431 + final Widget child = row.children.first;
  432 + if (child != null && row.decoration != null) {
  433 + row.decoration.paint(
  434 + context,
  435 + PdfRect(0, child.box.y, box.width, child.box.height),
  436 + PaintPhase.background,
  437 + );
  438 + }
  439 +
427 for (Widget child in row.children) { 440 for (Widget child in row.children) {
428 context.canvas 441 context.canvas
429 ..saveContext() 442 ..saveContext()
@@ -437,6 +450,27 @@ class Table extends Widget implements SpanningWidget { @@ -437,6 +450,27 @@ class Table extends Widget implements SpanningWidget {
437 break; 450 break;
438 } 451 }
439 } 452 }
  453 +
  454 + index = 0;
  455 + for (TableRow row in children) {
  456 + if (index++ < _context.firstLine && !row.repeat) {
  457 + continue;
  458 + }
  459 +
  460 + final Widget child = row.children.first;
  461 + if (child != null && row.decoration != null) {
  462 + row.decoration.paint(
  463 + context,
  464 + PdfRect(0, child.box.y, box.width, child.box.height),
  465 + PaintPhase.foreground,
  466 + );
  467 + }
  468 +
  469 + if (index >= _context.lastLine) {
  470 + break;
  471 + }
  472 + }
  473 +
440 context.canvas.restoreContext(); 474 context.canvas.restoreContext();
441 475
442 if (border != null) { 476 if (border != null) {