From fe8c1e6b526c96c86f57feda159d72ac53ff8a6a Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Tue, 7 Jul 2015 15:35:19 -0700 Subject: [PATCH] Tab bar should have white indicator if primary and accent color are the same R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1215313004 . --- sdk/lib/widgets/tabs.dart | 11 +++++++++-- tests/examples/stocks-expected.txt | 4 ++-- tests/examples/tabs-expected.txt | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sdk/lib/widgets/tabs.dart b/sdk/lib/widgets/tabs.dart index a19344b2a8e..5812413fef1 100644 --- a/sdk/lib/widgets/tabs.dart +++ b/sdk/lib/widgets/tabs.dart @@ -11,6 +11,7 @@ import 'package:sky/painting/text_style.dart'; import 'package:sky/rendering/box.dart'; import 'package:sky/rendering/object.dart'; import 'package:vector_math/vector_math.dart'; +import 'package:sky/theme/colors.dart' as colors; import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/icon.dart'; import 'package:sky/widgets/ink_well.dart'; @@ -433,11 +434,17 @@ class TabBar extends Scrollable { textAndIcons = true; } + Color backgroundColor = Theme.of(this).primaryColor; + Color indicatorColor = Theme.of(this).accentColor; + if (indicatorColor == backgroundColor) { + indicatorColor = colors.White; + } + TabBarWrapper tabBarWrapper = new TabBarWrapper( children: tabs, selectedIndex: selectedIndex, - backgroundColor: Theme.of(this).primaryColor, - indicatorColor: Theme.of(this).accentColor, + backgroundColor: backgroundColor, + indicatorColor: indicatorColor, textAndIcons: textAndIcons, scrollable: scrollable, onLayoutChanged: scrollable ? _layoutChanged : null diff --git a/tests/examples/stocks-expected.txt b/tests/examples/stocks-expected.txt index f8791a70f6c..e8ff259e667 100644 --- a/tests/examples/stocks-expected.txt +++ b/tests/examples/stocks-expected.txt @@ -27,7 +27,7 @@ PAINT FOR FRAME #2 ---------------------------------------------- 2 | | | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 2 | | | | | | | | translate(171.0, 14.0) 2 | | | | | | | | translate(-171.0, -14.0) -2 | | | | | drawRect(Rect.fromLTRB(0.0, 46.0, 400.0, 48.0), Paint(color:Color(0xff9c27b0))) +2 | | | | | drawRect(Rect.fromLTRB(0.0, 46.0, 400.0, 48.0), Paint(color:Color(0xffffffff))) 2 | | | | | paintChild RenderInkWell at Point(400.0, 0.0) 2 | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 2 | | | | | | paintChild RenderPositionedBox at Point(412.0, 0.0) @@ -107,7 +107,7 @@ PAINT FOR FRAME #3 ---------------------------------------------- 3 | | | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 3 | | | | | | | | translate(171.0, 14.0) 3 | | | | | | | | translate(-171.0, -14.0) -3 | | | | | drawRect(Rect.fromLTRB(0.0, 46.0, 400.0, 48.0), Paint(color:Color(0xff9c27b0))) +3 | | | | | drawRect(Rect.fromLTRB(0.0, 46.0, 400.0, 48.0), Paint(color:Color(0xffffffff))) 3 | | | | | paintChild RenderInkWell at Point(400.0, 0.0) 3 | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 3 | | | | | | paintChild RenderPositionedBox at Point(412.0, 0.0) diff --git a/tests/examples/tabs-expected.txt b/tests/examples/tabs-expected.txt index 9dc22a07d50..393c3656313 100644 --- a/tests/examples/tabs-expected.txt +++ b/tests/examples/tabs-expected.txt @@ -25,7 +25,7 @@ PAINT FOR FRAME #2 ---------------------------------------------- 2 | | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 2 | | | | | | | translate(82.0, 14.0) 2 | | | | | | | translate(-82.0, -14.0) -2 | | | | drawRect(Rect.fromLTRB(0.0, 46.0, 200.0, 48.0), Paint(color:Color(0xff2196f3))) +2 | | | | drawRect(Rect.fromLTRB(0.0, 46.0, 200.0, 48.0), Paint(color:Color(0xffffffff))) 2 | | | | paintChild RenderInkWell at Point(200.0, 0.0) 2 | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 2 | | | | | paintChild RenderPositionedBox at Point(212.0, 0.0) @@ -84,7 +84,7 @@ PAINT FOR FRAME #2 ---------------------------------------------- 2 | | | | | | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 2 | | | | | | | | | | | translate(78.5, 14.0) 2 | | | | | | | | | | | translate(-78.5, -14.0) -2 | | | | | | | | drawRect(Rect.fromLTRB(0.0, 46.0, 188.0, 48.0), Paint(color:Color(0xff2196f3))) +2 | | | | | | | | drawRect(Rect.fromLTRB(0.0, 46.0, 188.0, 48.0), Paint(color:Color(0xffffffff))) 2 | | | | | | | | paintChild RenderInkWell at Point(188.0, 0.0) 2 | | | | | | | | | TestPaintingCanvas() constructor: 800.0 x 600.0 2 | | | | | | | | | paintChild RenderPositionedBox at Point(200.0, 0.0)