- UI 系统: 新增 design_tokens / module_visuals / app_buttons / app_status_badge / app_toast / ai_content 六个共享模块; 28 个页面接入, SnackBar 全部替换为 AppToast - 趋势图: 直线折线 + 渐变填充 + 阴影; 去网格线; X 轴日+月份分隔; Y 轴整数刻度最多 4 个; 点击数据点/录入记录显示上方浮层, 选中点变实心 - 法律文档 H5: 后端 wwwroot 托管隐私政策/服务协议/关于/个人信息收集清单/第三方 SDK 清单 + 索引页; Program.cs 启用 UseDefaultFiles + UseStaticFiles - 其他: auth_provider 登录流程调整; api_client IP 适配; 主页智能体栏间距优化
87 lines
2.7 KiB
Dart
87 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:shadcn_ui/shadcn_ui.dart';
|
|
|
|
import '../core/app_colors.dart';
|
|
import '../core/app_design_tokens.dart';
|
|
|
|
enum AppToastType { success, error, warning, info }
|
|
|
|
class AppToast {
|
|
AppToast._();
|
|
|
|
static OverlayEntry? _entry;
|
|
|
|
static void show(
|
|
BuildContext context,
|
|
String message, {
|
|
AppToastType type = AppToastType.info,
|
|
Duration duration = const Duration(milliseconds: 2200),
|
|
}) {
|
|
_entry?.remove();
|
|
final overlay = Overlay.of(context);
|
|
final visual = _visual(type);
|
|
_entry = OverlayEntry(
|
|
builder: (ctx) => Positioned(
|
|
top: MediaQuery.paddingOf(ctx).top + 62,
|
|
left: 20,
|
|
right: 20,
|
|
child: IgnorePointer(
|
|
child: Center(
|
|
child: Material(
|
|
color: Colors.transparent,
|
|
child: Container(
|
|
constraints: BoxConstraints(
|
|
minHeight: 42,
|
|
maxWidth: MediaQuery.sizeOf(ctx).width * 0.82,
|
|
),
|
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: AppRadius.lgBorder,
|
|
border: Border.all(color: visual.color.withValues(alpha: 0.20)),
|
|
boxShadow: AppShadows.floating,
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(visual.icon, size: 18, color: visual.color),
|
|
const SizedBox(width: 8),
|
|
Flexible(
|
|
child: Text(
|
|
message,
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
fontSize: 15,
|
|
fontWeight: FontWeight.w700,
|
|
color: AppColors.textPrimary,
|
|
height: 1.25,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
overlay.insert(_entry!);
|
|
Future.delayed(duration, () {
|
|
_entry?.remove();
|
|
_entry = null;
|
|
});
|
|
}
|
|
|
|
static ({IconData icon, Color color}) _visual(AppToastType type) {
|
|
return switch (type) {
|
|
AppToastType.success => (icon: LucideIcons.circleCheck, color: AppColors.success),
|
|
AppToastType.error => (icon: LucideIcons.circleX, color: AppColors.error),
|
|
AppToastType.warning => (icon: LucideIcons.triangleAlert, color: AppColors.warning),
|
|
AppToastType.info => (icon: LucideIcons.info, color: AppColors.health),
|
|
};
|
|
}
|
|
}
|
|
|