Commit df9d48ac authored by Adam Barth's avatar Adam Barth

Make stocks-fn match the style for the Sky SDK

1) Add a pubspec.yaml.
2) Move all the code into a 'lib' directory.
3) Move the stock widgets out of the app's library.

TBR=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1011023003
parent d4f28b31
library stocksapp;
// 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 '../data/stocks.dart';
import 'dart:math';
import 'package:sky/framework/animation/scroll_behavior.dart';
import 'package:sky/framework/components/action_bar.dart';
import 'package:sky/framework/components/drawer.dart';
import 'package:sky/framework/components/drawer_header.dart';
import 'package:sky/framework/components/fixed_height_scrollable.dart';
import 'package:sky/framework/components/floating_action_button.dart';
import 'package:sky/framework/components/icon.dart';
import 'package:sky/framework/components/input.dart';
import 'package:sky/framework/components/material.dart';
import 'package:sky/framework/components/menu_divider.dart';
import 'package:sky/framework/components/menu_item.dart';
import 'package:sky/framework/fn.dart';
import 'package:sky/framework/theme/typography.dart' as typography;
part 'stockarrow.dart';
part 'stocklist.dart';
part 'stockrow.dart';
import 'stock_data.dart';
import 'stock_list.dart';
class StocksApp extends App {
......
part of stocksapp;
// 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.
class StockArrow extends Component {
double percentChange;
import 'dart:math';
import 'package:sky/framework/fn.dart';
static Style _style = new Style('''
class StockArrow extends Component {
static final Style _style = new Style('''
width: 40px;
height: 40px;
display: flex;
......@@ -15,7 +17,7 @@ class StockArrow extends Component {
border: 1px solid transparent;'''
);
static Style _upStyle = new Style('''
static final Style _upStyle = new Style('''
width: 0;
height: 0;
border-left: 9px solid transparent;
......@@ -24,7 +26,7 @@ class StockArrow extends Component {
border-bottom: 9px solid white;'''
);
static Style _downStyle = new Style('''
static final Style _downStyle = new Style('''
width: 0;
height: 0;
border-left: 9px solid transparent;
......@@ -33,8 +35,11 @@ class StockArrow extends Component {
border-top: 9px solid white'''
);
double percentChange;
StockArrow({ Object key, this.percentChange }) : super(key: key);
// TODO(abarth): These should use sky/framework/theme/colors.dart.
final List<String> _kRedColors = [
'#E57373',
'#EF5350',
......@@ -45,6 +50,7 @@ class StockArrow extends Component {
'#B71C1C',
];
// TODO(abarth): These should use sky/framework/theme/colors.dart.
final List<String> _kGreenColors = [
'#81C784',
'#66BB6A',
......
part of stocksapp;
// 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 'package:sky/framework/animation/scroll_behavior.dart';
import 'package:sky/framework/components/fixed_height_scrollable.dart';
import 'package:sky/framework/fn.dart';
import 'stock_data.dart';
import 'stock_row.dart';
class Stocklist extends FixedHeightScrollable {
String query;
......
part of stocksapp;
// 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.
class StockRow extends Component {
Stock stock;
import 'package:sky/framework/components/material.dart';
import 'package:sky/framework/fn.dart';
import 'package:sky/framework/theme/typography.dart' as typography;
import 'stock_arrow.dart';
import 'stock_data.dart';
static Style _style = new Style('''
class StockRow extends Component {
static final Style _style = new Style('''
transform: translateX(0);
display: flex;
align-items: center;
......@@ -15,20 +20,22 @@ class StockRow extends Component {
padding-bottom: 20px;'''
);
static Style _tickerStyle = new Style('''
static final Style _tickerStyle = new Style('''
flex: 1;'''
);
static Style _lastSaleStyle = new Style('''
static final Style _lastSaleStyle = new Style('''
text-align: right;
padding-right: 16px;'''
);
static Style _changeStyle = new Style('''
static final Style _changeStyle = new Style('''
${typography.black.caption};
text-align: right;'''
);
Stock stock;
StockRow({Stock stock}) : super(key: stock.symbol) {
this.stock = stock;
}
......
#!mojo mojo:sky_viewer
<!--
// 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.
-->
<sky>
<import src="/sky/framework/debug/shake-to-reload.sky" />
<script>
import 'stocksapp.dart';
// TODO(abarth): Should this be package:stocks/stocks_app.dart?
import 'lib/stock_app.dart';
main() {
new StocksApp();
}
......
name: stocks
author: Chromium Authors <sky-dev@googlegroups.com>
description: A demo application using Sky that shows stock data
homepage: https://github.com/domokit/mojo/tree/master/sky/examples/stocks-fn
version: 0.0.1
dependencies:
sky: '>=0.0.1 <1.0.0'
......@@ -70,7 +70,7 @@
<script>
import "dart:sky";
import "dart:math";
import "../data/stocks.dart" as model;
import "../stocks-fn/lib/stock_data.dart" as model;
List pick(List list, int count) {
var rng = new Random();
......
name: sky
author: Chromium Authors <sky-dev@googlegroups.com>
description: Dart files to support executing inside Sky.
homepage: https://github.com/domokit/mojo/sky
homepage: https://github.com/domokit/mojo/tree/master/sky
version: 0.0.1
dependencies:
mojo: '>=0.0.1 <1.0.0'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment