1
This commit is contained in:
@@ -57,13 +57,16 @@ class _FeedScreenState extends ConsumerState<FeedScreen>
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// App 退后台挂起、回前台恢复播放(suspend/resume 防在途 open 竞态)
|
||||
/// App 退后台挂起、回前台从断点续播。inactive(下拉通知栏等瞬时态)
|
||||
/// 只轻量 pause 当前槽防出声;paused(真退后台)才走 suspend(stop)
|
||||
/// 彻底断下载——避免瞬时 inactive 触发 stop+重载的画面闪烁
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
final notifier = ref.read(feedProvider(_strategy).notifier);
|
||||
if (state == AppLifecycleState.paused ||
|
||||
state == AppLifecycleState.inactive) {
|
||||
if (state == AppLifecycleState.paused) {
|
||||
notifier.pool.suspend();
|
||||
} else if (state == AppLifecycleState.inactive) {
|
||||
notifier.pool.pauseCurrent();
|
||||
} else if (state == AppLifecycleState.resumed) {
|
||||
// 仅在首页 Tab 可见时恢复(在"我的"等页面回前台不播)
|
||||
if (ref.read(feedTabVisibleProvider)) {
|
||||
@@ -99,11 +102,15 @@ class _FeedScreenState extends ConsumerState<FeedScreen>
|
||||
.events
|
||||
.listen(_handleEvent);
|
||||
_pageController.jumpToPage(0);
|
||||
// jumpToPage 触发新策略 bindWindow 后再 resume:等其在途 open 完成再播放,
|
||||
// 同时解除新策略池可能残留的挂起态
|
||||
// jumpToPage 后 resume + rebindCurrent:suspend 已 stop 槽位,仅 play
|
||||
// 播不起来,必须 rebind 重新 open(有断点记录则 seek 续播)
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
unawaited(ref.read(feedProvider(_strategy).notifier).pool.resume());
|
||||
unawaited(() async {
|
||||
final n = ref.read(feedProvider(_strategy).notifier);
|
||||
await n.pool.resume();
|
||||
await n.rebindCurrent();
|
||||
}());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -48,6 +48,10 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
||||
int _likeBurstTrigger = 0;
|
||||
Map<String, dynamic>? _seriesData;
|
||||
|
||||
/// 清屏模式:隐藏右侧互动栏与底部信息区,只留画面和进度条。
|
||||
/// 单击屏幕仍是暂停/继续;恢复显示只能通过长按菜单的「恢复清屏」
|
||||
bool _cleanMode = false;
|
||||
|
||||
static const _rates = [1.0, 1.5, 2.0, 3.0];
|
||||
|
||||
@override
|
||||
@@ -174,6 +178,25 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
||||
},
|
||||
),
|
||||
|
||||
// 清屏 / 恢复清屏:隐藏右侧互动栏与底部信息,只留进度条。
|
||||
// 恢复只能从长按菜单进入,避免单击误触把界面弹回来
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: Icon(_cleanMode
|
||||
? Icons.fullscreen
|
||||
: Icons.fullscreen_exit),
|
||||
title: Text(_cleanMode ? '恢复清屏' : '清屏'),
|
||||
subtitle: Text(_cleanMode
|
||||
? '重新显示点赞、评论、收藏、作者与标题'
|
||||
: '隐藏点赞、评论、收藏、作者与标题'),
|
||||
onTap: () {
|
||||
Navigator.of(sheetContext).pop();
|
||||
setState(() => _cleanMode = !_cleanMode);
|
||||
showTopToast(
|
||||
context, _cleanMode ? '已清屏,长按视频可恢复' : '已恢复显示');
|
||||
},
|
||||
),
|
||||
|
||||
// 下载(已下载/下载中置灰)
|
||||
Builder(builder: (_) {
|
||||
final dm = ref.read(downloadManagerProvider);
|
||||
@@ -341,6 +364,7 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
// 单击始终暂停/继续(清屏态也一样),恢复清屏需走长按菜单
|
||||
onTap: widget.pool.toggleCurrent,
|
||||
onDoubleTap: _onDoubleTap,
|
||||
onLongPress: _onLongPress,
|
||||
@@ -349,23 +373,27 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// 底部渐变(提升文字可读性)
|
||||
const Positioned(
|
||||
// 底部渐变(提升文字可读性):清屏时一并淡出
|
||||
Positioned(
|
||||
left: 0, right: 0, bottom: 0, height: 160,
|
||||
child: IgnorePointer(
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Colors.transparent, Colors.black54],
|
||||
child: AnimatedOpacity(
|
||||
opacity: _cleanMode ? 0 : 1,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: const DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Colors.transparent, Colors.black54],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 播放器(含抖音风格细进度条)
|
||||
// 播放器(含抖音风格细进度条)——清屏时仍保留
|
||||
VideoPlayerView(
|
||||
pool: widget.pool,
|
||||
slotIndex: widget.slotIndex,
|
||||
@@ -380,54 +408,60 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
||||
// 右侧互动栏(头像/点赞/评论/收藏 — 分享已移至长按菜单)
|
||||
Positioned(
|
||||
right: 8, bottom: 96,
|
||||
child: InteractionBar(
|
||||
item: widget.item,
|
||||
onLike: widget.onLike,
|
||||
onFavorite: widget.onFavorite,
|
||||
onComment: widget.onComment,
|
||||
child: _HidableOverlay(
|
||||
hidden: _cleanMode,
|
||||
child: InteractionBar(
|
||||
item: widget.item,
|
||||
onLike: widget.onLike,
|
||||
onFavorite: widget.onFavorite,
|
||||
onComment: widget.onComment,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 左下信息区 + 系列标题(系列标题在信息区上方,不重叠)
|
||||
Positioned(
|
||||
left: 12, right: 88, bottom: 24,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// 系列标题(当前视频属于系列时显示,点击弹出系列列表)
|
||||
if (_hasSeries)
|
||||
GestureDetector(
|
||||
onTap: _showSeriesSheet,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black54,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.playlist_play, color: Colors.white, size: 16),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
_seriesTitle,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
child: _HidableOverlay(
|
||||
hidden: _cleanMode,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// 系列标题(当前视频属于系列时显示,点击弹出系列列表)
|
||||
if (_hasSeries)
|
||||
GestureDetector(
|
||||
onTap: _showSeriesSheet,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black54,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.playlist_play, color: Colors.white, size: 16),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
_seriesTitle,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
const Icon(Icons.chevron_right, color: Colors.white, size: 14),
|
||||
],
|
||||
const SizedBox(width: 2),
|
||||
const Icon(Icons.chevron_right, color: Colors.white, size: 14),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 视频信息(昵称/标题/描述)
|
||||
VideoInfoSection(item: widget.item),
|
||||
],
|
||||
// 视频信息(昵称/标题/描述)
|
||||
VideoInfoSection(item: widget.item),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -436,3 +470,24 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 可隐藏浮层:淡出 + 禁用点击。隐藏时仍占位但不拦截手势,
|
||||
/// 保证点击/长按能穿透到下层的手势层
|
||||
class _HidableOverlay extends StatelessWidget {
|
||||
const _HidableOverlay({required this.hidden, required this.child});
|
||||
|
||||
final bool hidden;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IgnorePointer(
|
||||
ignoring: hidden,
|
||||
child: AnimatedOpacity(
|
||||
opacity: hidden ? 0 : 1,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user