mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Each layer is supposed to reexport the parts of the previous layer that are part of its API. - In painting.dart, export from dart:ui all the Canvas-related APIs that make sense to be used at higher levels, e.g. PaintingStyle. - Delete painting/shadows.dart. It was dead code. - In rendering/object.dart, export all of painting.dart. - In widgets/basic.dart, export all of painting.dart and animation.dart. Some classes in animation/ are renamed to make this less disruptive and confusing to the namespace. - Split out Stocks back into an import model rather than a part model, so that it's easier to manage its dependencies on a per-file basis. - Move Ticker to scheduler library. - Remove as many redundant imports as possible now. - Some minor nit picking cleanup in various files.
99 lines
3.1 KiB
Dart
99 lines
3.1 KiB
Dart
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ProgressIndicatorDemo extends StatefulComponent {
|
|
_ProgressIndicatorDemoState createState() => new _ProgressIndicatorDemoState();
|
|
}
|
|
|
|
class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
|
|
|
|
void initState() {
|
|
super.initState();
|
|
controller = new AnimationController(
|
|
duration: const Duration(milliseconds: 1500)
|
|
)..play(AnimationDirection.forward);
|
|
|
|
animation = new CurvedAnimation(
|
|
parent: controller,
|
|
curve: new Interval(0.0, 0.9, curve: Curves.ease),
|
|
reverseCurve: Curves.ease
|
|
)..addStatusListener((AnimationStatus status) {
|
|
if (status == AnimationStatus.dismissed || status == AnimationStatus.completed)
|
|
reverseValueAnimationDirection();
|
|
});
|
|
}
|
|
|
|
Animation<double> animation;
|
|
AnimationController controller;
|
|
|
|
void handleTap() {
|
|
setState(() {
|
|
// valueAnimation.isAnimating is part of our build state
|
|
if (controller.isAnimating)
|
|
controller.stop();
|
|
else
|
|
controller.resume();
|
|
});
|
|
}
|
|
|
|
void reverseValueAnimationDirection() {
|
|
AnimationDirection direction = (controller.direction == AnimationDirection.forward)
|
|
? AnimationDirection.reverse
|
|
: AnimationDirection.forward;
|
|
controller.play(direction);
|
|
}
|
|
|
|
Widget buildIndicators(BuildContext context, Widget child) {
|
|
List<Widget> indicators = <Widget>[
|
|
new SizedBox(
|
|
width: 200.0,
|
|
child: new LinearProgressIndicator()
|
|
),
|
|
new LinearProgressIndicator(),
|
|
new LinearProgressIndicator(),
|
|
new LinearProgressIndicator(value: animation.value),
|
|
new CircularProgressIndicator(),
|
|
new SizedBox(
|
|
width: 20.0,
|
|
height: 20.0,
|
|
child: new CircularProgressIndicator(value: animation.value)
|
|
),
|
|
new SizedBox(
|
|
width: 50.0,
|
|
height: 30.0,
|
|
child: new CircularProgressIndicator(value: animation.value)
|
|
),
|
|
new Text("${(animation.value * 100.0).toStringAsFixed(1)}%" + (controller.isAnimating ? '' : ' (paused)'))
|
|
];
|
|
return new Column(
|
|
children: indicators
|
|
.map((Widget c) => new Container(child: c, margin: const EdgeDims.symmetric(vertical: 15.0, horizontal: 20.0)))
|
|
.toList(),
|
|
justifyContent: FlexJustifyContent.center
|
|
);
|
|
}
|
|
|
|
Widget build(BuildContext context) {
|
|
return new Scaffold(
|
|
toolBar: new ToolBar(center: new Text('Progress Indicators')),
|
|
body: new DefaultTextStyle(
|
|
style: Theme.of(context).text.title,
|
|
child: new GestureDetector(
|
|
onTap: handleTap,
|
|
behavior: HitTestBehavior.opaque,
|
|
child: new Container(
|
|
padding: const EdgeDims.symmetric(vertical: 12.0, horizontal: 8.0),
|
|
child: new AnimatedBuilder(
|
|
animation: animation,
|
|
builder: buildIndicators
|
|
)
|
|
)
|
|
)
|
|
)
|
|
);
|
|
}
|
|
}
|