Merge pull request #2228 from abarth/fix_demo_template
Simplify demo template
This commit is contained in:
commit
29e5573593
@ -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
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user