Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: sky/examples/stocks/stocks.sky

Issue 930193004: Attempt to make the stocks example more more material-friendly. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/examples/stocks/stock.sky ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/stocks/stocks.sky
diff --git a/sky/examples/stocks/stocks.sky b/sky/examples/stocks/stocks.sky
index d5637b72e5fb6f5a0e707478d0c1ba2d6db26998..60138108c186e1db22fdb0a02b6bf689d2fee466 100644
--- a/sky/examples/stocks/stocks.sky
+++ b/sky/examples/stocks/stocks.sky
@@ -16,7 +16,8 @@
display: flex;
flex-direction: column;
height: -webkit-fill-available;
- font: 'Helvetica';
+ font-family: 'Roboto Regular', 'Helvetica';
+ font-size: 16px;
}
sky-drawer {
position: absolute;
@@ -66,6 +67,15 @@
import "dart:sky";
import "dart:math";
+List pick(List list, int count) {
+ var rng = new Random();
+ List picked = new List();
+ for (int i = 0; i < count; i++) {
+ picked.add(list[rng.nextInt(list.length)]);
+ }
+ return picked;
+}
+
@Tagname('stocks')
class Stocks extends SkyElement {
Element _drawer;
@@ -80,10 +90,9 @@ class Stocks extends SkyElement {
void populateStockList() {
Element stockList = shadowRoot.getElementById('stock_list');
// Limit to 100 to avoid taking seconds to load.
- var rng = new Random();
- for (var i = 0; i < 100; i++) {
- List<model.Stock> list = model.oracle.stocks;
- model.Stock stock = list[rng.nextInt(list.length)];
+ List<model.Stock> picked = pick(model.oracle.stocks, 100);
+ picked.sort((a, b) => a.symbol.compareTo(b.symbol));
+ for (model.Stock stock in picked) {
stockList.appendChild(new view.Stock()..model = stock);
}
}
« no previous file with comments | « sky/examples/stocks/stock.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698