-
Notifications
You must be signed in to change notification settings - Fork 30.3k
[Material] Add TabBarTheme #22012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[Material] Add TabBarTheme #22012
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
acd472d
Add tab bar theme.
johnsonmh 6b4cf35
Add tab bar theme.
johnsonmh 2804691
Add tests, pass context to getters.
johnsonmh a7da098
update goldens from linux box
johnsonmh 0578919
update goldens from linux box
johnsonmh c0ff989
Added new golden test, addressed comments
johnsonmh 531267d
override hashCode and == in TabBarTheme
johnsonmh 2d7f0f6
Fix comment typos
johnsonmh f0b43e0
Addressed Hans' comments.
johnsonmh 3a17852
Formatting changes
johnsonmh 67e4a2a
[TabBarTheme] Fixed spacing
johnsonmh 27fee7f
[TabBarTheme] Update goldens version to latest commit
johnsonmh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| a7f6061b8171f6fc82b6f437d13079ee26189438 | ||
| b84f87078729d0af8380fd9826091d8bafe6fcc7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| // Copyright 2018 The Chromium Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:flutter/foundation.dart'; | ||
| import 'package:flutter/rendering.dart'; | ||
|
|
||
| import 'tabs.dart'; | ||
|
|
||
| /// Defines a theme for [TabBar] widgets. | ||
| /// | ||
| /// A tab bar theme describes the color of the tab label and the size/shape of | ||
| /// the [TabBar.indicator]. | ||
| /// | ||
| /// Descendant widgets obtain the current theme's [TabBarTheme] object using | ||
| /// `Theme.of(context).tabBarTheme`. | ||
| /// [ThemeData.tabBarTheme] can be customized by copying it (using | ||
| /// [TabBarTheme.copyWith]). | ||
|
johnsonmh marked this conversation as resolved.
Outdated
|
||
| /// | ||
| /// See also: | ||
| /// | ||
| /// * [TabBar], a widget that displays a horizontal row of tabs. | ||
| /// * [ThemeData], which describes the overall theme information for the | ||
| /// application. | ||
| class TabBarTheme extends Diagnosticable { | ||
|
willlarche marked this conversation as resolved.
Outdated
|
||
| /// Creates a tab bar theme that can be used with [ThemeData.tabBarTheme]. | ||
| const TabBarTheme({ | ||
| this.indicator, | ||
| this.indicatorSize, | ||
| this.labelColor, | ||
| this.unselectedLabelColor, | ||
| }); | ||
|
|
||
| /// Default value for [TabBar.indicator]. | ||
| final Decoration indicator; | ||
|
|
||
| /// Default value for [TabBar.indicatorSize]. | ||
| final TabBarIndicatorSize indicatorSize; | ||
|
|
||
| /// Default value for [TabBar.labelColor]. | ||
| final Color labelColor; | ||
|
|
||
| /// Default value for [TabBar.unselectedLabelColor]. | ||
| final Color unselectedLabelColor; | ||
|
|
||
| /// Creates a copy of this object but with the given fields replaced with the | ||
| /// new values. | ||
| TabBarTheme copyWith({ | ||
| Decoration indicator, | ||
| TabBarIndicatorSize indicatorSize, | ||
| Color labelColor, | ||
| Color unselectedLabelColor, | ||
| }) { | ||
| return TabBarTheme( | ||
| indicator: indicator ?? this.indicator, | ||
| indicatorSize: indicatorSize ?? this.indicatorSize, | ||
| labelColor: labelColor ?? this.labelColor, | ||
| unselectedLabelColor: unselectedLabelColor ?? this.unselectedLabelColor | ||
| ); | ||
| } | ||
|
|
||
| /// Linearly interpolate between two tab bar themes. | ||
| /// | ||
| /// {@macro flutter.material.themeData.lerp} | ||
| static TabBarTheme lerp(TabBarTheme a, TabBarTheme b, double t) { | ||
| assert(a != null); | ||
| assert(b != null); | ||
| assert(t != null); | ||
| return TabBarTheme( | ||
| indicator: Decoration.lerp(a.indicator, b.indicator, t), | ||
| indicatorSize: t < 0.5 ? a.indicatorSize : b.indicatorSize, | ||
| labelColor: Color.lerp(a.labelColor, b.labelColor, t), | ||
| unselectedLabelColor: Color.lerp(a.unselectedLabelColor, b.unselectedLabelColor, t) | ||
| ); | ||
| } | ||
|
|
||
| @override | ||
| int get hashCode { | ||
| return hashValues(indicator, indicatorSize, labelColor, unselectedLabelColor); | ||
| } | ||
|
|
||
| @override | ||
| bool operator ==(dynamic other) { | ||
| if (identical(this, other)) | ||
| return true; | ||
| if (other.runtimeType != runtimeType) | ||
| return false; | ||
| final TabBarTheme typedOther = other; | ||
| return typedOther.indicator == indicator | ||
| && typedOther.indicatorSize == indicatorSize | ||
| && typedOther.labelColor == labelColor | ||
| && typedOther.unselectedLabelColor == unselectedLabelColor; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.