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
68efa6a3
Commit
68efa6a3
authored
Jun 23, 2016
by
Hans Muller
Committed by
GitHub
Jun 23, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct scrolling tabbar tab indicator size (#4723)
parent
05eef4a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
5 deletions
+32
-5
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+32
-5
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
68efa6a3
...
...
@@ -683,6 +683,22 @@ class TabBarSelectionState<T> extends State<TabBarSelection<T>> {
}
}
// Used when the user is dragging the TabBar or the TabBarView left or right.
// Dragging from the selected tab to the left varies t between 0.5 and 0.0.
// Dragging towards the tab on the right varies t between 0.5 and 1.0.
class
_TabIndicatorTween
extends
Tween
<
Rect
>
{
_TabIndicatorTween
({
Rect
begin
,
this
.
middle
,
Rect
end
})
:
super
(
begin:
begin
,
end:
end
);
final
Rect
middle
;
@override
Rect
lerp
(
double
t
)
{
return
t
<=
0.5
?
Rect
.
lerp
(
begin
,
middle
,
t
*
2.0
)
:
Rect
.
lerp
(
middle
,
end
,
(
t
-
0.5
)
*
2.0
);
}
}
/// A widget that displays a horizontal row of tabs, one per label.
///
/// Requires one of its ancestors to be a [TabBarSelection] widget to enable
...
...
@@ -789,10 +805,21 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
// when it's under the tab on the right.
void
_initIndicatorTweenForDrag
()
{
assert
(!
_valueIsChanging
);
_indicatorTween
=
new
RectTween
(
begin:
_tabIndicatorRect
(
math
.
max
(
0
,
_selection
.
index
-
1
)),
end:
_tabIndicatorRect
(
math
.
min
(
config
.
labels
.
length
-
1
,
_selection
.
index
+
1
))
);
int
index
=
_selection
.
index
;
int
beginIndex
=
math
.
max
(
0
,
index
-
1
);
int
endIndex
=
math
.
min
(
config
.
labels
.
length
-
1
,
index
+
1
);
if
(
beginIndex
==
index
||
endIndex
==
index
)
{
_indicatorTween
=
new
RectTween
(
begin:
_tabIndicatorRect
(
beginIndex
),
end:
_tabIndicatorRect
(
endIndex
)
);
}
else
{
_indicatorTween
=
new
_TabIndicatorTween
(
begin:
_tabIndicatorRect
(
beginIndex
),
middle:
_tabIndicatorRect
(
index
),
end:
_tabIndicatorRect
(
endIndex
)
);
}
}
// Initialize _indicatorTween for animating the selected tab indicator from the
...
...
@@ -869,7 +896,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
Size
_tabBarSize
;
List
<
double
>
_tabWidths
;
Rect
_indicatorRect
;
RectTween
_indicatorTween
;
Tween
<
Rect
>
_indicatorTween
;
Rect
_tabRect
(
int
tabIndex
)
{
assert
(
_tabBarSize
!=
null
);
...
...
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