approval_actions.dart 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import 'package:flutter/material.dart';
  2. import 'package:tdesign_flutter/tdesign_flutter.dart';
  3. import '../../core/i18n/app_localizations.dart';
  4. import '../../core/theme/app_colors_extension.dart';
  5. class ApprovalActions extends StatelessWidget {
  6. final int queryId;
  7. final bool isSubmitting;
  8. final VoidCallback onApprove;
  9. final VoidCallback onReject;
  10. final VoidCallback onReverseAudit;
  11. const ApprovalActions({
  12. super.key,
  13. required this.queryId,
  14. this.isSubmitting = false,
  15. required this.onApprove,
  16. required this.onReject,
  17. required this.onReverseAudit,
  18. });
  19. @override
  20. Widget build(BuildContext context) {
  21. if (isSubmitting) {
  22. return const SafeArea(
  23. child: Padding(
  24. padding: EdgeInsets.all(12),
  25. child: Center(child: TDLoading(size: TDLoadingSize.large, icon: TDLoadingIcon.activity)),
  26. ),
  27. );
  28. }
  29. // queryId 1/2/3: 审核(通过+驳回)
  30. // queryId 4/5: 反审核
  31. // 其他: 无按钮
  32. if (queryId < 1 || queryId > 5) return const SizedBox.shrink();
  33. final l10n = AppLocalizations.of(context);
  34. final colors = Theme.of(context).extension<AppColorsExtension>()!;
  35. return ColoredBox(
  36. color: colors.bgCard,
  37. child: SafeArea(
  38. top: false,
  39. child: Padding(
  40. padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
  41. child: queryId >= 1 && queryId <= 3
  42. ? Row(children: [
  43. Expanded(child: TDButton(text: l10n.get('reject'), size: TDButtonSize.large, theme: TDButtonTheme.danger, type: TDButtonType.outline, onTap: onReject)),
  44. const SizedBox(width: 12),
  45. Expanded(child: TDButton(text: l10n.get('approve'), size: TDButtonSize.large, theme: TDButtonTheme.primary, onTap: onApprove)),
  46. ])
  47. : SizedBox(
  48. width: double.infinity,
  49. child: TDButton(text: l10n.get('withdrawApplication'), size: TDButtonSize.large, theme: TDButtonTheme.danger, type: TDButtonType.outline, onTap: onReverseAudit),
  50. ),
  51. ),
  52. ),
  53. );
  54. }
  55. }