| 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'; | 5 import 'dart:sky'; |
| 6 | 6 |
| 7 import 'package:mojom/intents/intents.mojom.dart'; | 7 import 'package:mojom/intents/intents.mojom.dart'; |
| 8 import 'package:sky/mojo/shell.dart' as shell; | 8 import 'package:sky/mojo/shell.dart' as shell; |
| 9 import 'package:sky/painting/box_painter.dart'; | 9 import 'package:sky/painting/box_painter.dart'; |
| 10 import 'package:sky/theme/colors.dart' as colors; | 10 import 'package:sky/theme/colors.dart' as colors; |
| 11 import 'package:sky/theme/edges.dart'; | 11 import 'package:sky/theme/edges.dart'; |
| 12 import 'package:sky/theme/typography.dart' as typography; | 12 import 'package:sky/theme/typography.dart' as typography; |
| 13 import 'package:sky/widgets/basic.dart'; | 13 import 'package:sky/widgets/basic.dart'; |
| 14 import 'package:sky/widgets/card.dart'; | 14 import 'package:sky/widgets/card.dart'; |
| 15 import 'package:sky/widgets/fixed_height_scrollable.dart'; | 15 import 'package:sky/widgets/fixed_height_scrollable.dart'; |
| 16 import 'package:sky/widgets/flat_button.dart'; | 16 import 'package:sky/widgets/flat_button.dart'; |
| 17 import 'package:sky/widgets/material.dart'; | 17 import 'package:sky/widgets/material.dart'; |
| 18 import 'package:sky/widgets/scaffold.dart'; | 18 import 'package:sky/widgets/scaffold.dart'; |
| 19 import 'package:sky/widgets/theme.dart'; | 19 import 'package:sky/widgets/theme.dart'; |
| 20 import 'package:sky/widgets/tool_bar.dart'; | 20 import 'package:sky/widgets/tool_bar.dart'; |
| 21 | 21 |
| 22 void launch(String relativeUrl) { | 22 void launch(String relativeUrl, String bundleName) { |
| 23 Uri url = Uri.base.resolve(relativeUrl); | 23 Uri url = Uri.base.resolve(relativeUrl); |
| 24 | 24 |
| 25 ActivityManagerProxy activityManager = new ActivityManagerProxy.unbound(); | 25 ActivityManagerProxy activityManager = new ActivityManagerProxy.unbound(); |
| 26 ComponentName component = new ComponentName() | 26 ComponentName component = new ComponentName() |
| 27 ..packageName = 'org.domokit.sky.demo' | 27 ..packageName = 'org.domokit.sky.demo' |
| 28 ..className = 'org.domokit.sky.demo.SkyDemoActivity'; | 28 ..className = 'org.domokit.sky.demo.SkyDemoActivity'; |
| 29 Intent intent = new Intent() | 29 Intent intent = new Intent() |
| 30 ..action = 'android.intent.action.VIEW' | 30 ..action = 'android.intent.action.VIEW' |
| 31 ..component = component | 31 ..component = component |
| 32 ..url = url.toString(); | 32 ..url = url.toString(); |
| 33 |
| 34 if (bundleName != null) { |
| 35 StringExtra extra = new StringExtra() |
| 36 ..name = 'bundleName' |
| 37 ..value = bundleName; |
| 38 intent.stringExtras = [extra]; |
| 39 } |
| 40 |
| 33 shell.requestService(null, activityManager); | 41 shell.requestService(null, activityManager); |
| 34 activityManager.ptr.startActivity(intent); | 42 activityManager.ptr.startActivity(intent); |
| 35 } | 43 } |
| 36 | 44 |
| 37 class SkyDemo { | 45 class SkyDemo { |
| 38 String name; | 46 String name; |
| 39 String href; | 47 String href; |
| 48 String bundleName; |
| 40 String description; | 49 String description; |
| 41 typography.TextTheme textTheme; | 50 typography.TextTheme textTheme; |
| 42 BoxDecoration decoration; | 51 BoxDecoration decoration; |
| 43 SkyDemo({ this.name, this.href, this.description, this.textTheme, this.decorat
ion }); | 52 SkyDemo({ this.name, this.href, this.bundleName, this.description, this.textTh
eme, this.decoration }); |
| 44 } | 53 } |
| 45 | 54 |
| 46 List<Widget> demos = [ | 55 List<Widget> demos = [ |
| 47 new SkyDemo( | 56 new SkyDemo( |
| 48 name: 'Stocks', | 57 name: 'Stocks', |
| 49 href: 'example/stocks/lib/main.dart', | 58 href: 'example/stocks/lib/main.dart', |
| 59 bundleName: 'stocks.skyx', |
| 50 description: 'Multi-screen app with scrolling list', | 60 description: 'Multi-screen app with scrolling list', |
| 51 textTheme: typography.black, | 61 textTheme: typography.black, |
| 52 decoration: new BoxDecoration( | 62 decoration: new BoxDecoration( |
| 53 backgroundImage: new BackgroundImage( | 63 backgroundImage: new BackgroundImage( |
| 54 src: 'example/stocks/thumbnail.png', | 64 src: 'example/stocks/thumbnail.png', |
| 55 fit: BackgroundFit.cover | 65 fit: BackgroundFit.cover |
| 56 ) | 66 ) |
| 57 ) | 67 ) |
| 58 ), | 68 ), |
| 59 new SkyDemo( | 69 new SkyDemo( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 87 backgroundImage: new BackgroundImage( | 97 backgroundImage: new BackgroundImage( |
| 88 src: 'example/widgets/sector_thumbnail.png', | 98 src: 'example/widgets/sector_thumbnail.png', |
| 89 fit: BackgroundFit.cover | 99 fit: BackgroundFit.cover |
| 90 ) | 100 ) |
| 91 ) | 101 ) |
| 92 ), | 102 ), |
| 93 // new SkyDemo( | 103 // new SkyDemo( |
| 94 // 'Touch Demo', 'examples/rendering/touch_demo.dart', 'Simple example showi
ng handling of touch events at a low level'), | 104 // 'Touch Demo', 'examples/rendering/touch_demo.dart', 'Simple example showi
ng handling of touch events at a low level'), |
| 95 new SkyDemo( | 105 new SkyDemo( |
| 96 name: 'Minedigger Game', | 106 name: 'Minedigger Game', |
| 97 href: 'example/mine_digger/mine_digger.dart', | 107 href: 'example/mine_digger/lib/main.dart', |
| 108 bundleName: 'mine_digger.skyx', |
| 98 description: 'Clone of the classic Minesweeper game', | 109 description: 'Clone of the classic Minesweeper game', |
| 99 textTheme: typography.white | 110 textTheme: typography.white |
| 100 ), | 111 ), |
| 101 | 112 |
| 102 // TODO(eseidel): We could use to separate these groups? | 113 // TODO(eseidel): We could use to separate these groups? |
| 103 // new SkyDemo('Old Stocks App', 'examples/stocks/main.sky'), | 114 // new SkyDemo('Old Stocks App', 'examples/stocks/main.sky'), |
| 104 // new SkyDemo('Old Touch Demo', 'examples/raw/touch-demo.sky'), | 115 // new SkyDemo('Old Touch Demo', 'examples/raw/touch-demo.sky'), |
| 105 // new SkyDemo('Old Spinning Square', 'examples/raw/spinning-square.sky'), | 116 // new SkyDemo('Old Spinning Square', 'examples/raw/spinning-square.sky'), |
| 106 | 117 |
| 107 // TODO(jackson): This doesn't seem to be working | 118 // TODO(jackson): This doesn't seem to be working |
| 108 // new SkyDemo('Licenses', 'LICENSES.sky'), | 119 // new SkyDemo('Licenses', 'LICENSES.sky'), |
| 109 ]; | 120 ]; |
| 110 | 121 |
| 111 const double kCardHeight = 120.0; | 122 const double kCardHeight = 120.0; |
| 112 const EdgeDims kListPadding = const EdgeDims.all(4.0); | 123 const EdgeDims kListPadding = const EdgeDims.all(4.0); |
| 113 | 124 |
| 114 class DemoList extends FixedHeightScrollable { | 125 class DemoList extends FixedHeightScrollable { |
| 115 DemoList({ String key }) : super(key: key, itemHeight: kCardHeight, padding: k
ListPadding) { | 126 DemoList({ String key }) : super(key: key, itemHeight: kCardHeight, padding: k
ListPadding) { |
| 116 itemCount = demos.length; | 127 itemCount = demos.length; |
| 117 } | 128 } |
| 118 | 129 |
| 119 Widget buildDemo(SkyDemo demo) { | 130 Widget buildDemo(SkyDemo demo) { |
| 120 return new Listener( | 131 return new Listener( |
| 121 key: demo.name, | 132 key: demo.name, |
| 122 onGestureTap: (_) => launch(demo.href), | 133 onGestureTap: (_) => launch(demo.href, demo.bundleName), |
| 123 child: new Container( | 134 child: new Container( |
| 124 height: kCardHeight, | 135 height: kCardHeight, |
| 125 child: new Card( | 136 child: new Card( |
| 126 child: new Flex([ | 137 child: new Flex([ |
| 127 new Flexible( | 138 new Flexible( |
| 128 child: new Stack([ | 139 child: new Stack([ |
| 129 new Container( | 140 new Container( |
| 130 decoration: demo.decoration, | 141 decoration: demo.decoration, |
| 131 child: new Container() | 142 child: new Container() |
| 132 ), | 143 ), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 child: new DemoList() | 179 child: new DemoList() |
| 169 ) | 180 ) |
| 170 ) | 181 ) |
| 171 ); | 182 ); |
| 172 } | 183 } |
| 173 } | 184 } |
| 174 | 185 |
| 175 void main() { | 186 void main() { |
| 176 runApp(new SkyHome()); | 187 runApp(new SkyHome()); |
| 177 } | 188 } |
| OLD | NEW |