feat(flutter): 应用浅色暖橙视觉主题
This commit is contained in:
1 parent
0d2367431d
commit
634b63e16c
56 files changed
+941
-409
No files matched your search
@@ -2,13 +2,13 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.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';
|
||||
|
||||
void main() {
|
||||
testWidgets('should_render_64_high_navigation_and_keep_item_keys', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('should_render_five_slots_with_center_action', (tester) async {
|
||||
var centerTaps = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -23,24 +23,74 @@ void main() {
|
||||
onTap: () {},
|
||||
),
|
||||
AppBottomNavItem(
|
||||
tabKey: const Key('tab-my'),
|
||||
tabKey: const Key('tab-theater'),
|
||||
icon: Icons.explore_outlined,
|
||||
selectedIcon: Icons.explore_rounded,
|
||||
label: 'Theater',
|
||||
onTap: () {},
|
||||
),
|
||||
AppBottomNavItem(
|
||||
tabKey: const Key('tab-create'),
|
||||
icon: Icons.add_box_outlined,
|
||||
selectedIcon: Icons.add_box_rounded,
|
||||
label: 'Create',
|
||||
onTap: () {},
|
||||
),
|
||||
AppBottomNavItem(
|
||||
tabKey: const Key('tab-mine'),
|
||||
icon: Icons.person_outline_rounded,
|
||||
selectedIcon: Icons.person_rounded,
|
||||
label: 'Me',
|
||||
onTap: () {},
|
||||
),
|
||||
],
|
||||
centerAction: AppBottomNavCenterAction(
|
||||
label: 'Create',
|
||||
onTap: () => centerTaps++,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byKey(const Key('tab-home')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-my')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-theater')), findsOneWidget);
|
||||
expect(find.byKey(const Key('nav-center-action')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-create')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-mine')), findsOneWidget);
|
||||
expect(find.text('Home'), findsOneWidget);
|
||||
final centers = [
|
||||
Key('tab-home'),
|
||||
Key('tab-theater'),
|
||||
Key('nav-center-action'),
|
||||
Key('tab-create'),
|
||||
Key('tab-mine'),
|
||||
].map((key) => tester.getCenter(find.byKey(key)).dx).toList();
|
||||
expect(centers, orderedEquals(centers.toList()..sort()));
|
||||
expect(
|
||||
tester.getSize(find.byType(AppBottomNav)).height,
|
||||
AppDimens.navHeight,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('nav-center-action'))),
|
||||
const Size.square(AppDimens.navCenter),
|
||||
);
|
||||
final ink = tester.widget<Ink>(
|
||||
find
|
||||
.ancestor(
|
||||
of: find.byKey(const Key('nav-center-action')),
|
||||
matching: find.byType(Ink),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
final decoration = ink.decoration! as BoxDecoration;
|
||||
expect(decoration.shape, BoxShape.circle);
|
||||
expect((decoration.gradient! as LinearGradient).colors, const [
|
||||
AppColors.navCenterStart,
|
||||
AppColors.navCenterEnd,
|
||||
]);
|
||||
|
||||
await tester.tap(find.byKey(const Key('nav-center-action')));
|
||||
expect(centerTaps, 1);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/data/models/drama.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/widgets/home_drama_grid.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('should_render_warm_orange_cover_badges_and_plus_action', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.light(),
|
||||
locale: const Locale('en'),
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) => SizedBox(
|
||||
width: 180,
|
||||
child: HomeDramaCard(
|
||||
l10n: AppLocalizations.of(context)!,
|
||||
drama: _drama,
|
||||
onTap: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final card = find.byKey(const Key('home-drama-card-style-drama'));
|
||||
final cardContainer = tester.widget<Container>(
|
||||
find.ancestor(of: card, matching: find.byType(Container)).last,
|
||||
);
|
||||
final cardDecoration = cardContainer.decoration! as BoxDecoration;
|
||||
expect(cardDecoration.color, AppColors.card);
|
||||
expect(
|
||||
cardDecoration.borderRadius,
|
||||
BorderRadius.circular(AppDimens.cardRadius),
|
||||
);
|
||||
expect(cardDecoration.boxShadow, const [AppTheme.cardShadow]);
|
||||
|
||||
final tag = tester.widget<Container>(
|
||||
find.byKey(const Key('home-drama-tag-style-drama')),
|
||||
);
|
||||
expect((tag.decoration! as BoxDecoration).color, AppColors.badgePink);
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
const _drama = Drama(
|
||||
id: 'style-drama',
|
||||
title: 'Warm Orange Story',
|
||||
synopsis: '暖橙短剧',
|
||||
posterUrl: '/files/style.jpg',
|
||||
genre: 'Romance',
|
||||
totalEpisodes: 24,
|
||||
freeEpisodes: 6,
|
||||
);
|
||||
@@ -20,6 +20,7 @@ const _keys = [
|
||||
Key('home-tabs-bar'),
|
||||
Key('tab-home'),
|
||||
Key('tab-theater'),
|
||||
Key('nav-center-action'),
|
||||
Key('tab-create'),
|
||||
Key('tab-mine'),
|
||||
];
|
||||
@@ -53,7 +54,7 @@ void main() {
|
||||
final decoration = bar.decoration as BoxDecoration;
|
||||
final border = decoration.border as Border;
|
||||
expect(decoration.color, AppColors.bar.withValues(alpha: 0.95));
|
||||
expect(border.top.color, AppColors.outlineVariantDark);
|
||||
expect(border.top.color, AppColors.border);
|
||||
expect(border.top.color, isNot(Colors.white));
|
||||
expect(
|
||||
tester
|
||||
@@ -73,6 +74,17 @@ void main() {
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<Icon>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.byIcon(Icons.home_rounded),
|
||||
),
|
||||
)
|
||||
.color,
|
||||
AppColors.blue,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-theater')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -87,6 +99,30 @@ void main() {
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-theater')),
|
||||
matching: find.text('Theater'),
|
||||
),
|
||||
)
|
||||
.style
|
||||
?.color,
|
||||
AppColors.blue,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.text('Home'),
|
||||
),
|
||||
)
|
||||
.style
|
||||
?.color,
|
||||
AppColors.navUnselected,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
@@ -103,6 +139,7 @@ void main() {
|
||||
|
||||
expect(find.byKey(const Key('tab-home')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-theater')), findsOneWidget);
|
||||
expect(find.byKey(const Key('nav-center-action')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-create')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-mine')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-browse-page')), findsOneWidget);
|
||||
@@ -111,6 +148,12 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('nav-center-action')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('create-page')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-create')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('create-page')), findsOneWidget);
|
||||
|
||||
@@ -82,7 +82,7 @@ void main() {
|
||||
Future<void> pumpEpisode(Episode episode) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.dark(),
|
||||
theme: AppTheme.light(),
|
||||
locale: const Locale('en'),
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
@@ -141,7 +141,7 @@ void main() {
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.dark(),
|
||||
theme: AppTheme.light(),
|
||||
locale: const Locale('en'),
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
|
||||
@@ -8,6 +8,7 @@ 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/pages/player/player_view.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';
|
||||
@@ -32,8 +33,9 @@ void main() {
|
||||
for (final key in _tabKeys) {
|
||||
expect(find.byKey(key), findsOneWidget);
|
||||
}
|
||||
expect(find.byKey(const Key('nav-center-action')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-create')));
|
||||
await tester.tap(find.byKey(const Key('nav-center-action')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('create-page')), findsOneWidget);
|
||||
@@ -46,12 +48,22 @@ void main() {
|
||||
|
||||
expect(_chip(tester, 'home-channel-hot').selected, isTrue);
|
||||
expect(_chip(tester, 'home-channel-free').selected, isFalse);
|
||||
expect(_chip(tester, 'home-channel-hot').selectedColor, AppColors.blue);
|
||||
expect(_chip(tester, 'home-channel-free').backgroundColor, AppColors.card);
|
||||
expect(
|
||||
_chip(tester, 'home-channel-free').labelStyle?.color,
|
||||
AppColors.onSurface,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-channel-free')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(_chip(tester, 'home-channel-hot').selected, isFalse);
|
||||
expect(_chip(tester, 'home-channel-free').selected, isTrue);
|
||||
expect(
|
||||
_chip(tester, 'home-channel-free').labelStyle?.color,
|
||||
AppColors.onPrimary,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_open_theater_search_when_home_search_is_tapped', (
|
||||
|
||||
Reference in new issue
Block a user