From 4b6e5744665f3253c53b5c049a029e8153f37c09 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 9 May 2018 09:56:35 -0700 Subject: [PATCH] Use unselected styles for the tabs adjacent to the selected tab (#17397) Fixes https://github.com/flutter/flutter/issues/16169 --- packages/flutter/lib/src/material/tabs.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index 495d18754e..1ead76f70f 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -151,12 +151,12 @@ class _TabStyle extends AnimatedWidget { final ThemeData themeData = Theme.of(context); final TextStyle defaultStyle = labelStyle ?? themeData.primaryTextTheme.body2; final TextStyle defaultUnselectedStyle = unselectedLabelStyle ?? labelStyle ?? themeData.primaryTextTheme.body2; + final Animation animation = listenable; final TextStyle textStyle = selected - ? defaultStyle - : defaultUnselectedStyle; + ? TextStyle.lerp(defaultStyle, defaultUnselectedStyle, animation.value) + : TextStyle.lerp(defaultUnselectedStyle, defaultStyle, animation.value); final Color selectedColor = labelColor ?? themeData.primaryTextTheme.body2.color; final Color unselectedColor = unselectedLabelColor ?? selectedColor.withAlpha(0xB2); // 70% alpha - final Animation animation = listenable; final Color color = selected ? Color.lerp(selectedColor, unselectedColor, animation.value) : Color.lerp(unselectedColor, selectedColor, animation.value); @@ -919,13 +919,13 @@ class _TabBarState extends State { wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], true, centerAnimation); if (_currentIndex > 0) { final int tabIndex = _currentIndex - 1; - final Animation previousAnimation = new _DragAnimation(_controller, tabIndex); - wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], true, previousAnimation); + final Animation previousAnimation = new ReverseAnimation(new _DragAnimation(_controller, tabIndex)); + wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], false, previousAnimation); } if (_currentIndex < widget.tabs.length - 1) { final int tabIndex = _currentIndex + 1; - final Animation nextAnimation = new _DragAnimation(_controller, tabIndex); - wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], true, nextAnimation); + final Animation nextAnimation = new ReverseAnimation(new _DragAnimation(_controller, tabIndex)); + wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], false, nextAnimation); } } }