Commit 11fa94cd authored by Adam Barth's avatar Adam Barth

Simplify demo template

We don't need these keys. Also, improve style in several places.

Fixes #2225
parent 240e499b
......@@ -9,6 +9,7 @@ import 'icon_theme_data.dart';
import 'ink_well.dart';
import 'material.dart';
import 'theme.dart';
import 'tooltip.dart';
// TODO(eseidel): This needs to change based on device size?
// http://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keylines-keylines-spacing
......@@ -35,6 +36,7 @@ class FloatingActionButton extends StatefulComponent {
const FloatingActionButton({
Key key,
this.child,
this.tooltip,
this.backgroundColor,
this.elevation: 6,
this.highlightElevation: 12,
......@@ -43,6 +45,7 @@ class FloatingActionButton extends StatefulComponent {
}) : super(key: key);
final Widget child;
final String tooltip;
final Color backgroundColor;
/// The callback that is invoked when the button is tapped or otherwise activated.
......@@ -99,6 +102,23 @@ class _FloatingActionButtonState extends State<FloatingActionButton> {
iconThemeColor = themeData.accentColorBrightness == ThemeBrightness.dark ? IconThemeColor.white : IconThemeColor.black;
}
Widget result = new Center(
child: new IconTheme(
data: new IconThemeData(color: iconThemeColor),
child: new RotationTransition(
turns: _childSegue,
child: config.child
)
)
);
if (config.tooltip != null) {
result = new Tooltip(
message: config.tooltip,
child: result
);
}
return new Material(
color: materialColor,
type: MaterialType.circle,
......@@ -109,15 +129,7 @@ class _FloatingActionButtonState extends State<FloatingActionButton> {
child: new InkWell(
onTap: config.onPressed,
onHighlightChanged: _handleHighlightChanged,
child: new Center(
child: new IconTheme(
data: new IconThemeData(color: iconThemeColor),
child: new RotationTransition(
turns: _childSegue,
child: config.child
)
)
)
child: result
)
)
);
......
......@@ -12,7 +12,7 @@ void main() {
}
class FlutterDemo extends StatefulComponent {
State createState() => new _FlutterDemoState();
_FlutterDemoState createState() => new _FlutterDemoState();
}
class _FlutterDemoState extends State<FlutterDemo> {
......@@ -30,17 +30,14 @@ class _FlutterDemoState extends State<FlutterDemo> {
center: new Text('Flutter Demo')
),
body: new Center(
child: new Text(
'Button tapped $_counter times.',
key: const ValueKey('counter')
)
child: new Text('Button tapped $_counter time${ _counter == 1 ? '' : 's' }.')
),
floatingActionButton: new FloatingActionButton(
key: const ValueKey('fab'),
onPressed: _incrementCounter,
tooltip: 'Increment',
child: new Icon(
icon: 'content/add'
),
onPressed: _incrementCounter
)
)
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment