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

Unified Diff: sky/sdk/example/widgets/tabs.dart

Issue 1221673006: Scrollable TabBar Version 0 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Updated per review feedback Created 5 years, 5 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 | « no previous file | sky/sdk/lib/widgets/scrollable.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/example/widgets/tabs.dart
diff --git a/sky/sdk/example/widgets/tabs.dart b/sky/sdk/example/widgets/tabs.dart
index 93d259caa394eaedd19373338c265059f32cc442..4b69a6a4e5955a1de2e42189aa66d8fc7153f6ca 100644
--- a/sky/sdk/example/widgets/tabs.dart
+++ b/sky/sdk/example/widgets/tabs.dart
@@ -14,12 +14,13 @@ import 'package:sky/widgets/widget.dart';
class TabbedNavigatorApp extends App {
// The index of the selected tab for each of the TabNavigators constructed below.
- List<int> selectedIndices = new List<int>.filled(4, 0);
+ List<int> selectedIndices = new List<int>.filled(5, 0);
- TabNavigator _buildTabNavigator(int n, List<TabNavigatorView> views) {
+ TabNavigator _buildTabNavigator(int n, List<TabNavigatorView> views, {scrollable: false}) {
return new TabNavigator(
views: views,
selectedIndex: selectedIndices[n],
+ scrollable: scrollable,
onChanged: (tabIndex) {
setState(() { selectedIndices[n] = tabIndex; } );
}
@@ -72,9 +73,32 @@ class TabbedNavigatorApp extends App {
return _buildTabNavigator(n, views);
}
+ TabNavigator _buildScrollableTabNavigator(int n) {
+ Iterable<TabNavigatorView> views = [
+ "MIN WIDTH",
+ "THIS TAB LABEL IS SO WIDE THAT IT OCCUPIES TWO LINES",
+ "THIS TAB IS PRETTY WIDE TOO",
+ "MORE",
+ "TABS",
+ "TO",
+ "STRETCH",
+ "OUT",
+ "THE",
+ "TAB BAR"
+ ]
+ .map((text) {
+ return new TabNavigatorView(
+ label: new TabLabel(text: text),
+ builder: () => _buildContent(text)
+ );
+ });
+ return _buildTabNavigator(n, views.toList(), scrollable: true);
+ }
+
+
Container _buildCard(TabNavigator tabNavigator) {
return new Container(
- child: new Card(child: tabNavigator),
+ child: new Card(child: new Padding(child: tabNavigator, padding: const EdgeDims.all(8.0))),
padding: const EdgeDims.all(12.0),
decoration: new BoxDecoration(backgroundColor: Theme.of(this).primarySwatch[50])
);
@@ -93,10 +117,15 @@ class TabbedNavigatorApp extends App {
new TabNavigatorView(
label: const TabLabel(text: 'BOTH'),
builder: () => _buildCard(_buildTextAndIconLabelsTabNavigator(2))
+ ),
+ new TabNavigatorView(
+ label: const TabLabel(text: 'SCROLL'),
+ builder: () => _buildCard(_buildScrollableTabNavigator(3))
)
];
- TabNavigator tabNavigator = _buildTabNavigator(3, views);
+ TabNavigator tabNavigator = _buildTabNavigator(4, views);
+ assert(selectedIndices.length == 5);
ToolBar toolbar = new ToolBar(
center: new Text('Tabbed Navigator', style: typography.white.title)
« no previous file with comments | « no previous file | sky/sdk/lib/widgets/scrollable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698