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

Unified Diff: sky/examples/stocks-fn/stockarrow.dart

Issue 1011023003: Make stocks-fn match the style for the Sky SDK (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: more Created 5 years, 9 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-fn/pubspec.yaml ('k') | sky/examples/stocks-fn/stocklist.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/stocks-fn/stockarrow.dart
diff --git a/sky/examples/stocks-fn/stockarrow.dart b/sky/examples/stocks-fn/stockarrow.dart
deleted file mode 100644
index 82e52815d2ea57b1d7763f6a0a54933d5c15e9cb..0000000000000000000000000000000000000000
--- a/sky/examples/stocks-fn/stockarrow.dart
+++ /dev/null
@@ -1,86 +0,0 @@
-part of stocksapp;
-
-class StockArrow extends Component {
-
- double percentChange;
-
- static Style _style = new Style('''
- width: 40px;
- height: 40px;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 40px;
- margin-right: 16px;
- border: 1px solid transparent;'''
- );
-
- static Style _upStyle = new Style('''
- width: 0;
- height: 0;
- border-left: 9px solid transparent;
- border-right: 9px solid transparent;
- margin-bottom: 3px;
- border-bottom: 9px solid white;'''
- );
-
- static Style _downStyle = new Style('''
- width: 0;
- height: 0;
- border-left: 9px solid transparent;
- border-right: 9px solid transparent;
- margin-top: 3px;
- border-top: 9px solid white'''
- );
-
- StockArrow({ Object key, this.percentChange }) : super(key: key);
-
- final List<String> _kRedColors = [
- '#E57373',
- '#EF5350',
- '#F44336',
- '#E53935',
- '#D32F2F',
- '#C62828',
- '#B71C1C',
- ];
-
- final List<String> _kGreenColors = [
- '#81C784',
- '#66BB6A',
- '#4CAF50',
- '#43A047',
- '#388E3C',
- '#2E7D32',
- '#1B5E20',
- ];
-
- int _colorIndexForPercentChange(double percentChange) {
- // Currently the max is 10%.
- double maxPercent = 10.0;
- return max(0, ((percentChange.abs() / maxPercent) * _kGreenColors.length).floor());
- }
-
- String _colorForPercentChange(double percentChange) {
- if (percentChange > 0)
- return _kGreenColors[_colorIndexForPercentChange(percentChange)];
- return _kRedColors[_colorIndexForPercentChange(percentChange)];
- }
-
- Node build() {
- String border = _colorForPercentChange(percentChange).toString();
- bool up = percentChange > 0;
- String type = up ? 'bottom' : 'top';
-
- return new Container(
- inlineStyle: 'border-color: $border',
- style: _style,
- children: [
- new Container(
- inlineStyle: 'border-$type-color: $border',
- style: up ? _upStyle : _downStyle
- )
- ]
- );
- }
-}
« no previous file with comments | « sky/examples/stocks-fn/pubspec.yaml ('k') | sky/examples/stocks-fn/stocklist.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698