Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
40179aaa
Commit
40179aaa
authored
May 23, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for specifying tab label and indicator colors (#4107)
parent
d5e3ea2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+16
-4
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
40179aaa
...
...
@@ -652,7 +652,9 @@ class TabBar<T> extends Scrollable {
TabBar
({
Key
key
,
this
.
labels
,
this
.
isScrollable
:
false
this
.
isScrollable
:
false
,
this
.
indicatorColor
,
this
.
labelColor
})
:
super
(
key:
key
,
scrollDirection:
Axis
.
horizontal
);
/// The labels to display in the tabs.
...
...
@@ -665,6 +667,15 @@ class TabBar<T> extends Scrollable {
/// share of the available space.
final
bool
isScrollable
;
/// The color of the line that appears below the selected tab. If this parameter
/// is null then the value of the Theme's indicatorColor property is used.
final
Color
indicatorColor
;
/// The color of selected tab labels. Unselected tab labels are rendered
/// with the same color rendered at 70% opacity. If this parameter is null then
/// the color of the theme's body2 text color is used.
final
Color
labelColor
;
double
get
minimumHeight
{
for
(
TabLabel
label
in
labels
.
values
)
{
if
(
label
.
text
!=
null
&&
(
label
.
icon
!=
null
||
label
.
iconBuilder
!=
null
))
...
...
@@ -900,7 +911,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
ThemeData
themeData
=
Theme
.
of
(
context
);
Color
backgroundColor
=
Material
.
of
(
context
).
color
;
Color
indicatorColor
=
themeData
.
indicatorColor
;
Color
indicatorColor
=
config
.
indicatorColor
??
themeData
.
indicatorColor
;
if
(
indicatorColor
==
backgroundColor
)
{
// ThemeData tries to avoid this by having indicatorColor avoid being the
// primaryColor. However, it's possible that the tab bar is on a
...
...
@@ -914,13 +925,14 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
final
TextStyle
textStyle
=
themeData
.
primaryTextTheme
.
body2
;
final
IconThemeData
iconTheme
=
themeData
.
primaryIconTheme
;
final
Color
textColor
=
themeData
.
primaryTextTheme
.
body2
.
color
.
withAlpha
(
0xB2
);
// 70% alpha
final
Color
selectedLabelColor
=
config
.
labelColor
??
themeData
.
primaryTextTheme
.
body2
.
color
;
final
Color
labelColor
=
selectedLabelColor
.
withAlpha
(
0xB2
);
// 70% alpha
List
<
Widget
>
tabs
=
<
Widget
>[];
bool
textAndIcons
=
false
;
int
tabIndex
=
0
;
for
(
TabLabel
label
in
config
.
labels
.
values
)
{
tabs
.
add
(
_toTab
(
label
,
tabIndex
++,
textColor
,
indicator
Color
));
tabs
.
add
(
_toTab
(
label
,
tabIndex
++,
labelColor
,
selectedLabel
Color
));
if
(
label
.
text
!=
null
&&
(
label
.
icon
!=
null
||
label
.
iconBuilder
!=
null
))
textAndIcons
=
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment