diff --git a/sdk/example/stocks/lib/stock_home.dart b/sdk/example/stocks/lib/stock_home.dart index 7182f51f847..24a9853c925 100644 --- a/sdk/example/stocks/lib/stock_home.dart +++ b/sdk/example/stocks/lib/stock_home.dart @@ -17,6 +17,7 @@ import 'package:sky/widgets/navigator.dart'; import 'package:sky/widgets/popup_menu.dart'; import 'package:sky/widgets/radio.dart'; import 'package:sky/widgets/scaffold.dart'; +import 'package:sky/widgets/tabs.dart'; import 'package:sky/widgets/tool_bar.dart'; import 'package:sky/widgets/widget.dart'; @@ -160,7 +161,7 @@ class StockHome extends Component { _drawerController.close(); }); } - + Widget buildToolBar() { return new ToolBar( left: new IconButton( @@ -178,6 +179,36 @@ class StockHome extends Component { ); } + int selectedTabIndex = 0; + List portfolioSymbols = ["AAPL","FIZZ", "FIVE", "FLAT", "ZINC", "ZNGA"]; + + Widget buildPortfolioStocklist() { + return new Stocklist( + stocks: stocks.where((s) => portfolioSymbols.contains(s.symbol)).toList(), + query: _searchQuery + ); + } + + Widget buildTabNavigator() { + List views = [ + new TabNavigatorView( + label: const TabLabel(text: 'MARKET'), + builder: () => new Stocklist(stocks: stocks, query: _searchQuery) + ), + new TabNavigatorView( + label: const TabLabel(text: 'PORTFOLIO'), + builder: buildPortfolioStocklist + ) + ]; + return new TabNavigator( + views: views, + selectedIndex: selectedTabIndex, + onChanged: (tabIndex) { + setState(() { selectedTabIndex = tabIndex; } ); + } + ); + } + // TODO(abarth): Should we factor this into a SearchBar in the framework? Widget buildSearchBar() { return new ToolBar( @@ -208,7 +239,7 @@ class StockHome extends Component { List overlays = [ new Scaffold( toolbar: _isSearching ? buildSearchBar() : buildToolBar(), - body: new Stocklist(stocks: stocks, query: _searchQuery), + body: buildTabNavigator(), floatingActionButton: new FloatingActionButton( child: new Icon(type: 'content/add_white', size: 24) ), diff --git a/sdk/lib/editing/editable_text.dart b/sdk/lib/editing/editable_text.dart index 3d18a877d45..7b0328430d3 100644 --- a/sdk/lib/editing/editable_text.dart +++ b/sdk/lib/editing/editable_text.dart @@ -67,7 +67,6 @@ class EditableText extends Component { if (!_showCursor) return; - print("Draw cursor"); Rect cursorRect = new Rect.fromLTWH( _kCursorGap, -_kCursorHeightOffset, diff --git a/sdk/lib/widgets/fixed_height_scrollable.dart b/sdk/lib/widgets/fixed_height_scrollable.dart index 01ac4f9ac36..1a0997cf7f1 100644 --- a/sdk/lib/widgets/fixed_height_scrollable.dart +++ b/sdk/lib/widgets/fixed_height_scrollable.dart @@ -49,6 +49,14 @@ abstract class FixedHeightScrollable extends Scrollable { }); } + bool scrollTo(double newScrollOffset) { + if (_height != null && _height > 0.0) { + double maxScrollOffset = math.max(0.0, itemCount * itemHeight - _height); + newScrollOffset = math.min(newScrollOffset, maxScrollOffset); + } + return super.scrollTo(newScrollOffset); + } + Widget buildContent() { var itemShowIndex = 0; var itemShowCount = 0; diff --git a/tests/examples/stocks-expected.txt b/tests/examples/stocks-expected.txt index fafea500fe1..52d64de6b1c 100644 --- a/tests/examples/stocks-expected.txt +++ b/tests/examples/stocks-expected.txt @@ -10,16 +10,36 @@ PAINT FOR FRAME #2 ---------------------------------------------- 2 | | TestPaintingCanvas() constructor: 800.0 x 600.0 2 | | paintChild RenderScaffold at Point(0.0, 0.0) 2 | | | TestPaintingCanvas() constructor: 800.0 x 600.0 -2 | | | paintChild RenderDecoratedBox at Point(0.0, 81.0) +2 | | | paintChild RenderFlex at Point(0.0, 81.0) 2 | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 -2 | | | | drawRect(Rect.fromLTRB(0.0, 81.0, 800.0, 600.0), Paint(color:Color(0xfffafafa))) -2 | | | | save -2 | | | | clipRect(Rect.fromLTRB(0.0, 81.0, 800.0, 600.0)) -2 | | | | save -2 | | | | translate(0.0, 81.0) -2 | | | | concat([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]) -2 | | | | restore -2 | | | | restore +2 | | | | paintChild RenderTabBar at Point(0.0, 81.0) +2 | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +2 | | | | | drawRect(Rect.fromLTRB(0.0, 81.0, 800.0, 129.0), Paint(color:Color(0xff9c27b0))) +2 | | | | | paintChild RenderInkWell at Point(0.0, 81.0) +2 | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +2 | | | | | | paintChild RenderOpacity at Point(174.5, 97.0) +2 | | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +2 | | | | | | | translate(174.5, 97.0) +2 | | | | | | | translate(-174.5, -97.0) +2 | | | | | drawRect(Rect.fromLTRB(0.0, 127.0, 400.0, 129.0), Paint(color:Color(0xffff5252))) +2 | | | | | paintChild RenderInkWell at Point(400.0, 81.0) +2 | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +2 | | | | | | paintChild RenderOpacity at Point(562.0, 97.0) +2 | | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +2 | | | | | | | saveLayer(null, Paint(color:Color(0xb3000000))) +2 | | | | | | | translate(562.0, 97.0) +2 | | | | | | | translate(-562.0, -97.0) +2 | | | | | | | restore +2 | | | | paintChild RenderDecoratedBox at Point(0.0, 129.0) +2 | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +2 | | | | | drawRect(Rect.fromLTRB(0.0, 129.0, 800.0, 600.0), Paint(color:Color(0xfffafafa))) +2 | | | | | save +2 | | | | | clipRect(Rect.fromLTRB(0.0, 129.0, 800.0, 600.0)) +2 | | | | | save +2 | | | | | translate(0.0, 129.0) +2 | | | | | concat([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]) +2 | | | | | restore +2 | | | | | restore 2 | | | paintChild RenderDecoratedBox at Point(0.0, 0.0) 2 | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 2 | | | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 81.0), Paint(color:Color(0xff9c27b0), drawLooper:true)) @@ -61,16 +81,36 @@ PAINT FOR FRAME #3 ---------------------------------------------- 3 | | TestPaintingCanvas() constructor: 800.0 x 600.0 3 | | paintChild RenderScaffold at Point(0.0, 0.0) 3 | | | TestPaintingCanvas() constructor: 800.0 x 600.0 -3 | | | paintChild RenderDecoratedBox at Point(0.0, 81.0) +3 | | | paintChild RenderFlex at Point(0.0, 81.0) 3 | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 -3 | | | | drawRect(Rect.fromLTRB(0.0, 81.0, 800.0, 600.0), Paint(color:Color(0xfffafafa))) -3 | | | | save -3 | | | | clipRect(Rect.fromLTRB(0.0, 81.0, 800.0, 600.0)) -3 | | | | save -3 | | | | translate(0.0, 81.0) -3 | | | | concat([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]) -3 | | | | restore -3 | | | | restore +3 | | | | paintChild RenderTabBar at Point(0.0, 81.0) +3 | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +3 | | | | | drawRect(Rect.fromLTRB(0.0, 81.0, 800.0, 129.0), Paint(color:Color(0xff9c27b0))) +3 | | | | | paintChild RenderInkWell at Point(0.0, 81.0) +3 | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +3 | | | | | | paintChild RenderOpacity at Point(174.5, 97.0) +3 | | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +3 | | | | | | | translate(174.5, 97.0) +3 | | | | | | | translate(-174.5, -97.0) +3 | | | | | drawRect(Rect.fromLTRB(0.0, 127.0, 400.0, 129.0), Paint(color:Color(0xffff5252))) +3 | | | | | paintChild RenderInkWell at Point(400.0, 81.0) +3 | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +3 | | | | | | paintChild RenderOpacity at Point(562.0, 97.0) +3 | | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +3 | | | | | | | saveLayer(null, Paint(color:Color(0xb3000000))) +3 | | | | | | | translate(562.0, 97.0) +3 | | | | | | | translate(-562.0, -97.0) +3 | | | | | | | restore +3 | | | | paintChild RenderDecoratedBox at Point(0.0, 129.0) +3 | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 +3 | | | | | drawRect(Rect.fromLTRB(0.0, 129.0, 800.0, 600.0), Paint(color:Color(0xfffafafa))) +3 | | | | | save +3 | | | | | clipRect(Rect.fromLTRB(0.0, 129.0, 800.0, 600.0)) +3 | | | | | save +3 | | | | | translate(0.0, 129.0) +3 | | | | | concat([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]) +3 | | | | | restore +3 | | | | | restore 3 | | | paintChild RenderDecoratedBox at Point(0.0, 0.0) 3 | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 3 | | | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 81.0), Paint(color:Color(0xff9c27b0), drawLooper:true))