| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:sky' as sky; | 5 import 'dart:sky' as sky; |
| 6 import 'dart:math'; | 6 import 'dart:math'; |
| 7 | 7 |
| 8 import 'package:sky/painting/text_style.dart'; |
| 8 import 'package:sky/rendering/flex.dart'; | 9 import 'package:sky/rendering/flex.dart'; |
| 10 import 'package:sky/theme/colors.dart' as colors; |
| 9 import 'package:sky/widgets/basic.dart'; | 11 import 'package:sky/widgets/basic.dart'; |
| 10 import 'package:sky/widgets/scaffold.dart'; | 12 import 'package:sky/widgets/scaffold.dart'; |
| 13 import 'package:sky/widgets/task_description.dart'; |
| 14 import 'package:sky/widgets/theme.dart'; |
| 11 import 'package:sky/widgets/tool_bar.dart'; | 15 import 'package:sky/widgets/tool_bar.dart'; |
| 12 import 'package:sky/widgets/theme.dart'; | |
| 13 import 'package:sky/theme/colors.dart' as colors; | |
| 14 import 'package:sky/painting/text_style.dart'; | |
| 15 | 16 |
| 16 // Classic minesweeper-inspired game. The mouse controls are standard except | 17 // Classic minesweeper-inspired game. The mouse controls are standard except |
| 17 // for left + right combo which is not implemented. For touch, the duration of | 18 // for left + right combo which is not implemented. For touch, the duration of |
| 18 // the pointer determines probing versus flagging. | 19 // the pointer determines probing versus flagging. |
| 19 // | 20 // |
| 20 // There are only 3 classes to understand. Game, which is contains all the | 21 // There are only 3 classes to understand. Game, which is contains all the |
| 21 // logic and two UI classes: CoveredMineNode and ExposedMineNode, none of them | 22 // logic and two UI classes: CoveredMineNode and ExposedMineNode, none of them |
| 22 // holding state. | 23 // holding state. |
| 23 | 24 |
| 24 class Game { | 25 class Game { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 onPointerDown: handleBannerPointerDown, | 168 onPointerDown: handleBannerPointerDown, |
| 168 child: new Text(banner, style: Theme.of(this.app).text.title) | 169 child: new Text(banner, style: Theme.of(this.app).text.title) |
| 169 ) | 170 ) |
| 170 ); | 171 ); |
| 171 } | 172 } |
| 172 | 173 |
| 173 Widget buildUI() { | 174 Widget buildUI() { |
| 174 // FIXME: We need to build the board before we build the toolbar because | 175 // FIXME: We need to build the board before we build the toolbar because |
| 175 // we compute the win state during build step. | 176 // we compute the win state during build step. |
| 176 Widget board = buildBoard(); | 177 Widget board = buildBoard(); |
| 177 return new Scaffold( | 178 return new TaskDescription( |
| 178 toolbar: buildToolBar(), | 179 label: 'Mine Digger', |
| 179 body: new Container( | 180 child: new Scaffold( |
| 180 child: new Center(child: board), | 181 toolbar: buildToolBar(), |
| 181 decoration: new BoxDecoration(backgroundColor: colors.Grey[50]) | 182 body: new Container( |
| 183 child: new Center(child: board), |
| 184 decoration: new BoxDecoration(backgroundColor: colors.Grey[50]) |
| 185 ) |
| 182 ) | 186 ) |
| 183 ); | 187 ); |
| 184 } | 188 } |
| 185 | 189 |
| 186 void handleBannerPointerDown(sky.PointerEvent event) { | 190 void handleBannerPointerDown(sky.PointerEvent event) { |
| 187 initialize(); | 191 initialize(); |
| 188 app.scheduleBuild(); | 192 app.scheduleBuild(); |
| 189 } | 193 } |
| 190 | 194 |
| 191 // User action. The user uncovers the cell which can cause losing the game. | 195 // User action. The user uncovers the cell which can cause losing the game. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 367 } |
| 364 | 368 |
| 365 Widget build() { | 369 Widget build() { |
| 366 return game.buildUI(); | 370 return game.buildUI(); |
| 367 } | 371 } |
| 368 } | 372 } |
| 369 | 373 |
| 370 void main() { | 374 void main() { |
| 371 runApp(new MineDiggerApp()); | 375 runApp(new MineDiggerApp()); |
| 372 } | 376 } |
| OLD | NEW |