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
e0760e6a
Commit
e0760e6a
authored
Jan 11, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1173 from abarth/fix_stocks_loading
TabView fails to update tab contents
parents
c4545da2
432b1793
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
11 deletions
+29
-11
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+29
-11
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
e0760e6a
...
...
@@ -799,7 +799,7 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
_selection
=
selection
;
if
(
_selection
!=
null
)
{
_selection
.
registerPerformanceListener
(
this
);
_
initItemsAndScrollOffset
();
_
updateItemsAndScrollBehavior
();
}
}
...
...
@@ -808,6 +808,12 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
_initSelection
(
TabBarSelection
.
of
(
context
));
}
void
didUpdateConfig
(
TabBarView
oldConfig
)
{
super
.
didUpdateConfig
(
oldConfig
);
if
(
_selection
!=
null
&&
config
.
children
!=
oldConfig
.
children
)
_updateItemsForSelectedIndex
(
_selection
.
index
);
}
void
dispose
()
{
_selection
?.
unregisterPerformanceListener
(
this
);
super
.
dispose
();
...
...
@@ -817,28 +823,40 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
_selection
=
null
;
}
void
_updateItems
(
int
first
,
int
second
,
[
int
third
])
{
void
_updateItems
FromChildren
(
int
first
,
int
second
,
[
int
third
])
{
List
<
Widget
>
widgets
=
config
.
children
;
_items
=
<
Widget
>[
widgets
[
first
],
widgets
[
second
]];
if
(
third
!=
null
)
_items
.
add
(
widgets
[
third
]);
}
void
_initItemsAndScrollOffset
()
{
assert
(
_selection
!=
null
);
final
int
selectedIndex
=
_selection
.
index
;
void
_updateItemsForSelectedIndex
(
int
selectedIndex
)
{
if
(
selectedIndex
==
0
)
{
_updateItemsFromChildren
(
0
,
1
);
}
else
if
(
selectedIndex
==
_tabCount
-
1
)
{
_updateItemsFromChildren
(
selectedIndex
-
1
,
selectedIndex
);
}
else
{
_updateItemsFromChildren
(
selectedIndex
-
1
,
selectedIndex
,
selectedIndex
+
1
);
}
}
void
_updateScrollBehaviorForSelectedIndex
(
int
selectedIndex
)
{
if
(
selectedIndex
==
0
)
{
_updateItems
(
0
,
1
);
scrollTo
(
scrollBehavior
.
updateExtents
(
contentExtent:
2.0
,
containerExtent:
1.0
,
scrollOffset:
0.0
));
}
else
if
(
selectedIndex
==
_tabCount
-
1
)
{
_updateItems
(
selectedIndex
-
1
,
selectedIndex
);
scrollTo
(
scrollBehavior
.
updateExtents
(
contentExtent:
2.0
,
containerExtent:
1.0
,
scrollOffset:
1.0
));
}
else
{
_updateItems
(
selectedIndex
-
1
,
selectedIndex
,
selectedIndex
+
1
);
scrollTo
(
scrollBehavior
.
updateExtents
(
contentExtent:
3.0
,
containerExtent:
1.0
,
scrollOffset:
1.0
));
}
}
void
_updateItemsAndScrollBehavior
()
{
assert
(
_selection
!=
null
);
final
int
selectedIndex
=
_selection
.
index
;
_updateItemsForSelectedIndex
(
selectedIndex
);
_updateScrollBehaviorForSelectedIndex
(
selectedIndex
);
}
void
handleStatusChange
(
PerformanceStatus
status
)
{
}
...
...
@@ -850,7 +868,7 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
final
Performance
performance
=
_selection
.
performance
;
if
(
performance
.
status
==
PerformanceStatus
.
completed
)
{
_
initItemsAndScrollOffset
();
_
updateItemsAndScrollBehavior
();
return
;
}
...
...
@@ -861,10 +879,10 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
final
int
previousSelectedIndex
=
_selection
.
previousIndex
;
if
(
selectedIndex
<
previousSelectedIndex
)
{
_updateItems
(
selectedIndex
,
previousSelectedIndex
);
_updateItems
FromChildren
(
selectedIndex
,
previousSelectedIndex
);
_scrollDirection
=
AnimationDirection
.
reverse
;
}
else
{
_updateItems
(
previousSelectedIndex
,
selectedIndex
);
_updateItems
FromChildren
(
previousSelectedIndex
,
selectedIndex
);
_scrollDirection
=
AnimationDirection
.
forward
;
}
...
...
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