Commit c4f52177 authored by Hans Muller's avatar Hans Muller

demo updates

parent 55f65930
...@@ -22,31 +22,19 @@ class TabsDemo extends StatefulComponent { ...@@ -22,31 +22,19 @@ class TabsDemo extends StatefulComponent {
} }
class _TabsDemoState extends State<TabsDemo> { class _TabsDemoState extends State<TabsDemo> {
double _viewWidth = 100.0;
void _handleSizeChanged(Size newSize) {
setState(() {
_viewWidth = newSize.width;
});
}
Widget build(_) { Widget build(_) {
return new SizeObserver( return new TabBarView<String>(
onSizeChanged: _handleSizeChanged, selection: _selection,
child: new TabBarView<String>( items: _iconNames,
selection: _selection, itemBuilder: (BuildContext context, String iconName, int index) {
items: _iconNames, return new Container(
itemExtent: _viewWidth, key: new ValueKey<String>(iconName),
itemBuilder: (BuildContext context, String iconName, int index) { padding: const EdgeDims.all(12.0),
return new Container( child: new Card(
key: new ValueKey<String>(iconName), child: new Center(child: new Icon(icon: "action/$iconName", size:IconSize.s48))
padding: const EdgeDims.all(12.0), )
child: new Card( );
child: new Center(child: new Icon(icon: "action/$iconName", size:IconSize.s48)) }
)
);
}
)
); );
} }
} }
......
...@@ -272,36 +272,25 @@ class StockHomeState extends State<StockHome> { ...@@ -272,36 +272,25 @@ class StockHomeState extends State<StockHome> {
); );
} }
double _viewWidth = 100.0;
void _handleSizeChanged(Size newSize) {
setState(() {
_viewWidth = newSize.width;
});
}
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
toolBar: _isSearching ? buildSearchBar() : buildToolBar(), toolBar: _isSearching ? buildSearchBar() : buildToolBar(),
floatingActionButton: buildFloatingActionButton(), floatingActionButton: buildFloatingActionButton(),
drawer: _buildDrawer(context), drawer: _buildDrawer(context),
body: new SizeObserver( body: new TabBarView<StockHomeTab>(
onSizeChanged: _handleSizeChanged, selection: _tabBarSelection,
child: new TabBarView<StockHomeTab>( items: <StockHomeTab>[StockHomeTab.market, StockHomeTab.portfolio],
selection: _tabBarSelection, itemBuilder: (BuildContext context, StockHomeTab tab, _) {
items: <StockHomeTab>[StockHomeTab.market, StockHomeTab.portfolio], switch (tab) {
itemExtent: _viewWidth, case StockHomeTab.market:
itemBuilder: (BuildContext context, StockHomeTab tab, _) { return _buildStockTab(context, tab, config.symbols);
switch (tab) { case StockHomeTab.portfolio:
case StockHomeTab.market: return _buildStockTab(context, tab, portfolioSymbols);
return _buildStockTab(context, tab, config.symbols); default:
case StockHomeTab.portfolio: assert(false);
return _buildStockTab(context, tab, portfolioSymbols);
default:
assert(false);
}
} }
) }
) )
); );
} }
......
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