feat(flutter): 应用浅色暖橙视觉主题

This commit is contained in:
Zhou Weidong committed 2026-10-20 10:15:03 +08:00
1 parent 0d2367431d
commit 634b63e16c
56 files changed
+941 -409

No files matched your search

@@ -207,7 +207,7 @@ Widget _host(Drama drama) {
ChangeNotifierProvider(create: (_) => CatalogController(catalog)..load()),
],
child: MaterialApp(
theme: AppTheme.dark(),
theme: AppTheme.light(),
locale: const Locale('en'),
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: AppLocalizations.localizationsDelegates,
+6 -6
View File
@@ -12,7 +12,7 @@ void main() {
var taps = 0;
await _pump(
tester,
theme: AppTheme.dark(),
theme: AppTheme.light(),
child: EmptyState(
icon: Icons.movie_outlined,
title: 'No stories',
@@ -33,7 +33,7 @@ void main() {
);
expect(
tester.widget<Icon>(find.byKey(const Key('empty-state-icon'))).color,
AppColors.gold,
AppColors.blue,
);
expect(
tester
@@ -103,15 +103,15 @@ void main() {
expect(find.byKey(const Key('empty-state-action')), findsNothing);
});
testWidgets('should_tint_the_bare_icon_for_light_and_dark', (tester) async {
testWidgets('should_tint_the_bare_icon_with_the_light_theme', (tester) async {
await _pump(
tester,
theme: AppTheme.dark(),
theme: AppTheme.light(),
child: const EmptyState(icon: Icons.history_rounded, title: 'No history'),
);
expect(
tester.widget<Icon>(find.byKey(const Key('empty-state-icon'))).color,
AppColors.gold,
AppColors.blue,
);
await _pump(
@@ -156,7 +156,7 @@ Future<void> _pump(
}) async {
await tester.pumpWidget(
MaterialApp(
theme: theme ?? AppTheme.dark(),
theme: theme ?? AppTheme.light(),
home: Scaffold(body: child),
),
);
+55 -5
View File
@@ -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);
});
}
+69
View File
@@ -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,
);
+44 -1
View File
@@ -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);
+2 -2
View File
@@ -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,
+13 -1
View File
@@ -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', (
+2 -1
View File
@@ -2,6 +2,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/core/theme/app_colors.dart';
import 'package:fruitshorts/pages/player/widgets/player_center_toggle.dart';
void main() {
@@ -36,7 +37,7 @@ void main() {
find.descendant(of: find.byKey(key), matching: find.byType(Container)),
);
final decoration = container.decoration! as BoxDecoration;
expect(decoration.color, const Color(0x80000000));
expect(decoration.color, AppColors.blue);
expect(decoration.shape, BoxShape.circle);
final icon = tester.widget<Icon>(
find.descendant(of: find.byKey(key), matching: find.byType(Icon)),
+8 -4
View File
@@ -6,18 +6,22 @@ import 'package:fruitshorts/core/theme/app_dimens.dart';
void main() {
test('should_expose_the_k20_spacing_and_type_scale', () {
expect(AppDimens.pageHorizontal, 16);
expect(AppDimens.cardRadius, 12);
expect(AppDimens.innerRadius, 10);
expect(AppDimens.cardRadius, 16);
expect(AppDimens.coverRadius, 16);
expect(AppDimens.authCardRadius, 20);
expect(AppDimens.pillRadius, 999);
expect(AppDimens.buttonRadius, 999);
expect(AppDimens.caption, 12);
expect(AppDimens.body, 14);
expect(AppDimens.listTitle, 15);
expect(AppDimens.sectionTitle, 16);
expect(AppDimens.pageTitle, 20);
expect(AppDimens.navLabel, 9);
expect(AppDimens.navLabel, 10);
expect(AppDimens.buttonHeight, 48);
expect(AppDimens.primaryButtonHeight, 52);
expect(AppDimens.tapTarget, 44);
expect(AppDimens.navHeight, 54);
expect(AppDimens.navHeight, 64);
expect(AppDimens.navCenter, 56);
expect(AppDimens.progressHeight, 3);
});
}
+35 -60
View File
@@ -2,7 +2,7 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/core/theme/app_colors.dart';
import 'package:fruitshorts/core/theme/app_theme.dart';
@@ -14,71 +14,46 @@ double _contrast(Color foreground, Color background) {
}
void main() {
test('should_expose_obsidian_flare_brand_tokens', () {
expect(AppColors.blue, const Color(0xFFFF5B3D));
expect(AppColors.bluePressed, const Color(0xFFFF4321));
expect(AppColors.blueSoft, const Color(0xFF9278EA));
expect(AppColors.secondary, const Color(0xFF9278EA));
expect(AppColors.gold, const Color(0xFFFBBF24));
expect(AppColors.ink, const Color(0xFF0B0C10));
expect(AppColors.card, const Color(0xFF1B1C21));
expect(AppColors.cardAlt, const Color(0xFF1C1D21));
expect(AppColors.raised, const Color(0xFF1C1D21));
expect(AppColors.bar, const Color(0xFF0D0D11));
expect(AppColors.success, const Color(0xFF34D399));
expect(AppColors.onPrimary, const Color(0xFFFFFFFF));
test('should_expose_light_warm_orange_tokens', () {
expect(AppColors.blue, const Color(0xFFFF7A1A));
expect(AppColors.bluePressed, const Color(0xFFFF6A00));
expect(AppColors.secondary, const Color(0xFFFF6A8A));
expect(AppColors.ink, const Color(0xFFFFF8F0));
expect(AppColors.surfaceTop, const Color(0xFFFFE9D6));
expect(AppColors.card, const Color(0xFFFFFFFF));
expect(AppColors.onSurface, const Color(0xFF1F1B16));
expect(AppColors.muted, const Color(0xFF8C837B));
expect(AppColors.subtle, const Color(0xFFB3AAA1));
expect(AppColors.border, const Color(0xFFF0E4D6));
expect(AppColors.badgePink, const Color(0xFFFFE3EC));
expect(AppColors.badgePinkText, const Color(0xFFFF6A8A));
});
test('should_keep_primary_text_readable_on_warm_background', () {
expect(
_contrast(AppColors.onGold, AppColors.gold),
_contrast(AppColors.onSurface, AppColors.ink),
greaterThanOrEqualTo(4.5),
);
expect(_contrast(AppColors.muted, AppColors.card), greaterThanOrEqualTo(3));
});
test('should_meet_text_and_icon_contrast_when_using_theme_tokens', () {
expect(
_contrast(AppColors.onPrimary, AppColors.blue),
greaterThanOrEqualTo(3),
);
expect(_contrast(AppColors.blue, Colors.white), greaterThanOrEqualTo(3));
expect(
_contrast(AppColors.blueSoft, AppColors.ink),
greaterThanOrEqualTo(3),
);
test('should_use_light_color_scheme_and_dark_system_icons', () {
final theme = AppTheme.light();
expect(theme.brightness, Brightness.light);
expect(theme.colorScheme.primary, AppColors.blue);
expect(theme.colorScheme.onPrimary, AppColors.onPrimary);
expect(theme.colorScheme.surface, AppColors.ink);
expect(theme.colorScheme.onSurface, AppColors.onSurface);
expect(theme.colorScheme.outline, AppColors.border);
expect(theme.scaffoldBackgroundColor, AppColors.ink);
expect(theme.appBarTheme.systemOverlayStyle, SystemUiOverlayStyle.dark);
});
test('should_use_flare_brand_in_light_and_dark_color_schemes', () {
for (final theme in [AppTheme.light(), AppTheme.dark()]) {
expect(theme.colorScheme.primary, AppColors.blue);
expect(theme.colorScheme.onPrimary, AppColors.onPrimary);
}
});
test('should_define_non_white_outline_tokens_in_both_themes', () {
final light = AppTheme.light().colorScheme;
final dark = AppTheme.dark().colorScheme;
expect(light.outline, AppColors.outlineLight);
expect(light.outlineVariant, AppColors.outlineVariantLight);
expect(dark.outline, AppColors.outlineDark);
expect(dark.outlineVariant, AppColors.outlineVariantDark);
expect(dark.outlineVariant.computeLuminance(), lessThan(0.2));
expect(light.outlineVariant.computeLuminance(), lessThan(0.92));
});
testWidgets('should_expose_chili_brand_through_widget_theme', (tester) async {
late ThemeData applied;
await tester.pumpWidget(
MaterialApp(
theme: AppTheme.dark(),
home: Builder(
builder: (context) {
applied = Theme.of(context);
return const SizedBox.shrink();
},
),
),
);
expect(applied.colorScheme.primary, AppColors.blue);
expect(applied.colorScheme.onPrimary, AppColors.onPrimary);
test('should_expose_page_gradient_and_soft_card_shadow', () {
expect(AppTheme.pageGradient.colors, [AppColors.surfaceTop, AppColors.ink]);
expect(AppTheme.cardShadow.color, AppColors.cardShadow);
expect(AppTheme.cardShadow.blurRadius, 18);
expect(AppTheme.cardShadow.offset, const Offset(0, 6));
});
}