feat(app): 展示真实点赞与评论计数
This commit is contained in:
1 parent
7b927c794e
commit
dfc650456a
9 files changed
+123
-8
No files matched your search
@@ -337,6 +337,7 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
|
||||
drama: drama,
|
||||
episode: episode,
|
||||
liked: interactions.isLiked(drama.id),
|
||||
likeCount: interactions.likeCount(drama.id),
|
||||
saved: context.watch<FavoriteController>().isSaved(drama.id),
|
||||
onLike: () async {
|
||||
if (await ensureSignedIn(context)) {
|
||||
@@ -388,6 +389,7 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
|
||||
episode: episode,
|
||||
controller: ready ? videoPort!.controller : null,
|
||||
liked: interactions.isLiked(drama.id),
|
||||
likeCount: interactions.likeCount(drama.id),
|
||||
// 收藏以服务端为准(FavoriteController 由 app 注入,登录后自动加载)
|
||||
saved: context.watch<FavoriteController>().isSaved(drama.id),
|
||||
onBack: widget.embedded
|
||||
@@ -506,9 +508,7 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
errorText(l10n, logic.unlockError, l10n.unlockFailed),
|
||||
),
|
||||
content: Text(errorText(l10n, logic.unlockError, l10n.unlockFailed)),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -688,6 +688,7 @@ class _PlaybackOverlay extends StatefulWidget {
|
||||
required this.episode,
|
||||
required this.controller,
|
||||
required this.liked,
|
||||
this.likeCount,
|
||||
required this.saved,
|
||||
required this.playing,
|
||||
required this.playbackSpeed,
|
||||
@@ -714,6 +715,7 @@ class _PlaybackOverlay extends StatefulWidget {
|
||||
final Episode episode;
|
||||
final VideoPlayerController? controller;
|
||||
final bool liked;
|
||||
final int? likeCount;
|
||||
final bool saved;
|
||||
final bool playing;
|
||||
final double playbackSpeed;
|
||||
@@ -985,6 +987,12 @@ class _PlaybackOverlayState extends State<_PlaybackOverlay> {
|
||||
color: widget.liked ? AppColors.blue : AppColors.muted,
|
||||
),
|
||||
title: Text(widget.l10n.like),
|
||||
trailing: widget.likeCount == null
|
||||
? null
|
||||
: Text(
|
||||
'${widget.likeCount}',
|
||||
key: const Key('player-more-like-count'),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
widget.onLike();
|
||||
|
||||
@@ -178,11 +178,13 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
|
||||
|
||||
Widget _content(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final count = _controller.exactCount;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
l10n.comments,
|
||||
count == null ? l10n.comments : '${l10n.comments} · $count',
|
||||
key: count == null ? null : const Key('comment-count-label'),
|
||||
style: const TextStyle(
|
||||
color: AppColors.cream,
|
||||
fontSize: 18,
|
||||
|
||||
@@ -19,6 +19,7 @@ class HomeFeedOverlay extends StatelessWidget {
|
||||
required this.drama,
|
||||
required this.episode,
|
||||
required this.liked,
|
||||
this.likeCount,
|
||||
required this.saved,
|
||||
required this.onLike,
|
||||
required this.onSave,
|
||||
@@ -35,6 +36,7 @@ class HomeFeedOverlay extends StatelessWidget {
|
||||
final Drama drama;
|
||||
final Episode episode;
|
||||
final bool liked;
|
||||
final int? likeCount;
|
||||
final bool saved;
|
||||
final VoidCallback onLike;
|
||||
final VoidCallback onSave;
|
||||
@@ -123,7 +125,8 @@ class HomeFeedOverlay extends StatelessWidget {
|
||||
_RailItem(
|
||||
key: const Key('rail-like'),
|
||||
icon: liked ? Icons.favorite_rounded : Icons.favorite_border_rounded,
|
||||
label: l10n.like,
|
||||
label: likeCount?.toString() ?? l10n.like,
|
||||
countKey: likeCount == null ? null : const Key('rail-like-count'),
|
||||
selected: liked,
|
||||
onTap: onLike,
|
||||
),
|
||||
@@ -375,12 +378,14 @@ class _RailItem extends StatelessWidget {
|
||||
required this.label,
|
||||
required this.onTap,
|
||||
this.selected = false,
|
||||
this.countKey,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final VoidCallback onTap;
|
||||
final bool selected;
|
||||
final Key? countKey;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -404,6 +409,7 @@ class _RailItem extends StatelessWidget {
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
label,
|
||||
key: countKey,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
|
||||
Reference in new issue
Block a user