Files
patbond-flutter/lib/core/widgets/primary_button.dart
T
lixi af002edde3 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>
2026-09-04 10:34:18 +08:00

48 lines
1.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
import 'package:patbond_flutter/core/theme/app_theme.dart';
/// 主操作按钮:全宽 × 52 高,`primaryStrong` 填充(设计规范 §2.2 / §4.3 / §4.4)。
///
/// [isLoading] 为 true 时文字替换为 20×20 白色转圈,按钮尺寸不变、不可再点,
/// 填充保持 `primaryStrong`loading 不是禁用态,不置灰)。
class PrimaryButton extends StatelessWidget {
const PrimaryButton({
required this.label,
super.key,
this.onPressed,
this.isLoading = false,
});
final String label;
/// 传 null 进入禁用态(主题 disabled 置灰)。
final VoidCallback? onPressed;
final bool isLoading;
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
height: 52,
child: FilledButton(
onPressed: isLoading ? null : onPressed,
style: isLoading
? FilledButton.styleFrom(
disabledBackgroundColor: AppColors.primaryStrong,
)
: null,
child: isLoading
? const SizedBox.square(
dimension: 20,
child: CircularProgressIndicator(
strokeWidth: 2.5,
color: Colors.white,
),
)
: Text(label),
),
);
}
}