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