Files
sure/mobile/test/theme/sure_theme_test.dart
ghost 94d5ad2151 fix(mobile): neutral Sure tokens for FAB/badge/avatar surfaces + themed logo (#2366)
On screens not yet redesigned with SureColors (the Chats list, etc.), Material's
primary/secondary *container* roles were unset, so they fell back to defaults
that read as blue on the FAB, unread-badge, and avatar surfaces.

- Pin `primaryContainer`/`secondaryContainer` to a neutral Sure surface
  (`surfaceInset` + `textPrimary`), and add a `FloatingActionButtonThemeData` so
  FABs use Sure's neutral primary action color (`buttonPrimary`). `primary` /
  `secondary` stay `link` / `info`, so existing link/accent callers are unchanged.
- Add a `SureLogo` widget that renders `logomark.svg` with the wordmark's
  `currentColor` strokes tinted to the theme's secondary text color, and route
  every logomark consumer (nav bar, login) through it — so the mark stays legible
  in dark mode (the hardcoded grey was too dim) and no caller renders the strokes
  as the flutter_svg default (black). The green brand mark keeps its fill.

Refs #2235.
2026-06-16 10:03:28 +02:00

82 lines
3.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sure_mobile/main.dart';
import 'package:sure_mobile/theme/sure_theme.dart';
import 'package:sure_mobile/theme/sure_tokens.dart';
void main() {
test('light theme uses Sure token values', () {
final theme = SureTheme.light;
expect(theme.brightness, Brightness.light);
expect(theme.textTheme.bodyMedium?.fontFamily, SureTokens.fontSans);
expect(theme.colorScheme.primary, SureTokens.light.link);
expect(theme.colorScheme.onPrimary, SureTokens.light.textInverse);
expect(theme.colorScheme.primaryContainer, SureTokens.light.surfaceInset);
expect(theme.colorScheme.onPrimaryContainer, SureTokens.light.textPrimary);
expect(theme.colorScheme.secondary, SureTokens.light.info);
expect(theme.colorScheme.onSecondary, SureTokens.light.textInverse);
expect(theme.colorScheme.secondaryContainer, SureTokens.light.surfaceInset);
expect(
theme.colorScheme.onSecondaryContainer, SureTokens.light.textPrimary);
expect(theme.colorScheme.surface, SureTokens.light.surface);
expect(theme.colorScheme.onSurface, SureTokens.light.textPrimary);
expect(theme.colorScheme.error, SureTokens.light.destructive);
expect(
theme.colorScheme.errorContainer, SureTokens.light.destructiveSubtle);
expect(theme.colorScheme.onErrorContainer, SureTokens.light.textPrimary);
expect(theme.scaffoldBackgroundColor, SureTokens.light.surface);
expect(theme.cardTheme.color, SureTokens.light.container);
expect(theme.floatingActionButtonTheme.backgroundColor,
SureTokens.light.buttonPrimary);
expect(theme.floatingActionButtonTheme.foregroundColor,
SureTokens.light.textInverse);
expect(
theme.elevatedButtonTheme.style?.minimumSize?.resolve({}),
const Size(double.infinity, 50),
);
});
test('dark theme uses Sure token values', () {
final theme = SureTheme.dark;
expect(theme.brightness, Brightness.dark);
expect(theme.textTheme.bodyMedium?.fontFamily, SureTokens.fontSans);
expect(theme.colorScheme.primary, SureTokens.dark.link);
expect(theme.colorScheme.onPrimary, SureTokens.dark.textInverse);
expect(theme.colorScheme.primaryContainer, SureTokens.dark.surfaceInset);
expect(theme.colorScheme.onPrimaryContainer, SureTokens.dark.textPrimary);
expect(theme.colorScheme.secondary, SureTokens.dark.info);
expect(theme.colorScheme.onSecondary, SureTokens.dark.textInverse);
expect(theme.colorScheme.secondaryContainer, SureTokens.dark.surfaceInset);
expect(theme.colorScheme.onSecondaryContainer, SureTokens.dark.textPrimary);
expect(theme.colorScheme.surface, SureTokens.dark.surface);
expect(theme.colorScheme.onSurface, SureTokens.dark.textPrimary);
expect(theme.colorScheme.error, SureTokens.dark.destructive);
expect(theme.colorScheme.errorContainer, SureTokens.dark.destructiveSubtle);
expect(theme.colorScheme.onErrorContainer, SureTokens.dark.textPrimary);
expect(theme.scaffoldBackgroundColor, SureTokens.dark.surface);
expect(theme.cardTheme.color, SureTokens.dark.container);
expect(theme.floatingActionButtonTheme.backgroundColor,
SureTokens.dark.buttonPrimary);
expect(theme.floatingActionButtonTheme.foregroundColor,
SureTokens.dark.textInverse);
expect(
theme.elevatedButtonTheme.style?.minimumSize?.resolve({}),
const Size(double.infinity, 50),
);
});
testWidgets('app wires Sure light and dark themes', (tester) async {
SharedPreferences.setMockInitialValues({});
await tester.pumpWidget(const SureApp());
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.theme?.colorScheme.surface, SureTokens.light.surface);
expect(materialApp.darkTheme?.colorScheme.surface, SureTokens.dark.surface);
expect(materialApp.themeMode, ThemeMode.system);
});
}