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

Side by Side Diff: sky/examples/widgets/tabs.dart

Issue 1218593002: Move sky/examples to sky/sdk/lib/example, and code changes to support that change. Fixes T277. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 import 'package:sky/theme/colors.dart';
6 import 'package:sky/theme/typography.dart';
7 import 'package:sky/widgets/basic.dart';
8 import 'package:sky/widgets/material.dart';
9 import 'package:sky/widgets/scaffold.dart';
10 import 'package:sky/widgets/tabs.dart';
11 import 'package:sky/widgets/tool_bar.dart';
12 import 'package:sky/widgets/widget.dart';
13
14 class TabbedNavigatorApp extends App {
15 static Iterable<String> items = const <String>["ONE", "TWO", "FREE", "FOUR"];
16 final List<int> navigatorSelections = new List<int>.filled(items.length, 0);
17
18 Widget buildTabNavigator(Iterable<TabLabel> labels, int navigatorIndex) {
19 TabBar tabBar = new TabBar(
20 labels: labels.toList(),
21 selectedIndex: navigatorSelections[navigatorIndex],
22 onChanged: (selectionIndex) {
23 setState(() {
24 navigatorSelections[navigatorIndex] = selectionIndex;
25 });
26 }
27 );
28
29 return new Container(child: tabBar, margin: new EdgeDims.only(bottom: 16.0)) ;
30 }
31
32 Widget build() {
33 Iterable<TabLabel> textLabels = items
34 .map((s) => new TabLabel(text: "ITEM " + s));
35
36 Iterable<TabLabel> iconLabels = items
37 .map((s) => new TabLabel(icon: 'action/search_white'));
38
39 Iterable<TabLabel> textAndIconLabels = items
40 .map((s) => new TabLabel(text: "ITEM " + s, icon: 'action/search_white'));
41
42 var navigatorIndex = 0;
43 Iterable<Widget> tabNavigators = [textLabels, iconLabels, textAndIconLabels]
44 .map((labels) => buildTabNavigator(labels, navigatorIndex++));
45
46 ToolBar toolbar = new ToolBar(
47 center: new Text('Tabbed Navigator', style: white.title)
48 );
49
50 return new Scaffold(
51 toolbar: toolbar,
52 body: new Material(
53 child: new Center(child: new Block(tabNavigators.toList())),
54 color: Grey[500]
55 )
56 );
57 }
58 }
59
60 void main() {
61 runApp(new TabbedNavigatorApp());
62 }
OLDNEW
« no previous file with comments | « sky/examples/widgets/styled_text.dart ('k') | sky/home.dart » ('j') | sky/sdk/README.md » ('J')

Powered by Google App Engine
This is Rietveld 408576698