style(theme): 客户端切换深色视觉风格
This commit is contained in:
1 parent
295c21513c
commit
4bc04fd8ae
75 files changed
+732
-330
No files matched your search
@@ -7,6 +7,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/app.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';
|
||||
|
||||
double _contrast(Color foreground, Color background) {
|
||||
@@ -16,44 +17,59 @@ double _contrast(Color foreground, Color background) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
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_expose_dark_visual_tokens', () {
|
||||
expect(AppColors.blue, const Color(0xFFFF6B2C));
|
||||
expect(AppColors.bluePressed, const Color(0xFFE55A1F));
|
||||
expect(AppColors.secondary, const Color(0xFF22D3EE));
|
||||
expect(AppColors.ink, const Color(0xFF0B1020));
|
||||
expect(AppColors.card, const Color(0xFF151B2E));
|
||||
expect(AppColors.raised, const Color(0xFF1C2436));
|
||||
expect(AppColors.border, const Color(0x0FFFFFFF));
|
||||
expect(AppColors.onSurface, const Color(0xEBFFFFFF));
|
||||
expect(AppColors.muted, const Color(0xA3FFFFFF));
|
||||
expect(AppColors.subtle, const Color(0x61FFFFFF));
|
||||
expect(AppDimens.cardRadius, 12);
|
||||
expect(AppDimens.buttonRadius, 10);
|
||||
expect(AppDimens.inputRadius, 10);
|
||||
expect(AppDimens.chipRadius, 6);
|
||||
});
|
||||
|
||||
test('should_keep_primary_text_readable_on_warm_background', () {
|
||||
test('should_keep_primary_and_secondary_text_readable_on_dark', () {
|
||||
expect(
|
||||
_contrast(AppColors.onSurface, AppColors.ink),
|
||||
greaterThanOrEqualTo(4.5),
|
||||
);
|
||||
expect(
|
||||
_contrast(AppColors.onSurface, AppColors.card),
|
||||
greaterThanOrEqualTo(4.5),
|
||||
);
|
||||
expect(_contrast(AppColors.muted, AppColors.card), greaterThanOrEqualTo(3));
|
||||
expect(_contrast(AppColors.gold, AppColors.ink), greaterThanOrEqualTo(3));
|
||||
expect(_contrast(AppColors.blue, AppColors.ink), greaterThanOrEqualTo(3));
|
||||
});
|
||||
|
||||
test('should_use_light_color_scheme_and_dark_system_icons', () {
|
||||
final theme = AppTheme.light();
|
||||
test('should_use_dark_color_scheme_and_light_system_icons', () {
|
||||
final theme = AppTheme.dark();
|
||||
|
||||
expect(theme.brightness, Brightness.light);
|
||||
expect(theme.brightness, Brightness.dark);
|
||||
expect(theme.colorScheme.primary, AppColors.blue);
|
||||
expect(theme.colorScheme.onPrimary, AppColors.onPrimary);
|
||||
expect(theme.colorScheme.secondary, AppColors.secondary);
|
||||
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);
|
||||
expect(theme.appBarTheme.backgroundColor, AppColors.card);
|
||||
expect(theme.appBarTheme.systemOverlayStyle, SystemUiOverlayStyle.light);
|
||||
expect(theme.cardTheme.elevation, 0);
|
||||
expect(theme.dialogTheme.backgroundColor, AppColors.raised);
|
||||
expect(theme.bottomNavigationBarTheme.backgroundColor, AppColors.bar);
|
||||
expect(theme.inputDecorationTheme.fillColor, AppColors.input);
|
||||
});
|
||||
|
||||
test('should_use_ink_navigation_bar_without_contrast_scrim', () {
|
||||
test('should_use_ink_navigation_bar_with_light_icons', () {
|
||||
expect(appSystemOverlayStyle.statusBarColor, Colors.transparent);
|
||||
expect(appSystemOverlayStyle.statusBarIconBrightness, Brightness.light);
|
||||
expect(appSystemOverlayStyle.systemNavigationBarColor, AppColors.ink);
|
||||
expect(
|
||||
appSystemOverlayStyle.systemNavigationBarDividerColor,
|
||||
@@ -61,20 +77,20 @@ void main() {
|
||||
);
|
||||
expect(
|
||||
appSystemOverlayStyle.systemNavigationBarIconBrightness,
|
||||
Brightness.dark,
|
||||
Brightness.light,
|
||||
);
|
||||
expect(appSystemOverlayStyle.systemNavigationBarContrastEnforced, isFalse);
|
||||
|
||||
final sheetTheme = AppTheme.light().bottomSheetTheme;
|
||||
final sheetTheme = AppTheme.dark().bottomSheetTheme;
|
||||
expect(sheetTheme.backgroundColor, Colors.transparent);
|
||||
expect(sheetTheme.modalBackgroundColor, Colors.transparent);
|
||||
expect(sheetTheme.surfaceTintColor, Colors.transparent);
|
||||
});
|
||||
|
||||
test('should_expose_page_gradient_and_soft_card_shadow', () {
|
||||
test('should_expose_flat_page_gradient_without_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));
|
||||
expect(AppTheme.cardShadow.blurRadius, 0);
|
||||
expect(AppTheme.cardShadow.offset, Offset.zero);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user