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
e100ddfe
Unverified
Commit
e100ddfe
authored
Feb 20, 2019
by
xster
Committed by
GitHub
Feb 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename SuperellipseShare ContinuousRectangleBorder (#28183)
parent
39b1ff1a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
37 deletions
+38
-37
goldens.version
bin/internal/goldens.version
+1
-1
painting.dart
packages/flutter/lib/painting.dart
+1
-1
borders.dart
packages/flutter/lib/src/painting/borders.dart
+3
-2
continuous_rectangle_border.dart
...flutter/lib/src/painting/continuous_rectangle_border.dart
+15
-15
bottom_app_bar_test.dart
packages/flutter/test/material/bottom_app_bar_test.dart
+1
-1
continous_rectangle_border_test.dart
...lutter/test/painting/continous_rectangle_border_test.dart
+17
-17
No files found.
bin/internal/goldens.version
View file @
e100ddfe
316817d949c1f7051e8a4898486ae7643ce31167
8587c2409ec1b674a7d451c8bcd8d37ed5175fdc
packages/flutter/lib/painting.dart
View file @
e100ddfe
...
...
@@ -32,6 +32,7 @@ export 'src/painting/box_shadow.dart';
export
'src/painting/circle_border.dart'
;
export
'src/painting/clip.dart'
;
export
'src/painting/colors.dart'
;
export
'src/painting/continuous_rectangle_border.dart'
;
export
'src/painting/debug.dart'
;
export
'src/painting/decoration.dart'
;
export
'src/painting/decoration_image.dart'
;
...
...
@@ -52,7 +53,6 @@ export 'src/painting/rounded_rectangle_border.dart';
export
'src/painting/shape_decoration.dart'
;
export
'src/painting/stadium_border.dart'
;
export
'src/painting/strut_style.dart'
;
export
'src/painting/superellipse_shape.dart'
;
export
'src/painting/text_painter.dart'
;
export
'src/painting/text_span.dart'
;
export
'src/painting/text_style.dart'
;
packages/flutter/lib/src/painting/borders.dart
View file @
e100ddfe
...
...
@@ -265,8 +265,9 @@ class BorderSide {
///
/// This class handles how to add multiple borders together. Subclasses define
/// various shapes, like circles ([CircleBorder]), rounded rectangles
/// ([RoundedRectangleBorder]), superellipses ([SuperellipseShape]), or beveled
/// rectangles ([BeveledRectangleBorder]).
/// ([RoundedRectangleBorder]), continuous rectangles
/// ([ContinuousRectangleBorder]), or beveled rectangles
/// ([BeveledRectangleBorder]).
///
/// See also:
///
...
...
packages/flutter/lib/src/painting/
superellipse_shape
.dart
→
packages/flutter/lib/src/painting/
continuous_rectangle_border
.dart
View file @
e100ddfe
...
...
@@ -9,15 +9,14 @@ import 'border_radius.dart';
import
'borders.dart'
;
import
'edge_insets.dart'
;
/// Creates a superellipse - a shape similar to a rounded rectangle, but with
/// a smoother transition from the sides to the rounded corners and greater
/// curve continuity.
/// A rectangular border with smooth continuous transitions between the straight
/// sides and the rounded corners.
///
/// {@tool sample}
/// ```dart
/// Widget build(BuildContext context) {
/// return Material(
/// shape:
SuperellipseShape
(
/// shape:
ContinuousRectangleBorder
(
/// borderRadius: BorderRadius.circular(28.0),
/// ),
/// );
...
...
@@ -27,12 +26,13 @@ import 'edge_insets.dart';
///
/// See also:
///
/// * [RoundedRectangleBorder] Which creates a square with rounded corners,
/// however it doesn't allow the corners to bend the sides of the square
/// like a superellipse, resulting in a more square shape.
class
SuperellipseShape
extends
ShapeBorder
{
/// * [RoundedRectangleBorder] Which creates rectangles with rounded corners,
/// however its straight sides change into a rounded corner with a circular
/// radius in a step function instead of gradually like the
/// [ContinuousRectangleBorder].
class
ContinuousRectangleBorder
extends
ShapeBorder
{
/// The arguments must not be null.
const
SuperellipseShape
({
const
ContinuousRectangleBorder
({
this
.
side
=
BorderSide
.
none
,
this
.
borderRadius
=
BorderRadius
.
zero
,
})
:
assert
(
side
!=
null
),
...
...
@@ -52,7 +52,7 @@ class SuperellipseShape extends ShapeBorder {
@override
ShapeBorder
scale
(
double
t
)
{
return
SuperellipseShape
(
return
ContinuousRectangleBorder
(
side:
side
.
scale
(
t
),
borderRadius:
borderRadius
*
t
,
);
...
...
@@ -61,8 +61,8 @@ class SuperellipseShape extends ShapeBorder {
@override
ShapeBorder
lerpFrom
(
ShapeBorder
a
,
double
t
)
{
assert
(
t
!=
null
);
if
(
a
is
SuperellipseShape
)
{
return
SuperellipseShape
(
if
(
a
is
ContinuousRectangleBorder
)
{
return
ContinuousRectangleBorder
(
side:
BorderSide
.
lerp
(
a
.
side
,
side
,
t
),
borderRadius:
BorderRadiusGeometry
.
lerp
(
a
.
borderRadius
,
borderRadius
,
t
),
);
...
...
@@ -73,8 +73,8 @@ class SuperellipseShape extends ShapeBorder {
@override
ShapeBorder
lerpTo
(
ShapeBorder
b
,
double
t
)
{
assert
(
t
!=
null
);
if
(
b
is
SuperellipseShape
)
{
return
SuperellipseShape
(
if
(
b
is
ContinuousRectangleBorder
)
{
return
ContinuousRectangleBorder
(
side:
BorderSide
.
lerp
(
side
,
b
.
side
,
t
),
borderRadius:
BorderRadiusGeometry
.
lerp
(
borderRadius
,
b
.
borderRadius
,
t
),
);
...
...
@@ -151,7 +151,7 @@ class SuperellipseShape extends ShapeBorder {
bool
operator
==(
dynamic
other
)
{
if
(
runtimeType
!=
other
.
runtimeType
)
return
false
;
final
SuperellipseShape
typedOther
=
other
;
final
ContinuousRectangleBorder
typedOther
=
other
;
return
side
==
typedOther
.
side
&&
borderRadius
==
typedOther
.
borderRadius
;
}
...
...
packages/flutter/test/material/bottom_app_bar_test.dart
View file @
e100ddfe
...
...
@@ -56,7 +56,7 @@ void main() {
bottomNavigationBar:
BottomAppBar
(
shape:
AutomaticNotchedShape
(
BeveledRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
50.0
)),
SuperellipseShape
(
borderRadius:
BorderRadius
.
circular
(
30.0
)),
ContinuousRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
30.0
)),
),
notchMargin:
10.0
,
color:
Colors
.
green
,
...
...
packages/flutter/test/painting/
superellipse_shape
_test.dart
→
packages/flutter/test/painting/
continous_rectangle_border
_test.dart
View file @
e100ddfe
...
...
@@ -10,10 +10,10 @@ import 'package:flutter_test/flutter_test.dart';
import
'../rendering/mock_canvas.dart'
;
void
main
(
)
{
test
(
'
SuperellipseShape
scale and lerp'
,
()
{
final
SuperellipseShape
c10
=
SuperellipseShape
(
side:
const
BorderSide
(
width:
10.0
),
borderRadius:
BorderRadius
.
circular
(
100.0
));
final
SuperellipseShape
c15
=
SuperellipseShape
(
side:
const
BorderSide
(
width:
15.0
),
borderRadius:
BorderRadius
.
circular
(
150.0
));
final
SuperellipseShape
c20
=
SuperellipseShape
(
side:
const
BorderSide
(
width:
20.0
),
borderRadius:
BorderRadius
.
circular
(
200.0
));
test
(
'
ContinuousRectangleBorder
scale and lerp'
,
()
{
final
ContinuousRectangleBorder
c10
=
ContinuousRectangleBorder
(
side:
const
BorderSide
(
width:
10.0
),
borderRadius:
BorderRadius
.
circular
(
100.0
));
final
ContinuousRectangleBorder
c15
=
ContinuousRectangleBorder
(
side:
const
BorderSide
(
width:
15.0
),
borderRadius:
BorderRadius
.
circular
(
150.0
));
final
ContinuousRectangleBorder
c20
=
ContinuousRectangleBorder
(
side:
const
BorderSide
(
width:
20.0
),
borderRadius:
BorderRadius
.
circular
(
200.0
));
expect
(
c10
.
dimensions
,
const
EdgeInsets
.
all
(
10.0
));
expect
(
c10
.
scale
(
2.0
),
c20
);
expect
(
c20
.
scale
(
0.5
),
c10
);
...
...
@@ -22,7 +22,7 @@ void main() {
expect
(
ShapeBorder
.
lerp
(
c10
,
c20
,
1.0
),
c20
);
});
test
(
'
SuperellipseShape
BorderRadius.zero'
,
()
{
test
(
'
ContinuousRectangleBorder
BorderRadius.zero'
,
()
{
final
Rect
rect1
=
Rect
.
fromLTRB
(
10.0
,
20.0
,
30.0
,
40.0
);
final
Matcher
looksLikeRect1
=
isPathThat
(
includes:
const
<
Offset
>[
Offset
(
10.0
,
20.0
),
Offset
(
20.0
,
30.0
)
],
...
...
@@ -30,8 +30,8 @@ void main() {
);
// Default border radius and border side are zero, i.e. just a rectangle.
expect
(
const
SuperellipseShape
().
getOuterPath
(
rect1
),
looksLikeRect1
);
expect
(
const
SuperellipseShape
().
getInnerPath
(
rect1
),
looksLikeRect1
);
expect
(
const
ContinuousRectangleBorder
().
getOuterPath
(
rect1
),
looksLikeRect1
);
expect
(
const
ContinuousRectangleBorder
().
getInnerPath
(
rect1
),
looksLikeRect1
);
// Represents the inner path when borderSide.width = 4, which is just rect1
// inset by 4 on all sides.
...
...
@@ -41,17 +41,17 @@ void main() {
);
const
BorderSide
side
=
BorderSide
(
width:
4.0
);
expect
(
const
SuperellipseShape
(
side:
side
).
getOuterPath
(
rect1
),
looksLikeRect1
);
expect
(
const
SuperellipseShape
(
side:
side
).
getInnerPath
(
rect1
),
looksLikeInnerPath
);
expect
(
const
ContinuousRectangleBorder
(
side:
side
).
getOuterPath
(
rect1
),
looksLikeRect1
);
expect
(
const
ContinuousRectangleBorder
(
side:
side
).
getInnerPath
(
rect1
),
looksLikeInnerPath
);
});
test
(
'
SuperellipseShape
non-zero BorderRadius'
,
()
{
test
(
'
ContinuousRectangleBorder
non-zero BorderRadius'
,
()
{
final
Rect
rect
=
Rect
.
fromLTRB
(
10.0
,
20.0
,
30.0
,
40.0
);
final
Matcher
looksLikeRect
=
isPathThat
(
includes:
const
<
Offset
>[
Offset
(
15.0
,
25.0
),
Offset
(
20.0
,
30.0
)
],
excludes:
const
<
Offset
>[
Offset
(
10.0
,
20.0
),
Offset
(
30.0
,
40.0
)
],
);
const
SuperellipseShape
border
=
SuperellipseShape
(
const
ContinuousRectangleBorder
border
=
ContinuousRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
5.0
))
);
expect
(
border
.
getOuterPath
(
rect
),
looksLikeRect
);
...
...
@@ -62,7 +62,7 @@ void main() {
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Material
(
color:
Colors
.
blueAccent
[
400
],
shape:
SuperellipseShape
(
shape:
ContinuousRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
28.0
),
),
),
...
...
@@ -72,7 +72,7 @@ void main() {
await
expectLater
(
find
.
byType
(
RepaintBoundary
),
matchesGoldenFile
(
'
superellipse_shape
.golden_test_even_radii.png'
),
matchesGoldenFile
(
'
continuous_rectangle_border
.golden_test_even_radii.png'
),
skip:
!
Platform
.
isLinux
,
);
});
...
...
@@ -81,7 +81,7 @@ void main() {
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Material
(
color:
Colors
.
greenAccent
[
400
],
shape:
const
SuperellipseShape
(
shape:
const
ContinuousRectangleBorder
(
borderRadius:
BorderRadius
.
only
(
topLeft:
Radius
.
circular
(
28.0
),
bottomRight:
Radius
.
circular
(
14.0
),
...
...
@@ -94,7 +94,7 @@ void main() {
await
expectLater
(
find
.
byType
(
RepaintBoundary
),
matchesGoldenFile
(
'
superellipse_shape
.golden_test_varying_radii.png'
),
matchesGoldenFile
(
'
continuous_rectangle_border
.golden_test_varying_radii.png'
),
skip:
!
Platform
.
isLinux
,
);
});
...
...
@@ -103,7 +103,7 @@ void main() {
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Material
(
color:
Colors
.
redAccent
[
400
],
shape:
SuperellipseShape
(
shape:
ContinuousRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
50.0
),
),
),
...
...
@@ -113,7 +113,7 @@ void main() {
await
expectLater
(
find
.
byType
(
RepaintBoundary
),
matchesGoldenFile
(
'
superellipse_shape
.golden_test_large_radii.png'
),
matchesGoldenFile
(
'
continuous_rectangle_border
.golden_test_large_radii.png'
),
skip:
!
Platform
.
isLinux
,
);
});
...
...
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