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), ), ); } }