style(client): 对齐短剧列表字号与间距
This commit is contained in:
1 parent
d03dcf162e
commit
d7a59e5a27
17 files changed
+576
-148
No files matched your search
@@ -8,6 +8,8 @@ import 'package:fruitshorts/core/data/models/watch_progress.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
|
||||
import 'package:fruitshorts/core/theme/app_colors.dart';
|
||||
import 'package:fruitshorts/core/theme/app_dimens.dart';
|
||||
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
|
||||
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
||||
|
||||
@@ -41,6 +43,50 @@ void main() {
|
||||
expect(find.byKey(const Key('following-tab-reserve')), findsOneWidget);
|
||||
expect(find.byKey(const Key('following-favorites-grid')), findsOneWidget);
|
||||
expect(find.byType(CustomScrollView), findsWidgets);
|
||||
final tab = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('following-tab-favorites')),
|
||||
matching: find.text('Following'),
|
||||
),
|
||||
);
|
||||
expect(tab.style?.fontSize, AppDimens.followingTabFont);
|
||||
expect(tab.style?.fontWeight, FontWeight.w700);
|
||||
expect(tab.style?.color, AppColors.textPrimary);
|
||||
final grid = tester.widget<SliverGrid>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('following-favorites-grid')),
|
||||
matching: find.byType(SliverGrid),
|
||||
),
|
||||
);
|
||||
final delegate =
|
||||
grid.gridDelegate as SliverGridDelegateWithFixedCrossAxisCount;
|
||||
expect(delegate.crossAxisSpacing, AppDimens.homeGridGap);
|
||||
expect(delegate.mainAxisSpacing, AppDimens.homeGridRowGap);
|
||||
expect(delegate.childAspectRatio, AppDimens.followingGridAspectRatio);
|
||||
final card = find.byKey(const Key('following-card-the-signal-demo'));
|
||||
final cover = tester.widget<AspectRatio>(
|
||||
find.byKey(const Key('following-cover-the-signal-demo')),
|
||||
);
|
||||
expect(cover.aspectRatio, AppDimens.cardCoverAspectRatio);
|
||||
final title = tester.widget<Text>(
|
||||
find.descendant(of: card, matching: find.text('The Signal')),
|
||||
);
|
||||
expect(title.style?.fontSize, AppDimens.cardTitleFont);
|
||||
expect(title.style?.fontWeight, FontWeight.w500);
|
||||
expect(title.style?.height, AppDimens.cardTitleLineHeight);
|
||||
final views = tester.widget<Text>(
|
||||
find.byKey(const Key('following-views-the-signal-demo')),
|
||||
);
|
||||
expect(views.style?.fontSize, AppDimens.cardViewsFont);
|
||||
expect(views.style?.color, AppColors.textPrimary);
|
||||
final tag = find.byKey(const Key('following-tag-the-signal-demo-0'));
|
||||
expect(tag, findsOneWidget);
|
||||
expect(tester.getSize(tag).height, AppDimens.cardTagHeight);
|
||||
final tagText = tester.widget<Text>(
|
||||
find.descendant(of: tag, matching: find.byType(Text)),
|
||||
);
|
||||
expect(tagText.style?.fontSize, AppDimens.cardTagFont);
|
||||
expect(tagText.style?.color, AppColors.textTertiary);
|
||||
|
||||
await tester.tap(find.byKey(const Key('following-edit')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -171,6 +217,33 @@ void main() {
|
||||
);
|
||||
expect(find.byIcon(Icons.edit_outlined), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_fit_following_cards_on_compact_viewport', (tester) async {
|
||||
tester.view.physicalSize = const Size(320, 640);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
_signIn();
|
||||
final catalog = FakeCatalogRepository();
|
||||
await tester.pumpWidget(
|
||||
_app(
|
||||
catalog: catalog,
|
||||
favorites: InMemoryFavoriteRepository(
|
||||
cards: catalog.dramas.take(1).toList(),
|
||||
saved: {catalog.dramas.first.id},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
find.byKey(const Key('following-card-the-signal-demo')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
void _signIn() {
|
||||
|
||||
@@ -40,9 +40,19 @@ void main() {
|
||||
final cover = find.byKey(const Key('home-feed-cover-anime-card'));
|
||||
final coverSize = tester.getSize(cover);
|
||||
expect(coverSize.height / coverSize.width, closeTo(6 / 5, 0.02));
|
||||
final badge = find.byKey(const Key('home-feed-badge-anime-anime-card'));
|
||||
expect(badge, findsOneWidget);
|
||||
final badgeContainer = tester.widget<Container>(badge);
|
||||
expect(
|
||||
find.byKey(const Key('home-feed-badge-anime-anime-card')),
|
||||
findsOneWidget,
|
||||
(badgeContainer.decoration! as BoxDecoration).borderRadius,
|
||||
BorderRadius.circular(AppDimens.cardBadgeRadius),
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(find.descendant(of: badge, matching: find.byType(Text)))
|
||||
.style
|
||||
?.fontSize,
|
||||
AppDimens.cardBadgeFont,
|
||||
);
|
||||
expect(find.text('Anime'), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-views-anime-card')), findsOneWidget);
|
||||
@@ -51,16 +61,31 @@ void main() {
|
||||
find.descendant(of: views, matching: find.byType(Text)),
|
||||
);
|
||||
expect(viewsText.data, startsWith('44.'));
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(find.byKey(const Key('home-feed-title-anime-card')))
|
||||
.maxLines,
|
||||
2,
|
||||
expect(viewsText.style?.fontSize, AppDimens.cardViewsFont);
|
||||
expect(viewsText.style?.color, AppColors.navSelected);
|
||||
final title = tester.widget<Text>(
|
||||
find.byKey(const Key('home-feed-title-anime-card')),
|
||||
);
|
||||
expect(find.byKey(const Key('home-feed-tag-anime-card-0')), findsOneWidget);
|
||||
expect(title.maxLines, 2);
|
||||
expect(title.style?.fontSize, AppDimens.cardTitleFont);
|
||||
expect(title.style?.fontWeight, FontWeight.w500);
|
||||
expect(title.style?.height, AppDimens.cardTitleLineHeight);
|
||||
final firstTag = find.byKey(const Key('home-feed-tag-anime-card-0'));
|
||||
expect(firstTag, findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-tag-anime-card-1')), findsOneWidget);
|
||||
expect(find.text('Romance'), findsOneWidget);
|
||||
expect(find.text('Urban'), findsOneWidget);
|
||||
final tagContainer = tester.widget<Container>(firstTag);
|
||||
expect(tester.getSize(firstTag).height, AppDimens.cardTagHeight);
|
||||
expect(
|
||||
(tagContainer.decoration! as BoxDecoration).borderRadius,
|
||||
BorderRadius.circular(AppDimens.cardTagRadius),
|
||||
);
|
||||
final tagText = tester.widget<Text>(
|
||||
find.descendant(of: firstTag, matching: find.byType(Text)),
|
||||
);
|
||||
expect(tagText.style?.fontSize, AppDimens.cardTagFont);
|
||||
expect(tagText.style?.color, AppColors.textTertiary);
|
||||
|
||||
await tester.tap(card);
|
||||
expect(taps, 1);
|
||||
|
||||
@@ -16,6 +16,8 @@ import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
|
||||
import 'package:fruitshorts/core/data/services/playback_thumbnail_service.dart';
|
||||
import 'package:fruitshorts/core/theme/app_colors.dart';
|
||||
import 'package:fruitshorts/core/theme/app_dimens.dart';
|
||||
import 'package:fruitshorts/core/theme/app_theme.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/home/home_feed_channel.dart';
|
||||
@@ -82,8 +84,8 @@ void main() {
|
||||
final delegate =
|
||||
grid.gridDelegate as SliverGridDelegateWithFixedCrossAxisCount;
|
||||
expect(delegate.crossAxisCount, 3);
|
||||
expect(delegate.crossAxisSpacing, 8);
|
||||
expect(delegate.mainAxisSpacing, 8);
|
||||
expect(delegate.crossAxisSpacing, AppDimens.homeGridGap);
|
||||
expect(delegate.mainAxisSpacing, AppDimens.homeGridRowGap);
|
||||
expect(find.byKey(const Key('home-section-featured')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-section-new')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-section-categories')), findsOneWidget);
|
||||
@@ -92,6 +94,67 @@ void main() {
|
||||
expect(find.byKey(const Key('home-section-category-社群')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-secondary-tags')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-grid-filter')), findsOneWidget);
|
||||
final searchBox = find.descendant(
|
||||
of: find.byKey(const Key('home-search-entry')),
|
||||
matching: find.byType(Container),
|
||||
);
|
||||
expect(tester.getSize(searchBox).height, AppDimens.searchHeight);
|
||||
expect(
|
||||
(tester.widget<Container>(searchBox).decoration! as BoxDecoration)
|
||||
.borderRadius,
|
||||
BorderRadius.circular(AppDimens.searchRadius),
|
||||
);
|
||||
final placeholder = tester.widget<Text>(
|
||||
find.text('Search dramas, actors, genres...'),
|
||||
);
|
||||
expect(placeholder.style?.fontSize, AppDimens.searchPlaceholderFont);
|
||||
expect(placeholder.style?.color, AppColors.textSecondary);
|
||||
final selectedPrimary = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('home-section-featured')),
|
||||
matching: find.text('Featured'),
|
||||
),
|
||||
);
|
||||
final unselectedPrimary = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('home-section-new')),
|
||||
matching: find.text('New'),
|
||||
),
|
||||
);
|
||||
expect(selectedPrimary.style?.fontSize, AppDimens.homePrimaryTabFont);
|
||||
expect(selectedPrimary.style?.fontWeight, FontWeight.w700);
|
||||
expect(selectedPrimary.style?.color, AppColors.navSelected);
|
||||
expect(unselectedPrimary.style?.fontWeight, FontWeight.w400);
|
||||
expect(unselectedPrimary.style?.color, AppColors.textTertiary);
|
||||
final secondaryTag = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('home-tag-hot')),
|
||||
matching: find.text('Hot'),
|
||||
),
|
||||
);
|
||||
expect(secondaryTag.style?.fontSize, AppDimens.homeSecondaryTagFont);
|
||||
expect(secondaryTag.style?.fontWeight, FontWeight.w400);
|
||||
expect(secondaryTag.style?.color, AppColors.textTertiary);
|
||||
final unselectedTagChip = tester.widget<Container>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('home-tag-hot')),
|
||||
matching: find.byType(Container),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
(unselectedTagChip.decoration! as BoxDecoration).color,
|
||||
AppColors.transparent,
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('home-tag-hot')));
|
||||
await tester.pump();
|
||||
final selectedTag = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('home-tag-hot')),
|
||||
matching: find.text('Hot'),
|
||||
),
|
||||
);
|
||||
expect(selectedTag.style?.color, AppColors.navSelected);
|
||||
expect(selectedTag.style?.fontWeight, FontWeight.w700);
|
||||
expect(find.byType(PageView), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
@@ -128,10 +191,7 @@ void main() {
|
||||
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
|
||||
expect(find.byType(PlayerPage), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<PlayerPage>(find.byType(PlayerPage)).homeMode,
|
||||
isTrue,
|
||||
);
|
||||
expect(tester.widget<PlayerPage>(find.byType(PlayerPage)).homeMode, isTrue);
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-playlist')));
|
||||
|
||||
@@ -41,6 +41,14 @@ void main() {
|
||||
expect(find.byKey(const Key('mine-vip')), findsOneWidget);
|
||||
expect(find.byKey(const Key('mine-vip-open')), findsOneWidget);
|
||||
expect(find.byKey(const Key('mine-menu')), findsOneWidget);
|
||||
final title = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('mine-page-surface')),
|
||||
matching: find.text('My'),
|
||||
),
|
||||
);
|
||||
expect(title.style?.fontSize, AppDimens.minePageTitle);
|
||||
expect(title.style?.fontWeight, FontWeight.w700);
|
||||
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
|
||||
for (final oldShortcut in const [
|
||||
Key('mine-watchlist'),
|
||||
|
||||
@@ -6,6 +6,8 @@ import 'package:fruitshorts/app.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
|
||||
import 'package:fruitshorts/core/theme/app_colors.dart';
|
||||
import 'package:fruitshorts/core/theme/app_dimens.dart';
|
||||
import 'package:fruitshorts/core/widgets/app_bottom_nav.dart';
|
||||
import 'package:fruitshorts/pages/player/player_view.dart';
|
||||
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
|
||||
@@ -66,6 +68,53 @@ void main() {
|
||||
expect(find.text('New This Week'), findsOneWidget);
|
||||
expect(find.text('Costume Drama Awards'), findsOneWidget);
|
||||
expect(find.byType(AppBottomNav), findsOneWidget);
|
||||
final sectionTitle = tester.widget<Text>(find.text("This Week's Hits"));
|
||||
expect(sectionTitle.style?.fontSize, AppDimens.recommendSectionTitle);
|
||||
expect(sectionTitle.style?.fontWeight, FontWeight.w700);
|
||||
final sectionSubtitle = tester.widget<Text>(
|
||||
find.text('Binge the hottest stories of the week!'),
|
||||
);
|
||||
expect(sectionSubtitle.style?.fontSize, AppDimens.recommendSectionSubtitle);
|
||||
expect(sectionSubtitle.style?.color, AppColors.textSecondary);
|
||||
final moreText = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('recommend-more-hits')),
|
||||
matching: find.text('More'),
|
||||
),
|
||||
);
|
||||
expect(moreText.style?.fontSize, AppDimens.recommendSectionMore);
|
||||
expect(moreText.style?.color, AppColors.textSecondary);
|
||||
final card = find.byKey(const Key('recommend-card-hits-the-signal-demo'));
|
||||
final cover = tester.widget<AspectRatio>(
|
||||
find.descendant(of: card, matching: find.byType(AspectRatio)),
|
||||
);
|
||||
expect(cover.aspectRatio, AppDimens.cardCoverAspectRatio);
|
||||
final cardTitle = tester.widget<Text>(
|
||||
find.byKey(const Key('recommend-title-hits-the-signal-demo')),
|
||||
);
|
||||
expect(cardTitle.style?.fontSize, AppDimens.cardTitleFont);
|
||||
expect(cardTitle.style?.fontWeight, FontWeight.w500);
|
||||
expect(cardTitle.style?.height, AppDimens.cardTitleLineHeight);
|
||||
final views = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('recommend-views-hits-the-signal-demo')),
|
||||
matching: find.byType(Text),
|
||||
),
|
||||
);
|
||||
expect(views.style?.fontSize, AppDimens.cardViewsFont);
|
||||
expect(views.style?.color, AppColors.textPrimary);
|
||||
final tag = find.byKey(const Key('recommend-tag-hits-the-signal-demo-0'));
|
||||
expect(tag, findsOneWidget);
|
||||
expect(tester.getSize(tag).height, AppDimens.cardTagHeight);
|
||||
final tagText = tester.widget<Text>(
|
||||
find.descendant(of: tag, matching: find.byType(Text)),
|
||||
);
|
||||
expect(tagText.style?.fontSize, AppDimens.cardTagFont);
|
||||
expect(tagText.style?.color, AppColors.textTertiary);
|
||||
expect(
|
||||
(tester.widget<Container>(tag).decoration! as BoxDecoration).borderRadius,
|
||||
BorderRadius.circular(AppDimens.cardTagRadius),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_switch_inner_tabs_without_losing_grid_filter_state', (
|
||||
@@ -88,6 +137,21 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('all-sort-new')));
|
||||
await tester.pump();
|
||||
expect(_textStyle(tester, 'New').fontWeight, FontWeight.w700);
|
||||
expect(_textStyle(tester, 'New').fontSize, AppDimens.filterChipFont);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('all-sort-new'))).height,
|
||||
AppDimens.filterChipHeight,
|
||||
);
|
||||
final chipContainer = tester.widget<Container>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('all-sort-new')),
|
||||
matching: find.byType(Container),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
(chipContainer.decoration! as BoxDecoration).borderRadius,
|
||||
BorderRadius.circular(AppDimens.filterChipRadius),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-playlist')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
Reference in new issue
Block a user