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

Side by Side Diff: sky/sdk/home.dart

Issue 1215703010: Move home.dart into example/demo_launcher (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 import 'dart:sky';
6
7 import 'package:mojom/intents/intents.mojom.dart';
8 import 'package:sky/mojo/shell.dart' as shell;
9 import 'package:sky/painting/box_painter.dart';
10 import 'package:sky/theme/colors.dart' as colors;
11 import 'package:sky/theme/typography.dart' as typography;
12 import 'package:sky/widgets/basic.dart';
13 import 'package:sky/widgets/card.dart';
14 import 'package:sky/widgets/fixed_height_scrollable.dart';
15 import 'package:sky/widgets/flat_button.dart';
16 import 'package:sky/widgets/material.dart';
17 import 'package:sky/widgets/scaffold.dart';
18 import 'package:sky/widgets/theme.dart';
19 import 'package:sky/widgets/tool_bar.dart';
20
21 void launch(String relativeUrl, String bundle) {
22 Uri url = Uri.base.resolve(relativeUrl);
23
24 ActivityManagerProxy activityManager = new ActivityManagerProxy.unbound();
25 ComponentName component = new ComponentName()
26 ..packageName = 'org.domokit.sky.demo'
27 ..className = 'org.domokit.sky.demo.SkyDemoActivity';
28 Intent intent = new Intent()
29 ..action = 'android.intent.action.VIEW'
30 ..component = component
31 ..url = url.toString();
32
33 if (bundle != null) {
34 StringExtra extra = new StringExtra()
35 ..name = 'bundleName'
36 ..value = bundle;
37 intent.stringExtras = [extra];
38 }
39
40 shell.requestService(null, activityManager);
41 activityManager.ptr.startActivity(intent);
42 }
43
44 class SkyDemo {
45 String name;
46 String href;
47 String bundle;
48 String description;
49 typography.TextTheme textTheme;
50 BoxDecoration decoration;
51 SkyDemo({ this.name, this.href, this.bundle, this.description, this.textTheme, this.decoration });
52 }
53
54 List<Widget> demos = [
55 new SkyDemo(
56 name: 'Stocks',
57 href: 'example/stocks/lib/main.dart',
58 bundle: 'stocks.skyx',
59 description: 'Multi-screen app with scrolling list',
60 textTheme: typography.black,
61 decoration: new BoxDecoration(
62 backgroundImage: new BackgroundImage(
63 src: 'example/stocks/thumbnail.png',
64 fit: BackgroundFit.cover
65 )
66 )
67 ),
68 new SkyDemo(
69 name: 'Asteroids',
70 href: 'example/game/main.dart',
71 description: '2D game using sprite sheets to achieve high performance',
72 textTheme: typography.white,
73 decoration: new BoxDecoration(
74 backgroundImage: new BackgroundImage(
75 src: 'example/game/res/thumbnail.png',
76 fit: BackgroundFit.cover
77 )
78 )
79 ),
80 new SkyDemo(
81 name: 'Interactive Flex',
82 href: 'example/rendering/interactive_flex.dart',
83 bundle: 'interactive_flex.skyx',
84 description: 'Swipe to adjust the layout of the app',
85 textTheme: typography.white,
86 decoration: new BoxDecoration(
87 backgroundColor: const Color(0xFF0081C6)
88 )
89 ),
90 new SkyDemo(
91 name: 'Sector',
92 href: 'example/widgets/sector.dart',
93 bundle: 'sector.skyx',
94 description: 'Demo of alternative layouts',
95 textTheme: typography.black,
96 decoration: new BoxDecoration(
97 backgroundColor: colors.Black,
98 backgroundImage: new BackgroundImage(
99 src: 'example/widgets/sector_thumbnail.png',
100 fit: BackgroundFit.cover
101 )
102 )
103 ),
104 // new SkyDemo(
105 // 'Touch Demo', 'examples/rendering/touch_demo.dart', 'Simple example showi ng handling of touch events at a low level'),
106 new SkyDemo(
107 name: 'Minedigger Game',
108 href: 'example/mine_digger/lib/main.dart',
109 bundle: 'mine_digger.skyx',
110 description: 'Clone of the classic Minesweeper game',
111 textTheme: typography.white
112 ),
113
114 // TODO(eseidel): We could use to separate these groups?
115 // new SkyDemo('Old Stocks App', 'examples/stocks/main.sky'),
116 // new SkyDemo('Old Touch Demo', 'examples/raw/touch-demo.sky'),
117 // new SkyDemo('Old Spinning Square', 'examples/raw/spinning-square.sky'),
118
119 // TODO(jackson): This doesn't seem to be working
120 // new SkyDemo('Licenses', 'LICENSES.sky'),
121 ];
122
123 const double kCardHeight = 120.0;
124 const EdgeDims kListPadding = const EdgeDims.all(4.0);
125
126 class DemoList extends FixedHeightScrollable {
127 DemoList({ String key }) : super(key: key, itemHeight: kCardHeight, padding: k ListPadding) {
128 itemCount = demos.length;
129 }
130
131 Widget buildDemo(SkyDemo demo) {
132 return new Listener(
133 key: demo.name,
134 onGestureTap: (_) => launch(demo.href, demo.bundle),
135 child: new Container(
136 height: kCardHeight,
137 child: new Card(
138 child: new Flex([
139 new Flexible(
140 child: new Stack([
141 new Container(
142 decoration: demo.decoration,
143 child: new Container()
144 ),
145 new Container(
146 margin: const EdgeDims.all(24.0),
147 child: new Block([
148 new Text(demo.name, style: demo.textTheme.title),
149 new Text(demo.description, style: demo.textTheme.subhead)
150 ])
151 )
152 ])
153 ),
154 ], direction: FlexDirection.vertical)
155 )
156 )
157 );
158 }
159
160 List<Widget> buildItems(int start, int count) {
161 return demos
162 .skip(start)
163 .take(count)
164 .map(buildDemo)
165 .toList(growable: false);
166 }
167 }
168
169 class SkyHome extends App {
170 Widget build() {
171 return new Theme(
172 data: new ThemeData(
173 brightness: ThemeBrightness.dark,
174 primarySwatch: colors.Teal
175 ),
176 child: new Scaffold(
177 toolbar: new ToolBar(center: new Text('Sky Demos')),
178 body: new Material(
179 type: MaterialType.canvas,
180 child: new DemoList()
181 )
182 )
183 );
184 }
185 }
186
187 void main() {
188 runApp(new SkyHome());
189 }
OLDNEW
« no previous file with comments | « sky/sdk/example/widgets/sector_thumbnail.png ('k') | sky/shell/android/org/domokit/sky/shell/TracingController.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698