fix(favorite): 统一收藏状态与互动图标
This commit is contained in:
1 parent
4b97f89c0b
commit
d3dbc9f8dc
13 files changed
+347
-213
No files matched your search
@@ -269,8 +269,11 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
||||
liked: widget.liked,
|
||||
favoriteCount: widget.favoriteCount,
|
||||
likeCount: widget.likeCount,
|
||||
commentCount: widget.commentCount,
|
||||
onSave: widget.onSave,
|
||||
onLike: widget.onLike,
|
||||
onComments: widget.onComments,
|
||||
onShare: widget.onShare,
|
||||
onEpisodes: widget.onEpisodes ?? widget.onOpenFullPlayer,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,19 +5,16 @@ import 'dart:math' as math;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/data/models/drama.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 '../../home/widgets/home_drama_classification.dart';
|
||||
import 'interaction_rail.dart';
|
||||
|
||||
const double _seriesFont = 19;
|
||||
const double _tagFont = 13;
|
||||
const double _synopsisFont = 13;
|
||||
const double _watchAllHeight = 44;
|
||||
const double _actionGap = 28;
|
||||
const double _actionIcon = 32;
|
||||
const double _actionWidth = 64;
|
||||
const List<Shadow> _textShadows = [
|
||||
Shadow(color: AppColors.shadow, blurRadius: 6, offset: Offset(0, 1)),
|
||||
];
|
||||
@@ -307,112 +304,71 @@ class HomeFeedActionRail extends StatelessWidget {
|
||||
required this.liked,
|
||||
required this.onSave,
|
||||
required this.onLike,
|
||||
required this.onComments,
|
||||
required this.onShare,
|
||||
required this.onEpisodes,
|
||||
this.favoriteCount,
|
||||
this.likeCount,
|
||||
this.commentCount,
|
||||
});
|
||||
|
||||
final bool saved;
|
||||
final bool liked;
|
||||
final int? favoriteCount;
|
||||
final int? likeCount;
|
||||
final int? commentCount;
|
||||
final VoidCallback onSave;
|
||||
final VoidCallback onLike;
|
||||
final VoidCallback onComments;
|
||||
final VoidCallback onShare;
|
||||
final VoidCallback onEpisodes;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return SizedBox(
|
||||
width: _actionWidth,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_action(
|
||||
key: const Key('rail-save'),
|
||||
icon: saved
|
||||
? Icons.bookmark_rounded
|
||||
: Icons.bookmark_border_rounded,
|
||||
label: favoriteCount == null
|
||||
? l10n.favorite
|
||||
: formatInteractionCount(favoriteCount!),
|
||||
labelKey: const Key('rail-save-count'),
|
||||
onTap: onSave,
|
||||
),
|
||||
const SizedBox(height: _actionGap),
|
||||
_action(
|
||||
key: const Key('rail-like'),
|
||||
icon: liked
|
||||
? Icons.favorite_rounded
|
||||
: Icons.favorite_border_rounded,
|
||||
iconColor: liked
|
||||
? AppColors.doubleTapHeartRed
|
||||
: AppColors.textPrimary,
|
||||
label: likeCount == null
|
||||
? l10n.like
|
||||
: formatInteractionCount(likeCount!),
|
||||
labelKey: const Key('rail-like-count'),
|
||||
onTap: onLike,
|
||||
),
|
||||
const SizedBox(height: _actionGap),
|
||||
_action(
|
||||
key: const Key('rail-episodes'),
|
||||
icon: Icons.layers_rounded,
|
||||
label: l10n.episodes,
|
||||
labelKey: const Key('rail-episodes-label'),
|
||||
labelFontSize: 11,
|
||||
onTap: onEpisodes,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _action({
|
||||
required Key key,
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required Key labelKey,
|
||||
required VoidCallback onTap,
|
||||
Color iconColor = AppColors.textPrimary,
|
||||
double labelFontSize = 12,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
key: key,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: onTap,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: _actionIcon,
|
||||
color: iconColor,
|
||||
shadows: const [
|
||||
Shadow(
|
||||
color: AppColors.shadowSoft,
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
label,
|
||||
key: labelKey,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
fontSize: labelFontSize,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1,
|
||||
shadows: _textShadows,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
return InteractionRail(
|
||||
items: [
|
||||
InteractionRailItem(
|
||||
key: const Key('rail-save'),
|
||||
asset: 'assets/icon/rail/rail_save.png',
|
||||
label: l10n.favorite,
|
||||
count: favoriteCount,
|
||||
countKey: const Key('rail-save-count'),
|
||||
selected: saved,
|
||||
onTap: onSave,
|
||||
),
|
||||
InteractionRailItem(
|
||||
key: const Key('rail-comments'),
|
||||
asset: 'assets/icon/rail/rail_comment.png',
|
||||
label: l10n.comments,
|
||||
count: commentCount,
|
||||
countKey: const Key('rail-comments-count'),
|
||||
onTap: onComments,
|
||||
),
|
||||
InteractionRailItem(
|
||||
key: const Key('rail-like'),
|
||||
asset: 'assets/icon/rail/rail_like.png',
|
||||
label: l10n.like,
|
||||
count: likeCount,
|
||||
countKey: const Key('rail-like-count'),
|
||||
selected: liked,
|
||||
selectedColor: AppColors.doubleTapHeartRed,
|
||||
onTap: onLike,
|
||||
),
|
||||
InteractionRailItem(
|
||||
key: const Key('rail-share'),
|
||||
asset: 'assets/icon/rail/rail_share.png',
|
||||
label: l10n.share,
|
||||
onTap: onShare,
|
||||
),
|
||||
InteractionRailItem(
|
||||
key: const Key('rail-episodes'),
|
||||
icon: Icons.layers_rounded,
|
||||
label: l10n.episodes,
|
||||
countKey: const Key('rail-episodes-label'),
|
||||
onTap: onEpisodes,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -13,17 +13,19 @@ const double _itemGap = 24;
|
||||
class InteractionRailItem {
|
||||
const InteractionRailItem({
|
||||
required this.key,
|
||||
required this.asset,
|
||||
required this.label,
|
||||
required this.onTap,
|
||||
this.asset,
|
||||
this.icon,
|
||||
this.count,
|
||||
this.countKey,
|
||||
this.selected = false,
|
||||
this.selectedColor = AppColors.blue,
|
||||
});
|
||||
}) : assert((asset == null) != (icon == null));
|
||||
|
||||
final Key key;
|
||||
final String asset;
|
||||
final String? asset;
|
||||
final IconData? icon;
|
||||
final String label;
|
||||
final VoidCallback onTap;
|
||||
final int? count;
|
||||
@@ -68,14 +70,24 @@ class _RailButton extends StatelessWidget {
|
||||
child: IconButton(
|
||||
onPressed: item.onTap,
|
||||
padding: EdgeInsets.zero,
|
||||
icon: Image.asset(
|
||||
item.asset,
|
||||
width: _iconSize,
|
||||
height: _iconSize,
|
||||
fit: BoxFit.contain,
|
||||
color: item.selected ? item.selectedColor : AppColors.onPrimary,
|
||||
colorBlendMode: BlendMode.srcIn,
|
||||
),
|
||||
icon: item.asset != null
|
||||
? Image.asset(
|
||||
item.asset!,
|
||||
width: _iconSize,
|
||||
height: _iconSize,
|
||||
fit: BoxFit.contain,
|
||||
color: item.selected
|
||||
? item.selectedColor
|
||||
: AppColors.onPrimary,
|
||||
colorBlendMode: BlendMode.srcIn,
|
||||
)
|
||||
: Icon(
|
||||
item.icon,
|
||||
size: _iconSize,
|
||||
color: item.selected
|
||||
? item.selectedColor
|
||||
: AppColors.onPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
|
||||
Reference in new issue
Block a user