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
50937d1f
Commit
50937d1f
authored
Jan 20, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1306 from abarth/port_examples
Port examples to the new animation API
parents
477530f3
fc978c1a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
95 additions
and
95 deletions
+95
-95
page_selector_demo.dart
examples/material_gallery/lib/demo/page_selector_demo.dart
+7
-7
progress_indicator.dart
examples/widgets/progress_indicator.dart
+1
-1
smooth_resize.dart
examples/widgets/smooth_resize.dart
+21
-22
tween.dart
packages/flutter/lib/src/animation/tween.dart
+7
-9
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+45
-42
enter_exit_transition.dart
packages/flutter/lib/src/widgets/enter_exit_transition.dart
+14
-14
No files found.
examples/material_gallery/lib/demo/page_selector_demo.dart
View file @
50937d1f
...
@@ -12,21 +12,21 @@ final List<String> _iconNames = <String>["event", "home", "android", "alarm", "f
...
@@ -12,21 +12,21 @@ final List<String> _iconNames = <String>["event", "home", "android", "alarm", "f
class
TabViewDemo
extends
StatelessComponent
{
class
TabViewDemo
extends
StatelessComponent
{
Widget
_buildTabIndicator
(
BuildContext
context
,
String
iconName
)
{
Widget
_buildTabIndicator
(
BuildContext
context
,
String
iconName
)
{
final
Color
color
=
Theme
.
of
(
context
).
primaryColor
;
final
Color
color
=
Theme
.
of
(
context
).
primaryColor
;
final
AnimatedColorValue
_selectedColor
=
new
AnimatedColorValue
(
Colors
.
transparent
,
end:
color
,
curve:
Curves
.
ease
);
final
ColorTween
_selectedColor
=
new
ColorTween
(
begin:
Colors
.
transparent
,
end:
color
);
final
AnimatedColorValue
_previousColor
=
new
AnimatedColorValue
(
color
,
end:
Colors
.
transparent
,
curve:
Curves
.
ease
);
final
ColorTween
_previousColor
=
new
ColorTween
(
begin:
color
,
end:
Colors
.
transparent
);
final
TabBarSelectionState
selection
=
TabBarSelection
.
of
(
context
);
final
TabBarSelectionState
selection
=
TabBarSelection
.
of
(
context
);
return
new
BuilderTransition
(
Animation
animation
=
new
CurvedAnimation
(
parent:
selection
.
animation
,
curve:
Curves
.
ease
);
performance:
selection
.
performance
,
return
new
AnimationWatchingBuilder
(
variables:
<
AnimatedColorValue
>[
_selectedColor
,
_previousColor
]
,
watchable:
animation
,
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
Color
background
=
selection
.
value
==
iconName
?
_selectedColor
.
end
:
_selectedColor
.
begin
;
Color
background
=
selection
.
value
==
iconName
?
_selectedColor
.
end
:
_selectedColor
.
begin
;
if
(
selection
.
valueIsChanging
)
{
if
(
selection
.
valueIsChanging
)
{
// Then the selection's performance is animating from previousValue to value.
// Then the selection's performance is animating from previousValue to value.
if
(
selection
.
value
==
iconName
)
if
(
selection
.
value
==
iconName
)
background
=
_selectedColor
.
value
;
background
=
_selectedColor
.
evaluate
(
animation
)
;
else
if
(
selection
.
previousValue
==
iconName
)
else
if
(
selection
.
previousValue
==
iconName
)
background
=
_previousColor
.
value
;
background
=
_previousColor
.
evaluate
(
animation
)
;
}
}
return
new
Container
(
return
new
Container
(
width:
12.0
,
width:
12.0
,
...
...
examples/widgets/progress_indicator.dart
View file @
50937d1f
...
@@ -16,7 +16,7 @@ class _ProgressIndicatorAppState extends State<ProgressIndicatorApp> {
...
@@ -16,7 +16,7 @@ class _ProgressIndicatorAppState extends State<ProgressIndicatorApp> {
duration:
const
Duration
(
milliseconds:
1500
)
duration:
const
Duration
(
milliseconds:
1500
)
)..
play
(
AnimationDirection
.
forward
);
)..
play
(
AnimationDirection
.
forward
);
animation
=
new
ACurve
(
animation
=
new
CurvedAnimation
(
parent:
controller
,
parent:
controller
,
curve:
new
Interval
(
0.0
,
0.9
,
curve:
Curves
.
ease
),
curve:
new
Interval
(
0.0
,
0.9
,
curve:
Curves
.
ease
),
reverseCurve:
Curves
.
ease
reverseCurve:
Curves
.
ease
...
...
examples/widgets/smooth_resize.dart
View file @
50937d1f
...
@@ -26,29 +26,28 @@ class SmoothBlock extends StatefulComponent {
...
@@ -26,29 +26,28 @@ class SmoothBlock extends StatefulComponent {
class
CardTransition
extends
StatelessComponent
{
class
CardTransition
extends
StatelessComponent
{
CardTransition
({
CardTransition
({
this
.
child
,
this
.
child
,
this
.
performance
,
this
.
animation
,
this
.
x
,
this
.
x
,
this
.
opacity
,
this
.
opacity
,
this
.
scale
this
.
scale
});
});
final
Widget
child
;
final
Widget
child
;
final
Performance
performance
;
final
Animation
animation
;
final
AnimatedValu
e
<
double
>
x
;
final
Evaluatabl
e
<
double
>
x
;
final
AnimatedValu
e
<
double
>
opacity
;
final
Evaluatabl
e
<
double
>
opacity
;
final
AnimatedValu
e
<
double
>
scale
;
final
Evaluatabl
e
<
double
>
scale
;
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
new
AnimationWatchingBuilder
(
return
new
BuilderTransition
(
watchable:
animation
,
performance:
performance
,
variables:
<
AnimatedValue
<
double
>>[
x
,
opacity
,
scale
],
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
double
currentScale
=
scale
.
evaluate
(
animation
);
Matrix4
transform
=
new
Matrix4
.
identity
()
Matrix4
transform
=
new
Matrix4
.
identity
()
..
translate
(
x
.
value
)
..
translate
(
x
.
evaluate
(
animation
)
)
..
scale
(
scale
.
value
,
scale
.
valu
e
);
..
scale
(
currentScale
,
currentScal
e
);
return
new
Opacity
(
return
new
Opacity
(
opacity:
opacity
.
value
,
opacity:
opacity
.
evaluate
(
animation
)
,
child:
new
Transform
(
child:
new
Transform
(
transform:
transform
,
transform:
transform
,
child:
child
child:
child
...
@@ -63,22 +62,22 @@ class SmoothBlockState extends State<SmoothBlock> {
...
@@ -63,22 +62,22 @@ class SmoothBlockState extends State<SmoothBlock> {
double
_height
=
100.0
;
double
_height
=
100.0
;
Widget
_handleEnter
(
PerformanceView
performance
,
Widget
child
)
{
Widget
_handleEnter
(
Animation
animation
,
Widget
child
)
{
return
new
CardTransition
(
return
new
CardTransition
(
x:
new
AnimatedValue
<
double
>(-
200.0
,
end:
0.0
,
curve:
Curves
.
ease
),
x:
new
Tween
<
double
>(
begin:
-
200.0
,
end:
0.0
),
opacity:
new
AnimatedValue
<
double
>(
0.0
,
end:
1.0
,
curve:
Curves
.
ease
),
opacity:
new
Tween
<
double
>(
begin:
0.0
,
end:
1.0
),
scale:
new
AnimatedValue
<
double
>(
0.8
,
end:
1.0
,
curve:
Curves
.
ease
),
scale:
new
Tween
<
double
>(
begin:
0.8
,
end:
1.0
),
performance:
performance
,
animation:
new
CurvedAnimation
(
parent:
animation
,
curve:
Curves
.
ease
)
,
child:
child
child:
child
);
);
}
}
Widget
_handleExit
(
PerformanceView
performance
,
Widget
child
)
{
Widget
_handleExit
(
Animation
animation
,
Widget
child
)
{
return
new
CardTransition
(
return
new
CardTransition
(
x:
new
AnimatedValue
<
double
>(
0.0
,
end:
200.0
,
curve:
Curves
.
ease
),
x:
new
Tween
<
double
>(
begin:
0.0
,
end:
200.0
),
opacity:
new
AnimatedValue
<
double
>(
1.0
,
end:
0.0
,
curve:
Curves
.
ease
),
opacity:
new
Tween
<
double
>(
begin:
1.0
,
end:
0.0
),
scale:
new
AnimatedValue
<
double
>(
1.0
,
end:
0.8
,
curve:
Curves
.
ease
),
scale:
new
Tween
<
double
>(
begin:
1.0
,
end:
0.8
),
performance:
performance
,
animation:
new
CurvedAnimation
(
parent:
animation
,
curve:
Curves
.
ease
)
,
child:
child
child:
child
);
);
}
}
...
...
packages/flutter/lib/src/animation/tween.dart
View file @
50937d1f
...
@@ -92,7 +92,7 @@ abstract class ProxyWatchableMixin implements Watchable {
...
@@ -92,7 +92,7 @@ abstract class ProxyWatchableMixin implements Watchable {
abstract
class
Evaluatable
<
T
>
{
abstract
class
Evaluatable
<
T
>
{
const
Evaluatable
();
const
Evaluatable
();
T
evaluate
(
double
t
);
T
evaluate
(
Animation
animation
);
WatchableValue
<
T
>
watch
(
Animation
parent
)
{
WatchableValue
<
T
>
watch
(
Animation
parent
)
{
return
new
WatchableValue
<
T
>(
parent:
parent
,
evaluatable:
this
);
return
new
WatchableValue
<
T
>(
parent:
parent
,
evaluatable:
this
);
...
@@ -105,7 +105,7 @@ class WatchableValue<T> extends Watchable with ProxyWatchableMixin {
...
@@ -105,7 +105,7 @@ class WatchableValue<T> extends Watchable with ProxyWatchableMixin {
final
Animation
parent
;
final
Animation
parent
;
final
Evaluatable
<
T
>
evaluatable
;
final
Evaluatable
<
T
>
evaluatable
;
T
get
value
=>
evaluatable
.
evaluate
(
parent
.
progress
);
T
get
value
=>
evaluatable
.
evaluate
(
parent
);
}
}
abstract
class
Animation
extends
Watchable
{
abstract
class
Animation
extends
Watchable
{
...
@@ -261,9 +261,8 @@ class _RepeatingSimulation extends Simulation {
...
@@ -261,9 +261,8 @@ class _RepeatingSimulation extends Simulation {
bool
isDone
(
double
timeInSeconds
)
=>
false
;
bool
isDone
(
double
timeInSeconds
)
=>
false
;
}
}
// TODO(abarth): Rename Curve to UnitTransform and ACurve to Curve.
class
CurvedAnimation
extends
Animation
with
ProxyWatchableMixin
{
class
ACurve
extends
Animation
with
ProxyWatchableMixin
{
CurvedAnimation
({
this
.
parent
,
this
.
curve
,
this
.
reverseCurve
})
{
ACurve
({
this
.
parent
,
this
.
curve
,
this
.
reverseCurve
})
{
assert
(
parent
!=
null
);
assert
(
parent
!=
null
);
assert
(
curve
!=
null
);
assert
(
curve
!=
null
);
parent
.
addStatusListener
(
_handleStatusChanged
);
parent
.
addStatusListener
(
_handleStatusChanged
);
...
@@ -317,9 +316,7 @@ class ACurve extends Animation with ProxyWatchableMixin {
...
@@ -317,9 +316,7 @@ class ACurve extends Animation with ProxyWatchableMixin {
}
}
class
Tween
<
T
extends
dynamic
>
extends
Evaluatable
<
T
>
{
class
Tween
<
T
extends
dynamic
>
extends
Evaluatable
<
T
>
{
Tween
({
this
.
begin
,
this
.
end
})
{
Tween
({
this
.
begin
,
this
.
end
});
assert
(
begin
!=
null
);
}
/// The value this variable has at the beginning of the animation.
/// The value this variable has at the beginning of the animation.
T
begin
;
T
begin
;
...
@@ -330,9 +327,10 @@ class Tween<T extends dynamic> extends Evaluatable<T> {
...
@@ -330,9 +327,10 @@ class Tween<T extends dynamic> extends Evaluatable<T> {
/// Returns the value this variable has at the given animation clock value.
/// Returns the value this variable has at the given animation clock value.
T
lerp
(
double
t
)
=>
begin
+
(
end
-
begin
)
*
t
;
T
lerp
(
double
t
)
=>
begin
+
(
end
-
begin
)
*
t
;
T
evaluate
(
double
t
)
{
T
evaluate
(
Animation
animation
)
{
if
(
end
==
null
)
if
(
end
==
null
)
return
begin
;
return
begin
;
double
t
=
animation
.
progress
;
if
(
t
==
0.0
)
if
(
t
==
0.0
)
return
begin
;
return
begin
;
if
(
t
==
1.0
)
if
(
t
==
1.0
)
...
...
packages/flutter/lib/src/material/tabs.dart
View file @
50937d1f
...
@@ -415,10 +415,10 @@ class TabBarSelection<T> extends StatefulComponent {
...
@@ -415,10 +415,10 @@ class TabBarSelection<T> extends StatefulComponent {
class
TabBarSelectionState
<
T
>
extends
State
<
TabBarSelection
<
T
>>
{
class
TabBarSelectionState
<
T
>
extends
State
<
TabBarSelection
<
T
>>
{
PerformanceView
get
performance
=>
_performance
.
view
;
Animation
get
animation
=>
_controller
.
view
;
// Both the TabBar and TabBarView classes access _performance because they
// Both the TabBar and TabBarView classes access _performance because they
// alternately drive selection progress between tabs.
// alternately drive selection progress between tabs.
final
_performance
=
new
Performance
(
duration:
_kTabBarScroll
,
progress:
1.0
);
final
AnimationController
_controller
=
new
AnimationController
(
duration:
_kTabBarScroll
,
progress:
1.0
);
final
Map
<
T
,
int
>
_valueToIndex
=
new
Map
<
T
,
int
>();
final
Map
<
T
,
int
>
_valueToIndex
=
new
Map
<
T
,
int
>();
void
_initValueToIndex
()
{
void
_initValueToIndex
()
{
...
@@ -442,7 +442,7 @@ class TabBarSelectionState<T> extends State<TabBarSelection<T>> {
...
@@ -442,7 +442,7 @@ class TabBarSelectionState<T> extends State<TabBarSelection<T>> {
}
}
void
dispose
()
{
void
dispose
()
{
_
performance
.
stop
();
_
controller
.
stop
();
PageStorage
.
of
(
context
)?.
writeState
(
context
,
_value
);
PageStorage
.
of
(
context
)?.
writeState
(
context
,
_value
);
super
.
dispose
();
super
.
dispose
();
}
}
...
@@ -481,21 +481,21 @@ class TabBarSelectionState<T> extends State<TabBarSelection<T>> {
...
@@ -481,21 +481,21 @@ class TabBarSelectionState<T> extends State<TabBarSelection<T>> {
// the previous and current selection index.
// the previous and current selection index.
double
progress
;
double
progress
;
if
(
_
performance
.
status
==
PerformanceStatus
.
completed
)
if
(
_
controller
.
status
==
PerformanceStatus
.
completed
)
progress
=
0.0
;
progress
=
0.0
;
else
if
(
_previousValue
==
values
.
first
)
else
if
(
_previousValue
==
values
.
first
)
progress
=
_
performance
.
progress
;
progress
=
_
controller
.
progress
;
else
if
(
_previousValue
==
values
.
last
)
else
if
(
_previousValue
==
values
.
last
)
progress
=
1.0
-
_
performance
.
progress
;
progress
=
1.0
-
_
controller
.
progress
;
else
if
(
previousIndex
<
index
)
else
if
(
previousIndex
<
index
)
progress
=
(
_
performance
.
progress
-
0.5
)
*
2.0
;
progress
=
(
_
controller
.
progress
-
0.5
)
*
2.0
;
else
else
progress
=
1.0
-
_
performance
.
progress
*
2.0
;
progress
=
1.0
-
_
controller
.
progress
*
2.0
;
_
performance
_
controller
..
progress
=
progress
..
progress
=
progress
..
forward
().
then
((
_
)
{
..
forward
().
then
((
_
)
{
if
(
_
performance
.
progress
==
1.0
)
{
if
(
_
controller
.
progress
==
1.0
)
{
if
(
config
.
onChanged
!=
null
)
if
(
config
.
onChanged
!=
null
)
config
.
onChanged
(
_value
);
config
.
onChanged
(
_value
);
_valueIsChanging
=
false
;
_valueIsChanging
=
false
;
...
@@ -507,14 +507,14 @@ class TabBarSelectionState<T> extends State<TabBarSelection<T>> {
...
@@ -507,14 +507,14 @@ class TabBarSelectionState<T> extends State<TabBarSelection<T>> {
void
registerPerformanceListener
(
TabBarSelectionPerformanceListener
listener
)
{
void
registerPerformanceListener
(
TabBarSelectionPerformanceListener
listener
)
{
_performanceListeners
.
add
(
listener
);
_performanceListeners
.
add
(
listener
);
_
performance
_
controller
..
addStatusListener
(
listener
.
handleStatusChange
)
..
addStatusListener
(
listener
.
handleStatusChange
)
..
addListener
(
listener
.
handleProgressChange
);
..
addListener
(
listener
.
handleProgressChange
);
}
}
void
unregisterPerformanceListener
(
TabBarSelectionPerformanceListener
listener
)
{
void
unregisterPerformanceListener
(
TabBarSelectionPerformanceListener
listener
)
{
_performanceListeners
.
remove
(
listener
);
_performanceListeners
.
remove
(
listener
);
_
performance
_
controller
..
removeStatusListener
(
listener
.
handleStatusChange
)
..
removeStatusListener
(
listener
.
handleStatusChange
)
..
removeListener
(
listener
.
handleProgressChange
);
..
removeListener
(
listener
.
handleProgressChange
);
}
}
...
@@ -590,17 +590,11 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
...
@@ -590,17 +590,11 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
if
(
_valueIsChanging
&&
status
==
PerformanceStatus
.
completed
)
{
if
(
_valueIsChanging
&&
status
==
PerformanceStatus
.
completed
)
{
_valueIsChanging
=
false
;
_valueIsChanging
=
false
;
double
progress
=
0.5
;
_indicatorTween
if
(
_selection
.
index
==
0
)
progress
=
0.0
;
else
if
(
_selection
.
index
==
config
.
labels
.
length
-
1
)
progress
=
1.0
;
setState
(()
{
_indicatorRect
..
begin
=
_tabIndicatorRect
(
math
.
max
(
0
,
_selection
.
index
-
1
))
..
begin
=
_tabIndicatorRect
(
math
.
max
(
0
,
_selection
.
index
-
1
))
..
end
=
_tabIndicatorRect
(
math
.
min
(
config
.
labels
.
length
-
1
,
_selection
.
index
+
1
))
..
end
=
_tabIndicatorRect
(
math
.
min
(
config
.
labels
.
length
-
1
,
_selection
.
index
+
1
));
..
curve
=
null
setState
(()
{
..
setProgress
(
progress
,
AnimationDirection
.
forward
);
_indicatorRect
=
_tabIndicatorRect
(
_selection
.
index
);
});
});
}
}
}
}
...
@@ -612,23 +606,32 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
...
@@ -612,23 +606,32 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
if
(!
_valueIsChanging
&&
_selection
.
valueIsChanging
)
{
if
(!
_valueIsChanging
&&
_selection
.
valueIsChanging
)
{
if
(
config
.
isScrollable
)
if
(
config
.
isScrollable
)
scrollTo
(
_centeredTabScrollOffset
(
_selection
.
index
),
duration:
_kTabBarScroll
);
scrollTo
(
_centeredTabScrollOffset
(
_selection
.
index
),
duration:
_kTabBarScroll
);
_indicatorRect
_indicatorTween
..
begin
=
_indicatorRect
.
value
??
_tabIndicatorRect
(
_selection
.
previousIndex
)
..
begin
=
_indicatorRect
??
_tabIndicatorRect
(
_selection
.
previousIndex
)
..
end
=
_tabIndicatorRect
(
_selection
.
index
)
..
end
=
_tabIndicatorRect
(
_selection
.
index
);
..
curve
=
Curves
.
ease
;
_valueIsChanging
=
true
;
_valueIsChanging
=
true
;
}
}
Rect
oldRect
=
_indicatorRect
.
value
;
Rect
oldRect
=
_indicatorRect
;
_indicatorRect
.
setProgress
(
_selection
.
performance
.
progress
,
AnimationDirection
.
forward
);
double
t
=
_selection
.
animation
.
progress
;
Rect
newRect
=
_indicatorRect
.
value
;
if
(
_valueIsChanging
)
{
if
(
oldRect
!=
newRect
)
// When _valueIsChanging is true, we're animating based on a ticker and
// want to curve the animation. When _valueIsChanging is false, we're
// animating based on a pointer event and want linear feedback. It's
// possible we should move this curve into the selection animation.
t
=
Curves
.
ease
.
transform
(
t
);
}
// TODO(abarth): If we've never gone through handleStatusChange before, we
// might not have set up our _indicatorTween yet.
_indicatorRect
=
_indicatorTween
.
lerp
(
t
);
if
(
oldRect
!=
_indicatorRect
)
setState
(()
{
});
setState
(()
{
});
}
}
Size
_viewportSize
=
Size
.
zero
;
Size
_viewportSize
=
Size
.
zero
;
Size
_tabBarSize
;
Size
_tabBarSize
;
List
<
double
>
_tabWidths
;
List
<
double
>
_tabWidths
;
AnimatedRectValue
_indicatorRect
=
new
AnimatedRectValue
(
null
);
Rect
_indicatorRect
;
RectTween
_indicatorTween
=
new
RectTween
();
Rect
_tabRect
(
int
tabIndex
)
{
Rect
_tabRect
(
int
tabIndex
)
{
assert
(
_tabBarSize
!=
null
);
assert
(
_tabBarSize
!=
null
);
...
@@ -673,9 +676,9 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
...
@@ -673,9 +676,9 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
labelColor
=
isSelectedTab
?
selectedColor
:
color
;
labelColor
=
isSelectedTab
?
selectedColor
:
color
;
if
(
_selection
.
valueIsChanging
)
{
if
(
_selection
.
valueIsChanging
)
{
if
(
isSelectedTab
)
if
(
isSelectedTab
)
labelColor
=
Color
.
lerp
(
color
,
selectedColor
,
_selection
.
performance
.
progress
);
labelColor
=
Color
.
lerp
(
color
,
selectedColor
,
_selection
.
animation
.
progress
);
else
if
(
isPreviouslySelectedTab
)
else
if
(
isPreviouslySelectedTab
)
labelColor
=
Color
.
lerp
(
selectedColor
,
color
,
_selection
.
performance
.
progress
);
labelColor
=
Color
.
lerp
(
selectedColor
,
color
,
_selection
.
animation
.
progress
);
}
}
}
}
return
new
_Tab
(
return
new
_Tab
(
...
@@ -749,7 +752,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
...
@@ -749,7 +752,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
children:
tabs
,
children:
tabs
,
selectedIndex:
_selection
?.
index
,
selectedIndex:
_selection
?.
index
,
indicatorColor:
indicatorColor
,
indicatorColor:
indicatorColor
,
indicatorRect:
_indicatorRect
.
value
,
indicatorRect:
_indicatorRect
,
textAndIcons:
textAndIcons
,
textAndIcons:
textAndIcons
,
isScrollable:
config
.
isScrollable
,
isScrollable:
config
.
isScrollable
,
onLayoutChanged:
_layoutChanged
onLayoutChanged:
_layoutChanged
...
@@ -873,14 +876,14 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
...
@@ -873,14 +876,14 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
return
;
return
;
// The TabBar is driving the TabBarSelection performance.
// The TabBar is driving the TabBarSelection performance.
final
Performance
performance
=
_selection
.
performance
;
final
Animation
animation
=
_selection
.
animation
;
if
(
performance
.
status
==
PerformanceStatus
.
completed
)
{
if
(
animation
.
status
==
PerformanceStatus
.
completed
)
{
_updateItemsAndScrollBehavior
();
_updateItemsAndScrollBehavior
();
return
;
return
;
}
}
if
(
performance
.
status
!=
PerformanceStatus
.
forward
)
if
(
animation
.
status
!=
PerformanceStatus
.
forward
)
return
;
return
;
final
int
selectedIndex
=
_selection
.
index
;
final
int
selectedIndex
=
_selection
.
index
;
...
@@ -895,9 +898,9 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
...
@@ -895,9 +898,9 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
}
}
if
(
_scrollDirection
==
AnimationDirection
.
forward
)
if
(
_scrollDirection
==
AnimationDirection
.
forward
)
scrollTo
(
performance
.
progress
);
scrollTo
(
animation
.
progress
);
else
else
scrollTo
(
1.0
-
performance
.
progress
);
scrollTo
(
1.0
-
animation
.
progress
);
}
}
void
dispatchOnScroll
()
{
void
dispatchOnScroll
()
{
...
@@ -905,12 +908,12 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
...
@@ -905,12 +908,12 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
return
;
return
;
// This class is driving the TabBarSelection's performance.
// This class is driving the TabBarSelection's performance.
final
Performance
performance
=
_selection
.
_performance
;
final
AnimationController
controller
=
_selection
.
_controller
;
if
(
_selection
.
index
==
0
||
_selection
.
index
==
_tabCount
-
1
)
if
(
_selection
.
index
==
0
||
_selection
.
index
==
_tabCount
-
1
)
performance
.
progress
=
scrollOffset
;
controller
.
progress
=
scrollOffset
;
else
else
performance
.
progress
=
scrollOffset
/
2.0
;
controller
.
progress
=
scrollOffset
/
2.0
;
}
}
Future
fling
(
Offset
scrollVelocity
)
{
Future
fling
(
Offset
scrollVelocity
)
{
...
...
packages/flutter/lib/src/widgets/enter_exit_transition.dart
View file @
50937d1f
...
@@ -70,30 +70,30 @@ class _SmoothlyResizingOverflowBoxState extends State<SmoothlyResizingOverflowBo
...
@@ -70,30 +70,30 @@ class _SmoothlyResizingOverflowBoxState extends State<SmoothlyResizingOverflowBo
class
_Entry
{
class
_Entry
{
_Entry
({
_Entry
({
this
.
child
,
this
.
child
,
this
.
enter
Performance
,
this
.
enter
Controller
,
this
.
enterTransition
this
.
enterTransition
});
});
final
Widget
child
;
final
Widget
child
;
final
Performance
enterPerformance
;
final
AnimationController
enterController
;
final
Widget
enterTransition
;
final
Widget
enterTransition
;
Size
childSize
=
Size
.
zero
;
Size
childSize
=
Size
.
zero
;
Performance
exitPerformance
;
AnimationController
exitController
;
Widget
exitTransition
;
Widget
exitTransition
;
Widget
get
currentTransition
=>
exitTransition
??
enterTransition
;
Widget
get
currentTransition
=>
exitTransition
??
enterTransition
;
void
dispose
()
{
void
dispose
()
{
enter
Performance
?.
stop
();
enter
Controller
?.
stop
();
exit
Performance
?.
stop
();
exit
Controller
?.
stop
();
}
}
}
}
typedef
Widget
TransitionBuilderCallback
(
PerformanceView
performance
,
Widget
child
);
typedef
Widget
TransitionBuilderCallback
(
Animation
animation
,
Widget
child
);
Widget
_identityTransition
(
PerformanceView
performance
,
Widget
child
)
=>
child
;
Widget
_identityTransition
(
Animation
animation
,
Widget
child
)
=>
child
;
class
EnterExitTransition
extends
StatefulComponent
{
class
EnterExitTransition
extends
StatefulComponent
{
EnterExitTransition
({
EnterExitTransition
({
...
@@ -129,11 +129,11 @@ class _EnterExitTransitionState extends State<EnterExitTransition> {
...
@@ -129,11 +129,11 @@ class _EnterExitTransitionState extends State<EnterExitTransition> {
}
}
_Entry
_createEnterTransition
()
{
_Entry
_createEnterTransition
()
{
Performance
enterPerformance
=
new
Performance
(
duration:
config
.
duration
)..
play
();
AnimationController
enterController
=
new
AnimationController
(
duration:
config
.
duration
)..
forward
();
return
new
_Entry
(
return
new
_Entry
(
child:
config
.
child
,
child:
config
.
child
,
enter
Performance:
enterPerformance
,
enter
Controller:
enterController
,
enterTransition:
config
.
onEnter
(
enter
Performance
,
new
KeyedSubtree
(
enterTransition:
config
.
onEnter
(
enter
Controller
,
new
KeyedSubtree
(
key:
new
GlobalKey
(),
key:
new
GlobalKey
(),
child:
config
.
child
child:
config
.
child
))
))
...
@@ -141,11 +141,11 @@ class _EnterExitTransitionState extends State<EnterExitTransition> {
...
@@ -141,11 +141,11 @@ class _EnterExitTransitionState extends State<EnterExitTransition> {
}
}
Future
_createExitTransition
(
_Entry
entry
)
async
{
Future
_createExitTransition
(
_Entry
entry
)
async
{
Performance
exitPerformance
=
new
Performance
(
duration:
config
.
duration
);
AnimationController
exitController
=
new
AnimationController
(
duration:
config
.
duration
);
entry
entry
..
exit
Performance
=
exitPerformance
..
exit
Controller
=
exitController
..
exitTransition
=
config
.
onExit
(
exit
Performance
,
entry
.
enterTransition
);
..
exitTransition
=
config
.
onExit
(
exit
Controller
,
entry
.
enterTransition
);
await
exit
Performance
.
play
();
await
exit
Controller
.
forward
();
if
(!
mounted
)
if
(!
mounted
)
return
;
return
;
setState
(()
{
setState
(()
{
...
...
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