feat(flutter): 压缩首页剧卡并把播放次数上封面
This commit is contained in:
1 parent
8e2cd5c838
commit
124ba75ab8
3 files changed
+104
-58
No files matched your search
@@ -10,7 +10,7 @@ import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/home/widgets/home_drama_grid.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('should_render_warm_orange_cover_badges_and_plus_action', (
|
||||
testWidgets('should_render_compact_cover_badges_without_plus_action', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
@@ -20,13 +20,15 @@ void main() {
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) => SizedBox(
|
||||
width: 180,
|
||||
child: HomeDramaCard(
|
||||
l10n: AppLocalizations.of(context)!,
|
||||
drama: _drama,
|
||||
onTap: () {},
|
||||
body: SingleChildScrollView(
|
||||
child: Builder(
|
||||
builder: (context) => SizedBox(
|
||||
width: 180,
|
||||
child: HomeDramaCard(
|
||||
l10n: AppLocalizations.of(context)!,
|
||||
drama: _drama,
|
||||
onTap: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -54,7 +56,29 @@ void main() {
|
||||
expect(find.text('Free'), findsOneWidget);
|
||||
expect(find.text('18 locked'), findsOneWidget);
|
||||
expect(find.text('All 24'), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-drama-add-style-drama')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-drama-add-style-drama')), findsNothing);
|
||||
|
||||
// 播放次数角标落在封面内,并按万位格式化。
|
||||
final views = find.byKey(const Key('home-drama-views-style-drama'));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('home-drama-cover-style-drama')),
|
||||
matching: views,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: views, matching: find.text('1.2万')),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
// 压缩后卡片高度接近「卡宽 × 1.5」,明显矮于旧版 3:4 封面。
|
||||
final cardSize = tester.getSize(card);
|
||||
expect(cardSize.height, lessThan(cardSize.width * 1.6));
|
||||
final coverSize = tester.getSize(
|
||||
find.byKey(const Key('home-drama-cover-style-drama')),
|
||||
);
|
||||
expect(coverSize.height / coverSize.width, closeTo(6 / 5, 0.02));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,4 +90,5 @@ const _drama = Drama(
|
||||
genre: 'Romance',
|
||||
totalEpisodes: 24,
|
||||
freeEpisodes: 6,
|
||||
viewCount: 12400,
|
||||
);
|
||||
Reference in new issue
Block a user