feat(tokens): add design tokens, type scale, push scaffold, and root nav state

This commit is contained in:
2026-07-28 20:01:23 +02:00
parent 6dba89432e
commit 172b2a42ac
17 changed files with 856 additions and 30 deletions
+87
View File
@@ -0,0 +1,87 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pluriwave/tema/pluriwave_theme.dart';
import 'package:pluriwave/tema/pluriwave_typography.dart';
/// Design ADR-1: the named type scale is a second ThemeExtension, closed at
/// six styles. Pins the documented size/weight/letter-spacing per style and
/// confirms PluriWaveTheme.dark() registers it, mirroring how
/// PluriWaveTokens/PluriWaveMotion are already tested.
///
/// PluriWaveTheme.dark() is only ever resolved from inside a testWidgets
/// callback (never from setUpAll or a plain test()). GoogleFonts.
/// plusJakartaSansTextTheme fires a background network fetch per text role;
/// TestWidgetsFlutterBinding only installs its HTTP-blocking override
/// inside an active test-widgets zone, so calling PluriWaveTheme.dark()
/// outside one lets a real (and here unreachable) network request escape
/// and fail asynchronously. The numeric values asserted below (fontSize/
/// weight/letterSpacing/height) are set synchronously by
/// PluriWaveTypography.from regardless of that background fetch's outcome.
void main() {
late PluriWaveTypography type;
group('PluriWaveTypography', () {
testWidgets('PluriWaveTheme.dark() registers the extension', (
tester,
) async {
final theme = PluriWaveTheme.dark();
final extension = theme.extension<PluriWaveTypography>();
expect(extension, isNotNull);
type = extension!;
});
test('heroTime is 88 / w800 / height 1.0 / letter-spacing -2.0', () {
expect(type.heroTime.fontSize, 88);
expect(type.heroTime.fontWeight, FontWeight.w800);
expect(type.heroTime.height, 1.0);
expect(type.heroTime.letterSpacing, -2.0);
});
test('sectionTitle is 23 / w800 / letter-spacing -0.6', () {
expect(type.sectionTitle.fontSize, 23);
expect(type.sectionTitle.fontWeight, FontWeight.w800);
expect(type.sectionTitle.letterSpacing, -0.6);
});
test('screenTitle is 19 / w800 / letter-spacing -0.4', () {
expect(type.screenTitle.fontSize, 19);
expect(type.screenTitle.fontWeight, FontWeight.w800);
expect(type.screenTitle.letterSpacing, -0.4);
});
test('cardTitle is 14.5 / w700', () {
expect(type.cardTitle.fontSize, 14.5);
expect(type.cardTitle.fontWeight, FontWeight.w700);
});
test('bodyStrong is 13 / w600', () {
expect(type.bodyStrong.fontSize, 13);
expect(type.bodyStrong.fontWeight, FontWeight.w600);
});
test('eyebrowLabel is 11 / w800 / letter-spacing 0.8', () {
expect(type.eyebrowLabel.fontSize, 11);
expect(type.eyebrowLabel.fontWeight, FontWeight.w800);
expect(type.eyebrowLabel.letterSpacing, 0.8);
});
testWidgets('context.pluriType exposes the registered extension', (
tester,
) async {
late BuildContext capturedContext;
await tester.pumpWidget(
MaterialApp(
theme: PluriWaveTheme.dark(),
home: Builder(
builder: (context) {
capturedContext = context;
return const SizedBox.shrink();
},
),
),
);
expect(capturedContext.pluriType.cardTitle.fontSize, 14.5);
});
});
}