提交 d94e1d62 编写于 作者: A Adam Barth

Move home.dart into example/demo_launcher

This CL makes home.dart less of a special snowflake and instead makes it a peer
to the other Sky examples. As a result, we can add a sky.yaml file and embed
the thumbnail assets it needs into demo_launcher.skyx.

R=eseidel@chromium.org, eseidel@google.com

Review URL: https://codereview.chromium.org/1215703010.
上级 00dd5d3e
......@@ -12,7 +12,7 @@ import org.domokit.sky.shell.SkyActivity;
* Main activity for SkyDemo.
*/
public class SkyDemoActivity extends SkyActivity {
private static final String DEFAULT_URL = "https://domokit.github.io/home.dart";
private static final String DEFAULT_URL = "https://domokit.github.io/example/demo_launcher/lib/main.dart";
@Override
protected void onSkyReady() {
......
......@@ -9,6 +9,7 @@ group("example") {
if (is_android) {
deps += [
"//sky/sdk/example/demo_launcher",
"//sky/sdk/example/mine_digger",
"//sky/sdk/example/rendering",
"//sky/sdk/example/stocks",
......
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//sky/build/skyx.gni")
skyx("demo_launcher") {
main_dart = "lib/main.dart"
manifest = "sky.yaml"
}
......@@ -54,32 +54,32 @@ class SkyDemo {
List<Widget> demos = [
new SkyDemo(
name: 'Stocks',
href: 'example/stocks/lib/main.dart',
href: '../../stocks/lib/main.dart',
bundle: 'stocks.skyx',
description: 'Multi-screen app with scrolling list',
textTheme: typography.black,
decoration: new BoxDecoration(
backgroundImage: new BackgroundImage(
src: 'example/stocks/thumbnail.png',
src: '../assets/stocks_thumbnail.png',
fit: BackgroundFit.cover
)
)
),
new SkyDemo(
name: 'Asteroids',
href: 'example/game/main.dart',
href: '../../game/main.dart',
description: '2D game using sprite sheets to achieve high performance',
textTheme: typography.white,
decoration: new BoxDecoration(
backgroundImage: new BackgroundImage(
src: 'example/game/res/thumbnail.png',
src: '../assets/game_thumbnail.png',
fit: BackgroundFit.cover
)
)
),
new SkyDemo(
name: 'Interactive Flex',
href: 'example/rendering/interactive_flex.dart',
href: '../../rendering/interactive_flex.dart',
bundle: 'interactive_flex.skyx',
description: 'Swipe to adjust the layout of the app',
textTheme: typography.white,
......@@ -89,33 +89,28 @@ List<Widget> demos = [
),
new SkyDemo(
name: 'Sector',
href: 'example/widgets/sector.dart',
href: '../../widgets/sector.dart',
bundle: 'sector.skyx',
description: 'Demo of alternative layouts',
textTheme: typography.black,
decoration: new BoxDecoration(
backgroundColor: colors.Black,
backgroundImage: new BackgroundImage(
src: 'example/widgets/sector_thumbnail.png',
src: '../assets/sector_thumbnail.png',
fit: BackgroundFit.cover
)
)
),
// new SkyDemo(
// 'Touch Demo', 'examples/rendering/touch_demo.dart', 'Simple example showing handling of touch events at a low level'),
// 'Touch Demo', '../../rendering/touch_demo.dart', 'Simple example showing handling of touch events at a low level'),
new SkyDemo(
name: 'Minedigger Game',
href: 'example/mine_digger/lib/main.dart',
href: '../../mine_digger/lib/main.dart',
bundle: 'mine_digger.skyx',
description: 'Clone of the classic Minesweeper game',
textTheme: typography.white
),
// TODO(eseidel): We could use to separate these groups?
// new SkyDemo('Old Stocks App', 'examples/stocks/main.sky'),
// new SkyDemo('Old Touch Demo', 'examples/raw/touch-demo.sky'),
// new SkyDemo('Old Spinning Square', 'examples/raw/spinning-square.sky'),
// TODO(jackson): This doesn't seem to be working
// new SkyDemo('Licenses', 'LICENSES.sky'),
];
......
assets:
- assets/game_thumbnail.png
- assets/sector_thumbnail.png
- assets/stocks_thumbnail.png
......@@ -54,7 +54,6 @@ class TracingController {
class TracingIntentFilter extends IntentFilter {
TracingIntentFilter(Context context) {
Log.e(TAG, context.getPackageName() + TRACING_START);
addAction(context.getPackageName() + TRACING_START);
addAction(context.getPackageName() + TRACING_STOP);
}
......
......@@ -14,6 +14,21 @@ const List<String> kDensities = const ['drawable-xxhdpi'];
const List<String> kThemes = const ['white', 'black', 'grey600'];
const List<int> kSizes = const [24];
class Asset {
final String base;
final String key;
Asset({ this.base, this.key });
}
Iterable<Asset> parseAssets(Map manifestDescriptor, String manifestPath) sync* {
if (manifestDescriptor == null || !manifestDescriptor.containsKey('assets'))
return;
String basePath = new File(manifestPath).parent.path;
for (String asset in manifestDescriptor['assets'])
yield new Asset(base: basePath, key: asset);
}
class MaterialAsset {
final String name;
final String density;
......@@ -71,10 +86,10 @@ Future loadManifest(String manifestPath) async {
return loadYaml(manifestDescriptor);
}
Future<ArchiveFile> createFile(MaterialAsset asset, String assetBase) async {
File file = new File('${assetBase}/${asset.key}');
Future<ArchiveFile> createFile(String key, String assetBase) async {
File file = new File('${assetBase}/${key}');
List<int> content = await file.readAsBytes();
return new ArchiveFile.noCompress(asset.key, content.length, content);
return new ArchiveFile.noCompress(key, content.length, content);
}
Future<ArchiveFile> createSnapshotFile(String snapshotPath) async {
......@@ -99,6 +114,7 @@ main(List<String> argv) async {
String manifestPath = args['manifest'];
Map manifestDescriptor = await loadManifest(manifestPath);
Iterable<Asset> assets = parseAssets(manifestDescriptor, manifestPath);
Iterable<MaterialAsset> materialAssets = parseMaterialAssets(manifestDescriptor);
Archive archive = new Archive();
......@@ -107,8 +123,11 @@ main(List<String> argv) async {
if (snapshot != null)
archive.addFile(await createSnapshotFile(snapshot));
for (Asset asset in assets)
archive.addFile(await createFile(asset.key, asset.base));
for (MaterialAsset asset in materialAssets)
archive.addFile(await createFile(asset, args['asset-base']));
archive.addFile(await createFile(asset.key, args['asset-base']));
File outputFile = new File(args['output-file']);
await outputFile.writeAsBytes(new ZipEncoder().encode(archive));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册