Make TabBarSelection a parameterized type

This commit is contained in:
Hans Muller
2016-01-05 10:56:17 -08:00
parent 81b7067544
commit 6494cd1f35
4 changed files with 167 additions and 124 deletions

View File

@@ -9,16 +9,15 @@ import 'widget_demo.dart';
final List<String> _iconNames = <String>["event", "home", "android", "alarm", "face", "language"];
Widget _buildTabBarSelection(_, Widget child) {
return new TabBarSelection(
maxIndex: _iconNames.length - 1,
child: child
);
return new TabBarSelection<String>(values: _iconNames, child: child);
}
Widget _buildTabBar(_) {
return new TabBar(
return new TabBar<String>(
isScrollable: true,
labels: _iconNames.map((String iconName) => new TabLabel(text: iconName, icon: "action/$iconName")).toList()
labels: new Map.fromIterable(
_iconNames,
value: (String iconName) => new TabLabel(text: iconName, icon: "action/$iconName"))
);
}

View File

@@ -161,17 +161,15 @@ class StockHomeState extends State<StockHome> {
onPressed: _handleMenuShow
)
],
tabBar: new TabBar(
labels: <TabLabel>[
new TabLabel(text: StockStrings.of(context).market()),
new TabLabel(text: StockStrings.of(context).portfolio())
]
tabBar: new TabBar<StockHomeTab>(
labels: <StockHomeTab, TabLabel>{
StockHomeTab.market: new TabLabel(text: StockStrings.of(context).market()),
StockHomeTab.portfolio: new TabLabel(text: StockStrings.of(context).portfolio())
}
)
);
}
int selectedTabIndex = 0;
Iterable<Stock> _getStockList(Iterable<String> symbols) {
return symbols.map((String symbol) => config.stocks[symbol])
.where((Stock stock) => stock != null);
@@ -266,8 +264,8 @@ class StockHomeState extends State<StockHome> {
}
Widget build(BuildContext context) {
return new TabBarSelection(
maxIndex: 1,
return new TabBarSelection<StockHomeTab>(
values: <StockHomeTab>[StockHomeTab.market, StockHomeTab.portfolio],
child: new Scaffold(
key: _scaffoldKey,
toolBar: _isSearching ? buildSearchBar() : buildToolBar(),