diff --git a/docs/plans/PROGRESS.md b/docs/plans/PROGRESS.md index 48c4c2b..4b0b372 100644 --- a/docs/plans/PROGRESS.md +++ b/docs/plans/PROGRESS.md @@ -1186,4 +1186,4 @@ $ flutter test - 拖动仅控制视频浮层内容,顶部导航与根底栏保持常驻。 - 进度条固定中心并动画到 6 高,时间气泡限制在左右 12;end/cancel/pointer 兜底均恢复拖动前状态。 - 修复 `scrubCancelRequest` 误置于 `initState` 的编译错误,并清理推荐页未使用变量;`flutter analyze` 无问题。 -- 观看全集按钮相对进度条上移 8,间距调整为 20;`flutter analyze` 无问题。 +- 观看全集按钮相对进度条上移 8,间距调整为 20;按钮改为屏幕宽度 70% 左对齐,`flutter analyze` 无问题。 diff --git a/lib/pages/player/widgets/home_feed_recommend_panel.dart b/lib/pages/player/widgets/home_feed_recommend_panel.dart index 5d92347..6ca74a0 100644 --- a/lib/pages/player/widgets/home_feed_recommend_panel.dart +++ b/lib/pages/player/widgets/home_feed_recommend_panel.dart @@ -1,5 +1,7 @@ // Author: fruit.com.cn +import 'dart:math' as math; + import 'package:flutter/material.dart'; import '../../../core/data/models/drama.dart'; @@ -106,7 +108,7 @@ class _HomeFeedInfoPanelState extends State { _synopsis(l10n, synopsis), ], const SizedBox(height: 12), - _watchAll(l10n), + _watchAll(context, l10n), ], ); } @@ -245,37 +247,46 @@ class _HomeFeedInfoPanelState extends State { ); } - Widget _watchAll(AppLocalizations l10n) { - return SizedBox( - width: double.infinity, - height: _watchAllHeight, - child: DecoratedBox( - key: const Key('home-feed-full-series-bg'), - decoration: BoxDecoration( - gradient: const LinearGradient( - colors: [AppColors.actionRed, AppColors.blue], - ), - borderRadius: BorderRadius.circular(8), - ), - child: Material( - color: AppColors.transparent, - child: InkWell( - key: const Key('home-feed-full-series'), - onTap: widget.onOpenFullPlayer, - borderRadius: BorderRadius.circular(8), - child: Center( - child: Text( - l10n.homeWatchAll, - style: const TextStyle( - color: AppColors.textPrimary, - fontSize: 15, - fontWeight: FontWeight.w600, + Widget _watchAll(BuildContext context, AppLocalizations l10n) { + final screenWidth = MediaQuery.sizeOf(context).width; + return LayoutBuilder( + builder: (context, constraints) { + final buttonWidth = math.min(screenWidth * 0.7, constraints.maxWidth); + return Align( + alignment: Alignment.centerLeft, + child: SizedBox( + width: buttonWidth, + height: _watchAllHeight, + child: DecoratedBox( + key: const Key('home-feed-full-series-bg'), + decoration: BoxDecoration( + gradient: const LinearGradient( + colors: [AppColors.actionRed, AppColors.blue], + ), + borderRadius: BorderRadius.circular(8), + ), + child: Material( + color: AppColors.transparent, + child: InkWell( + key: const Key('home-feed-full-series'), + onTap: widget.onOpenFullPlayer, + borderRadius: BorderRadius.circular(8), + child: Center( + child: Text( + l10n.homeWatchAll, + style: const TextStyle( + color: AppColors.textPrimary, + fontSize: 15, + fontWeight: FontWeight.w600, + ), + ), + ), ), ), ), ), - ), - ), + ); + }, ); } diff --git a/test/home/home_preview_layout_test.dart b/test/home/home_preview_layout_test.dart index bdb5012..0fa0662 100644 --- a/test/home/home_preview_layout_test.dart +++ b/test/home/home_preview_layout_test.dart @@ -659,6 +659,11 @@ void main() { final bar = tester.getRect(find.byKey(const Key('home-feed-full-series'))); expect(bar.height, 44); + final overlayRect = tester.getRect( + find.byKey(const Key('home-feed-gesture')), + ); + expect(bar.left, closeTo(overlayRect.left + 14, 0.1)); + expect(bar.width, closeTo(overlayRect.width * 0.7, 1)); final buttonBackground = tester .widget(