Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Unified Diff: sky/examples/mine_digger/mine_digger.dart

Issue 1201293003: Use new Widgets in mine_digger. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/mine_digger/mine_digger.dart
diff --git a/sky/examples/mine_digger/mine_digger.dart b/sky/examples/mine_digger/mine_digger.dart
index 584cd7d272566eb556830f4e9c084ed8a8c00197..b5b798c495f312145c2dbc631be03684d3cdba34 100644
--- a/sky/examples/mine_digger/mine_digger.dart
+++ b/sky/examples/mine_digger/mine_digger.dart
@@ -7,13 +7,17 @@ import 'dart:math';
import 'package:sky/rendering/flex.dart';
import 'package:sky/widgets/basic.dart';
+import 'package:sky/widgets/scaffold.dart';
+import 'package:sky/widgets/tool_bar.dart';
+import 'package:sky/widgets/theme.dart';
+import 'package:sky/theme/colors.dart' as colors;
import 'package:sky/painting/text_style.dart';
// Classic minesweeper-inspired game. The mouse controls are standard except
// for left + right combo which is not implemented. For touch, the duration of
// the pointer determines probing versus flagging.
//
-// There are only 3 classes to understand. Game, which is contains all the
+// There are only 3 classes to understand. Game, which is contains all the
// logic and two UI classes: CoveredMineNode and ExposedMineNode, none of them
// holding state.
@@ -92,7 +96,7 @@ class Game {
}
}
- Widget generateBoard() {
+ Widget buildBoard() {
bool hasCoveredCell = false;
List<Flex> flexRows = new List<Flex>();
for (int iy = 0; iy != 9; iy++) {
@@ -152,28 +156,28 @@ class Game {
key: 'flxv'));
}
- Widget generateUI() {
- Widget board = generateBoard();
+ Widget buildToolBar() {
String banner = hasWon ?
'Awesome!!' : alive ?
'Mine Digger [$detectedCount-$totalMineCount]': 'Kaboom! [press here]';
- return new Flex([
- new Container(
- padding: new EdgeDims.all(10.0),
- margin: new EdgeDims.all(10.0),
- decoration: new BoxDecoration(backgroundColor: const Color(0xFFC0C0C0)),
- child: new Listener(
- onPointerDown: handleBannerPointerDown,
- child: new Text(banner))),
- board,
- new Container(
- height: 100.0, width: 100.0,
- decoration: new BoxDecoration(backgroundColor: const Color(0xFFCC1111))
+ return new ToolBar(
+ // FIXME: Strange to have the toolbar be tapable.
+ center: new Listener(
+ onPointerDown: handleBannerPointerDown,
+ child: new Text(banner, style: Theme.of(this.app).text.title)
)
- ],
- direction: FlexDirection.vertical,
- justifyContent: FlexJustifyContent.spaceAround);
+ );
+ }
+
+ Widget buildUI() {
+ return new Scaffold(
+ toolbar: buildToolBar(),
+ body: new Container(
+ child: new Center(child: buildBoard()),
+ decoration: new BoxDecoration(backgroundColor: colors.Grey[50])
+ )
+ );
}
void handleBannerPointerDown(sky.PointerEvent event) {
@@ -357,7 +361,7 @@ class MineDiggerApp extends App {
}
Widget build() {
- return game.generateUI();
+ return game.buildUI();
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698