55bac03eb0
后端 Pydantic schema 添加 Hant 繁体字段支持(guaNameHant, targetGuaNameHant, spiritNameHant, relationNameHant),解决 DerivedDivinationData extra=forbid 拒绝 AI 输出的繁体字段导致 agent_output 解析失败、历史记录为空的问题。 六爻解卦提示词修复:增加静卦五行生克链分析、假破假空降权、 六冲中性判断、用神核对防捏造、空亡数据对照等硬约束。 前端 Dart model 同步添加 Hant 字段(反向兼容,缺省为空字符串)。 其他:硬币翻转动画修复、弹窗单按钮居中、起卦按钮布局调整、 繁体 l10n 清理、pre-commit 排除集成测试。
174 lines
6.0 KiB
Dart
174 lines
6.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../theme/design_tokens.dart';
|
|
|
|
class AppModalDialogAction {
|
|
const AppModalDialogAction({
|
|
required this.label,
|
|
required this.onPressed,
|
|
this.primary = false,
|
|
this.destructive = false,
|
|
});
|
|
|
|
final String label;
|
|
final VoidCallback onPressed;
|
|
final bool primary;
|
|
final bool destructive;
|
|
}
|
|
|
|
class AppModalDialog extends StatelessWidget {
|
|
const AppModalDialog({
|
|
super.key,
|
|
required this.title,
|
|
required this.message,
|
|
required this.actions,
|
|
this.icon,
|
|
this.iconWidget,
|
|
});
|
|
|
|
final String title;
|
|
final String message;
|
|
final IconData? icon;
|
|
final Widget? iconWidget;
|
|
final List<AppModalDialogAction> actions;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colors = Theme.of(context).colorScheme;
|
|
|
|
return Dialog(
|
|
insetPadding: const EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.lg,
|
|
vertical: AppSpacing.xl,
|
|
),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(AppRadius.xl),
|
|
),
|
|
child: Container(
|
|
padding: const EdgeInsets.fromLTRB(
|
|
AppSpacing.lg,
|
|
AppSpacing.lg,
|
|
AppSpacing.lg,
|
|
AppSpacing.md,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: colors.surface,
|
|
borderRadius: BorderRadius.circular(AppRadius.xl),
|
|
border: Border.all(color: colors.outlineVariant),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
if (iconWidget != null || icon != null)
|
|
Container(
|
|
width: 36,
|
|
height: 36,
|
|
decoration: BoxDecoration(
|
|
color: colors.primaryContainer,
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
),
|
|
alignment: Alignment.center,
|
|
child:
|
|
iconWidget ??
|
|
Icon(icon, color: colors.primary, size: 20),
|
|
),
|
|
if (iconWidget != null || icon != null)
|
|
const SizedBox(width: AppSpacing.sm),
|
|
Expanded(
|
|
child: Text(
|
|
title,
|
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: AppSpacing.md),
|
|
Text(
|
|
message,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: colors.onSurfaceVariant,
|
|
height: 1.45,
|
|
),
|
|
),
|
|
const SizedBox(height: AppSpacing.lg),
|
|
if (actions.length == 1)
|
|
Center(
|
|
child: FilledButton(
|
|
onPressed: actions[0].onPressed,
|
|
style: FilledButton.styleFrom(
|
|
backgroundColor: actions[0].destructive
|
|
? colors.error
|
|
: colors.primary,
|
|
foregroundColor: actions[0].destructive
|
|
? colors.onError
|
|
: colors.onPrimary,
|
|
minimumSize: const Size.fromHeight(44),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(AppRadius.full),
|
|
),
|
|
),
|
|
child: Text(actions[0].label),
|
|
),
|
|
)
|
|
else
|
|
Row(
|
|
children: actions
|
|
.map((action) {
|
|
final child = action.primary
|
|
? FilledButton(
|
|
onPressed: action.onPressed,
|
|
style: FilledButton.styleFrom(
|
|
backgroundColor: action.destructive
|
|
? colors.error
|
|
: colors.primary,
|
|
foregroundColor: action.destructive
|
|
? colors.onError
|
|
: colors.onPrimary,
|
|
minimumSize: const Size.fromHeight(44),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(
|
|
AppRadius.full,
|
|
),
|
|
),
|
|
),
|
|
child: Text(action.label),
|
|
)
|
|
: OutlinedButton(
|
|
onPressed: action.onPressed,
|
|
style: OutlinedButton.styleFrom(
|
|
foregroundColor: colors.onSurface,
|
|
side: BorderSide(color: colors.outline),
|
|
minimumSize: const Size.fromHeight(44),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(
|
|
AppRadius.full,
|
|
),
|
|
),
|
|
),
|
|
child: Text(action.label),
|
|
);
|
|
|
|
return Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.xs,
|
|
),
|
|
child: child,
|
|
),
|
|
);
|
|
})
|
|
.toList(growable: false),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|