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
Hide 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> {
children:
<
Widget
>[
Positioned
.
fromRect
(
rect:
sheetRect
,
child:
Opacity
(
opacity:
_sheetOpacity
.
value
,
child:
FadeTransition
(
opacity:
_sheetOpacity
,
child:
Transform
.
scale
(
alignment:
getSheetAlignment
(
_contextMenuLocation
),
scale:
sheetScale
,
...
...
@@ -1028,8 +1028,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
return
Transform
.
scale
(
alignment:
_ContextMenuRoute
.
getSheetAlignment
(
widget
.
contextMenuLocation
),
scale:
_sheetScaleAnimation
.
value
,
child:
Opacity
(
opacity:
_sheetOpacityAnimation
.
value
,
child:
FadeTransition
(
opacity:
_sheetOpacityAnimation
,
child:
child
,
),
);
...
...
packages/flutter/lib/src/material/data_table.dart
View file @
96a63cfe
...
...
@@ -1211,8 +1211,8 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin {
@override
Widget
build
(
BuildContext
context
)
{
return
Opacity
(
opacity:
_opacityAnimation
.
value
,
return
FadeTransition
(
opacity:
_opacityAnimation
,
child:
Transform
(
transform:
Matrix4
.
rotationZ
(
_orientationOffset
+
_orientationAnimation
.
value
)
..
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
assert
(
widget
.
helperText
!=
null
);
return
Semantics
(
container:
true
,
child:
Opacity
(
opacity:
1.0
-
_controller
.
value
,
child:
FadeTransition
(
opacity:
Tween
<
double
>(
begin:
1.0
,
end:
0.0
).
animate
(
_controller
)
,
child:
Text
(
widget
.
helperText
!,
style:
widget
.
helperStyle
,
...
...
@@ -391,8 +391,8 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
return
Semantics
(
container:
true
,
liveRegion:
true
,
child:
Opacity
(
opacity:
_controller
.
value
,
child:
FadeTransition
(
opacity:
_controller
,
child:
FractionalTranslation
(
translation:
Tween
<
Offset
>(
begin:
const
Offset
(
0.0
,
-
0.25
),
...
...
@@ -441,8 +441,8 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
if
(
widget
.
errorText
!=
null
)
{
return
Stack
(
children:
<
Widget
>[
Opacity
(
opacity:
1.0
-
_controller
.
value
,
FadeTransition
(
opacity:
Tween
<
double
>(
begin:
1.0
,
end:
0.0
).
animate
(
_controller
)
,
child:
_helper
,
),
_buildError
(),
...
...
@@ -454,8 +454,8 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
return
Stack
(
children:
<
Widget
>[
_buildHelper
(),
Opacity
(
opacity:
_controller
.
value
,
FadeTransition
(
opacity:
_controller
,
child:
_error
,
),
],
...
...
packages/flutter/lib/src/material/navigation_rail.dart
View file @
96a63cfe
...
...
@@ -573,6 +573,7 @@ class _RailDestination extends StatelessWidget {
),
);
}
else
{
final
Animation
<
double
>
labelFadeAnimation
=
extendedTransitionAnimation
.
drive
(
CurveTween
(
curve:
const
Interval
(
0.0
,
0.25
)));
content
=
Padding
(
padding:
padding
??
EdgeInsets
.
zero
,
child:
ConstrainedBox
(
...
...
@@ -587,9 +588,9 @@ class _RailDestination extends StatelessWidget {
heightFactor:
1.0
,
widthFactor:
extendedTransitionAnimation
.
value
,
alignment:
AlignmentDirectional
.
centerStart
,
child:
Opacity
(
child:
FadeTransition
(
alwaysIncludeSemantics:
true
,
opacity:
_extendedLabelFadeValue
()
,
opacity:
labelFadeAnimation
,
child:
styledLabel
,
),
),
...
...
@@ -604,6 +605,8 @@ class _RailDestination extends StatelessWidget {
case
NavigationRailLabelType
.
selected
:
final
double
appearingAnimationValue
=
1
-
_positionAnimation
.
value
;
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
(
constraints:
BoxConstraints
(
minWidth:
minWidth
,
...
...
@@ -621,9 +624,9 @@ class _RailDestination extends StatelessWidget {
alignment:
Alignment
.
topCenter
,
heightFactor:
appearingAnimationValue
,
widthFactor:
1.0
,
child:
Opacity
(
child:
FadeTransition
(
alwaysIncludeSemantics:
true
,
opacity:
selected
?
_normalLabelFadeInValue
()
:
_normalLabelFadeOutValue
()
,
opacity:
labelFadeAnimation
,
child:
styledLabel
,
),
),
...
...
@@ -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].
...
...
packages/flutter/lib/src/material/popup_menu.dart
View file @
96a63cfe
...
...
@@ -596,8 +596,8 @@ class _PopupMenu<T> extends StatelessWidget {
return
AnimatedBuilder
(
animation:
route
.
animation
!,
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Opacity
(
opacity:
opacity
.
evalu
ate
(
route
.
animation
!),
return
FadeTransition
(
opacity:
opacity
.
anim
ate
(
route
.
animation
!),
child:
Material
(
shape:
route
.
shape
??
popupMenuTheme
.
shape
,
color:
route
.
color
??
popupMenuTheme
.
color
,
...
...
packages/flutter/lib/src/widgets/heroes.dart
View file @
96a63cfe
...
...
@@ -547,8 +547,8 @@ class _HeroFlight {
left:
offsets
.
left
,
child:
IgnorePointer
(
child:
RepaintBoundary
(
child:
Opacity
(
opacity:
_heroOpacity
.
value
,
child:
FadeTransition
(
opacity:
_heroOpacity
,
child:
child
,
),
),
...
...
packages/flutter/test/cupertino/nav_bar_transition_test.dart
View file @
96a63cfe
...
...
@@ -117,7 +117,7 @@ void checkBackgroundBoxHeight(WidgetTester tester, double height) {
void
checkOpacity
(
WidgetTester
tester
,
Finder
finder
,
double
opacity
)
{
expect
(
tester
.
r
enderObject
<
RenderAnimatedOpacity
>(
tester
.
firstR
enderObject
<
RenderAnimatedOpacity
>(
find
.
ancestor
(
of:
finder
,
matching:
find
.
byType
(
FadeTransition
),
...
...
packages/flutter/test/material/navigation_rail_test.dart
View file @
96a63cfe
...
...
@@ -2331,14 +2331,23 @@ Finder _opacityAboveLabel(String text) {
}
// Only valid when labelType != all.
double
_labelOpacity
(
WidgetTester
tester
,
String
text
)
{
final
Opacity
opacityWidget
=
tester
.
widget
<
Opacity
>(
double
?
_labelOpacity
(
WidgetTester
tester
,
String
text
)
{
// We search for both Opacity and FadeTransition since in some
// cases opacity is animated, in other it's not.
final
Iterable
<
Opacity
>
opacityWidgets
=
tester
.
widgetList
<
Opacity
>(
find
.
ancestor
(
of:
find
.
text
(
text
),
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
(
Opacity
),
)
,
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
)
{
...
...
packages/flutter/test/widgets/heroes_test.dart
View file @
96a63cfe
...
...
@@ -1182,7 +1182,7 @@ Future<void> main() async {
bool
isVisible
=
true
;
node
.
visitAncestorElements
((
Element
ancestor
)
{
final
RenderObject
r
=
ancestor
.
renderObject
!;
if
(
r
is
Render
Opacity
&&
r
.
opacity
==
0
)
{
if
(
r
is
Render
AnimatedOpacity
&&
r
.
opacity
.
value
==
0
)
{
isVisible
=
false
;
return
false
;
}
...
...
@@ -2920,12 +2920,12 @@ Future<void> main() async {
final
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
<
NavigatorState
>();
final
ScrollController
controller
=
ScrollController
();
Render
Opacity
?
findRender
Opacity
()
{
Render
AnimatedOpacity
?
findRenderAnimated
Opacity
()
{
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
;
}
return
parent
is
RenderOpacity
?
parent
:
null
;
return
parent
is
Render
Animated
Opacity
?
parent
:
null
;
}
await
tester
.
pumpWidget
(
...
...
@@ -2977,14 +2977,14 @@ Future<void> main() async {
// Starts Hero animation and scroll animation almost simultaneously.
// Scroll to make the Hero invisible.
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,
// and starts fading.
await
tester
.
pump
();
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
();
// 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