OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 import 'dart:math' as math; | 5 import 'dart:math' as math; |
6 | 6 |
7 import 'package:sky/animation/generators.dart'; | 7 import 'package:sky/animation/generators.dart'; |
8 import 'package:sky/animation/mechanics.dart'; | 8 import 'package:sky/animation/mechanics.dart'; |
9 import 'package:sky/animation/scroll_behavior.dart'; | 9 import 'package:sky/animation/scroll_behavior.dart'; |
10 import 'package:sky/painting/text_style.dart'; | 10 import 'package:sky/painting/text_style.dart'; |
11 import 'package:sky/rendering/box.dart'; | 11 import 'package:sky/rendering/box.dart'; |
12 import 'package:sky/rendering/object.dart'; | 12 import 'package:sky/rendering/object.dart'; |
13 import 'package:vector_math/vector_math.dart'; | 13 import 'package:vector_math/vector_math.dart'; |
| 14 import 'package:sky/theme/colors.dart' as colors; |
14 import 'package:sky/widgets/basic.dart'; | 15 import 'package:sky/widgets/basic.dart'; |
15 import 'package:sky/widgets/icon.dart'; | 16 import 'package:sky/widgets/icon.dart'; |
16 import 'package:sky/widgets/ink_well.dart'; | 17 import 'package:sky/widgets/ink_well.dart'; |
17 import 'package:sky/widgets/scrollable.dart'; | 18 import 'package:sky/widgets/scrollable.dart'; |
18 import 'package:sky/widgets/theme.dart'; | 19 import 'package:sky/widgets/theme.dart'; |
19 import 'package:sky/widgets/widget.dart'; | 20 import 'package:sky/widgets/widget.dart'; |
20 | 21 |
21 typedef void SelectedIndexChanged(int selectedIndex); | 22 typedef void SelectedIndexChanged(int selectedIndex); |
22 typedef void LayoutChanged(Size size, List<double> widths); | 23 typedef void LayoutChanged(Size size, List<double> widths); |
23 | 24 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 assert(labels != null && labels.isNotEmpty); | 427 assert(labels != null && labels.isNotEmpty); |
427 List<Widget> tabs = <Widget>[]; | 428 List<Widget> tabs = <Widget>[]; |
428 bool textAndIcons = false; | 429 bool textAndIcons = false; |
429 int tabIndex = 0; | 430 int tabIndex = 0; |
430 for (TabLabel label in labels) { | 431 for (TabLabel label in labels) { |
431 tabs.add(_toTab(label, tabIndex++)); | 432 tabs.add(_toTab(label, tabIndex++)); |
432 if (label.text != null && label.icon != null) | 433 if (label.text != null && label.icon != null) |
433 textAndIcons = true; | 434 textAndIcons = true; |
434 } | 435 } |
435 | 436 |
| 437 Color backgroundColor = Theme.of(this).primaryColor; |
| 438 Color indicatorColor = Theme.of(this).accentColor; |
| 439 if (indicatorColor == backgroundColor) { |
| 440 indicatorColor = colors.White; |
| 441 } |
| 442 |
436 TabBarWrapper tabBarWrapper = new TabBarWrapper( | 443 TabBarWrapper tabBarWrapper = new TabBarWrapper( |
437 children: tabs, | 444 children: tabs, |
438 selectedIndex: selectedIndex, | 445 selectedIndex: selectedIndex, |
439 backgroundColor: Theme.of(this).primaryColor, | 446 backgroundColor: backgroundColor, |
440 indicatorColor: Theme.of(this).accentColor, | 447 indicatorColor: indicatorColor, |
441 textAndIcons: textAndIcons, | 448 textAndIcons: textAndIcons, |
442 scrollable: scrollable, | 449 scrollable: scrollable, |
443 onLayoutChanged: scrollable ? _layoutChanged : null | 450 onLayoutChanged: scrollable ? _layoutChanged : null |
444 ); | 451 ); |
445 | 452 |
446 Matrix4 transform = new Matrix4.identity(); | 453 Matrix4 transform = new Matrix4.identity(); |
447 transform.translate(-scrollOffset, 0.0); | 454 transform.translate(-scrollOffset, 0.0); |
448 return new Transform(child: tabBarWrapper, transform: transform); | 455 return new Transform(child: tabBarWrapper, transform: transform); |
449 } | 456 } |
450 } | 457 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 selectedIndex: selectedIndex, | 499 selectedIndex: selectedIndex, |
493 scrollable: scrollable | 500 scrollable: scrollable |
494 ); | 501 ); |
495 | 502 |
496 Widget content = views[selectedIndex].buildContent(); | 503 Widget content = views[selectedIndex].buildContent(); |
497 return new Flex([tabBar, new Flexible(child: content)], | 504 return new Flex([tabBar, new Flexible(child: content)], |
498 direction: FlexDirection.vertical | 505 direction: FlexDirection.vertical |
499 ); | 506 ); |
500 } | 507 } |
501 } | 508 } |
OLD | NEW |