新增:档案页共享组件三件 + TagPill 深变体映射(DEBT-1 偿还)
- PetAvatar 四尺寸档(96/64/44/32)收敛头像重复实现:3px 白描边 + 轻投影,编辑徽标底改 primaryStrong(白图标 4.49:1 达非文字 3:1), M2 无上传(ADR-010),url 缺省渲染本地占位形态 - RecordTypeDot 三尺寸档 + 五类记录类型的图标/三色映射唯一出口 (05 号规范 §2 表,供 T2-13/14 时间线复用) - EmptyStateIllustration 空态插画区(112 圆 + 标题 + 说明 + 可选 CTA) - TagPill 增可选 inkColor,缺省按 color 查深变体映射 (primary→primaryDark 8.74:1 / success→successInk 7.39:1 / accent→accentDark 7.07:1 / error→errorDark 5.78:1 / 未命中→ink), 既有调用零参数回归 - AppColors 新增 errorDark #B02C25、inkSoft #6B5A4A(05 号规范 D8) flutter test 141/141 全绿;analyze 0 问题(T2-12 第一部分) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:patbond_flutter/core/theme/app_theme.dart';
|
||||
import 'package:patbond_flutter/widgets/common.dart';
|
||||
|
||||
/// DEBT-1 偿还回归(05 号规范 §5.3):TagPill 文字色改深变体映射,
|
||||
/// 底色维持 8% 淡染;既有零参数调用仅视觉变深、不改布局。
|
||||
void main() {
|
||||
Future<Text> pumpPill(WidgetTester tester, TagPill pill) async {
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: pill)));
|
||||
return tester.widget<Text>(find.text(pill.label));
|
||||
}
|
||||
|
||||
testWidgets('默认色(primary)文字映射为 primaryDark', (tester) async {
|
||||
final text = await pumpPill(tester, const TagPill('标签'));
|
||||
expect(text.style?.color, AppColors.primaryDark);
|
||||
});
|
||||
|
||||
testWidgets('success → successInk、accent → accentDark、error → errorDark', (
|
||||
tester,
|
||||
) async {
|
||||
final success = await pumpPill(
|
||||
tester,
|
||||
const TagPill('成功', color: AppColors.success),
|
||||
);
|
||||
expect(success.style?.color, AppColors.successInk);
|
||||
|
||||
final accent = await pumpPill(
|
||||
tester,
|
||||
const TagPill('强调', color: AppColors.accent),
|
||||
);
|
||||
expect(accent.style?.color, AppColors.accentDark);
|
||||
|
||||
final error = await pumpPill(
|
||||
tester,
|
||||
const TagPill('错误', color: AppColors.error),
|
||||
);
|
||||
expect(error.style?.color, AppColors.errorDark);
|
||||
});
|
||||
|
||||
testWidgets('未命中映射的自定义色兜底为 ink', (tester) async {
|
||||
final text = await pumpPill(
|
||||
tester,
|
||||
const TagPill('自定义', color: Color(0xFF123456)),
|
||||
);
|
||||
expect(text.style?.color, AppColors.ink);
|
||||
});
|
||||
|
||||
testWidgets('inkColor 显式指定时优先于内置映射', (tester) async {
|
||||
final text = await pumpPill(
|
||||
tester,
|
||||
const TagPill('指定', color: AppColors.success, inkColor: AppColors.ink),
|
||||
);
|
||||
expect(text.style?.color, AppColors.ink);
|
||||
});
|
||||
|
||||
testWidgets('底色维持基色 8% 淡染不变', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(home: Scaffold(body: TagPill('底色'))),
|
||||
);
|
||||
final box = tester.widget<DecoratedBox>(
|
||||
find.ancestor(of: find.text('底色'), matching: find.byType(DecoratedBox)),
|
||||
);
|
||||
final decoration = box.decoration as BoxDecoration;
|
||||
expect(decoration.color, AppColors.primary.withAlpha(20));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user