Commit d6e21d7f authored by Adam Barth's avatar Adam Barth

Merge pull request #598 from abarth/gallery

Move Material Gallery demos into a directory
parents 77cf420a 9fae3864
......@@ -4,13 +4,14 @@
import 'package:flutter/material.dart';
import 'widget_demo.dart';
import 'demo/widget_demo.dart';
class GalleryPage extends StatelessComponent {
GalleryPage({ this.demos, this.active });
GalleryPage({ this.demos, this.active, this.onThemeChanged });
final List<WidgetDemo> demos;
final WidgetDemo active;
final ValueChanged<ThemeData> onThemeChanged;
void _showDrawer(BuildContext context) {
List<Widget> items = <Widget>[
......
......@@ -4,13 +4,13 @@
import 'package:flutter/material.dart';
import 'chip_demo.dart';
import 'date_picker_demo.dart';
import 'drop_down_demo.dart';
import 'demo/chip_demo.dart';
import 'demo/date_picker_demo.dart';
import 'demo/drop_down_demo.dart';
import 'demo/slider_demo.dart';
import 'demo/time_picker_demo.dart';
import 'demo/widget_demo.dart';
import 'gallery_page.dart';
import 'slider_demo.dart';
import 'time_picker_demo.dart';
import 'widget_demo.dart';
final List<WidgetDemo> _kDemos = <WidgetDemo>[
kChipDemo,
......@@ -20,15 +20,47 @@ final List<WidgetDemo> _kDemos = <WidgetDemo>[
kDropDownDemo,
];
void main() {
Map<String, RouteBuilder> routes = new Map<String, RouteBuilder>();
routes['/'] = (_) => new GalleryPage(demos: _kDemos);
class _MaterialGallery extends StatefulComponent {
_MaterialGalleryState createState() => new _MaterialGalleryState();
}
class _MaterialGalleryState extends State<_MaterialGallery> {
final Map<String, RouteBuilder> _routes = new Map<String, RouteBuilder>();
void initState() {
super.initState();
_routes['/'] = (_) => new GalleryPage(
demos: _kDemos,
onThemeChanged: _handleThemeChanged
);
for (WidgetDemo demo in _kDemos) {
_routes[demo.routeName] = (_) {
return new GalleryPage(
demos: _kDemos,
active: demo,
onThemeChanged: _handleThemeChanged
);
};
}
}
for (WidgetDemo demo in _kDemos)
routes[demo.routeName] = (_) => new GalleryPage(demos: _kDemos, active: demo);
ThemeData _theme;
runApp(new MaterialApp(
title: 'Material Gallery',
routes: routes
));
void _handleThemeChanged(ThemeData newTheme) {
setState(() {
_theme = newTheme;
});
}
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Material Gallery',
theme: _theme,
routes: _routes
);
}
}
void main() {
runApp(new _MaterialGallery());
}
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