fix(recommend): 稳定进度拖动与清屏状态
This commit is contained in:
1 parent
76c4f1d411
commit
30b55afdd4
9 files changed
+339
-96
No files matched your search
@@ -44,6 +44,7 @@ class RecommendPage extends StatefulWidget {
|
||||
class _RecommendPageState extends State<RecommendPage> {
|
||||
RecommendInnerTab _tab = RecommendInnerTab.feed;
|
||||
bool _scrubbing = false;
|
||||
int _scrubCancelRequest = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -80,21 +81,40 @@ class _RecommendPageState extends State<RecommendPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!_scrubbing)
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: SafeArea(
|
||||
bottom: false,
|
||||
child: RecommendTopNav(
|
||||
selected: _tab,
|
||||
onVideo: _tab == RecommendInnerTab.feed,
|
||||
onSelected: (tab) => setState(() => _tab = tab),
|
||||
onSearch: widget.onSearch,
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: IgnorePointer(
|
||||
child: SizedBox(
|
||||
height: 72,
|
||||
child: DecoratedBox(
|
||||
key: const Key('recommend-top-gradient'),
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [AppColors.mediaBlack, AppColors.transparent],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: SafeArea(
|
||||
bottom: false,
|
||||
child: RecommendTopNav(
|
||||
selected: _tab,
|
||||
onVideo: _tab == RecommendInnerTab.feed,
|
||||
onSelected: _selectTab,
|
||||
onSearch: _handleSearch,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -141,9 +161,31 @@ class _RecommendPageState extends State<RecommendPage> {
|
||||
onRefreshFeed: widget.feedController.refreshCurrent,
|
||||
onLoadMore: widget.feedController.loadMore,
|
||||
onScrubVisibilityChanged: _setScrubbing,
|
||||
scrubCancelRequest: _scrubCancelRequest,
|
||||
);
|
||||
}
|
||||
|
||||
void _selectTab(RecommendInnerTab tab) {
|
||||
final wasScrubbing = _scrubbing;
|
||||
setState(() {
|
||||
_tab = tab;
|
||||
if (wasScrubbing) _scrubCancelRequest++;
|
||||
_scrubbing = false;
|
||||
});
|
||||
if (wasScrubbing) widget.onScrubVisibilityChanged(false);
|
||||
}
|
||||
|
||||
void _handleSearch() {
|
||||
if (_scrubbing) {
|
||||
setState(() {
|
||||
_scrubbing = false;
|
||||
_scrubCancelRequest++;
|
||||
});
|
||||
widget.onScrubVisibilityChanged(false);
|
||||
}
|
||||
widget.onSearch();
|
||||
}
|
||||
|
||||
void _setScrubbing(bool value) {
|
||||
if (_scrubbing == value) return;
|
||||
setState(() => _scrubbing = value);
|
||||
|
||||
Reference in new issue
Block a user