feat(recommend): 对齐沉浸式推荐页视觉布局
This commit is contained in:
1 parent
77689a3eaa
commit
5dd3492aea
17 files changed
+831
-398
No files matched your search
@@ -9,30 +9,23 @@ import 'package:video_player/video_player.dart';
|
||||
import '../../../core/data/models/drama.dart';
|
||||
import '../../../core/data/services/playback_thumbnail_service.dart';
|
||||
import '../../../core/data/services/sprite_thumbnail_axis.dart';
|
||||
import '../../../core/formatting/count_format.dart';
|
||||
import '../../../core/formatting/localized_content.dart';
|
||||
import '../../../core/theme/app_colors.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'interaction_rail.dart';
|
||||
import 'home_feed_recommend_panel.dart';
|
||||
import 'loading_progress_track.dart';
|
||||
import 'scrub_preview_card.dart';
|
||||
import 'seek_progress_bar.dart';
|
||||
|
||||
part 'home_feed_overlay_parts.dart';
|
||||
|
||||
const Color _overlayPill = AppColors.overlaySoft;
|
||||
const Color _fullBarBackground = AppColors.overlayBar;
|
||||
const double _titleFontSize = 17;
|
||||
const double _metaFontSize = 12;
|
||||
const double _tagFontSize = 11;
|
||||
const double _fullBarHeight = 44;
|
||||
const double _progressHeight = 2;
|
||||
const double _progressHitHeight = 24;
|
||||
const double _progressHitHeight = 12;
|
||||
const double _pageHorizontal = 14;
|
||||
const double _railGap = 12;
|
||||
const double _railBottomOffset = 60;
|
||||
const List<Shadow> _boostTextShadows = [
|
||||
Shadow(color: AppColors.shadow, blurRadius: 5, offset: Offset(0, 1)),
|
||||
];
|
||||
const int _maxTags = 4;
|
||||
final RegExp _tagSplitter = RegExp(r'[,/、·]');
|
||||
|
||||
/// 首页沉浸式 feed 浮层:手势层、右侧互动栏、底部信息与整集进度条。
|
||||
class HomeFeedOverlay extends StatefulWidget {
|
||||
@@ -53,6 +46,7 @@ class HomeFeedOverlay extends StatefulWidget {
|
||||
required this.onShare,
|
||||
required this.onDetail,
|
||||
required this.onOpenFullPlayer,
|
||||
this.onEpisodes,
|
||||
required this.onTogglePlay,
|
||||
required this.onBoostStart,
|
||||
required this.onBoostEnd,
|
||||
@@ -86,6 +80,7 @@ class HomeFeedOverlay extends StatefulWidget {
|
||||
final VoidCallback onShare;
|
||||
final VoidCallback onDetail;
|
||||
final VoidCallback onOpenFullPlayer;
|
||||
final VoidCallback? onEpisodes;
|
||||
final VoidCallback onTogglePlay;
|
||||
final VoidCallback onBoostStart;
|
||||
final VoidCallback onBoostEnd;
|
||||
@@ -124,17 +119,42 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
||||
),
|
||||
),
|
||||
if (widget.boosting)
|
||||
Column(children: [const Spacer(), _boostHint(), _fullSeriesBar()])
|
||||
else
|
||||
Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
if (widget.visible) _bottomInfo(),
|
||||
_fullSeriesBar(),
|
||||
],
|
||||
Positioned(left: 0, right: 0, bottom: 20, child: _boostHint())
|
||||
else if (widget.visible)
|
||||
Positioned(
|
||||
left: _pageHorizontal,
|
||||
right: _pageHorizontal,
|
||||
bottom: 12,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(child: _bottomInfo()),
|
||||
const SizedBox(width: _railGap),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: _railBottomOffset),
|
||||
child: _rail(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (widget.visible && !widget.boosting)
|
||||
Positioned(right: 10, bottom: 56, child: _rail()),
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: _FeedProgressBar(
|
||||
controller: widget.controller,
|
||||
locked: widget.locked,
|
||||
height: _progressHeight,
|
||||
hitHeight: _progressHitHeight,
|
||||
onScrubStart: widget.onScrubStart,
|
||||
onSeek: widget.onSeek,
|
||||
thumbnailService: widget.thumbnailService,
|
||||
spriteAxisService: widget.spriteAxisService,
|
||||
thumbnailsUrl: widget.episode.thumbnailsUrl,
|
||||
episodeId: widget.episode.id,
|
||||
posterUrl: widget.drama.posterUrl,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -179,244 +199,23 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
||||
}
|
||||
|
||||
Widget _rail() {
|
||||
return InteractionRail(
|
||||
items: [
|
||||
InteractionRailItem(
|
||||
key: const Key('rail-save'),
|
||||
asset: 'assets/icon/rail/rail_save.png',
|
||||
label: widget.l10n.favorite,
|
||||
count: widget.favoriteCount,
|
||||
countKey: const Key('rail-save-count'),
|
||||
selected: widget.saved,
|
||||
onTap: widget.onSave,
|
||||
),
|
||||
InteractionRailItem(
|
||||
key: const Key('rail-comments'),
|
||||
asset: 'assets/icon/rail/rail_comment.png',
|
||||
label: widget.l10n.comments,
|
||||
count: widget.commentCount,
|
||||
countKey: const Key('rail-comments-count'),
|
||||
onTap: widget.onComments,
|
||||
),
|
||||
InteractionRailItem(
|
||||
key: const Key('rail-like'),
|
||||
asset: 'assets/icon/rail/rail_like.png',
|
||||
label: widget.l10n.like,
|
||||
count: widget.likeCount,
|
||||
countKey: const Key('rail-like-count'),
|
||||
selected: widget.liked,
|
||||
onTap: widget.onLike,
|
||||
),
|
||||
InteractionRailItem(
|
||||
key: const Key('rail-share'),
|
||||
asset: 'assets/icon/rail/rail_share.png',
|
||||
label: widget.l10n.share,
|
||||
onTap: widget.onShare,
|
||||
),
|
||||
],
|
||||
return HomeFeedActionRail(
|
||||
saved: widget.saved,
|
||||
liked: widget.liked,
|
||||
favoriteCount: widget.favoriteCount,
|
||||
likeCount: widget.likeCount,
|
||||
onSave: widget.onSave,
|
||||
onLike: widget.onLike,
|
||||
onEpisodes: widget.onEpisodes ?? widget.onOpenFullPlayer,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _bottomInfo() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 0, 56, 8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_seriesMetaRow(),
|
||||
const SizedBox(height: 2),
|
||||
_titleRow(),
|
||||
const SizedBox(height: 6),
|
||||
_tagsRow(),
|
||||
if (widget.authorNote.isNotEmpty) ...[
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'${widget.l10n.authorNoteLabel}: ${widget.authorNote}',
|
||||
key: const Key('home-feed-author-note'),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: AppColors.muted, fontSize: 11),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _seriesMetaRow() {
|
||||
return GestureDetector(
|
||||
key: const Key('home-feed-series-meta'),
|
||||
onTap: widget.onDetail,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
widget.l10n.seriesMeta(
|
||||
'${widget.drama.episodeCount}',
|
||||
formatInteractionCount(widget.drama.viewCount),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.muted,
|
||||
fontSize: _metaFontSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
color: AppColors.muted,
|
||||
size: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _titleRow() {
|
||||
return GestureDetector(
|
||||
onTap: widget.onDetail,
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
localizedDramaTitle(widget.l10n, widget.drama),
|
||||
key: const Key('home-feed-title'),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Outfit',
|
||||
color: AppColors.onPrimary,
|
||||
fontSize: _titleFontSize,
|
||||
fontWeight: FontWeight.w800,
|
||||
shadows: [Shadow(blurRadius: 8, color: AppColors.mediaBlack)],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
color: AppColors.onPrimary,
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _tagsRow() {
|
||||
final tags = [
|
||||
widget.l10n.episodeLabel(widget.episode.number),
|
||||
..._tagValues(),
|
||||
].take(_maxTags).toList();
|
||||
return Wrap(
|
||||
key: const Key('home-feed-tags'),
|
||||
spacing: 6,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
for (final tag in tags)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: _overlayPill,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
tag,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(
|
||||
color: AppColors.onPrimary,
|
||||
fontSize: _tagFontSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
List<String> _tagValues() {
|
||||
final result = <String>[];
|
||||
for (final value in [widget.drama.genre, widget.drama.category]) {
|
||||
for (final part in value.split(_tagSplitter)) {
|
||||
final tag = part.trim();
|
||||
if (tag.isEmpty || result.contains(tag)) continue;
|
||||
result.add(tag);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Widget _fullSeriesBar() {
|
||||
return GestureDetector(
|
||||
key: const Key('home-feed-full-series'),
|
||||
onTap: widget.onOpenFullPlayer,
|
||||
child: SizedBox(
|
||||
height: _fullBarHeight,
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
key: const Key('home-feed-full-series-bg'),
|
||||
color: _fullBarBackground,
|
||||
),
|
||||
),
|
||||
Positioned.fill(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.play_arrow_rounded,
|
||||
color: AppColors.onPrimary,
|
||||
size: 14,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.l10n.watchFullSeries(
|
||||
'${widget.drama.episodeCount}',
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.onPrimary,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
color: AppColors.onPrimary,
|
||||
size: 18,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: _FeedProgressBar(
|
||||
controller: widget.controller,
|
||||
locked: widget.locked,
|
||||
height: _progressHeight,
|
||||
hitHeight: _progressHitHeight,
|
||||
onScrubStart: widget.onScrubStart,
|
||||
onSeek: widget.onSeek,
|
||||
thumbnailService: widget.thumbnailService,
|
||||
spriteAxisService: widget.spriteAxisService,
|
||||
thumbnailsUrl: widget.episode.thumbnailsUrl,
|
||||
episodeId: widget.episode.id,
|
||||
posterUrl: widget.drama.posterUrl,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
return HomeFeedInfoPanel(
|
||||
drama: widget.drama,
|
||||
episode: widget.episode,
|
||||
onDetail: widget.onDetail,
|
||||
onOpenFullPlayer: widget.onOpenFullPlayer,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user