From acfaf8ea62872a64f367b7de2dded2ac3eb2c540 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Tue, 17 Mar 2015 15:08:53 -0700 Subject: [PATCH] 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 --- .../{stocksapp.dart => lib/stock_app.dart} | 15 ++++-------- .../{stockarrow.dart => lib/stock_arrow.dart} | 20 ++++++++++------ .../lib/stock_data.dart} | 0 .../{stocklist.dart => lib/stock_list.dart} | 10 +++++++- .../{stockrow.dart => lib/stock_row.dart} | 23 ++++++++++++------- examples/stocks-fn/main.sky | 16 +++++++++++++ examples/stocks-fn/pubspec.yaml | 7 ++++++ examples/stocks-fn/stocks.sky | 10 -------- examples/stocks/stocks.sky | 2 +- sdk/packages/sky/pubspec.yaml | 2 +- 10 files changed, 67 insertions(+), 38 deletions(-) rename examples/stocks-fn/{stocksapp.dart => lib/stock_app.dart} (91%) rename examples/stocks-fn/{stockarrow.dart => lib/stock_arrow.dart} (78%) rename examples/{data/stocks.dart => stocks-fn/lib/stock_data.dart} (100%) rename examples/stocks-fn/{stocklist.dart => lib/stock_list.dart} (57%) rename examples/stocks-fn/{stockrow.dart => lib/stock_row.dart} (69%) create mode 100644 examples/stocks-fn/main.sky create mode 100644 examples/stocks-fn/pubspec.yaml delete mode 100644 examples/stocks-fn/stocks.sky 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 83e3c978d36..6ea4841b268 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 82e52815d2e..9524ffe37cc 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 @@ 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 _kRedColors = [ '#E57373', '#EF5350', @@ -45,6 +50,7 @@ class StockArrow extends Component { '#B71C1C', ]; + // TODO(abarth): These should use sky/framework/theme/colors.dart. final List _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/stocklist.dart b/examples/stocks-fn/lib/stock_list.dart similarity index 57% rename from examples/stocks-fn/stocklist.dart rename to examples/stocks-fn/lib/stock_list.dart index f7330d130bb..04738ba4d4b 100644 --- a/examples/stocks-fn/stocklist.dart +++ b/examples/stocks-fn/lib/stock_list.dart @@ -1,4 +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 '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; 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 4d7d688256e..6f75dee5db7 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 @@ 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; } diff --git a/examples/stocks-fn/main.sky b/examples/stocks-fn/main.sky new file mode 100644 index 00000000000..16c16888843 --- /dev/null +++ b/examples/stocks-fn/main.sky @@ -0,0 +1,16 @@ +#!mojo mojo:sky_viewer + + + + + diff --git a/examples/stocks-fn/pubspec.yaml b/examples/stocks-fn/pubspec.yaml new file mode 100644 index 00000000000..81725bd7d08 --- /dev/null +++ b/examples/stocks-fn/pubspec.yaml @@ -0,0 +1,7 @@ +name: stocks +author: Chromium Authors +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/stocks.sky b/examples/stocks-fn/stocks.sky deleted file mode 100644 index 50f9a4e3760..00000000000 --- a/examples/stocks-fn/stocks.sky +++ /dev/null @@ -1,10 +0,0 @@ -#!mojo mojo:sky_viewer - - - - diff --git a/examples/stocks/stocks.sky b/examples/stocks/stocks.sky index 6b97386f219..50d8fdd0c9e 100644 --- a/examples/stocks/stocks.sky +++ b/examples/stocks/stocks.sky @@ -70,7 +70,7 @@