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
96a63cfe
Unverified
Commit
96a63cfe
authored
Sep 29, 2021
by
nt4f04uNd
Committed by
GitHub
Sep 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use FadeTransition instead of Opacity where applicable (#75110)
parent
bac1af32
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
56 deletions
+46
-56
context_menu.dart
packages/flutter/lib/src/cupertino/context_menu.dart
+4
-4
data_table.dart
packages/flutter/lib/src/material/data_table.dart
+2
-2
input_decorator.dart
packages/flutter/lib/src/material/input_decorator.dart
+8
-8
navigation_rail.dart
packages/flutter/lib/src/material/navigation_rail.dart
+7
-26
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+2
-2
heroes.dart
packages/flutter/lib/src/widgets/heroes.dart
+2
-2
nav_bar_transition_test.dart
packages/flutter/test/cupertino/nav_bar_transition_test.dart
+1
-1
navigation_rail_test.dart
packages/flutter/test/material/navigation_rail_test.dart
+14
-5
heroes_test.dart
packages/flutter/test/widgets/heroes_test.dart
+6
-6
No files found.
packages/flutter/lib/src/cupertino/context_menu.dart
View file @
96a63cfe
...
@@ -758,8 +758,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
...
@@ -758,8 +758,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
children:
<
Widget
>[
children:
<
Widget
>[
Positioned
.
fromRect
(
Positioned
.
fromRect
(
rect:
sheetRect
,
rect:
sheetRect
,
child:
Opacity
(
child:
FadeTransition
(
opacity:
_sheetOpacity
.
value
,
opacity:
_sheetOpacity
,
child:
Transform
.
scale
(
child:
Transform
.
scale
(
alignment:
getSheetAlignment
(
_contextMenuLocation
),
alignment:
getSheetAlignment
(
_contextMenuLocation
),
scale:
sheetScale
,
scale:
sheetScale
,
...
@@ -1028,8 +1028,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
...
@@ -1028,8 +1028,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
return
Transform
.
scale
(
return
Transform
.
scale
(
alignment:
_ContextMenuRoute
.
getSheetAlignment
(
widget
.
contextMenuLocation
),
alignment:
_ContextMenuRoute
.
getSheetAlignment
(
widget
.
contextMenuLocation
),
scale:
_sheetScaleAnimation
.
value
,
scale:
_sheetScaleAnimation
.
value
,
child:
Opacity
(
child:
FadeTransition
(
opacity:
_sheetOpacityAnimation
.
value
,
opacity:
_sheetOpacityAnimation
,
child:
child
,
child:
child
,
),
),
);
);
...
...
packages/flutter/lib/src/material/data_table.dart
View file @
96a63cfe
...
@@ -1211,8 +1211,8 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin {
...
@@ -1211,8 +1211,8 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Opacity
(
return
FadeTransition
(
opacity:
_opacityAnimation
.
value
,
opacity:
_opacityAnimation
,
child:
Transform
(
child:
Transform
(
transform:
Matrix4
.
rotationZ
(
_orientationOffset
+
_orientationAnimation
.
value
)
transform:
Matrix4
.
rotationZ
(
_orientationOffset
+
_orientationAnimation
.
value
)
..
setTranslationRaw
(
0.0
,
_arrowIconBaselineOffset
,
0.0
),
..
setTranslationRaw
(
0.0
,
_arrowIconBaselineOffset
,
0.0
),
...
...
packages/flutter/lib/src/material/input_decorator.dart
View file @
96a63cfe
...
@@ -373,8 +373,8 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
...
@@ -373,8 +373,8 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
assert
(
widget
.
helperText
!=
null
);
assert
(
widget
.
helperText
!=
null
);
return
Semantics
(
return
Semantics
(
container:
true
,
container:
true
,
child:
Opacity
(
child:
FadeTransition
(
opacity:
1.0
-
_controller
.
value
,
opacity:
Tween
<
double
>(
begin:
1.0
,
end:
0.0
).
animate
(
_controller
)
,
child:
Text
(
child:
Text
(
widget
.
helperText
!,
widget
.
helperText
!,
style:
widget
.
helperStyle
,
style:
widget
.
helperStyle
,
...
@@ -391,8 +391,8 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
...
@@ -391,8 +391,8 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
return
Semantics
(
return
Semantics
(
container:
true
,
container:
true
,
liveRegion:
true
,
liveRegion:
true
,
child:
Opacity
(
child:
FadeTransition
(
opacity:
_controller
.
value
,
opacity:
_controller
,
child:
FractionalTranslation
(
child:
FractionalTranslation
(
translation:
Tween
<
Offset
>(
translation:
Tween
<
Offset
>(
begin:
const
Offset
(
0.0
,
-
0.25
),
begin:
const
Offset
(
0.0
,
-
0.25
),
...
@@ -441,8 +441,8 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
...
@@ -441,8 +441,8 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
if
(
widget
.
errorText
!=
null
)
{
if
(
widget
.
errorText
!=
null
)
{
return
Stack
(
return
Stack
(
children:
<
Widget
>[
children:
<
Widget
>[
Opacity
(
FadeTransition
(
opacity:
1.0
-
_controller
.
value
,
opacity:
Tween
<
double
>(
begin:
1.0
,
end:
0.0
).
animate
(
_controller
)
,
child:
_helper
,
child:
_helper
,
),
),
_buildError
(),
_buildError
(),
...
@@ -454,8 +454,8 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
...
@@ -454,8 +454,8 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
return
Stack
(
return
Stack
(
children:
<
Widget
>[
children:
<
Widget
>[
_buildHelper
(),
_buildHelper
(),
Opacity
(
FadeTransition
(
opacity:
_controller
.
value
,
opacity:
_controller
,
child:
_error
,
child:
_error
,
),
),
],
],
...
...
packages/flutter/lib/src/material/navigation_rail.dart
View file @
96a63cfe
...
@@ -573,6 +573,7 @@ class _RailDestination extends StatelessWidget {
...
@@ -573,6 +573,7 @@ class _RailDestination extends StatelessWidget {
),
),
);
);
}
else
{
}
else
{
final
Animation
<
double
>
labelFadeAnimation
=
extendedTransitionAnimation
.
drive
(
CurveTween
(
curve:
const
Interval
(
0.0
,
0.25
)));
content
=
Padding
(
content
=
Padding
(
padding:
padding
??
EdgeInsets
.
zero
,
padding:
padding
??
EdgeInsets
.
zero
,
child:
ConstrainedBox
(
child:
ConstrainedBox
(
...
@@ -587,9 +588,9 @@ class _RailDestination extends StatelessWidget {
...
@@ -587,9 +588,9 @@ class _RailDestination extends StatelessWidget {
heightFactor:
1.0
,
heightFactor:
1.0
,
widthFactor:
extendedTransitionAnimation
.
value
,
widthFactor:
extendedTransitionAnimation
.
value
,
alignment:
AlignmentDirectional
.
centerStart
,
alignment:
AlignmentDirectional
.
centerStart
,
child:
Opacity
(
child:
FadeTransition
(
alwaysIncludeSemantics:
true
,
alwaysIncludeSemantics:
true
,
opacity:
_extendedLabelFadeValue
()
,
opacity:
labelFadeAnimation
,
child:
styledLabel
,
child:
styledLabel
,
),
),
),
),
...
@@ -604,6 +605,8 @@ class _RailDestination extends StatelessWidget {
...
@@ -604,6 +605,8 @@ class _RailDestination extends StatelessWidget {
case
NavigationRailLabelType
.
selected
:
case
NavigationRailLabelType
.
selected
:
final
double
appearingAnimationValue
=
1
-
_positionAnimation
.
value
;
final
double
appearingAnimationValue
=
1
-
_positionAnimation
.
value
;
final
double
verticalPadding
=
lerpDouble
(
_verticalDestinationPaddingNoLabel
,
_verticalDestinationPaddingWithLabel
,
appearingAnimationValue
)!;
final
double
verticalPadding
=
lerpDouble
(
_verticalDestinationPaddingNoLabel
,
_verticalDestinationPaddingWithLabel
,
appearingAnimationValue
)!;
final
Interval
interval
=
selected
?
const
Interval
(
0.25
,
0.75
)
:
const
Interval
(
0.75
,
1.0
);
final
Animation
<
double
>
labelFadeAnimation
=
destinationAnimation
.
drive
(
CurveTween
(
curve:
interval
));
content
=
Container
(
content
=
Container
(
constraints:
BoxConstraints
(
constraints:
BoxConstraints
(
minWidth:
minWidth
,
minWidth:
minWidth
,
...
@@ -621,9 +624,9 @@ class _RailDestination extends StatelessWidget {
...
@@ -621,9 +624,9 @@ class _RailDestination extends StatelessWidget {
alignment:
Alignment
.
topCenter
,
alignment:
Alignment
.
topCenter
,
heightFactor:
appearingAnimationValue
,
heightFactor:
appearingAnimationValue
,
widthFactor:
1.0
,
widthFactor:
1.0
,
child:
Opacity
(
child:
FadeTransition
(
alwaysIncludeSemantics:
true
,
alwaysIncludeSemantics:
true
,
opacity:
selected
?
_normalLabelFadeInValue
()
:
_normalLabelFadeOutValue
()
,
opacity:
labelFadeAnimation
,
child:
styledLabel
,
child:
styledLabel
,
),
),
),
),
...
@@ -679,28 +682,6 @@ class _RailDestination extends StatelessWidget {
...
@@ -679,28 +682,6 @@ class _RailDestination extends StatelessWidget {
),
),
);
);
}
}
double
_normalLabelFadeInValue
()
{
if
(
destinationAnimation
.
value
<
0.25
)
{
return
0
;
}
else
if
(
destinationAnimation
.
value
<
0.75
)
{
return
(
destinationAnimation
.
value
-
0.25
)
*
2
;
}
else
{
return
1
;
}
}
double
_normalLabelFadeOutValue
()
{
if
(
destinationAnimation
.
value
>
0.75
)
{
return
(
destinationAnimation
.
value
-
0.75
)
*
4.0
;
}
else
{
return
0
;
}
}
double
_extendedLabelFadeValue
()
{
return
extendedTransitionAnimation
.
value
<
0.25
?
extendedTransitionAnimation
.
value
*
4.0
:
1.0
;
}
}
}
/// Defines the behavior of the labels of a [NavigationRail].
/// Defines the behavior of the labels of a [NavigationRail].
...
...
packages/flutter/lib/src/material/popup_menu.dart
View file @
96a63cfe
...
@@ -596,8 +596,8 @@ class _PopupMenu<T> extends StatelessWidget {
...
@@ -596,8 +596,8 @@ class _PopupMenu<T> extends StatelessWidget {
return
AnimatedBuilder
(
return
AnimatedBuilder
(
animation:
route
.
animation
!,
animation:
route
.
animation
!,
builder:
(
BuildContext
context
,
Widget
?
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Opacity
(
return
FadeTransition
(
opacity:
opacity
.
evalu
ate
(
route
.
animation
!),
opacity:
opacity
.
anim
ate
(
route
.
animation
!),
child:
Material
(
child:
Material
(
shape:
route
.
shape
??
popupMenuTheme
.
shape
,
shape:
route
.
shape
??
popupMenuTheme
.
shape
,
color:
route
.
color
??
popupMenuTheme
.
color
,
color:
route
.
color
??
popupMenuTheme
.
color
,
...
...
packages/flutter/lib/src/widgets/heroes.dart
View file @
96a63cfe
...
@@ -547,8 +547,8 @@ class _HeroFlight {
...
@@ -547,8 +547,8 @@ class _HeroFlight {
left:
offsets
.
left
,
left:
offsets
.
left
,
child:
IgnorePointer
(
child:
IgnorePointer
(
child:
RepaintBoundary
(
child:
RepaintBoundary
(
child:
Opacity
(
child:
FadeTransition
(
opacity:
_heroOpacity
.
value
,
opacity:
_heroOpacity
,
child:
child
,
child:
child
,
),
),
),
),
...
...
packages/flutter/test/cupertino/nav_bar_transition_test.dart
View file @
96a63cfe
...
@@ -117,7 +117,7 @@ void checkBackgroundBoxHeight(WidgetTester tester, double height) {
...
@@ -117,7 +117,7 @@ void checkBackgroundBoxHeight(WidgetTester tester, double height) {
void
checkOpacity
(
WidgetTester
tester
,
Finder
finder
,
double
opacity
)
{
void
checkOpacity
(
WidgetTester
tester
,
Finder
finder
,
double
opacity
)
{
expect
(
expect
(
tester
.
r
enderObject
<
RenderAnimatedOpacity
>(
tester
.
firstR
enderObject
<
RenderAnimatedOpacity
>(
find
.
ancestor
(
find
.
ancestor
(
of:
finder
,
of:
finder
,
matching:
find
.
byType
(
FadeTransition
),
matching:
find
.
byType
(
FadeTransition
),
...
...
packages/flutter/test/material/navigation_rail_test.dart
View file @
96a63cfe
...
@@ -2331,14 +2331,23 @@ Finder _opacityAboveLabel(String text) {
...
@@ -2331,14 +2331,23 @@ Finder _opacityAboveLabel(String text) {
}
}
// Only valid when labelType != all.
// Only valid when labelType != all.
double
_labelOpacity
(
WidgetTester
tester
,
String
text
)
{
double
?
_labelOpacity
(
WidgetTester
tester
,
String
text
)
{
final
Opacity
opacityWidget
=
tester
.
widget
<
Opacity
>(
// We search for both Opacity and FadeTransition since in some
find
.
ancestor
(
// cases opacity is animated, in other it's not.
final
Iterable
<
Opacity
>
opacityWidgets
=
tester
.
widgetList
<
Opacity
>(
find
.
ancestor
(
of:
find
.
text
(
text
),
of:
find
.
text
(
text
),
matching:
find
.
byType
(
Opacity
),
matching:
find
.
byType
(
Opacity
),
),
));
if
(
opacityWidgets
.
isNotEmpty
)
return
opacityWidgets
.
single
.
opacity
;
final
FadeTransition
fadeTransitionWidget
=
tester
.
widget
<
FadeTransition
>(
find
.
ancestor
(
of:
find
.
text
(
text
),
matching:
find
.
byType
(
FadeTransition
),
).
first
,
// first because there's also a FadeTransition from the MaterialPageRoute, which is up the tree
);
);
return
opacityWidget
.
opacity
;
return
fadeTransitionWidget
.
opacity
.
value
;
}
}
Material
_railMaterial
(
WidgetTester
tester
)
{
Material
_railMaterial
(
WidgetTester
tester
)
{
...
...
packages/flutter/test/widgets/heroes_test.dart
View file @
96a63cfe
...
@@ -1182,7 +1182,7 @@ Future<void> main() async {
...
@@ -1182,7 +1182,7 @@ Future<void> main() async {
bool
isVisible
=
true
;
bool
isVisible
=
true
;
node
.
visitAncestorElements
((
Element
ancestor
)
{
node
.
visitAncestorElements
((
Element
ancestor
)
{
final
RenderObject
r
=
ancestor
.
renderObject
!;
final
RenderObject
r
=
ancestor
.
renderObject
!;
if
(
r
is
Render
Opacity
&&
r
.
opacity
==
0
)
{
if
(
r
is
Render
AnimatedOpacity
&&
r
.
opacity
.
value
==
0
)
{
isVisible
=
false
;
isVisible
=
false
;
return
false
;
return
false
;
}
}
...
@@ -2920,12 +2920,12 @@ Future<void> main() async {
...
@@ -2920,12 +2920,12 @@ Future<void> main() async {
final
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
<
NavigatorState
>();
final
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
<
NavigatorState
>();
final
ScrollController
controller
=
ScrollController
();
final
ScrollController
controller
=
ScrollController
();
Render
Opacity
?
findRender
Opacity
()
{
Render
AnimatedOpacity
?
findRenderAnimated
Opacity
()
{
AbstractNode
?
parent
=
tester
.
renderObject
(
find
.
byType
(
Placeholder
));
AbstractNode
?
parent
=
tester
.
renderObject
(
find
.
byType
(
Placeholder
));
while
(
parent
is
RenderObject
&&
parent
is
!
RenderOpacity
)
{
while
(
parent
is
RenderObject
&&
parent
is
!
Render
Animated
Opacity
)
{
parent
=
parent
.
parent
;
parent
=
parent
.
parent
;
}
}
return
parent
is
RenderOpacity
?
parent
:
null
;
return
parent
is
Render
Animated
Opacity
?
parent
:
null
;
}
}
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -2977,14 +2977,14 @@ Future<void> main() async {
...
@@ -2977,14 +2977,14 @@ Future<void> main() async {
// Starts Hero animation and scroll animation almost simultaneously.
// Starts Hero animation and scroll animation almost simultaneously.
// Scroll to make the Hero invisible.
// Scroll to make the Hero invisible.
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
findRender
Opacity
()?.
opacity
,
anyOf
(
isNull
,
1.0
));
expect
(
findRender
AnimatedOpacity
()?.
opacity
.
value
,
anyOf
(
isNull
,
1.0
));
// In this frame the Hero animation finds out the toHero is not paintable,
// In this frame the Hero animation finds out the toHero is not paintable,
// and starts fading.
// and starts fading.
await
tester
.
pump
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
findRender
Opacity
()?.
opacity
,
lessThan
(
1.0
));
expect
(
findRender
AnimatedOpacity
()?.
opacity
.
value
,
lessThan
(
1.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
// The Hero on the new route should be invisible.
// The Hero on the new route should be invisible.
...
...
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