feat(flutter): 统一二级页头并恢复新剧暖色

This commit is contained in:
Zhou Weidong committed 2026-10-20 15:55:12 +08:00
1 parent 7b2970d5c5
commit 1c6c92170d
26 files changed
+492 -427

No files matched your search

+86
View File
@@ -0,0 +1,86 @@
// Author: fruit.com.cn
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_theme.dart';
import 'package:fruitshorts/core/widgets/subpage_header.dart';
void main() {
testWidgets('should_render_unified_light_header_dimensions', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: AppTheme.light(),
home: Scaffold(
body: AppSubpageHeader(
title: 'Title',
backKey: const Key('sample-back'),
),
),
),
);
expect(tester.getSize(find.byKey(const Key('subpage-header'))).height, 52);
expect(
tester.getSize(find.byKey(const Key('sample-back'))),
const Size(36, 36),
);
final title = tester.widget<Text>(find.byKey(const Key('subpage-title')));
expect(title.style?.fontSize, 18);
expect(title.style?.fontWeight, FontWeight.w800);
expect(title.style?.color, AppColors.onSurface);
final back = tester.getRect(find.byKey(const Key('sample-back')));
final titleRect = tester.getRect(find.byKey(const Key('subpage-title')));
expect(titleRect.left - back.right, closeTo(12, 0.5));
});
testWidgets('should_use_64_height_when_subtitle_exists', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: AppTheme.light(),
home: Scaffold(
body: AppSubpageHeader(
title: 'Title',
subtitle: 'Subtitle',
backKey: const Key('sample-back'),
),
),
),
);
expect(tester.getSize(find.byKey(const Key('subpage-header'))).height, 64);
expect(find.byKey(const Key('subpage-subtitle')), findsOneWidget);
});
testWidgets('should_use_transparent_dark_back_button', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: AppTheme.light(),
home: const Scaffold(
backgroundColor: Colors.black,
body: AppSubpageHeader(
title: 'Title',
backKey: Key('sample-back'),
dark: true,
),
),
),
);
final material = tester.widget<Material>(
find.descendant(
of: find.byKey(const Key('sample-back')),
matching: find.byType(Material),
),
);
final icon = tester.widget<Icon>(
find.descendant(
of: find.byKey(const Key('sample-back')),
matching: find.byIcon(Icons.chevron_left_rounded),
),
);
expect(material.color, Colors.transparent);
expect(icon.color, Colors.white);
expect(icon.size, 20);
});
}