Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a7dd6698
Unverified
Commit
a7dd6698
authored
Jul 15, 2021
by
Mohammad Ghalayini
Committed by
GitHub
Jul 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a borderRadius property to TableBorder (#85946)
parent
a67f618a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
6 deletions
+48
-6
table_border.dart
packages/flutter/lib/src/rendering/table_border.dart
+18
-5
table_border_test.dart
packages/flutter/test/rendering/table_border_test.dart
+8
-1
table_test.dart
packages/flutter/test/rendering/table_test.dart
+22
-0
No files found.
packages/flutter/lib/src/rendering/table_border.dart
View file @
a7dd6698
...
...
@@ -23,6 +23,7 @@ class TableBorder {
this
.
left
=
BorderSide
.
none
,
this
.
horizontalInside
=
BorderSide
.
none
,
this
.
verticalInside
=
BorderSide
.
none
,
this
.
borderRadius
=
BorderRadius
.
zero
,
});
/// A uniform border with all sides the same color and width.
...
...
@@ -32,9 +33,10 @@ class TableBorder {
Color
color
=
const
Color
(
0xFF000000
),
double
width
=
1.0
,
BorderStyle
style
=
BorderStyle
.
solid
,
BorderRadius
borderRadius
=
BorderRadius
.
zero
,
})
{
final
BorderSide
side
=
BorderSide
(
color:
color
,
width:
width
,
style:
style
);
return
TableBorder
(
top:
side
,
right:
side
,
bottom:
side
,
left:
side
,
horizontalInside:
side
,
verticalInside:
side
);
return
TableBorder
(
top:
side
,
right:
side
,
bottom:
side
,
left:
side
,
horizontalInside:
side
,
verticalInside:
side
,
borderRadius:
borderRadius
);
}
/// Creates a border for a table where all the interior sides use the same
...
...
@@ -71,6 +73,9 @@ class TableBorder {
/// The vertical interior sides of this border.
final
BorderSide
verticalInside
;
/// The [BorderRadius] to use when painting the corners of this border.
final
BorderRadius
borderRadius
;
/// The widths of the sides of this border represented as an [EdgeInsets].
///
/// This can be used, for example, with a [Padding] widget to inset a box by
...
...
@@ -256,7 +261,14 @@ class TableBorder {
}
}
}
paintBorder
(
canvas
,
rect
,
top:
top
,
right:
right
,
bottom:
bottom
,
left:
left
);
if
(!
isUniform
||
borderRadius
==
BorderRadius
.
zero
)
paintBorder
(
canvas
,
rect
,
top:
top
,
right:
right
,
bottom:
bottom
,
left:
left
);
else
{
final
RRect
outer
=
borderRadius
.
toRRect
(
rect
);
final
RRect
inner
=
outer
.
deflate
(
top
.
width
);
final
Paint
paint
=
Paint
()..
color
=
top
.
color
;
canvas
.
drawDRRect
(
outer
,
inner
,
paint
);
}
}
@override
...
...
@@ -271,12 +283,13 @@ class TableBorder {
&&
other
.
bottom
==
bottom
&&
other
.
left
==
left
&&
other
.
horizontalInside
==
horizontalInside
&&
other
.
verticalInside
==
verticalInside
;
&&
other
.
verticalInside
==
verticalInside
&&
other
.
borderRadius
==
borderRadius
;
}
@override
int
get
hashCode
=>
hashValues
(
top
,
right
,
bottom
,
left
,
horizontalInside
,
verticalInside
);
int
get
hashCode
=>
hashValues
(
top
,
right
,
bottom
,
left
,
horizontalInside
,
verticalInside
,
borderRadius
);
@override
String
toString
()
=>
'TableBorder(
$top
,
$right
,
$bottom
,
$left
,
$horizontalInside
,
$verticalInside
)'
;
String
toString
()
=>
'TableBorder(
$top
,
$right
,
$bottom
,
$left
,
$horizontalInside
,
$verticalInside
,
$borderRadius
)'
;
}
packages/flutter/test/rendering/table_border_test.dart
View file @
a7dd6698
...
...
@@ -124,6 +124,13 @@ void main() {
test
(
'TableBorder Object API'
,
()
{
final
String
none
=
BorderSide
.
none
.
toString
();
expect
(
const
TableBorder
().
toString
(),
'TableBorder(
$none
,
$none
,
$none
,
$none
,
$none
,
$none
)'
);
final
String
zeroRadius
=
BorderRadius
.
zero
.
toString
();
expect
(
const
TableBorder
().
toString
(),
'TableBorder(
$none
,
$none
,
$none
,
$none
,
$none
,
$none
,
$zeroRadius
)'
);
});
test
(
'TableBorder.all with a borderRadius'
,
()
{
final
TableBorder
tableA
=
TableBorder
.
all
(
borderRadius:
BorderRadius
.
circular
(
8.0
));
expect
(
tableA
.
borderRadius
,
BorderRadius
.
circular
(
8.0
));
});
}
packages/flutter/test/rendering/table_test.dart
View file @
a7dd6698
...
...
@@ -253,4 +253,26 @@ void main() {
layout
(
table
,
constraints:
BoxConstraints
.
tight
(
const
Size
(
800.0
,
600.0
)));
expect
(
table
.
hasSize
,
true
);
});
test
(
'Table paints a borderRadius'
,
()
{
final
RenderTable
table
=
RenderTable
(
textDirection:
TextDirection
.
ltr
,
border:
TableBorder
.
all
(
borderRadius:
BorderRadius
.
circular
(
8.0
)),
);
layout
(
table
);
table
.
setFlatChildren
(
2
,
<
RenderBox
>[
RenderPositionedBox
(),
RenderPositionedBox
(),
RenderPositionedBox
(),
RenderPositionedBox
(),
]);
pumpFrame
();
expect
(
table
,
paints
..
path
()
..
path
()
..
drrect
(
outer:
RRect
.
fromLTRBR
(
0.0
,
0.0
,
800.0
,
0.0
,
const
Radius
.
circular
(
8.0
)),
inner:
RRect
.
fromLTRBR
(
1.0
,
1.0
,
799.0
,
-
1.0
,
const
Radius
.
circular
(
7.0
)),
)
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment