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
c4545da2
Commit
c4545da2
authored
Jan 11, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1172 from abarth/simplify_tabview
Simplify TabView API
parents
f757211f
dd08bf79
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
39 deletions
+23
-39
page_selector_demo.dart
examples/material_gallery/lib/demo/page_selector_demo.dart
+2
-3
tabs_demo.dart
examples/material_gallery/lib/demo/tabs_demo.dart
+3
-4
stock_home.dart
examples/stocks/lib/stock_home.dart
+5
-12
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+11
-18
scrollable_list.dart
packages/flutter/lib/src/widgets/scrollable_list.dart
+2
-2
No files found.
examples/material_gallery/lib/demo/page_selector_demo.dart
View file @
c4545da2
...
...
@@ -85,9 +85,8 @@ class TabViewDemo extends StatelessComponent {
)
),
new
Flexible
(
child:
new
TabBarView
<
String
>(
items:
_iconNames
,
itemBuilder:
_buildTabView
child:
new
TabBarView
(
children:
_iconNames
.
map
(
_buildTabView
).
toList
()
)
)
]);
...
...
examples/material_gallery/lib/demo/tabs_demo.dart
View file @
c4545da2
...
...
@@ -27,9 +27,8 @@ class TabsDemo extends StatefulComponent {
class
_TabsDemoState
extends
State
<
TabsDemo
>
{
Widget
build
(
_
)
{
return
new
TabBarView
<
String
>(
items:
_iconNames
,
itemBuilder:
(
String
iconName
)
{
return
new
TabBarView
(
children:
_iconNames
.
map
((
String
iconName
)
{
return
new
Container
(
key:
new
ValueKey
<
String
>(
iconName
),
padding:
const
EdgeDims
.
all
(
12.0
),
...
...
@@ -37,7 +36,7 @@ class _TabsDemoState extends State<TabsDemo> {
child:
new
Center
(
child:
new
Icon
(
icon:
"action/
$iconName
"
,
size:
IconSize
.
s48
))
)
);
}
}
).
toList
()
);
}
}
...
...
examples/stocks/lib/stock_home.dart
View file @
c4545da2
...
...
@@ -267,18 +267,11 @@ class StockHomeState extends State<StockHome> {
toolBar:
_isSearching
?
buildSearchBar
()
:
buildToolBar
(),
floatingActionButton:
buildFloatingActionButton
(),
drawer:
_buildDrawer
(
context
),
body:
new
TabBarView
<
StockHomeTab
>(
items:
<
StockHomeTab
>[
StockHomeTab
.
market
,
StockHomeTab
.
portfolio
],
itemBuilder:
(
StockHomeTab
tab
)
{
switch
(
tab
)
{
case
StockHomeTab
.
market
:
return
_buildStockTab
(
context
,
tab
,
config
.
symbols
);
case
StockHomeTab
.
portfolio
:
return
_buildStockTab
(
context
,
tab
,
portfolioSymbols
);
default
:
assert
(
false
);
}
}
body:
new
TabBarView
(
children:
<
Widget
>[
_buildStockTab
(
context
,
StockHomeTab
.
market
,
config
.
symbols
),
_buildStockTab
(
context
,
StockHomeTab
.
portfolio
,
portfolioSymbols
),
]
)
)
);
...
...
packages/flutter/lib/src/material/tabs.dart
View file @
c4545da2
...
...
@@ -764,36 +764,29 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
}
}
typedef
Widget
TabItemBuilder
<
T
>(
T
item
);
class
TabBarView
<
T
>
extends
PageableList
{
class
TabBarView
extends
PageableList
{
TabBarView
({
Key
key
,
List
<
T
>
items
,
TabItemBuilder
<
T
>
itemBuilder
})
:
items
=
items
,
itemBuilder
=
itemBuilder
,
super
(
List
<
Widget
>
children
})
:
super
(
key:
key
,
scrollDirection:
ScrollDirection
.
horizontal
,
children:
items
.
map
((
T
item
)
=>
itemBuilder
(
item
)).
toList
(),
itemsWrap:
false
children:
children
)
{
assert
(
items
!=
null
);
assert
(
items
.
length
>
1
);
assert
(
children
!=
null
);
assert
(
children
.
length
>
1
);
}
final
List
<
T
>
items
;
final
TabItemBuilder
<
T
>
itemBuilder
;
_TabBarViewState
createState
()
=>
new
_TabBarViewState
<
T
>();
_TabBarViewState
createState
()
=>
new
_TabBarViewState
();
}
class
_TabBarViewState
<
T
>
extends
PageableListState
<
TabBarView
<
T
>
>
implements
TabBarSelectionPerformanceListener
{
class
_TabBarViewState
extends
PageableListState
<
TabBarView
>
implements
TabBarSelectionPerformanceListener
{
TabBarSelectionState
_selection
;
List
<
Widget
>
_items
;
AnimationDirection
_scrollDirection
=
AnimationDirection
.
forward
;
int
get
_tabCount
=>
config
.
items
.
length
;
int
get
_tabCount
=>
config
.
children
.
length
;
BoundedBehavior
_boundedBehavior
;
...
...
@@ -802,7 +795,7 @@ class _TabBarViewState<T> extends PageableListState<TabBarView<T>> implements Ta
return
_boundedBehavior
;
}
void
_initSelection
(
TabBarSelectionState
<
T
>
selection
)
{
void
_initSelection
(
TabBarSelectionState
selection
)
{
_selection
=
selection
;
if
(
_selection
!=
null
)
{
_selection
.
registerPerformanceListener
(
this
);
...
...
@@ -919,7 +912,7 @@ class _TabBarViewState<T> extends PageableListState<TabBarView<T>> implements Ta
}
Widget
buildContent
(
BuildContext
context
)
{
TabBarSelectionState
<
T
>
newSelection
=
TabBarSelection
.
of
(
context
);
TabBarSelectionState
newSelection
=
TabBarSelection
.
of
(
context
);
if
(
_selection
!=
newSelection
)
_initSelection
(
newSelection
);
return
new
PageViewport
(
...
...
packages/flutter/lib/src/widgets/scrollable_list.dart
View file @
c4545da2
...
...
@@ -41,10 +41,10 @@ class ScrollableList extends Scrollable {
final
ScrollableListPainter
scrollableListPainter
;
final
Iterable
<
Widget
>
children
;
ScrollableState
createState
()
=>
new
_ScrollableList
2
State
();
ScrollableState
createState
()
=>
new
_ScrollableListState
();
}
class
_ScrollableList
2
State
extends
ScrollableState
<
ScrollableList
>
{
class
_ScrollableListState
extends
ScrollableState
<
ScrollableList
>
{
ScrollBehavior
createScrollBehavior
()
=>
new
OverscrollBehavior
();
ExtentScrollBehavior
get
scrollBehavior
=>
super
.
scrollBehavior
;
...
...
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