-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[two_dimensional_scrollables] Add borderRadius support to TableSpanDecoration #5184
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
Changes from 7 commits
8b8ac0c
8a411ec
c9d08dc
f5a19d4
2243ea2
6f45ee7
0b935b4
6076126
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,12 +296,19 @@ class TableSpanDecoration { | |
| const TableSpanDecoration({ | ||
| this.border, | ||
| this.color, | ||
| this.borderRadius, | ||
| this.consumeSpanPadding = true, | ||
| }); | ||
|
|
||
| /// The border drawn around the span. | ||
| final TableSpanBorder? border; | ||
|
|
||
| /// The radius by which the leading and trailing ends of a row or | ||
| /// column will be rounded. | ||
| /// | ||
| /// Applies to the [border] and [color] of the given [TableSpan]. | ||
| final BorderRadius? borderRadius; | ||
|
|
||
| /// The color to fill the bounds of the span with. | ||
| final Color? color; | ||
|
|
||
|
|
@@ -364,15 +371,20 @@ class TableSpanDecoration { | |
| /// cells. | ||
| void paint(TableSpanDecorationPaintDetails details) { | ||
| if (color != null) { | ||
| details.canvas.drawRect( | ||
| details.rect, | ||
| Paint() | ||
| ..color = color! | ||
| ..isAntiAlias = false, | ||
| ); | ||
| final Paint paint = Paint() | ||
| ..color = color! | ||
| ..isAntiAlias = false; | ||
|
||
| if (borderRadius == null || borderRadius == BorderRadius.zero) { | ||
| details.canvas.drawRect(details.rect, paint); | ||
| } else { | ||
| details.canvas.drawRRect( | ||
| borderRadius!.toRRect(details.rect), | ||
| paint, | ||
| ); | ||
| } | ||
| } | ||
| if (border != null) { | ||
| border!.paint(details); | ||
| border!.paint(details, borderRadius); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -416,24 +428,33 @@ class TableSpanBorder { | |
| /// cell representing the pinned column and separately with another | ||
| /// [TableSpanDecorationPaintDetails.rect] containing all the other unpinned | ||
| /// cells. | ||
| void paint(TableSpanDecorationPaintDetails details) { | ||
| void paint( | ||
| TableSpanDecorationPaintDetails details, | ||
| BorderRadius? borderRadius, | ||
| ) { | ||
| final AxisDirection axisDirection = details.axisDirection; | ||
| switch (axisDirectionToAxis(axisDirection)) { | ||
| case Axis.horizontal: | ||
| paintBorder( | ||
| details.canvas, | ||
| details.rect, | ||
| final Border border = Border( | ||
| top: axisDirection == AxisDirection.right ? leading : trailing, | ||
| bottom: axisDirection == AxisDirection.right ? trailing : leading, | ||
| ); | ||
| break; | ||
| case Axis.vertical: | ||
| paintBorder( | ||
| border.paint( | ||
| details.canvas, | ||
| details.rect, | ||
| borderRadius: borderRadius, | ||
| ); | ||
| break; | ||
| case Axis.vertical: | ||
| final Border border = Border( | ||
| left: axisDirection == AxisDirection.down ? leading : trailing, | ||
| right: axisDirection == AxisDirection.down ? trailing : leading, | ||
| ); | ||
| border.paint( | ||
| details.canvas, | ||
| details.rect, | ||
| borderRadius: borderRadius, | ||
| ); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own understanding: Why is this a property on TableSpanDecoration instead of on TableSpanBorder? Just going by the name, it seems to be a border property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it applies to both the color and the border. I modeled this to follow BoxDecoration, which is the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍