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
42a81223
Unverified
Commit
42a81223
authored
Jan 26, 2022
by
Amir Panahandeh
Committed by
GitHub
Jan 26, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mirror before scaling in _AnimatedIconPainter (#93312)
parent
32122480
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
9 deletions
+56
-9
AUTHORS
AUTHORS
+1
-0
animated_icons.dart
...utter/lib/src/material/animated_icons/animated_icons.dart
+1
-1
animated_icons_test.dart
packages/flutter/test/material/animated_icons_test.dart
+53
-7
animated_icons_private_test.dart.tmpl
...r/test_private/test/animated_icons_private_test.dart.tmpl
+1
-1
No files found.
AUTHORS
View file @
42a81223
...
...
@@ -91,3 +91,4 @@ Denis Grafov <grafov.denis@gmail.com>
TheOneWithTheBraid <the-one@with-the-braid.cf>
Alberto Miola <betoman96@gmail.com>
Twin Sun, LLC <google-contrib@twinsunsolutions.com>
Taskulu LDA <contributions@taskulu.com>
packages/flutter/lib/src/material/animated_icons/animated_icons.dart
View file @
42a81223
...
...
@@ -156,11 +156,11 @@ class _AnimatedIconPainter extends CustomPainter {
void
paint
(
ui
.
Canvas
canvas
,
Size
size
)
{
// The RenderCustomPaint render object performs canvas.save before invoking
// this and canvas.restore after, so we don't need to do it here.
canvas
.
scale
(
scale
,
scale
);
if
(
shouldMirror
)
{
canvas
.
rotate
(
math
.
pi
);
canvas
.
translate
(-
size
.
width
,
-
size
.
height
);
}
canvas
.
scale
(
scale
,
scale
);
final
double
clampedProgress
=
progress
.
value
.
clamp
(
0.0
,
1.0
);
for
(
final
_PathFrames
path
in
paths
)
...
...
packages/flutter/test/material/animated_icons_test.dart
View file @
42a81223
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@Tags
(<
String
>[
'reduced-test-set'
])
import
'dart:math'
as
math
show
pi
;
import
'package:flutter/material.dart'
;
...
...
@@ -26,6 +28,7 @@ class MockCanvas extends Fake implements Canvas {
void
scale
(
double
sx
,
[
double
?
sy
])
{
capturedSx
=
sx
;
capturedSy
=
sy
!;
invocations
.
add
(
RecordedScale
(
sx
,
sy
));
}
final
List
<
RecordedCanvasCall
>
invocations
=
<
RecordedCanvasCall
>[];
...
...
@@ -75,6 +78,21 @@ class RecordedTranslate extends RecordedCanvasCall {
int
get
hashCode
=>
hashValues
(
dx
,
dy
);
}
class
RecordedScale
extends
RecordedCanvasCall
{
const
RecordedScale
(
this
.
sx
,
this
.
sy
);
final
double
sx
;
final
double
sy
;
@override
bool
operator
==(
Object
other
)
{
return
other
is
RecordedScale
&&
other
.
sx
==
sx
&&
other
.
sy
==
sy
;
}
@override
int
get
hashCode
=>
hashValues
(
sx
,
sy
);
}
void
main
(
)
{
testWidgets
(
'IconTheme color'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
...
...
@@ -218,12 +236,14 @@ void main() {
data:
IconThemeData
(
color:
Color
(
0xFF666666
),
),
child:
RepaintBoundary
(
child:
AnimatedIcon
(
progress:
AlwaysStoppedAnimation
<
double
>(
0.0
),
icon:
AnimatedIcons
.
arrow_menu
,
),
),
),
),
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
...
...
@@ -231,7 +251,10 @@ void main() {
expect
(
canvas
.
invocations
,
const
<
RecordedCanvasCall
>[
RecordedRotate
(
math
.
pi
),
RecordedTranslate
(-
48
,
-
48
),
RecordedScale
(
0.5
,
0.5
),
]);
await
expectLater
(
find
.
byType
(
AnimatedIcon
),
matchesGoldenFile
(
'animated_icons_test.icon.rtl.png'
));
});
testWidgets
(
'Inherited text direction ltr'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -242,17 +265,23 @@ void main() {
data:
IconThemeData
(
color:
Color
(
0xFF666666
),
),
child:
RepaintBoundary
(
child:
AnimatedIcon
(
progress:
AlwaysStoppedAnimation
<
double
>(
0.0
),
icon:
AnimatedIcons
.
arrow_menu
,
),
),
),
),
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
!.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
invocations
,
isEmpty
);
expect
(
canvas
.
invocations
,
const
<
RecordedCanvasCall
>[
RecordedScale
(
0.5
,
0.5
),
]);
await
expectLater
(
find
.
byType
(
AnimatedIcon
),
matchesGoldenFile
(
'animated_icons_test.icon.ltr.png'
));
});
testWidgets
(
'Inherited text direction overridden'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -277,8 +306,25 @@ void main() {
expect
(
canvas
.
invocations
,
const
<
RecordedCanvasCall
>[
RecordedRotate
(
math
.
pi
),
RecordedTranslate
(-
48
,
-
48
),
RecordedScale
(
0.5
,
0.5
),
]);
});
testWidgets
(
'Direction has no effect on position of widget'
,
(
WidgetTester
tester
)
async
{
const
AnimatedIcon
icon
=
AnimatedIcon
(
progress:
AlwaysStoppedAnimation
<
double
>(
0.0
),
icon:
AnimatedIcons
.
arrow_menu
,
);
await
tester
.
pumpWidget
(
const
Directionality
(
textDirection:
TextDirection
.
rtl
,
child:
icon
),
);
final
Rect
rtlRect
=
tester
.
getRect
(
find
.
byType
(
AnimatedIcon
));
await
tester
.
pumpWidget
(
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
icon
),
);
final
Rect
ltrRect
=
tester
.
getRect
(
find
.
byType
(
AnimatedIcon
));
expect
(
rtlRect
,
ltrRect
);
});
}
PaintColorMatcher
hasColor
(
int
color
)
{
...
...
packages/flutter/test_private/test/animated_icons_private_test.dart.tmpl
View file @
42a81223
...
...
@@ -187,9 +187,9 @@ void main() {
);
painter.paint(mockCanvas, size);
mockCanvas.verifyCallsInOrder(<MockCall>[
MockCall('scale', <dynamic>[1.0, 1.0]),
MockCall('rotate', <dynamic>[math.pi]),
MockCall('translate', <dynamic>[-48.0, -48.0]),
MockCall('scale', <dynamic>[1.0, 1.0]),
MockCall.any('drawPath'),
]);
});
...
...
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