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
d0c95608
Commit
d0c95608
authored
Oct 03, 2018
by
Philip
Committed by
Jonah Williams
Oct 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make RotationTransition widget alignment configurable (#22535)
parent
07fc9f64
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletion
+61
-1
transitions.dart
packages/flutter/lib/src/widgets/transitions.dart
+9
-1
transitions_test.dart
packages/flutter/test/widgets/transitions_test.dart
+52
-0
No files found.
packages/flutter/lib/src/widgets/transitions.dart
View file @
d0c95608
...
...
@@ -254,6 +254,7 @@ class RotationTransition extends AnimatedWidget {
const
RotationTransition
({
Key
key
,
@required
Animation
<
double
>
turns
,
this
.
alignment
=
Alignment
.
center
,
this
.
child
,
})
:
super
(
key:
key
,
listenable:
turns
);
...
...
@@ -263,6 +264,13 @@ class RotationTransition extends AnimatedWidget {
/// rotated v * 2 * pi radians before being painted.
Animation
<
double
>
get
turns
=>
listenable
;
/// The alignment of the origin of the coordinate system around which the
/// rotation occurs, relative to the size of the box.
///
/// For example, to set the origin of the rotation to top right corner, use
/// an alignment of (1.0, -1.0) or use [Alignment.topRight]
final
Alignment
alignment
;
/// The widget below this widget in the tree.
///
/// {@macro flutter.widgets.child}
...
...
@@ -274,7 +282,7 @@ class RotationTransition extends AnimatedWidget {
final
Matrix4
transform
=
Matrix4
.
rotationZ
(
turnsValue
*
math
.
pi
*
2.0
);
return
Transform
(
transform:
transform
,
alignment:
Alignment
.
center
,
alignment:
alignment
,
child:
child
,
);
}
...
...
packages/flutter/test/widgets/transitions_test.dart
View file @
d0c95608
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:math'
as
math
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
@@ -253,4 +255,54 @@ void main() {
await
tester
.
pump
();
expect
(
actualPositionedBox
.
widthFactor
,
1.0
);
});
testWidgets
(
'RotationTransition animates'
,
(
WidgetTester
tester
)
async
{
final
AnimationController
controller
=
new
AnimationController
(
vsync:
const
TestVSync
());
final
Widget
widget
=
new
RotationTransition
(
alignment:
Alignment
.
topRight
,
turns:
controller
,
child:
const
Text
(
'Rotation'
,
textDirection:
TextDirection
.
ltr
),
);
await
tester
.
pumpWidget
(
widget
);
Transform
actualRotatedBox
=
tester
.
widget
(
find
.
byType
(
Transform
));
Matrix4
actualTurns
=
actualRotatedBox
.
transform
;
expect
(
actualTurns
,
equals
(
Matrix4
.
rotationZ
(
0.0
)));
controller
.
value
=
0.5
;
await
tester
.
pump
();
actualRotatedBox
=
tester
.
widget
(
find
.
byType
(
Transform
));
actualTurns
=
actualRotatedBox
.
transform
;
expect
(
actualTurns
,
Matrix4
.
rotationZ
(
math
.
pi
));
controller
.
value
=
0.75
;
await
tester
.
pump
();
actualRotatedBox
=
tester
.
widget
(
find
.
byType
(
Transform
));
actualTurns
=
actualRotatedBox
.
transform
;
expect
(
actualTurns
,
Matrix4
.
rotationZ
(
math
.
pi
*
1.5
));
});
testWidgets
(
'RotationTransition maintains chosen alignment during animation'
,
(
WidgetTester
tester
)
async
{
final
AnimationController
controller
=
new
AnimationController
(
vsync:
const
TestVSync
());
final
Widget
widget
=
new
RotationTransition
(
alignment:
Alignment
.
topRight
,
turns:
controller
,
child:
const
Text
(
'Rotation'
,
textDirection:
TextDirection
.
ltr
),
);
await
tester
.
pumpWidget
(
widget
);
RotationTransition
actualRotatedBox
=
tester
.
widget
(
find
.
byType
(
RotationTransition
));
Alignment
actualAlignment
=
actualRotatedBox
.
alignment
;
expect
(
actualAlignment
,
const
Alignment
(
1.0
,
-
1.0
));
controller
.
value
=
0.5
;
await
tester
.
pump
();
actualRotatedBox
=
tester
.
widget
(
find
.
byType
(
RotationTransition
));
actualAlignment
=
actualRotatedBox
.
alignment
;
expect
(
actualAlignment
,
const
Alignment
(
1.0
,
-
1.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