| 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 'package:sky/mojo/activity.dart' as activity; | 5 import 'package:sky/mojo/activity.dart' as activity; |
| 6 import 'package:sky/mojo/asset_bundle.dart'; | 6 import 'package:sky/mojo/asset_bundle.dart'; |
| 7 import 'package:sky/painting/box_painter.dart'; | 7 import 'package:sky/painting/box_painter.dart'; |
| 8 import 'package:sky/theme/colors.dart' as colors; | 8 import 'package:sky/theme/colors.dart' as colors; |
| 9 import 'package:sky/theme/typography.dart' as typography; | 9 import 'package:sky/theme/typography.dart' as typography; |
| 10 import 'package:sky/widgets/basic.dart'; | 10 import 'package:sky/widgets/basic.dart'; |
| 11 import 'package:sky/widgets/card.dart'; | 11 import 'package:sky/widgets/card.dart'; |
| 12 import 'package:sky/widgets/material.dart'; | 12 import 'package:sky/widgets/material.dart'; |
| 13 import 'package:sky/widgets/scaffold.dart'; | 13 import 'package:sky/widgets/scaffold.dart'; |
| 14 import 'package:sky/widgets/task_description.dart'; | 14 import 'package:sky/widgets/task_description.dart'; |
| 15 import 'package:sky/widgets/theme.dart'; | 15 import 'package:sky/widgets/theme.dart'; |
| 16 import 'package:sky/widgets/tool_bar.dart'; | 16 import 'package:sky/widgets/tool_bar.dart'; |
| 17 import 'package:sky/widgets/scrollable_list.dart'; | 17 import 'package:sky/widgets/scrollable_list.dart'; |
| 18 import 'package:sky/widgets/ink_well.dart'; |
| 18 | 19 |
| 19 AssetBundle _initBundle() { | 20 AssetBundle _initBundle() { |
| 20 if (rootBundle != null) | 21 if (rootBundle != null) |
| 21 return rootBundle; | 22 return rootBundle; |
| 22 const String _kAssetBase = '..'; | 23 const String _kAssetBase = '..'; |
| 23 return new NetworkAssetBundle(Uri.base.resolve(_kAssetBase)); | 24 return new NetworkAssetBundle(Uri.base.resolve(_kAssetBase)); |
| 24 } | 25 } |
| 25 | 26 |
| 26 final AssetBundle _bundle = _initBundle(); | 27 final AssetBundle _bundle = _initBundle(); |
| 27 | 28 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 textTheme: typography.black, | 107 textTheme: typography.black, |
| 107 decoration: new BoxDecoration( | 108 decoration: new BoxDecoration( |
| 108 backgroundColor: colors.black, | 109 backgroundColor: colors.black, |
| 109 backgroundImage: new BackgroundImage( | 110 backgroundImage: new BackgroundImage( |
| 110 image: _bundle.loadImage('assets/sector_thumbnail.png'), | 111 image: _bundle.loadImage('assets/sector_thumbnail.png'), |
| 111 fit: BackgroundFit.cover | 112 fit: BackgroundFit.cover |
| 112 ) | 113 ) |
| 113 ) | 114 ) |
| 114 ), | 115 ), |
| 115 // new SkyDemo( | 116 // new SkyDemo( |
| 117 |
| 116 // 'Touch Demo', '../../rendering/touch_demo.dart', 'Simple example showing
handling of touch events at a low level'), | 118 // 'Touch Demo', '../../rendering/touch_demo.dart', 'Simple example showing
handling of touch events at a low level'), |
| 117 new SkyDemo( | 119 new SkyDemo( |
| 118 name: 'Minedigger Game', | 120 name: 'Minedigger Game', |
| 119 href: '../../mine_digger/lib/main.dart', | 121 href: '../../mine_digger/lib/main.dart', |
| 120 bundle: 'mine_digger.skyx', | 122 bundle: 'mine_digger.skyx', |
| 121 description: 'Clone of the classic Minesweeper game', | 123 description: 'Clone of the classic Minesweeper game', |
| 122 textTheme: typography.white | 124 textTheme: typography.white |
| 123 ), | 125 ), |
| 124 | 126 |
| 125 // TODO(jackson): This doesn't seem to be working | 127 // TODO(jackson): This doesn't seem to be working |
| 126 // new SkyDemo('Licenses', 'LICENSES.sky'), | 128 // new SkyDemo('Licenses', 'LICENSES.sky'), |
| 127 ]; | 129 ]; |
| 128 | 130 |
| 129 const double kCardHeight = 120.0; | 131 const double kCardHeight = 120.0; |
| 130 const EdgeDims kListPadding = const EdgeDims.all(4.0); | 132 const EdgeDims kListPadding = const EdgeDims.all(4.0); |
| 131 | 133 |
| 132 class DemoList extends Component { | 134 class DemoList extends Component { |
| 135 Widget buildCardContents(SkyDemo demo) { |
| 136 return new Container( |
| 137 decoration: demo.decoration, |
| 138 child: new InkWell( |
| 139 child: new Container( |
| 140 margin: const EdgeDims.all(24.0), |
| 141 child: new Flex([ |
| 142 new Text(demo.name, style: demo.textTheme.title), |
| 143 new Flexible( |
| 144 child: new Text(demo.description, style: demo.textTheme.subhead) |
| 145 ) |
| 146 ], |
| 147 direction: FlexDirection.vertical, |
| 148 alignItems: FlexAlignItems.start) |
| 149 ) |
| 150 ) |
| 151 ); |
| 152 } |
| 153 |
| 133 Widget buildDemo(SkyDemo demo) { | 154 Widget buildDemo(SkyDemo demo) { |
| 134 return new Listener( | 155 return new Listener( |
| 135 key: demo.name, | 156 key: demo.name, |
| 136 onGestureTap: (_) => launch(demo.href, demo.bundle), | 157 onGestureTap: (_) => launch(demo.href, demo.bundle), |
| 137 child: new Container( | 158 child: new Container( |
| 138 height: kCardHeight, | 159 height: kCardHeight, |
| 139 child: new Card( | 160 child: new Card( |
| 140 child: new Flex([ | 161 child: buildCardContents(demo) |
| 141 new Flexible( | |
| 142 child: new Stack([ | |
| 143 new Container( | |
| 144 decoration: demo.decoration, | |
| 145 child: new Container() | |
| 146 ), | |
| 147 new Container( | |
| 148 margin: const EdgeDims.all(24.0), | |
| 149 child: new Flex([ | |
| 150 new Text(demo.name, style: demo.textTheme.title), | |
| 151 new Flexible( | |
| 152 child: new Text(demo.description, style: demo.textTheme.
subhead) | |
| 153 ) | |
| 154 ], | |
| 155 direction: FlexDirection.vertical, | |
| 156 alignItems: FlexAlignItems.start) | |
| 157 ) | |
| 158 ]) | |
| 159 ), | |
| 160 ], direction: FlexDirection.vertical) | |
| 161 ) | 162 ) |
| 162 ) | 163 ) |
| 163 ); | 164 ); |
| 164 } | 165 } |
| 165 | 166 |
| 166 Widget build() { | 167 Widget build() { |
| 167 return new ScrollableList<SkyDemo>( | 168 return new ScrollableList<SkyDemo>( |
| 168 items: demos, | 169 items: demos, |
| 169 itemHeight: kCardHeight, | 170 itemHeight: kCardHeight, |
| 170 itemBuilder: buildDemo, | 171 itemBuilder: buildDemo, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 190 ) | 191 ) |
| 191 ) | 192 ) |
| 192 ) | 193 ) |
| 193 ); | 194 ); |
| 194 } | 195 } |
| 195 } | 196 } |
| 196 | 197 |
| 197 void main() { | 198 void main() { |
| 198 runApp(new SkyHome()); | 199 runApp(new SkyHome()); |
| 199 } | 200 } |
| OLD | NEW |