OLD | NEW |
| (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/framework/shell.dart' as shell; | |
9 import 'package:sky/theme/colors.dart' as colors; | |
10 import 'package:sky/theme/edges.dart'; | |
11 import 'package:sky/theme/typography.dart' as typography; | |
12 import 'package:sky/widgets/material.dart'; | |
13 import 'package:sky/widgets/raised_button.dart'; | |
14 import 'package:sky/widgets/scaffold.dart'; | |
15 import 'package:sky/widgets/tool_bar.dart'; | |
16 import 'package:sky/widgets/basic.dart'; | |
17 | |
18 void launch(String relativeUrl) { | |
19 Uri url = Uri.base.resolve(relativeUrl); | |
20 url = url.replace(scheme: 'sky'); | |
21 | |
22 ActivityManagerProxy activityManager = new ActivityManagerProxy.unbound(); | |
23 Intent intent = new Intent() | |
24 ..action = 'android.intent.action.VIEW' | |
25 ..url = url.toString(); | |
26 shell.requestService(null, activityManager); | |
27 activityManager.ptr.startActivity(intent); | |
28 } | |
29 | |
30 class SkyDemo extends Component { | |
31 String text; | |
32 String href; | |
33 | |
34 SkyDemo(String text, this.href) : this.text = text, super(key: text); | |
35 | |
36 void _handlePress() { | |
37 launch(href); | |
38 } | |
39 | |
40 Widget build() { | |
41 return new ConstrainedBox( | |
42 constraints: const BoxConstraints.expandWidth(), | |
43 child: new RaisedButton( | |
44 child: new Text(text), | |
45 onPressed: _handlePress | |
46 ) | |
47 ); | |
48 } | |
49 } | |
50 | |
51 class SkyHome extends App { | |
52 Widget build() { | |
53 List<Widget> children = [ | |
54 new SkyDemo('Stocks App', 'examples/stocks2/lib/stock_app.dart'), | |
55 new SkyDemo('Asteroids Game', 'examples/game/main.dart'), | |
56 new SkyDemo('Interactive Flex', 'examples/rendering/interactive_flex.dart'
), | |
57 new SkyDemo('Sector Layout', 'examples/widgets/sector.dart'), | |
58 new SkyDemo('Touch Demo', 'examples/rendering/touch_demo.dart'), | |
59 new SkyDemo('Minedigger Game', 'examples/mine_digger/mine_digger.dart'), | |
60 | |
61 // TODO(eseidel): We could use to separate these groups? | |
62 new SkyDemo('Old Stocks App', 'examples/stocks/main.sky'), | |
63 new SkyDemo('Old Touch Demo', 'examples/raw/touch-demo.sky'), | |
64 new SkyDemo('Old Spinning Square', 'examples/raw/spinning-square.sky'), | |
65 | |
66 new SkyDemo('Licences (Old)', 'LICENSES.sky'), | |
67 ]; | |
68 | |
69 return new Scaffold( | |
70 toolbar: new ToolBar( | |
71 center: new Text('Sky Demos', style: typography.white.title), | |
72 backgroundColor: colors.Blue[500]), | |
73 body: new Material( | |
74 edge: MaterialEdge.canvas, | |
75 child: new Flex( | |
76 children, | |
77 direction: FlexDirection.vertical, | |
78 justifyContent: FlexJustifyContent.spaceAround | |
79 ) | |
80 ) | |
81 ); | |
82 } | |
83 } | |
84 | |
85 void main() { | |
86 runApp(new SkyHome()); | |
87 } | |
OLD | NEW |