Commit 5e221334 authored by Hixie's avatar Hixie

Fix some examples.

- drag and drop was using the wrong draggables (long press vs short
  press).

- navigation.dart wasn't using material correctly and so was ending up
  with some red text.

- piano wasn't followig our style guide even a little.

- date picker was not scrollable.
parent 86879814
...@@ -110,7 +110,7 @@ class ExampleDragSource extends StatelessComponent { ...@@ -110,7 +110,7 @@ class ExampleDragSource extends StatelessComponent {
} }
if (heavy) { if (heavy) {
return new Draggable<Color>( return new LongPressDraggable<Color>(
data: color, data: color,
child: contents, child: contents,
feedback: feedback, feedback: feedback,
...@@ -118,7 +118,7 @@ class ExampleDragSource extends StatelessComponent { ...@@ -118,7 +118,7 @@ class ExampleDragSource extends StatelessComponent {
dragAnchor: anchor dragAnchor: anchor
); );
} else { } else {
return new LongPressDraggable<Color>( return new Draggable<Color>(
data: color, data: color,
child: contents, child: contents,
feedback: feedback, feedback: feedback,
......
...@@ -6,20 +6,24 @@ import 'package:flutter/material.dart'; ...@@ -6,20 +6,24 @@ import 'package:flutter/material.dart';
class Home extends StatelessComponent { class Home extends StatelessComponent {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Container( return new Material(
padding: const EdgeDims.all(30.0), child: new Center(
decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)), child: new Block(<Widget>[
child: new Column(<Widget>[ new Text(
new Text("You are at home"), 'You are at home.',
new RaisedButton( style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center)
child: new Text('GO SHOPPING'), ),
onPressed: () => Navigator.of(context).pushNamed('/shopping') new RaisedButton(
), child: new Text('GO SHOPPING'),
new RaisedButton( onPressed: () => Navigator.of(context).pushNamed('/shopping')
child: new Text('START ADVENTURE'), ),
onPressed: () => Navigator.of(context).pushNamed('/adventure') new RaisedButton(
)], child: new Text('START ADVENTURE'),
justifyContent: FlexJustifyContent.center onPressed: () => Navigator.of(context).pushNamed('/adventure')
)
],
padding: const EdgeDims.all(30.0)
)
) )
); );
} }
...@@ -27,20 +31,25 @@ class Home extends StatelessComponent { ...@@ -27,20 +31,25 @@ class Home extends StatelessComponent {
class Shopping extends StatelessComponent { class Shopping extends StatelessComponent {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Container( return new Material(
padding: const EdgeDims.all(20.0), color: Colors.deepPurple[300],
decoration: new BoxDecoration(backgroundColor: const Color(0xFFBF5FFF)), child: new Center(
child: new Column(<Widget>[ child: new Block(<Widget>[
new Text("Village Shop"), new Text(
new RaisedButton( 'Village Shop',
child: new Text('RETURN HOME'), style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center)
onPressed: () => Navigator.of(context).pop() ),
), new RaisedButton(
new RaisedButton( child: new Text('RETURN HOME'),
child: new Text('GO TO DUNGEON'), onPressed: () => Navigator.of(context).pop()
onPressed: () => Navigator.of(context).pushNamed('/adventure') ),
)], new RaisedButton(
justifyContent: FlexJustifyContent.center child: new Text('GO TO DUNGEON'),
onPressed: () => Navigator.of(context).pushNamed('/adventure')
)
],
padding: const EdgeDims.all(30.0)
)
) )
); );
} }
...@@ -48,16 +57,21 @@ class Shopping extends StatelessComponent { ...@@ -48,16 +57,21 @@ class Shopping extends StatelessComponent {
class Adventure extends StatelessComponent { class Adventure extends StatelessComponent {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Container( return new Material(
padding: const EdgeDims.all(20.0), color: Colors.red[300],
decoration: new BoxDecoration(backgroundColor: const Color(0xFFDC143C)), child: new Center(
child: new Column(<Widget>[ child: new Block(<Widget>[
new Text("Monster's Lair"), new Text(
new RaisedButton( 'Monster\'s Lair',
child: new Text('RUN!!!'), style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center)
onPressed: () => Navigator.of(context).pop() ),
)], new RaisedButton(
justifyContent: FlexJustifyContent.center child: new Text('RUN!!!'),
onPressed: () => Navigator.of(context).pop()
)
],
padding: const EdgeDims.all(30.0)
)
) )
); );
} }
......
...@@ -61,11 +61,7 @@ class PianoApp extends StatelessComponent { ...@@ -61,11 +61,7 @@ class PianoApp extends StatelessComponent {
new PianoKey(Colors.purple[500], iLoveYou), new PianoKey(Colors.purple[500], iLoveYou),
]; ];
Future connect() { Future loadSounds() async {
return _loadSounds();
}
Future _loadSounds() async {
MediaServiceProxy mediaService = new MediaServiceProxy.unbound(); MediaServiceProxy mediaService = new MediaServiceProxy.unbound();
try { try {
shell.connectToService(null, mediaService); shell.connectToService(null, mediaService);
...@@ -82,14 +78,16 @@ class PianoApp extends StatelessComponent { ...@@ -82,14 +78,16 @@ class PianoApp extends StatelessComponent {
List<Widget> children = <Widget>[]; List<Widget> children = <Widget>[];
for (PianoKey key in keys) { for (PianoKey key in keys) {
children.add(new Flexible( children.add(new Flexible(
child: new Listener( child: new Listener(
child: new Container( child: new Container(
decoration: new BoxDecoration(backgroundColor: key.color)), decoration: new BoxDecoration(backgroundColor: key.color)
onPointerCancel: (_) => key.up(), ),
onPointerDown: (_) => key.down(), onPointerCancel: (_) => key.up(),
onPointerUp: (_) => key.up()))); onPointerDown: (_) => key.down(),
onPointerUp: (_) => key.up()
)
));
} }
return new Column(children); return new Column(children);
} }
} }
...@@ -98,20 +96,29 @@ Widget statusBox(Widget child) { ...@@ -98,20 +96,29 @@ Widget statusBox(Widget child) {
const mediumGray = const Color(0xff555555); const mediumGray = const Color(0xff555555);
const darkGray = const Color(0xff222222); const darkGray = const Color(0xff222222);
return new Center( return new Center(
child: new Container( child: new Container(
decoration: const BoxDecoration(boxShadow: const <BoxShadow>[ decoration: const BoxDecoration(
const BoxShadow( boxShadow: const <BoxShadow>[
color: mediumGray, offset: const Offset(6.0, 6.0), blur: 5.0) const BoxShadow(
], backgroundColor: darkGray), color: mediumGray, offset: const Offset(6.0, 6.0), blur: 5.0)
height: 90.0, ],
padding: const EdgeDims.all(8.0), backgroundColor: darkGray
margin: const EdgeDims.symmetric(horizontal: 50.0), ),
child: new Center(child: child))); height: 90.0,
padding: const EdgeDims.all(8.0),
margin: const EdgeDims.symmetric(horizontal: 50.0),
child: new Center(child: child)
)
);
} }
Widget splashScreen() { Widget splashScreen() {
return statusBox( return statusBox(
new Text('Loading sound files!', style: new TextStyle(fontSize: 18.0))); new Text(
'Loading sound files!',
style: new TextStyle(fontSize: 18.0)
)
);
} }
main() async { main() async {
...@@ -119,7 +126,7 @@ main() async { ...@@ -119,7 +126,7 @@ main() async {
PianoApp app = new PianoApp(); PianoApp app = new PianoApp();
// use "await" to make sure the sound files are loaded before we show the ui. // use "await" to make sure the sound files are loaded before we show the ui.
await app.connect(); await app.loadSounds();
runApp(app); runApp(app);
// runApp() returns immediately so you can't put application cleanup code // runApp() returns immediately so you can't put application cleanup code
// here. Android apps can be killed at any time, so there's also no way to // here. Android apps can be killed at any time, so there's also no way to
......
...@@ -247,6 +247,7 @@ class _DismissableState extends State<Dismissable> { ...@@ -247,6 +247,7 @@ class _DismissableState extends State<Dismissable> {
onVerticalDragStart: _directionIsYAxis ? _handleDragStart : null, onVerticalDragStart: _directionIsYAxis ? _handleDragStart : null,
onVerticalDragUpdate: _directionIsYAxis ? _handleDragUpdate : null, onVerticalDragUpdate: _directionIsYAxis ? _handleDragUpdate : null,
onVerticalDragEnd: _directionIsYAxis ? _handleDragEnd : null, onVerticalDragEnd: _directionIsYAxis ? _handleDragEnd : null,
behavior: HitTestBehavior.opaque,
child: new SizeObserver( child: new SizeObserver(
onSizeChanged: _handleSizeChanged, onSizeChanged: _handleSizeChanged,
child: new FadeTransition( child: new FadeTransition(
......
...@@ -104,6 +104,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> { ...@@ -104,6 +104,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
onHorizontalDragStart: _getDragStartHandler(ScrollDirection.horizontal), onHorizontalDragStart: _getDragStartHandler(ScrollDirection.horizontal),
onHorizontalDragUpdate: _getDragUpdateHandler(ScrollDirection.horizontal), onHorizontalDragUpdate: _getDragUpdateHandler(ScrollDirection.horizontal),
onHorizontalDragEnd: _getDragEndHandler(ScrollDirection.horizontal), onHorizontalDragEnd: _getDragEndHandler(ScrollDirection.horizontal),
behavior: HitTestBehavior.opaque,
child: new Listener( child: new Listener(
child: buildContent(context), child: buildContent(context),
onPointerDown: _handlePointerDown onPointerDown: _handlePointerDown
......
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