fix(flutter): 调整收藏页星标操作

This commit is contained in:
Zhou Weidong committed 2026-10-20 16:36:56 +08:00
1 parent f62324084e
commit 1d8582dfaa
9 files changed
+28 -49

No files matched your search

-1
View File
@@ -512,7 +512,6 @@
"count": {"type": "int"}
}
},
"favoriteLongPressHint": "Long press a card to remove",
"clearWatchHistoryTitle": "Clear watch history?",
"clearWatchHistoryMessage": "This removes the watch history from your account.",
"confirmClear": "Clear",
-1
View File
@@ -476,7 +476,6 @@
"clearAll": "Hapus semua",
"watchRecordsCount": "{count} riwayat",
"favoritesCount": "{count} favorit",
"favoriteLongPressHint": "Tekan lama kartu untuk menghapus",
"clearWatchHistoryTitle": "Hapus riwayat tontonan?",
"clearWatchHistoryMessage": "Semua riwayat akan dihapus dari akun kamu.",
"confirmClear": "Hapus",
-6
View File
@@ -2086,12 +2086,6 @@ abstract class AppLocalizations {
/// **'{count} favorites'**
String favoritesCount(int count);
/// No description provided for @favoriteLongPressHint.
///
/// In en, this message translates to:
/// **'Long press a card to remove'**
String get favoriteLongPressHint;
/// No description provided for @clearWatchHistoryTitle.
///
/// In en, this message translates to:
-3
View File
@@ -1078,9 +1078,6 @@ class AppLocalizationsEn extends AppLocalizations {
return '$count favorites';
}
@override
String get favoriteLongPressHint => 'Long press a card to remove';
@override
String get clearWatchHistoryTitle => 'Clear watch history?';
-3
View File
@@ -1078,9 +1078,6 @@ class AppLocalizationsId extends AppLocalizations {
return '$count favorit';
}
@override
String get favoriteLongPressHint => 'Tekan lama kartu untuk menghapus';
@override
String get clearWatchHistoryTitle => 'Hapus riwayat tontonan?';
-3
View File
@@ -1059,9 +1059,6 @@ class AppLocalizationsZh extends AppLocalizations {
return '共 $count 部';
}
@override
String get favoriteLongPressHint => '长按卡片可取消收藏';
@override
String get clearWatchHistoryTitle => '清空观看记录?';
-1
View File
@@ -438,7 +438,6 @@
"clearAll": "清空",
"watchRecordsCount": "共 {count} 条",
"favoritesCount": "共 {count} 部",
"favoriteLongPressHint": "长按卡片可取消收藏",
"clearWatchHistoryTitle": "清空观看记录?",
"clearWatchHistoryMessage": "这会从当前账号移除全部观看记录。",
"confirmClear": "清空",
+20 -30
View File
@@ -28,7 +28,7 @@ const double _coverWidth = 80;
const double _coverHeight = 106;
const double _coverRadius = 10;
const double _removeSize = 28;
const double _removeIconSize = 15;
const double _removeIconSize = 20;
const double _statsFontSize = 12;
const double _metaFontSize = 11;
const double _titleFontSize = 15;
@@ -134,7 +134,7 @@ class _FavoritesBody extends StatelessWidget {
height: _emptyListHeight,
child: EmptyState(
key: const Key('favorites-empty'),
icon: Icons.favorite_border_rounded,
icon: Icons.star_border_rounded,
title: l10n.noFavorites,
subtitle: l10n.emptyHint,
),
@@ -150,6 +150,7 @@ class _FavoritesBody extends StatelessWidget {
if (index > 0) const SizedBox(height: 10),
_FavoriteCard(
drama: drama,
isFavorite: favorites.isSaved(drama.id),
onOpen: () => _open(context, drama),
onRemove: () => _remove(context, drama.id),
),
@@ -181,30 +182,16 @@ class _FavoritesBody extends StatelessWidget {
}
Widget _summary(AppLocalizations l10n) {
return Row(
children: [
Text(
l10n.favoritesCount(favorites.cards.length),
key: const Key('favorites-count'),
style: const TextStyle(
color: AppColors.muted,
fontSize: _statsFontSize,
),
return Align(
alignment: Alignment.centerLeft,
child: Text(
l10n.favoritesCount(favorites.cards.length),
key: const Key('favorites-count'),
style: const TextStyle(
color: AppColors.muted,
fontSize: _statsFontSize,
),
const Spacer(),
Flexible(
child: Text(
l10n.favoriteLongPressHint,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.end,
style: const TextStyle(
color: AppColors.subtle,
fontSize: _metaFontSize,
),
),
),
],
),
);
}
@@ -228,11 +215,13 @@ class _FavoritesBody extends StatelessWidget {
class _FavoriteCard extends StatelessWidget {
const _FavoriteCard({
required this.drama,
required this.isFavorite,
required this.onOpen,
required this.onRemove,
});
final Drama drama;
final bool isFavorite;
final VoidCallback onOpen;
final VoidCallback onRemove;
@@ -253,7 +242,6 @@ class _FavoriteCard extends StatelessWidget {
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onOpen,
onLongPress: onRemove,
child: Padding(
padding: const EdgeInsets.all(_cardPadding),
child: Stack(
@@ -373,7 +361,7 @@ class _FavoriteCard extends StatelessWidget {
child: SizedBox.square(
dimension: _removeSize,
child: Material(
color: AppColors.badgePink,
color: AppColors.raised,
shape: const CircleBorder(),
clipBehavior: Clip.antiAlias,
child: IconButton(
@@ -381,9 +369,11 @@ class _FavoriteCard extends StatelessWidget {
tooltip: l10n.remove,
padding: EdgeInsets.zero,
onPressed: onRemove,
icon: const Icon(
Icons.favorite_rounded,
color: AppColors.favorite,
icon: Icon(
isFavorite
? Icons.star_rounded
: Icons.star_border_rounded,
color: isFavorite ? AppColors.blue : AppColors.muted,
size: _removeIconSize,
),
),
+8 -1
View File
@@ -54,7 +54,7 @@ void main() {
tester.widget<Text>(find.byKey(const Key('favorites-count'))).data,
'2 favorites',
);
expect(find.text('Long press a card to remove'), findsOneWidget);
expect(find.text('Long press a card to remove'), findsNothing);
expect(find.text('Drama signal'), findsOneWidget);
expect(find.text('Drama city'), findsOneWidget);
final title = tester.widget<Text>(
@@ -71,12 +71,19 @@ void main() {
tester.getSize(find.byKey(const Key('favorite-remove-signal'))),
const Size(28, 28),
);
expect(find.byIcon(Icons.star_rounded), findsNWidgets(2));
expect(find.byIcon(Icons.favorite_rounded), findsNothing);
final refresh = tester.widget<RefreshIndicator>(
find.byType(RefreshIndicator),
);
expect(refresh.color, AppColors.blue);
expect(refresh.backgroundColor, AppColors.card);
expect(refresh.strokeWidth, 2);
await tester.tap(find.byKey(const Key('favorite-remove-signal')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('favorite-card-signal')), findsNothing);
});
testWidgets('should_keep_card_and_show_failure_when_remove_fails', (