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
aaeaed9b
Commit
aaeaed9b
authored
Aug 25, 2015
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
done
parent
1867b58c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
48 deletions
+65
-48
flex.dart
packages/flutter/lib/rendering/flex.dart
+1
-1
tabs.dart
packages/flutter/lib/widgets/tabs.dart
+64
-47
No files found.
packages/flutter/lib/rendering/flex.dart
View file @
aaeaed9b
packages/flutter/lib/widgets/tabs.dart
View file @
aaeaed9b
...
...
@@ -35,7 +35,6 @@ const double _kTextAndIconTabHeight = 72.0;
const
double
_kTabIndicatorHeight
=
2.0
;
const
double
_kMinTabWidth
=
72.0
;
const
double
_kMaxTabWidth
=
264.0
;
const
double
_kRelativeMaxTabWidth
=
56.0
;
const
EdgeDims
_kTabLabelPadding
=
const
EdgeDims
.
symmetric
(
horizontal:
12.0
);
const
int
_kTabIconSize
=
24
;
const
double
_kTabBarScrollDrag
=
0.025
;
...
...
@@ -139,9 +138,8 @@ class RenderTabBar extends RenderBox with
return
constraints
.
constrainWidth
(
width
);
}
double
get
_tabBarHeight
{
return
(
textAndIcons
?
_kTextAndIconTabHeight
:
_kTabHeight
)
+
_kTabIndicatorHeight
;
}
double
get
_tabHeight
=>
textAndIcons
?
_kTextAndIconTabHeight
:
_kTabHeight
;
double
get
_tabBarHeight
=>
_tabHeight
+
_kTabIndicatorHeight
;
double
_getIntrinsicHeight
(
BoxConstraints
constraints
)
=>
constraints
.
constrainHeight
(
_tabBarHeight
);
...
...
@@ -152,7 +150,7 @@ class RenderTabBar extends RenderBox with
void
layoutFixedWidthTabs
()
{
double
tabWidth
=
size
.
width
/
childCount
;
BoxConstraints
tabConstraints
=
new
BoxConstraints
.
tightFor
(
width:
tabWidth
,
height:
size
.
h
eight
);
new
BoxConstraints
.
tightFor
(
width:
tabWidth
,
height:
_tabH
eight
);
double
x
=
0.0
;
RenderBox
child
=
firstChild
;
while
(
child
!=
null
)
{
...
...
@@ -164,12 +162,13 @@ class RenderTabBar extends RenderBox with
}
}
void
layoutScrollableTabs
()
{
double
layoutScrollableTabs
()
{
BoxConstraints
tabConstraints
=
new
BoxConstraints
(
minWidth:
_kMinTabWidth
,
maxWidth:
math
.
min
(
size
.
width
-
_kRelativeMaxTabWidth
,
_kMaxTabWidth
),
minHeight:
size
.
height
,
maxHeight:
size
.
height
);
maxWidth:
_kMaxTabWidth
,
minHeight:
_tabHeight
,
maxHeight:
_tabHeight
);
double
x
=
0.0
;
RenderBox
child
=
firstChild
;
while
(
child
!=
null
)
{
...
...
@@ -179,6 +178,7 @@ class RenderTabBar extends RenderBox with
x
+=
child
.
size
.
width
;
child
=
child
.
parentData
.
nextSibling
;
}
return
x
;
}
Size
layoutSize
;
...
...
@@ -209,17 +209,16 @@ class RenderTabBar extends RenderBox with
void
performLayout
()
{
assert
(
constraints
is
BoxConstraints
);
size
=
constraints
.
constrain
(
new
Size
(
constraints
.
maxWidth
,
_tabBarHeight
));
assert
(!
size
.
isInfinite
);
if
(
childCount
==
0
)
return
;
if
(
isScrollable
)
layoutScrollableTabs
();
else
if
(
isScrollable
)
{
double
tabBarWidth
=
layoutScrollableTabs
();
size
=
constraints
.
constrain
(
new
Size
(
tabBarWidth
,
_tabBarHeight
));
}
else
{
size
=
constraints
.
constrain
(
new
Size
(
constraints
.
maxWidth
,
_tabBarHeight
));
layoutFixedWidthTabs
();
}
if
(
onLayoutChanged
!=
null
)
reportLayoutChangedIfNeeded
();
...
...
@@ -234,7 +233,7 @@ class RenderTabBar extends RenderBox with
return
;
if
(
indicatorRect
!=
null
)
{
canvas
.
drawRect
(
indicatorRect
,
new
Paint
()..
color
=
indicatorColor
);
canvas
.
drawRect
(
indicatorRect
.
shift
(
offset
)
,
new
Paint
()..
color
=
indicatorColor
);
return
;
}
...
...
@@ -404,6 +403,7 @@ class TabBar extends Scrollable {
bool
isScrollable
;
Size
_tabBarSize
;
Size
_viewportSize
=
Size
.
zero
;
List
<
double
>
_tabWidths
;
ValueAnimation
<
Rect
>
_indicatorAnimation
;
...
...
@@ -412,6 +412,7 @@ class TabBar extends Scrollable {
_indicatorAnimation
=
new
ValueAnimation
<
Rect
>()
..
duration
=
_kTabBarScroll
..
variable
=
new
AnimatedRect
(
null
,
curve:
ease
);
scrollBehavior
.
isScrollable
=
isScrollable
;
}
void
syncConstructorArguments
(
TabBar
source
)
{
...
...
@@ -447,7 +448,7 @@ class TabBar extends Scrollable {
if
(
tabIndex
>
0
)
tabLeft
=
_tabWidths
.
take
(
tabIndex
).
reduce
((
sum
,
width
)
=>
sum
+
width
);
double
tabTop
=
0.0
;
double
tabBottom
=
_tabBarSize
.
height
-
_kTabIndicatorHeight
;
double
tabBottom
=
_tabBarSize
.
height
-
_kTabIndicatorHeight
;
double
tabRight
=
tabLeft
+
_tabWidths
[
tabIndex
];
return
new
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
}
...
...
@@ -489,16 +490,26 @@ class TabBar extends Scrollable {
);
}
void
_updateScrollBehavior
()
{
scrollBehavior
.
updateExtents
(
containerExtent:
scrollDirection
==
ScrollDirection
.
vertical
?
_viewportSize
.
height
:
_viewportSize
.
width
,
contentExtent:
_tabWidths
.
reduce
((
sum
,
width
)
=>
sum
+
width
)
);
}
void
_layoutChanged
(
Size
tabBarSize
,
List
<
double
>
tabWidths
)
{
setState
(()
{
_tabBarSize
=
tabBarSize
;
_tabWidths
=
tabWidths
;
scrollBehavior
.
updateExtents
(
containerExtent:
_tabBarSize
.
width
,
contentExtent:
_tabWidths
.
reduce
((
sum
,
width
)
=>
sum
+
width
));
_updateScrollBehavior
();
});
}
void
_handleViewportSizeChanged
(
Size
newSize
)
{
_viewportSize
=
newSize
;
_updateScrollBehavior
();
}
Widget
buildContent
()
{
assert
(
labels
!=
null
&&
labels
.
isNotEmpty
);
...
...
@@ -531,12 +542,7 @@ class TabBar extends Scrollable {
textAndIcons
=
true
;
}
Matrix4
transform
=
new
Matrix4
.
identity
();
transform
.
translate
(-
scrollOffset
,
0.0
);
return
new
Transform
(
transform:
transform
,
child:
new
IconTheme
(
Widget
tabBar
=
new
IconTheme
(
data:
new
IconThemeData
(
color:
iconThemeColor
),
child:
new
DefaultTextStyle
(
style:
textStyle
,
...
...
@@ -558,6 +564,17 @@ class TabBar extends Scrollable {
}
)
)
);
if
(!
isScrollable
)
return
tabBar
;
return
new
SizeObserver
(
callback:
_handleViewportSizeChanged
,
child:
new
Viewport
(
scrollDirection:
ScrollDirection
.
horizontal
,
scrollOffset:
new
Offset
(
scrollOffset
,
0.0
),
child:
tabBar
)
);
}
...
...
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