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
diff --git a/examples/stocks-fn/stocksapp.dart b/examples/stocks-fn/lib/stock_app.dart
similarity index 91%
rename from examples/stocks-fn/stocksapp.dart
rename to examples/stocks-fn/lib/stock_app.dart
index 83e3c97..6ea4841 100644
--- a/examples/stocks-fn/stocksapp.dart
+++ b/examples/stocks-fn/lib/stock_app.dart
@@ -1,24 +1,19 @@
-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 {
 
diff --git a/examples/stocks-fn/stockarrow.dart b/examples/stocks-fn/lib/stock_arrow.dart
similarity index 78%
rename from examples/stocks-fn/stockarrow.dart
rename to examples/stocks-fn/lib/stock_arrow.dart
index 82e5281..9524ffe 100644
--- a/examples/stocks-fn/stockarrow.dart
+++ b/examples/stocks-fn/lib/stock_arrow.dart
@@ -1,10 +1,12 @@
-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 'dart:math';
+import 'package:sky/framework/fn.dart';
 
 class StockArrow extends Component {
-
-  double percentChange;
-
-  static Style _style = new Style('''
+  static final Style _style = new Style('''
     width: 40px;
     height: 40px;
     display: flex;
@@ -15,7 +17,7 @@
     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 @@
     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 @@
     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 @@
     '#B71C1C',
   ];
 
+  // TODO(abarth): These should use sky/framework/theme/colors.dart.
   final List<String> _kGreenColors = [
     '#81C784',
     '#66BB6A',
diff --git a/examples/data/stocks.dart b/examples/stocks-fn/lib/stock_data.dart
similarity index 100%
rename from examples/data/stocks.dart
rename to examples/stocks-fn/lib/stock_data.dart
diff --git a/examples/stocks-fn/lib/stock_list.dart b/examples/stocks-fn/lib/stock_list.dart
new file mode 100644
index 0000000..04738ba
--- /dev/null
+++ b/examples/stocks-fn/lib/stock_list.dart
@@ -0,0 +1,30 @@
+// 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;
+  List<Stock> stocks;
+
+  Stocklist({
+    Object key,
+    this.stocks,
+    this.query
+  }) : super(key: key, scrollBehavior: new OverscrollBehavior());
+
+  List<Node> buildItems(int start, int count) {
+    return stocks
+      .skip(start)
+      .where((stock) => query == null || stock.symbol.contains(
+          new RegExp(query, caseSensitive: false)))
+      .take(count)
+      .map((stock) => new StockRow(stock: stock))
+      .toList(growable: false);
+  }
+}
diff --git a/examples/stocks-fn/stockrow.dart b/examples/stocks-fn/lib/stock_row.dart
similarity index 69%
rename from examples/stocks-fn/stockrow.dart
rename to examples/stocks-fn/lib/stock_row.dart
index 4d7d688..6f75dee 100644
--- a/examples/stocks-fn/stockrow.dart
+++ b/examples/stocks-fn/lib/stock_row.dart
@@ -1,10 +1,15 @@
-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/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';
 
 class StockRow extends Component {
-
-  Stock stock;
-
-  static Style _style = new Style('''
+  static final Style _style = new Style('''
     transform: translateX(0);
     display: flex;
     align-items: center;
@@ -15,20 +20,22 @@
     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;
   }
diff --git a/examples/stocks-fn/main.sky b/examples/stocks-fn/main.sky
new file mode 100644
index 0000000..16c1688
--- /dev/null
+++ b/examples/stocks-fn/main.sky
@@ -0,0 +1,16 @@
+#!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>
+// TODO(abarth): Should this be package:stocks/stocks_app.dart?
+import 'lib/stock_app.dart';
+main() {
+  new StocksApp();
+}
+</script>
+</sky>
diff --git a/examples/stocks-fn/pubspec.yaml b/examples/stocks-fn/pubspec.yaml
new file mode 100644
index 0000000..81725bd
--- /dev/null
+++ b/examples/stocks-fn/pubspec.yaml
@@ -0,0 +1,7 @@
+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'
diff --git a/examples/stocks-fn/stocklist.dart b/examples/stocks-fn/stocklist.dart
deleted file mode 100644
index f7330d1..0000000
--- a/examples/stocks-fn/stocklist.dart
+++ /dev/null
@@ -1,22 +0,0 @@
-part of stocksapp;
-
-class Stocklist extends FixedHeightScrollable {
-  String query;
-  List<Stock> stocks;
-
-  Stocklist({
-    Object key,
-    this.stocks,
-    this.query
-  }) : super(key: key, scrollBehavior: new OverscrollBehavior());
-
-  List<Node> buildItems(int start, int count) {
-    return stocks
-      .skip(start)
-      .where((stock) => query == null || stock.symbol.contains(
-          new RegExp(query, caseSensitive: false)))
-      .take(count)
-      .map((stock) => new StockRow(stock: stock))
-      .toList(growable: false);
-  }
-}
diff --git a/examples/stocks-fn/stocks.sky b/examples/stocks-fn/stocks.sky
deleted file mode 100644
index 50f9a4e..0000000
--- a/examples/stocks-fn/stocks.sky
+++ /dev/null
@@ -1,10 +0,0 @@
-#!mojo mojo:sky_viewer
-<sky>
-<import src="/sky/framework/debug/shake-to-reload.sky" />
-<script>
-import 'stocksapp.dart';
-main() {
-  new StocksApp();
-}
-</script>
-</sky>
diff --git a/examples/stocks/stocks.sky b/examples/stocks/stocks.sky
index 6b97386..50d8fdd 100644
--- a/examples/stocks/stocks.sky
+++ b/examples/stocks/stocks.sky
@@ -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();
diff --git a/packages/flutter/pubspec.yaml b/packages/flutter/pubspec.yaml
index 548456a..8d9c4d8 100644
--- a/packages/flutter/pubspec.yaml
+++ b/packages/flutter/pubspec.yaml
@@ -1,7 +1,7 @@
 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'