fix(flutter): 优化二级页面返回按钮样式

This commit is contained in:
Zhou Weidong committed 2026-10-20 16:09:10 +08:00
1 parent 457d2fa6f2
commit 8493c4ef3b
7 files changed
+95 -21

No files matched your search

+32 -4
View File
@@ -23,7 +23,7 @@ void main() {
expect(tester.getSize(find.byKey(const Key('subpage-header'))).height, 52);
expect(
tester.getSize(find.byKey(const Key('sample-back'))),
const Size(36, 36),
const Size(40, 40),
);
final title = tester.widget<Text>(find.byKey(const Key('subpage-title')));
expect(title.style?.fontSize, 18);
@@ -32,6 +32,24 @@ void main() {
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));
final surface = tester.widget<Material>(
find.descendant(
of: find.byKey(const Key('sample-back')),
matching: find.byType(Material),
),
);
expect(surface.color, AppColors.card);
expect((surface.shape! as CircleBorder).side.color, AppColors.border);
final shadow =
tester
.widget<DecoratedBox>(
find.byKey(const Key('subpage-back-shadow')),
)
.decoration
as BoxDecoration;
expect(shadow.boxShadow!.single.color, const Color(0x14000000));
expect(shadow.boxShadow!.single.blurRadius, 8);
expect(shadow.boxShadow!.single.offset, const Offset(0, 2));
});
testWidgets('should_use_64_height_when_subtitle_exists', (tester) async {
@@ -52,7 +70,7 @@ void main() {
expect(find.byKey(const Key('subpage-subtitle')), findsOneWidget);
});
testWidgets('should_use_transparent_dark_back_button', (tester) async {
testWidgets('should_use_translucent_dark_back_button', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: AppTheme.light(),
@@ -79,8 +97,18 @@ void main() {
matching: find.byIcon(Icons.chevron_left_rounded),
),
);
expect(material.color, Colors.transparent);
expect(material.color, const Color(0x59000000));
expect(icon.color, Colors.white);
expect(icon.size, 20);
expect(icon.size, 22);
expect(icon.weight, 600);
final shadow =
tester
.widget<DecoratedBox>(
find.byKey(const Key('subpage-back-shadow')),
)
.decoration
as BoxDecoration;
expect(shadow.boxShadow!.single.color, const Color(0x33000000));
expect(shadow.boxShadow!.single.blurRadius, 8);
});
}