Move Scaffold over to using AnimationController
Also, clean up the class hierarchy for AnimationController now that we've renamed progress to value. That means everything in the hierarchy now has a value, include Watchable. This patch renames Watchable to Animated<T>, which lets us use that type almost everywhere. I've added some ducktape to modal bottom sheets to avoid having to refactor all of Navigator to use AnimationController. I'll remove the ducktape in the next patch.
This commit is contained in:
@@ -12,9 +12,9 @@ class PageSelectorDemo extends StatelessComponent {
|
||||
final ColorTween _previousColor = new ColorTween(begin: color, end: Colors.transparent);
|
||||
final TabBarSelectionState selection = TabBarSelection.of(context);
|
||||
|
||||
Animation animation = new CurvedAnimation(parent: selection.animation, curve: Curves.ease);
|
||||
return new AnimationWatchingBuilder(
|
||||
watchable: animation,
|
||||
CurvedAnimation animation = new CurvedAnimation(parent: selection.animation, curve: Curves.ease);
|
||||
return new AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: (BuildContext context) {
|
||||
Color background = selection.value == iconName ? _selectedColor.end : _selectedColor.begin;
|
||||
if (selection.valueIsChanging) {
|
||||
|
||||
@@ -27,7 +27,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
|
||||
});
|
||||
}
|
||||
|
||||
Animation animation;
|
||||
Animated<double> animation;
|
||||
AnimationController controller;
|
||||
|
||||
void handleTap() {
|
||||
@@ -55,19 +55,19 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
|
||||
),
|
||||
new LinearProgressIndicator(),
|
||||
new LinearProgressIndicator(),
|
||||
new LinearProgressIndicator(value: animation.progress),
|
||||
new LinearProgressIndicator(value: animation.value),
|
||||
new CircularProgressIndicator(),
|
||||
new SizedBox(
|
||||
width: 20.0,
|
||||
height: 20.0,
|
||||
child: new CircularProgressIndicator(value: animation.progress)
|
||||
child: new CircularProgressIndicator(value: animation.value)
|
||||
),
|
||||
new SizedBox(
|
||||
width: 50.0,
|
||||
height: 30.0,
|
||||
child: new CircularProgressIndicator(value: animation.progress)
|
||||
child: new CircularProgressIndicator(value: animation.value)
|
||||
),
|
||||
new Text("${(animation.progress * 100.0).toStringAsFixed(1)}%" + (controller.isAnimating ? '' : ' (paused)'))
|
||||
new Text("${(animation.value * 100.0).toStringAsFixed(1)}%" + (controller.isAnimating ? '' : ' (paused)'))
|
||||
];
|
||||
return new Column(
|
||||
children: indicators
|
||||
@@ -87,8 +87,8 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: new Container(
|
||||
padding: const EdgeDims.symmetric(vertical: 12.0, horizontal: 8.0),
|
||||
child: new AnimationWatchingBuilder(
|
||||
watchable: animation,
|
||||
child: new AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: buildIndicators
|
||||
)
|
||||
)
|
||||
|
||||
@@ -33,14 +33,14 @@ class CardTransition extends StatelessComponent {
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final Animation animation;
|
||||
final Animated<double> animation;
|
||||
final Evaluatable<double> x;
|
||||
final Evaluatable<double> opacity;
|
||||
final Evaluatable<double> scale;
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return new AnimationWatchingBuilder(
|
||||
watchable: animation,
|
||||
return new AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: (BuildContext context) {
|
||||
double currentScale = scale.evaluate(animation);
|
||||
Matrix4 transform = new Matrix4.identity()
|
||||
@@ -62,7 +62,7 @@ class SmoothBlockState extends State<SmoothBlock> {
|
||||
|
||||
double _height = 100.0;
|
||||
|
||||
Widget _handleEnter(Animation animation, Widget child) {
|
||||
Widget _handleEnter(Animated<double> animation, Widget child) {
|
||||
return new CardTransition(
|
||||
x: new Tween<double>(begin: -200.0, end: 0.0),
|
||||
opacity: new Tween<double>(begin: 0.0, end: 1.0),
|
||||
@@ -72,7 +72,7 @@ class SmoothBlockState extends State<SmoothBlock> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _handleExit(Animation animation, Widget child) {
|
||||
Widget _handleExit(Animated<double> animation, Widget child) {
|
||||
return new CardTransition(
|
||||
x: new Tween<double>(begin: 0.0, end: 200.0),
|
||||
opacity: new Tween<double>(begin: 1.0, end: 0.0),
|
||||
|
||||
Reference in New Issue
Block a user