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
This commit is contained in:
parent
d4f28b311e
commit
df9d48ac83
@ -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 {
|
||||
|
@ -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<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',
|
@ -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;
|
@ -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;
|
||||
}
|
16
examples/stocks-fn/main.sky
Normal file
16
examples/stocks-fn/main.sky
Normal file
@ -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>
|
7
examples/stocks-fn/pubspec.yaml
Normal file
7
examples/stocks-fn/pubspec.yaml
Normal file
@ -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'
|
@ -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>
|
@ -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();
|
||||
|
@ -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'
|
||||
|
Loading…
x
Reference in New Issue
Block a user