Commit fa8c4515 authored by Hixie's avatar Hixie Committed by Ian Hickson

Heroes

parent 8414b4c1
......@@ -186,14 +186,16 @@ class StockHomeState extends State<StockHome> {
Widget buildStockList(BuildContext context, Iterable<Stock> stocks) {
return new StockList(
stocks: stocks.toList(),
onAction: (Stock stock, GlobalKey arrowKey) {
onAction: (Stock stock, Key arrowKey) {
setState(() {
stock.percentChange = 100.0 * (1.0 / stock.lastSale);
stock.lastSale += 1.0;
});
},
onOpen: (Stock stock, GlobalKey arrowKey) {
config.navigator.pushNamed('/stock/${stock.symbol}');
onOpen: (Stock stock, Key arrowKey) {
Set<Key> mostValuableKeys = new Set<Key>();
mostValuableKeys.add(arrowKey);
config.navigator.pushNamed('/stock/${stock.symbol}', mostValuableKeys: mostValuableKeys);
}
);
}
......
......@@ -6,7 +6,7 @@ part of stocks;
enum StockRowPartKind { arrow }
class StockRowPartKey extends GlobalKey {
class StockRowPartKey extends Key {
const StockRowPartKey(this.stock, this.part) : super.constructor();
final Stock stock;
final StockRowPartKind part;
......@@ -21,7 +21,7 @@ class StockRowPartKey extends GlobalKey {
String toString() => '[StockRowPartKey ${stock.symbol}:${part.toString().split(".")[1]})]';
}
typedef void StockRowActionCallback(Stock stock, GlobalKey arrowKey);
typedef void StockRowActionCallback(Stock stock, Key arrowKey);
class StockRow extends StatelessComponent {
StockRow({
......@@ -30,7 +30,7 @@ class StockRow extends StatelessComponent {
this.onLongPressed
}) : this.stock = stock,
_arrowKey = new StockRowPartKey(stock, StockRowPartKind.arrow),
super(key: new GlobalObjectKey(stock));
super(key: new ObjectKey(stock));
final Stock stock;
final StockRowActionCallback onPressed;
......@@ -53,7 +53,7 @@ class StockRow extends StatelessComponent {
}
Widget build(BuildContext context) {
String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}";
final String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}";
String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%";
if (stock.percentChange > 0)
changeInPrice = "+" + changeInPrice;
......@@ -69,9 +69,12 @@ class StockRow extends StatelessComponent {
),
child: new Row(<Widget>[
new Container(
key: _arrowKey,
child: new StockArrow(percentChange: stock.percentChange),
margin: const EdgeDims.only(right: 5.0)
margin: const EdgeDims.only(right: 5.0),
child: new Hero(
tag: StockRowPartKind.arrow,
key: _arrowKey,
child: new StockArrow(percentChange: stock.percentChange)
)
),
new Flexible(
child: new Row(<Widget>[
......
......@@ -36,7 +36,11 @@ class StockSymbolViewer extends StatelessComponent {
'${stock.symbol}',
style: Theme.of(context).text.display2
),
new StockArrow(percentChange: stock.percentChange)
new Hero(
tag: StockRowPartKind.arrow,
turns: 2,
child: new StockArrow(percentChange: stock.percentChange)
),
],
justifyContent: FlexJustifyContent.spaceBetween
),
......@@ -51,7 +55,8 @@ class StockSymbolViewer extends StatelessComponent {
)
)
)
])
]
)
);
}
......
This diff is collapsed.
......@@ -16,6 +16,7 @@ export 'src/widgets/focus.dart';
export 'src/widgets/framework.dart';
export 'src/widgets/gesture_detector.dart';
export 'src/widgets/gridpaper.dart';
export 'src/widgets/heroes.dart';
export 'src/widgets/homogeneous_viewport.dart';
export 'src/widgets/mimic.dart';
export 'src/widgets/mixed_viewport.dart';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment