Commit 7ecc698c authored by Eric Seidel's avatar Eric Seidel

wip

parent ecf1cce8
...@@ -16,16 +16,20 @@ class GalleryApp extends StatefulWidget { ...@@ -16,16 +16,20 @@ class GalleryApp extends StatefulWidget {
class GalleryAppState extends State<GalleryApp> { class GalleryAppState extends State<GalleryApp> {
bool _useLightTheme = true; bool _useLightTheme = true;
bool _showPerformanceOverlay = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new MaterialApp( return new MaterialApp(
title: 'Flutter Material Gallery', title: 'Flutter Material Gallery',
theme: _useLightTheme ? _kGalleryLightTheme : _kGalleryDarkTheme, theme: _useLightTheme ? _kGalleryLightTheme : _kGalleryDarkTheme,
showPerformanceOverlay: _showPerformanceOverlay,
routes: { routes: {
'/': (BuildContext context) => new GalleryHome( '/': (BuildContext context) => new GalleryHome(
theme: _useLightTheme, useLightTheme: _useLightTheme,
onThemeChanged: (bool value) { setState(() { _useLightTheme = value; }); }, onThemeChanged: (bool value) { setState(() { _useLightTheme = value; }); },
showPerformanceOverlay: _showPerformanceOverlay,
onShowPerformanceOverlayChanged: (bool value) { setState(() { _showPerformanceOverlay = value; }); },
timeDilation: timeDilation, timeDilation: timeDilation,
onTimeDilationChanged: (double value) { setState(() { timeDilation = value; }); } onTimeDilationChanged: (double value) { setState(() { timeDilation = value; }); }
) )
......
...@@ -7,21 +7,26 @@ import 'package:flutter/material.dart'; ...@@ -7,21 +7,26 @@ import 'package:flutter/material.dart';
class GalleryDrawer extends StatelessWidget { class GalleryDrawer extends StatelessWidget {
GalleryDrawer({ GalleryDrawer({
Key key, Key key,
this.theme, this.useLightTheme,
this.onThemeChanged, this.onThemeChanged,
this.timeDilation, this.timeDilation,
this.onTimeDilationChanged this.onTimeDilationChanged,
this.showPerformanceOverlay,
this.onShowPerformanceOverlayChanged
}) : super(key: key) { }) : super(key: key) {
assert(onThemeChanged != null); assert(onThemeChanged != null);
assert(onTimeDilationChanged != null); assert(onTimeDilationChanged != null);
} }
final bool theme; final bool useLightTheme;
final ValueChanged<bool> onThemeChanged; final ValueChanged<bool> onThemeChanged;
final double timeDilation; final double timeDilation;
final ValueChanged<double> onTimeDilationChanged; final ValueChanged<double> onTimeDilationChanged;
final bool showPerformanceOverlay;
final ValueChanged<bool> onShowPerformanceOverlayChanged;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Drawer( return new Drawer(
...@@ -31,13 +36,13 @@ class GalleryDrawer extends StatelessWidget { ...@@ -31,13 +36,13 @@ class GalleryDrawer extends StatelessWidget {
new DrawerItem( new DrawerItem(
icon: Icons.brightness_5, icon: Icons.brightness_5,
onPressed: () { onThemeChanged(true); }, onPressed: () { onThemeChanged(true); },
selected: theme, selected: useLightTheme,
child: new Row( child: new Row(
children: <Widget>[ children: <Widget>[
new Flexible(child: new Text('Light')), new Flexible(child: new Text('Light')),
new Radio<bool>( new Radio<bool>(
value: true, value: true,
groupValue: theme, groupValue: useLightTheme,
onChanged: onThemeChanged onChanged: onThemeChanged
) )
] ]
...@@ -46,13 +51,13 @@ class GalleryDrawer extends StatelessWidget { ...@@ -46,13 +51,13 @@ class GalleryDrawer extends StatelessWidget {
new DrawerItem( new DrawerItem(
icon: Icons.brightness_7, icon: Icons.brightness_7,
onPressed: () { onThemeChanged(false); }, onPressed: () { onThemeChanged(false); },
selected: theme, selected: useLightTheme,
child: new Row( child: new Row(
children: <Widget>[ children: <Widget>[
new Flexible(child: new Text('Dark')), new Flexible(child: new Text('Dark')),
new Radio<bool>( new Radio<bool>(
value: false, value: false,
groupValue: theme, groupValue: useLightTheme,
onChanged: onThemeChanged onChanged: onThemeChanged
) )
] ]
...@@ -72,7 +77,21 @@ class GalleryDrawer extends StatelessWidget { ...@@ -72,7 +77,21 @@ class GalleryDrawer extends StatelessWidget {
) )
] ]
) )
) ),
new DrawerItem(
icon: Icons.assessment,
onPressed: () { onShowPerformanceOverlayChanged(!showPerformanceOverlay); },
selected: showPerformanceOverlay,
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Performance Overlay')),
new Checkbox(
value: showPerformanceOverlay,
onChanged: (bool value) { onShowPerformanceOverlayChanged(!showPerformanceOverlay); }
)
]
)
),
] ]
) )
); );
......
...@@ -46,21 +46,27 @@ const double _kFlexibleSpaceMaxHeight = 256.0; ...@@ -46,21 +46,27 @@ const double _kFlexibleSpaceMaxHeight = 256.0;
class GalleryHome extends StatefulWidget { class GalleryHome extends StatefulWidget {
GalleryHome({ GalleryHome({
Key key, Key key,
this.theme, this.useLightTheme,
this.onThemeChanged, this.onThemeChanged,
this.timeDilation, this.timeDilation,
this.onTimeDilationChanged this.onTimeDilationChanged,
this.showPerformanceOverlay,
this.onShowPerformanceOverlayChanged
}) : super(key: key) { }) : super(key: key) {
assert(onThemeChanged != null); assert(onThemeChanged != null);
assert(onTimeDilationChanged != null); assert(onTimeDilationChanged != null);
assert(onShowPerformanceOverlayChanged != null);
} }
final bool theme; final bool useLightTheme;
final ValueChanged<bool> onThemeChanged; final ValueChanged<bool> onThemeChanged;
final double timeDilation; final double timeDilation;
final ValueChanged<double> onTimeDilationChanged; final ValueChanged<double> onTimeDilationChanged;
final bool showPerformanceOverlay;
final ValueChanged<bool> onShowPerformanceOverlayChanged;
@override @override
GalleryHomeState createState() => new GalleryHomeState(); GalleryHomeState createState() => new GalleryHomeState();
} }
...@@ -76,10 +82,12 @@ class GalleryHomeState extends State<GalleryHome> { ...@@ -76,10 +82,12 @@ class GalleryHomeState extends State<GalleryHome> {
return new Scaffold( return new Scaffold(
key: _homeKey, key: _homeKey,
drawer: new GalleryDrawer( drawer: new GalleryDrawer(
theme: config.theme, useLightTheme: config.useLightTheme,
onThemeChanged: config.onThemeChanged, onThemeChanged: config.onThemeChanged,
timeDilation: config.timeDilation, timeDilation: config.timeDilation,
onTimeDilationChanged: config.onTimeDilationChanged onTimeDilationChanged: config.onTimeDilationChanged,
showPerformanceOverlay: config.showPerformanceOverlay,
onShowPerformanceOverlayChanged: config.onShowPerformanceOverlayChanged
), ),
appBar: new AppBar( appBar: new AppBar(
expandedHeight: _kFlexibleSpaceMaxHeight, expandedHeight: _kFlexibleSpaceMaxHeight,
......
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