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,
|
||||
);
|
||||
@@ -3,6 +3,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/app.dart';
|
||||
import 'package:fruitshorts/core/data/models/drama.dart';
|
||||
import 'package:fruitshorts/core/data/models/home_feed.dart';
|
||||
import 'package:fruitshorts/core/data/models/watch_progress.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
|
||||
@@ -104,7 +105,23 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('should_pin_home_channels_when_scrolling', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
// 多放几部剧,保证内容高度足够滚过吸顶阈值。
|
||||
await _pumpApp(
|
||||
tester,
|
||||
withBanner: false,
|
||||
dramas: [
|
||||
for (var index = 0; index < 10; index++)
|
||||
Drama(
|
||||
id: 'scroll-$index',
|
||||
title: 'Scroll Drama $index',
|
||||
synopsis: 'synopsis',
|
||||
posterUrl: '/files/scroll-$index.png',
|
||||
genre: 'Drama',
|
||||
totalEpisodes: 10,
|
||||
freeEpisodes: 10,
|
||||
),
|
||||
],
|
||||
);
|
||||
final before = tester.getRect(find.byKey(const Key('home-channel-hot')));
|
||||
expect(find.byKey(const Key('home-channels-pinned')), findsNothing);
|
||||
|
||||
@@ -278,12 +295,14 @@ Future<void> _pumpApp(
|
||||
WatchHistoryRepository? history,
|
||||
Size size = const Size(390, 844),
|
||||
bool withBanner = true,
|
||||
List<Drama>? dramas,
|
||||
}) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final catalog = FakeCatalogRepository(
|
||||
dramas: dramas,
|
||||
banners: withBanner
|
||||
? const [
|
||||
FeedBanner(
|
||||
|
||||
Reference in new issue
Block a user