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