mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Port sky_home to the new SkyView world
R=ianh@google.com, eseidel@chromium.org Review URL: https://codereview.chromium.org/1178293004.
This commit is contained in:
parent
f3c036dd64
commit
ff9b0b092c
83
engine/src/flutter/home.dart
Normal file
83
engine/src/flutter/home.dart
Normal file
@ -0,0 +1,83 @@
|
||||
// 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 'dart:sky';
|
||||
|
||||
import 'package:mojom/intents/intents.mojom.dart';
|
||||
import 'package:sky/framework/shell.dart' as shell;
|
||||
import 'package:sky/framework/theme2/colors.dart' as colors;
|
||||
import 'package:sky/framework/theme2/edges.dart';
|
||||
import 'package:sky/framework/theme2/typography.dart' as typography;
|
||||
import 'package:sky/framework/widgets/material.dart';
|
||||
import 'package:sky/framework/widgets/raised_button.dart';
|
||||
import 'package:sky/framework/widgets/scaffold.dart';
|
||||
import 'package:sky/framework/widgets/tool_bar.dart';
|
||||
import 'package:sky/framework/widgets/wrappers.dart';
|
||||
|
||||
void launch(String relativeUrl) {
|
||||
Uri url = Uri.base.resolve(relativeUrl);
|
||||
url = url.replace(scheme: 'sky');
|
||||
|
||||
ActivityManagerProxy activityManager = new ActivityManagerProxy.unbound();
|
||||
Intent intent = new Intent()
|
||||
..action = 'android.intent.action.VIEW'
|
||||
..url = url.toString();
|
||||
shell.requestService(null, activityManager);
|
||||
activityManager.ptr.startActivity(intent);
|
||||
}
|
||||
|
||||
class SkyDemo extends Component {
|
||||
String text;
|
||||
String href;
|
||||
|
||||
SkyDemo(String text, this.href) : this.text = text, super(key: text);
|
||||
|
||||
void _handlePress() {
|
||||
launch(href);
|
||||
}
|
||||
|
||||
UINode build() {
|
||||
return new RaisedButton(
|
||||
child: new Text(text),
|
||||
onPressed: _handlePress
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SkyHome extends App {
|
||||
UINode build() {
|
||||
List<UINode> children = [
|
||||
new SkyDemo('Stocks2 App', 'examples/stocks2/lib/stock_app.dart'),
|
||||
new SkyDemo('Box2D Game', 'examples/game/main.dart'),
|
||||
new SkyDemo('Interactive Flex', 'examples/rendering/interactive_flex.dart'),
|
||||
new SkyDemo('Sector Layout', 'examples/rendering/sector_layout.dart'),
|
||||
new SkyDemo('Touch Demo', 'examples/rendering/touch_demo.dart'),
|
||||
|
||||
// TODO(eseidel): We could use to separate these groups?
|
||||
new SkyDemo('Stocks App (Old)', 'examples/stocks/main.sky'),
|
||||
new SkyDemo('Touch Demo (Old)', 'examples/raw/touch-demo.sky'),
|
||||
new SkyDemo('Spinning Square (Old)', 'examples/raw/spinning-square.sky'),
|
||||
|
||||
new SkyDemo('Licences (Old)', 'LICENSES.sky'),
|
||||
];
|
||||
|
||||
return new Scaffold(
|
||||
toolbar: new ToolBar(
|
||||
center: new Text('Sky Demos', style: typography.white.title),
|
||||
backgroundColor: colors.Blue[500]),
|
||||
body: new Material(
|
||||
edge: MaterialEdge.canvas,
|
||||
child: new Flex(
|
||||
children,
|
||||
direction: FlexDirection.vertical,
|
||||
justifyContent: FlexJustifyContent.spaceAround
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
new SkyHome();
|
||||
}
|
||||
@ -53,7 +53,7 @@
|
||||
Sky Load URL
|
||||
-->
|
||||
<key>com.google.sky.load_url</key>
|
||||
<string>https://domokit.github.io/sky_home</string>
|
||||
<string>https://domokit.github.io/home.dart</string>
|
||||
|
||||
<!--
|
||||
FIXME(csg): Xcode, as part of its build process, adds the following
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
#!mojo mojo:sky_viewer
|
||||
<sky>
|
||||
<script>
|
||||
import 'sky_home.dart';
|
||||
|
||||
void main() {
|
||||
new SkyHome();
|
||||
}
|
||||
</script>
|
||||
</sky>
|
||||
@ -1,56 +0,0 @@
|
||||
import 'dart:sky';
|
||||
import 'package:sky/framework/fn.dart';
|
||||
import 'package:sky/framework/components/button.dart';
|
||||
import 'package:sky/framework/components/scaffold.dart';
|
||||
import 'package:sky/framework/components/tool_bar.dart';
|
||||
import 'package:sky/framework/theme/colors.dart';
|
||||
import 'package:sky/framework/theme/typography.dart' as typography;
|
||||
|
||||
class SkyLink extends Component {
|
||||
String text;
|
||||
String href;
|
||||
|
||||
SkyLink(String text, this.href) : this.text = text, super(key: text);
|
||||
|
||||
UINode build() {
|
||||
return new EventListenerNode(
|
||||
new Button(key: text, content: new Text(text), level: 1),
|
||||
onPointerUp: (_) => window.location.href = href
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SkyHome extends App {
|
||||
static final Style _actionBarStyle = new Style('''
|
||||
background-color: ${Green[500]};''');
|
||||
|
||||
static final Style _titleStyle = new Style('''
|
||||
${typography.white.title};''');
|
||||
|
||||
UINode build() {
|
||||
List<UINode> children = [
|
||||
new SkyLink('Stocks2 App', 'examples/stocks2/lib/stock_app.dart'),
|
||||
new SkyLink('Box2D Game', 'examples/game/main.dart'),
|
||||
new SkyLink('Interactive Flex', 'examples/rendering/interactive_flex.dart'),
|
||||
new SkyLink('Sector Layout', 'examples/rendering/sector_layout.dart'),
|
||||
new SkyLink('Touch Demo', 'examples/rendering/touch_demo.dart'),
|
||||
|
||||
// TODO(eseidel): We could use to separate these groups?
|
||||
new SkyLink('Stocks App (Old)', 'examples/stocks/main.sky'),
|
||||
new SkyLink('Touch Demo (Old)', 'examples/raw/touch-demo.sky'),
|
||||
new SkyLink('Spinning Square (Old)', 'examples/raw/spinning-square.sky'),
|
||||
|
||||
new SkyLink('Licences (Old)', 'LICENSES.sky'),
|
||||
];
|
||||
|
||||
return new Scaffold(
|
||||
// FIXME: ActionBar should have a better default style than transparent.
|
||||
header: new StyleNode(
|
||||
// FIXME: left should be optional, but currently crashes when null.
|
||||
new ToolBar(left: new Text(''),
|
||||
center: new Container(children: [new Text('Sky Demos')], style: _titleStyle)),
|
||||
_actionBarStyle),
|
||||
content: new Container(children: children)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ SRC_ROOT = os.path.dirname(SKY_ROOT)
|
||||
GDB_PORT = 8888
|
||||
SKY_SERVER_PORT = 9888
|
||||
OBSERVATORY_PORT = 8181
|
||||
DEFAULT_URL = "sky://domokit.github.io/sky_home"
|
||||
DEFAULT_URL = "sky://domokit.github.io/home.dart"
|
||||
APK_NAME = 'SkyDemo.apk'
|
||||
ADB_PATH = os.path.join(SRC_ROOT,
|
||||
'third_party/android_tools/sdk/platform-tools/adb')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user