Commit 1d3f734a authored by Ian Hickson's avatar Ian Hickson

Merge pull request #414 from Hixie/fix-demos

Fix some examples.
parents 70ab160e 5e221334
...@@ -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,11 +6,13 @@ import 'package:flutter/material.dart'; ...@@ -6,11 +6,13 @@ 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.',
style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center)
),
new RaisedButton( new RaisedButton(
child: new Text('GO SHOPPING'), child: new Text('GO SHOPPING'),
onPressed: () => Navigator.of(context).pushNamed('/shopping') onPressed: () => Navigator.of(context).pushNamed('/shopping')
...@@ -18,8 +20,10 @@ class Home extends StatelessComponent { ...@@ -18,8 +20,10 @@ class Home extends StatelessComponent {
new RaisedButton( new RaisedButton(
child: new Text('START ADVENTURE'), child: new Text('START ADVENTURE'),
onPressed: () => Navigator.of(context).pushNamed('/adventure') onPressed: () => Navigator.of(context).pushNamed('/adventure')
)], )
justifyContent: FlexJustifyContent.center ],
padding: const EdgeDims.all(30.0)
)
) )
); );
} }
...@@ -27,11 +31,14 @@ class Home extends StatelessComponent { ...@@ -27,11 +31,14 @@ 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(
'Village Shop',
style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center)
),
new RaisedButton( new RaisedButton(
child: new Text('RETURN HOME'), child: new Text('RETURN HOME'),
onPressed: () => Navigator.of(context).pop() onPressed: () => Navigator.of(context).pop()
...@@ -39,8 +46,10 @@ class Shopping extends StatelessComponent { ...@@ -39,8 +46,10 @@ class Shopping extends StatelessComponent {
new RaisedButton( new RaisedButton(
child: new Text('GO TO DUNGEON'), child: new Text('GO TO DUNGEON'),
onPressed: () => Navigator.of(context).pushNamed('/adventure') onPressed: () => Navigator.of(context).pushNamed('/adventure')
)], )
justifyContent: FlexJustifyContent.center ],
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(
'Monster\'s Lair',
style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center)
),
new RaisedButton( new RaisedButton(
child: new Text('RUN!!!'), child: new Text('RUN!!!'),
onPressed: () => Navigator.of(context).pop() onPressed: () => Navigator.of(context).pop()
)], )
justifyContent: FlexJustifyContent.center ],
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);
...@@ -84,12 +80,14 @@ class PianoApp extends StatelessComponent { ...@@ -84,12 +80,14 @@ class PianoApp extends StatelessComponent {
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(), onPointerCancel: (_) => key.up(),
onPointerDown: (_) => key.down(), onPointerDown: (_) => key.down(),
onPointerUp: (_) => key.up()))); onPointerUp: (_) => key.up()
)
));
} }
return new Column(children); return new Column(children);
} }
} }
...@@ -99,19 +97,28 @@ Widget statusBox(Widget child) { ...@@ -99,19 +97,28 @@ Widget statusBox(Widget child) {
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(
boxShadow: const <BoxShadow>[
const BoxShadow( const BoxShadow(
color: mediumGray, offset: const Offset(6.0, 6.0), blur: 5.0) color: mediumGray, offset: const Offset(6.0, 6.0), blur: 5.0)
], backgroundColor: darkGray), ],
backgroundColor: darkGray
),
height: 90.0, height: 90.0,
padding: const EdgeDims.all(8.0), padding: const EdgeDims.all(8.0),
margin: const EdgeDims.symmetric(horizontal: 50.0), margin: const EdgeDims.symmetric(horizontal: 50.0),
child: new Center(child: child))); 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