feat(recommend): 对齐沉浸式推荐页视觉布局
This commit is contained in:
1 parent
77689a3eaa
commit
5dd3492aea
17 files changed
+831
-398
No files matched your search
@@ -291,7 +291,10 @@ void main() {
|
||||
const drama = Drama(
|
||||
id: 'feed-drama',
|
||||
title: 'Feed Drama',
|
||||
synopsis: 'synopsis',
|
||||
synopsis:
|
||||
'A long synopsis follows the heroine through a dangerous city, '
|
||||
'a hidden identity, and a final choice that changes everyone around '
|
||||
'her forever.',
|
||||
posterUrl: '',
|
||||
genre: 'Romance',
|
||||
category: 'Urban',
|
||||
@@ -302,6 +305,7 @@ void main() {
|
||||
favoriteCount: 32000,
|
||||
commentCount: 12,
|
||||
);
|
||||
var episodesOpened = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.light(),
|
||||
@@ -337,6 +341,7 @@ void main() {
|
||||
onShare: () {},
|
||||
onDetail: () {},
|
||||
onOpenFullPlayer: () {},
|
||||
onEpisodes: () => episodesOpened++,
|
||||
onMore: () {},
|
||||
),
|
||||
),
|
||||
@@ -347,13 +352,28 @@ void main() {
|
||||
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('home-feed-title'))).data,
|
||||
'Feed Drama',
|
||||
'Ignored Episode Title',
|
||||
);
|
||||
expect(find.text('Feed Drama'), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-info-card')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-full-series')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-tags')), findsOneWidget);
|
||||
expect(find.text('Episode 2'), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-synopsis-more')), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('home-feed-synopsis-more')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('home-feed-synopsis'))).maxLines,
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(find.byKey(const Key('home-feed-episode-progress')))
|
||||
.data,
|
||||
'Episode 2 / 8 total',
|
||||
);
|
||||
expect(find.textContaining('41.9万'), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-ranking-pill')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-view-pill')), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('rail-like-count'))).data,
|
||||
'1006',
|
||||
@@ -363,43 +383,38 @@ void main() {
|
||||
'3.2万',
|
||||
);
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('rail-comments-count'))).data,
|
||||
'12',
|
||||
);
|
||||
String railAsset(Key key) {
|
||||
final image = tester.widget<Image>(
|
||||
find.descendant(of: find.byKey(key), matching: find.byType(Image)),
|
||||
);
|
||||
return (image.image as AssetImage).assetName;
|
||||
}
|
||||
|
||||
expect(railAsset(const Key('rail-save')), 'assets/icon/rail/rail_save.png');
|
||||
expect(
|
||||
railAsset(const Key('rail-comments')),
|
||||
'assets/icon/rail/rail_comment.png',
|
||||
);
|
||||
expect(railAsset(const Key('rail-like')), 'assets/icon/rail/rail_like.png');
|
||||
expect(
|
||||
railAsset(const Key('rail-share')),
|
||||
'assets/icon/rail/rail_share.png',
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('rail-like')),
|
||||
matching: find.byIcon(Icons.favorite_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<Image>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('rail-share')),
|
||||
matching: find.byType(Image),
|
||||
),
|
||||
)
|
||||
.colorBlendMode,
|
||||
BlendMode.srcIn,
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('rail-save')),
|
||||
matching: find.byIcon(Icons.bookmark_border_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(const Key('rail-episodes')), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('rail-episodes')),
|
||||
matching: find.byIcon(Icons.layers_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(const Key('rail-comments')), findsNothing);
|
||||
expect(find.byKey(const Key('rail-share')), findsNothing);
|
||||
expect(find.text('Comments'), findsNothing);
|
||||
expect(find.byKey(const Key('progress-loading')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('home-feed-progress-inactive')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(const Key('home-feed-progress-thumb')), findsNothing);
|
||||
await tester.tap(find.byKey(const Key('rail-episodes')));
|
||||
expect(episodesOpened, 1);
|
||||
});
|
||||
|
||||
testWidgets('should_show_static_track_without_seek_when_feed_is_locked', (
|
||||
@@ -597,14 +612,19 @@ void main() {
|
||||
|
||||
final bar = tester.getRect(find.byKey(const Key('home-feed-full-series')));
|
||||
expect(bar.height, 44);
|
||||
final buttonBackground =
|
||||
tester
|
||||
.widget<DecoratedBox>(
|
||||
find.byKey(const Key('home-feed-full-series-bg')),
|
||||
)
|
||||
.decoration
|
||||
as BoxDecoration;
|
||||
expect((buttonBackground.gradient! as LinearGradient).colors, [
|
||||
AppColors.actionRed,
|
||||
AppColors.blue,
|
||||
]);
|
||||
expect(
|
||||
tester
|
||||
.widget<Container>(find.byKey(const Key('home-feed-full-series-bg')))
|
||||
.color,
|
||||
const Color(0x4D000000),
|
||||
);
|
||||
expect(
|
||||
tester.getRect(find.textContaining('Watch full series')).center.dy,
|
||||
tester.getRect(find.text('Watch all')).center.dy,
|
||||
closeTo(bar.center.dy, 2),
|
||||
);
|
||||
expect(
|
||||
@@ -613,7 +633,7 @@ void main() {
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('home-feed-progress'))).height,
|
||||
greaterThanOrEqualTo(24),
|
||||
12,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
|
||||
@@ -35,6 +35,55 @@ void main() {
|
||||
expect(find.byKey(const Key('recommend-tab-playlist')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-tab-all')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
|
||||
final recommendText = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('recommend-tab-recommend')),
|
||||
matching: find.text('Recommend'),
|
||||
),
|
||||
);
|
||||
expect(recommendText.style?.fontSize, 17);
|
||||
expect(recommendText.style?.fontWeight, FontWeight.w700);
|
||||
expect(recommendText.style?.color, AppColors.textPrimary);
|
||||
final playlistText = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('recommend-tab-playlist')),
|
||||
matching: find.text('Playlists'),
|
||||
),
|
||||
);
|
||||
expect(playlistText.style?.fontSize, 17);
|
||||
expect(playlistText.style?.fontWeight, FontWeight.w400);
|
||||
expect(playlistText.style?.color, AppColors.textTabInactive);
|
||||
expect(
|
||||
tester
|
||||
.widget<IconButton>(find.byKey(const Key('recommend-search')))
|
||||
.iconSize,
|
||||
26,
|
||||
);
|
||||
final topNavRect = tester.getRect(
|
||||
find.byKey(const Key('recommend-top-nav')),
|
||||
);
|
||||
expect(
|
||||
tester.getRect(find.byKey(const Key('recommend-search'))).right,
|
||||
closeTo(topNavRect.right - AppDimens.feedPageHorizontal, 0.1),
|
||||
);
|
||||
final tabGroupLeft = tester
|
||||
.getRect(find.byKey(const Key('recommend-tab-recommend')))
|
||||
.left;
|
||||
final tabGroupRight = tester
|
||||
.getRect(find.byKey(const Key('recommend-tab-all')))
|
||||
.right;
|
||||
expect(
|
||||
(tabGroupLeft + tabGroupRight) / 2,
|
||||
closeTo(topNavRect.center.dx, 0.1),
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.getRect(find.byKey(const Key('recommend-top-nav')))
|
||||
.overlaps(
|
||||
tester.getRect(find.byKey(const Key('recommend-feed-player'))),
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
final player = tester.widget<PlayerPage>(
|
||||
find.byKey(const Key('recommend-feed-player')),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user