feat: 迁移珊瑚橙主题体系并新增认证基础组件(ADR-005)

- app_theme.dart 重写为语义 token(AppColors/AppRadius),落地 primaryStrong/error 等 AA 对比度色
- 五个页面与公共组件的旧靛蓝硬编码色值全部替换为 token,仅换色不动布局
- 新增 BrandMark/AppTextField/PrimaryButton/InlineErrorBanner/AuthScaffold 及 6 个 widget 测试
- 门禁:dart format(0 changed)/ flutter analyze(0 issues)/ flutter test(7 passed)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-04 10:34:18 +08:00
parent 2601da395c
commit af002edde3
13 changed files with 500 additions and 49 deletions
@@ -0,0 +1,58 @@
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/core/widgets/primary_button.dart';
Widget wrap(Widget child) {
return MaterialApp(
theme: buildAppTheme(),
home: Scaffold(body: Center(child: child)),
);
}
void main() {
testWidgets('默认态显示文字,点击触发回调', (tester) async {
var tapped = 0;
await tester.pumpWidget(
wrap(PrimaryButton(label: '登录', onPressed: () => tapped++)),
);
expect(find.text('登录'), findsOneWidget);
await tester.tap(find.byType(PrimaryButton));
expect(tapped, 1);
});
testWidgets('loading 态显示转圈、隐藏文字且不可点击', (tester) async {
var tapped = 0;
await tester.pumpWidget(
wrap(
PrimaryButton(label: '登录', isLoading: true, onPressed: () => tapped++),
),
);
expect(find.byType(CircularProgressIndicator), findsOneWidget);
expect(find.text('登录'), findsNothing);
await tester.tap(find.byType(PrimaryButton), warnIfMissed: false);
await tester.pump();
expect(tapped, 0);
// loading 不是禁用态:填充保持 primaryStrong,尺寸保持 52 高。
final button = tester.widget<FilledButton>(find.byType(FilledButton));
expect(button.onPressed, isNull);
expect(
button.style?.backgroundColor?.resolve({WidgetState.disabled}),
AppColors.primaryStrong,
);
expect(tester.getSize(find.byType(PrimaryButton)).height, 52);
});
testWidgets('onPressed 为 null 时进入禁用态', (tester) async {
await tester.pumpWidget(wrap(const PrimaryButton(label: '登录')));
final button = tester.widget<FilledButton>(find.byType(FilledButton));
expect(button.onPressed, isNull);
expect(find.text('登录'), findsOneWidget);
expect(find.byType(CircularProgressIndicator), findsNothing);
});
}