1.3.5:更名 EDC|易得设计,空白启动首页 + 可扩展图元库识别,架构图大版本
- 品牌:更名 EDC|易得设计(exe/安卓/仓库 EasyDesignCollection;旧地址 301 兼容老客户端更新) - 首页:空白启动 + 六模块「新建文档」选择 + 最近打开;品牌菜单重做 - 架构图:手绘识别统一图形;Visio 式可扩展图元库(导入 / 存为图元 / 分类折叠 / 手绘匹配 / 多笔回溯组合);识别后图形尺寸编辑(宽高长径 + 画布标注 + 双击改值); IT 系统图元;mm 标尺(右轴数值 / 实线游标 / A0 默认画布);图层、F8 正交 / F10 极轴、 对齐均布;连线端点换绑重吸附;DXF / SVG / PNG 导出;缩小时画布溢出到侧栏的裁剪修复 - 时序图:分文件保存(*.seq.json / *.arch.json;旧 .edc.json 兼容) - 路径:运行时目录迁移 %APPDATA%/EDC;素材库 library/;安卓 Documents/EDC - 清理:参数化草图入口冻结;Windows Ink 原生桥移除;dist/ 退役 - 构建:exe + APK 双端同步(1.3.5+26);发布脚本切换 release/ 新目录结构
This commit is contained in:
@@ -0,0 +1,429 @@
|
||||
/// 左上角品牌按钮 +「EDC|易得设计」设计合集菜单。
|
||||
///
|
||||
/// 点开左上角 logo:菜单从 logo **下方**下拉展开(不遮挡 logo)。
|
||||
/// 菜单由模块注册表驱动:首页入口 + 已开放模块(可进入/新建)+
|
||||
/// 未开放模块(灰色显示,无「规划中」字样)+ 底部「软件设置」。
|
||||
/// 具体动作由外壳(AppShell)通过 [BrandMenuButton.onCommand] 执行:
|
||||
/// 命令为 `_home` / `_settings` / 模块 id。
|
||||
library;
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../model/models.dart';
|
||||
import '../modules/module_registry.dart';
|
||||
import '../state/app_controller.dart';
|
||||
import '../theme/tokens.dart';
|
||||
import '../version.dart';
|
||||
import 'app_logo.dart';
|
||||
|
||||
/// 品牌按钮:logo + 当前模块名,点击在下方弹出合集菜单。
|
||||
class BrandMenuButton extends StatelessWidget {
|
||||
/// 构造品牌按钮。
|
||||
const BrandMenuButton({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.onCommand,
|
||||
this.scale = 1.0,
|
||||
this.compact = false,
|
||||
});
|
||||
|
||||
/// 全局应用控制器。
|
||||
final AppController controller;
|
||||
|
||||
/// 菜单命令回调(`_home` / `_settings` / 模块 id)。
|
||||
final Future<void> Function(String cmd) onCommand;
|
||||
|
||||
/// 工具栏缩放系数(触屏平台整体缩小)。
|
||||
final double scale;
|
||||
|
||||
/// 紧凑布局(隐藏副标题)。
|
||||
final bool compact;
|
||||
|
||||
/// 当前模块名(首页显示「设计合集」)。
|
||||
String get _label {
|
||||
final EdcModule? m = moduleOf(controller.appMode);
|
||||
return m == null ? '设计合集' : '${m.name}设计';
|
||||
}
|
||||
|
||||
/// 构建按钮。
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Tokens t = context.tok;
|
||||
final BorderRadius radius = BorderRadius.circular(10);
|
||||
return Tooltip(
|
||||
message: 'EDC|易得设计:设计合集',
|
||||
child: Material(
|
||||
color: t.panel,
|
||||
borderRadius: radius,
|
||||
child: InkWell(
|
||||
onTap: () => _open(context),
|
||||
borderRadius: radius,
|
||||
hoverColor: t.accent.withValues(alpha: 0.08),
|
||||
child: Container(
|
||||
// 高度只由内容决定:去掉上下留白(按钮高度 = 内容高度)。
|
||||
padding: EdgeInsets.only(left: 9 * scale, right: 9 * scale),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: radius,
|
||||
border: Border.all(color: t.line2),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
AppLogo(size: (compact ? 22 : 24) * scale),
|
||||
SizedBox(width: 7 * scale),
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
_label,
|
||||
style: TextStyle(
|
||||
color: t.text,
|
||||
fontSize: (compact ? 12.5 : 13) * scale,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 0.5 * scale,
|
||||
height: 1.1,
|
||||
),
|
||||
),
|
||||
if (!compact)
|
||||
Text(
|
||||
'Easy Design Collection',
|
||||
style: TextStyle(
|
||||
color: t.dim,
|
||||
fontSize: 9.5 * scale,
|
||||
height: 1.1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(width: 4 * scale),
|
||||
Icon(Icons.arrow_drop_down, color: t.sub, size: 17 * scale),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 弹出合集菜单(logo 下方下拉,不遮挡 logo)。
|
||||
Future<void> _open(BuildContext context) async {
|
||||
final RenderBox button = context.findRenderObject()! as RenderBox;
|
||||
final OverlayState overlay = Overlay.of(context);
|
||||
final RenderBox overlayBox =
|
||||
overlay.context.findRenderObject()! as RenderBox;
|
||||
final Offset tl = button.localToGlobal(Offset.zero, ancestor: overlayBox);
|
||||
final Offset br = button.localToGlobal(
|
||||
button.size.bottomRight(Offset.zero),
|
||||
ancestor: overlayBox);
|
||||
const double menuW = 204;
|
||||
final double left = tl.dx
|
||||
.clamp(8.0, math.max(8.0, overlayBox.size.width - menuW - 8));
|
||||
final double top = br.dy + 6;
|
||||
final Object? picked = await showGeneralDialog<Object>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
barrierLabel: '关闭菜单',
|
||||
barrierColor: Colors.black.withValues(alpha: 0.06),
|
||||
transitionDuration: const Duration(milliseconds: 150),
|
||||
pageBuilder: (BuildContext ctx, Animation<double> a1,
|
||||
Animation<double> a2) =>
|
||||
const SizedBox.shrink(),
|
||||
transitionBuilder: (BuildContext ctx, Animation<double> anim,
|
||||
Animation<double> sec, Widget child) {
|
||||
final Animation<double> curved =
|
||||
CurvedAnimation(parent: anim, curve: Curves.easeOutCubic);
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Positioned(
|
||||
left: left,
|
||||
top: top,
|
||||
child: FadeTransition(
|
||||
opacity: curved,
|
||||
child: ScaleTransition(
|
||||
scale: Tween<double>(begin: 0.96, end: 1).animate(curved),
|
||||
alignment: Alignment.topLeft,
|
||||
child: _panel(ctx),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
if (picked is String && context.mounted) {
|
||||
await onCommand(picked);
|
||||
}
|
||||
}
|
||||
|
||||
/// 菜单底部「软件设置」入口。
|
||||
Widget _settingsItem(BuildContext context) {
|
||||
final Tokens t = context.tok;
|
||||
return InkWell(
|
||||
onTap: () => Navigator.of(context).pop('_settings'),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: t.panel2,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: t.line),
|
||||
),
|
||||
child: Icon(Icons.settings_outlined, size: 17, color: t.sub),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text('软件设置',
|
||||
style: TextStyle(
|
||||
color: t.text,
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
)),
|
||||
Text('外观 · 网格 · 更新',
|
||||
style: TextStyle(color: t.dim, fontSize: 10.5)),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right, size: 16, color: t.dim),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 菜单面板(品牌头部 + 首页 + 模块注册表 + 未开放模块 + 软件设置)。
|
||||
Widget _panel(BuildContext context) {
|
||||
final Tokens t = context.tok;
|
||||
final bool atHome = controller.appMode == AppMode.home;
|
||||
final String? curId = moduleOf(controller.appMode)?.id;
|
||||
final double maxH = math.max(
|
||||
180,
|
||||
MediaQuery.sizeOf(context).height - 120,
|
||||
);
|
||||
return Material(
|
||||
color: t.dialog,
|
||||
elevation: 14,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
child: Container(
|
||||
width: 204,
|
||||
constraints: BoxConstraints(maxHeight: maxH),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: t.line2),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 6, 12, 8),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text('EDC|易得设计',
|
||||
style: TextStyle(
|
||||
color: t.text,
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
)),
|
||||
const Spacer(),
|
||||
Text('v$kAppVersion',
|
||||
style: TextStyle(color: t.dim, fontSize: 10)),
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(height: 1, thickness: 1, color: t.line),
|
||||
const SizedBox(height: 6),
|
||||
// 首页(空白启动工作台)。
|
||||
_homeItem(context, atHome),
|
||||
const SizedBox(height: 6),
|
||||
Divider(height: 1, thickness: 1, color: t.line),
|
||||
const SizedBox(height: 4),
|
||||
// 已开放模块(可通过「设计合集」进入并新建文档)。
|
||||
for (final EdcModule m in kModules)
|
||||
if (m.available) _item(context, m, current: curId == m.id),
|
||||
const SizedBox(height: 6),
|
||||
Divider(height: 1, thickness: 1, color: t.line),
|
||||
// 未开放模块:仅灰色显示。
|
||||
for (final EdcModule m in kModules)
|
||||
if (!m.available) _soon(context, m),
|
||||
const SizedBox(height: 6),
|
||||
Divider(height: 1, thickness: 1, color: t.line),
|
||||
const SizedBox(height: 4),
|
||||
_settingsItem(context),
|
||||
const SizedBox(height: 4),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 「首页」条目。
|
||||
Widget _homeItem(BuildContext context, bool current) {
|
||||
final Tokens t = context.tok;
|
||||
return InkWell(
|
||||
onTap: () => Navigator.of(context).pop('_home'),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: current ? t.accent.withValues(alpha: 0.16) : t.panel2,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: current ? t.accent : t.line),
|
||||
),
|
||||
child:
|
||||
Icon(Icons.home_outlined, size: 17, color: current ? t.accent : t.sub),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'首页',
|
||||
style: TextStyle(
|
||||
color: t.text,
|
||||
fontSize: 12.5,
|
||||
fontWeight:
|
||||
current ? FontWeight.w700 : FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text('新建 · 打开 · 最近',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: t.dim, fontSize: 10.5)),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (current) Icon(Icons.check_circle, size: 16, color: t.accent),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 已开放模块条目(点按 = 进入该模块并新建文档)。
|
||||
Widget _item(
|
||||
BuildContext context,
|
||||
EdcModule m, {
|
||||
required bool current,
|
||||
}) {
|
||||
final Tokens t = context.tok;
|
||||
return InkWell(
|
||||
onTap: () => Navigator.of(context).pop(m.id),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: current
|
||||
? t.accent.withValues(alpha: 0.16)
|
||||
: Color(m.accent).withValues(alpha: 0.12),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: current ? t.accent : t.line),
|
||||
),
|
||||
child: Icon(m.icon,
|
||||
size: 17, color: current ? t.accent : Color(m.accent)),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'${m.name}设计',
|
||||
style: TextStyle(
|
||||
color: t.text,
|
||||
fontSize: 12.5,
|
||||
fontWeight:
|
||||
current ? FontWeight.w700 : FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
m.blurb,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: t.dim, fontSize: 10.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (current) Icon(Icons.check_circle, size: 16, color: t.accent),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 未开放模块:仅灰色显示(不可点)。
|
||||
Widget _soon(BuildContext context, EdcModule m) {
|
||||
final Tokens t = context.tok;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 26,
|
||||
height: 26,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: t.panel2.withValues(alpha: 0.6),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
border: Border.all(color: t.line.withValues(alpha: 0.6)),
|
||||
),
|
||||
child: Icon(m.icon, size: 15, color: t.dim.withValues(alpha: 0.75)),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(m.name,
|
||||
style: TextStyle(
|
||||
color: t.dim.withValues(alpha: 0.75),
|
||||
fontSize: 12,
|
||||
)),
|
||||
Text(m.blurb,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: t.dim.withValues(alpha: 0.55),
|
||||
fontSize: 10,
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user