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
e1ac331b
Commit
e1ac331b
authored
Mar 29, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2972 from Hixie/implicit-opacity
AnimatedOpacity
parents
d312c9dc
962a33f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
3 deletions
+82
-3
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+11
-3
implicit_animations.dart
packages/flutter/lib/src/widgets/implicit_animations.dart
+71
-0
No files found.
packages/flutter/lib/src/widgets/basic.dart
View file @
e1ac331b
...
...
@@ -55,18 +55,26 @@ export 'package:flutter/rendering.dart' show
/// This class paints its child into an intermediate buffer and then blends the
/// child back into the scene partially transparent.
///
/// This class is relatively expensive because it requires painting the child
/// into an intermediate buffer.
/// For values of opacity other than 0.0 and 1.0, this class is relatively
/// expensive because it requires painting the child into an intermediate
/// buffer. For the value 0.0, the child is simply not painted at all. For the
/// value 1.0, the child is painted immediately without an intermediate buffer.
class
Opacity
extends
SingleChildRenderObjectWidget
{
Opacity
({
Key
key
,
this
.
opacity
,
Widget
child
})
:
super
(
key:
key
,
child:
child
)
{
assert
(
opacity
>=
0.0
&&
opacity
<=
1.0
);
assert
(
opacity
!=
null
&&
opacity
>=
0.0
&&
opacity
<=
1.0
);
}
/// The fraction to scale the child's alpha value.
///
/// An opacity of 1.0 is fully opaque. An opacity of 0.0 is fully transparent
/// (i.e., invisible).
///
/// The opacity must not be null.
///
/// Values 1.0 and 0.0 are painted with a fast path. Other values
/// require painting the child into an intermediate buffer, which is
/// expensive.
final
double
opacity
;
@override
...
...
packages/flutter/lib/src/widgets/implicit_animations.dart
View file @
e1ac331b
...
...
@@ -382,6 +382,23 @@ class AnimatedPositioned extends ImplicitlyAnimatedWidget {
@override
_AnimatedPositionedState
createState
()
=>
new
_AnimatedPositionedState
();
@override
void
debugFillDescription
(
List
<
String
>
description
)
{
super
.
debugFillDescription
(
description
);
if
(
left
!=
null
)
description
.
add
(
'left:
$left
'
);
if
(
top
!=
null
)
description
.
add
(
'top:
$top
'
);
if
(
right
!=
null
)
description
.
add
(
'right:
$right
'
);
if
(
bottom
!=
null
)
description
.
add
(
'bottom:
$bottom
'
);
if
(
width
!=
null
)
description
.
add
(
'width:
$width
'
);
if
(
height
!=
null
)
description
.
add
(
'height:
$height
'
);
}
}
class
_AnimatedPositionedState
extends
AnimatedWidgetBaseState
<
AnimatedPositioned
>
{
...
...
@@ -433,3 +450,57 @@ class _AnimatedPositionedState extends AnimatedWidgetBaseState<AnimatedPositione
description
.
add
(
'has height'
);
}
}
/// Animated version of [Opacity] which automatically transitions the child's
/// opacity over a given duration whenever the given opacity changes.
///
/// Animating an opacity is relatively expensive.
class
AnimatedOpacity
extends
ImplicitlyAnimatedWidget
{
AnimatedOpacity
({
Key
key
,
this
.
child
,
this
.
opacity
,
Curve
curve:
Curves
.
linear
,
Duration
duration
})
:
super
(
key:
key
,
curve:
curve
,
duration:
duration
)
{
assert
(
opacity
!=
null
&&
opacity
>=
0.0
&&
opacity
<=
1.0
);
}
/// The widget below this widget in the tree.
final
Widget
child
;
/// The target opacity.
///
/// An opacity of 1.0 is fully opaque. An opacity of 0.0 is fully transparent
/// (i.e., invisible).
///
/// The opacity must not be null.
final
double
opacity
;
@override
_AnimatedOpacityState
createState
()
=>
new
_AnimatedOpacityState
();
@override
void
debugFillDescription
(
List
<
String
>
description
)
{
super
.
debugFillDescription
(
description
);
description
.
add
(
'opacity:
$opacity
'
);
}
}
class
_AnimatedOpacityState
extends
AnimatedWidgetBaseState
<
AnimatedOpacity
>
{
Tween
<
double
>
_opacity
;
@override
void
forEachTween
(
TweenVisitor
<
dynamic
>
visitor
)
{
// TODO(ianh): Use constructor tear-offs when it becomes possible
_opacity
=
visitor
(
_opacity
,
config
.
opacity
,
(
dynamic
value
)
=>
new
Tween
<
double
>(
begin:
value
));
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Opacity
(
opacity:
_opacity
.
evaluate
(
animation
),
child:
config
.
child
);
}
}
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