diff --git a/BUILD-NOTES.md b/BUILD-NOTES.md index ec85306..08cdedc 100644 --- a/BUILD-NOTES.md +++ b/BUILD-NOTES.md @@ -127,7 +127,7 @@ flutter pub get flutter build apk --release # 产物:build\app\outputs\flutter-apk\app-release.apk ``` -- 发布包归档:`release\sequence_diagram_android_v1.2.0_release.apk`(**本地保留,不入库**;exe 的 `dist\` 同理)。 +- 发布包归档:`release\sequence_diagram_android_v1.2.1_release.apk`(**本地保留,不入库**;exe 的 `dist\` 同理)。 - 上架应用商店时建议在 `android\app\build.gradle.kts` 配置正式签名后再构建 AAB: `flutter build appbundle --release`。 - 应用名「时序图设计」、包名 `cc.sincos.sequence_diagram`、launcher 图标由 diff --git a/README.md b/README.md index 5e158d2..9a513a5 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ - **深色 / 浅色双主题**:右上角 ☀ / ☾ 一键切换,语义颜色不变,导出 SVG 与屏幕一致 - **导出 SVG**:矢量、分层、带语义 `id` / `data-*` 元数据,可直接进工艺卡与 MES -## 正式版 V1.2.0 +## 正式版 V1.2.1 **可运行的 Flutter Windows 桌面正式版**(源码在 `lib/`),设计人:呆头鹅。 @@ -97,7 +97,7 @@ Flutter 3.29+(Desktop) · CustomPainter 自绘 · Riverpod · 不可变模 - **正式签名**:release 用独立 keystore 签名(`android/key/release.jks`,见 `BUILD-NOTES.md`),更新安装无需卸载重装; - **构建**:JDK 17 + Android SDK 36(详见 `BUILD-NOTES.md`),Gradle 与 Maven 已配置国内镜像: ```bash - flutter build apk --release # 产物 → release/sequence_diagram_android_v1.2.0_release.apk + flutter build apk --release # 产物 → release/sequence_diagram_android_v1.2.1_release.apk ``` - **自测**:`test/tablet_layout_test.dart` 覆盖 1280×800、2560×1600、960×600、800×480、竖屏 800×1280、600×960 等 7 种分辨率的无溢出回归; - **demo 图**:`demo/tablet-*.png`(由 `test/tablet_screenshots_test.dart` 生成)。 @@ -113,6 +113,6 @@ Flutter 3.29+(Desktop) · CustomPainter 自绘 · Riverpod · 不可变模 - **软件**:时序图设计 · Sequence Diagram Studio - **设计人**:呆头鹅 -- **版本**:V1.2.0 +- **版本**:V1.2.1 - **版权**:Copyright © 2026 呆头鹅。保留所有权利。 - **架构文档**:[`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) · **使用帮助**:[`docs/HELP.md`](docs/HELP.md) diff --git a/docs/更新.png b/docs/更新.png new file mode 100644 index 0000000..2172882 Binary files /dev/null and b/docs/更新.png differ diff --git a/docs/更新.svg b/docs/更新.svg new file mode 100644 index 0000000..62fa8c8 --- /dev/null +++ b/docs/更新.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/lib/export/svg_writer.dart b/lib/export/svg_writer.dart index 52d39cd..f41e588 100644 --- a/lib/export/svg_writer.dart +++ b/lib/export/svg_writer.dart @@ -144,7 +144,7 @@ class SvgWriter { final Color c = Color(a.color); _b.write(''); - _rect(r.left, r.top, r.width, r.height, fill: _hex(c), rx: 7, opacity: 0.92); + _rect(r.left, r.top, r.width, r.height, fill: _hex(c), rx: 3, opacity: 0.92); _text(r.left + 8, r.center.dy + 4, '${a.name} ${tfmt(a.durationAngle / 360 * cycle, u)}', color: _hex(tokens.arcText), size: 12, weight: '700'); _b.write(''); @@ -231,7 +231,7 @@ class SvgWriter { 'data-duration="${a.durationAngle}" data-layer="${a.layer}" data-station="${_esc(a.stationId)}">'); for (final List s in splitArcs(a.startAngle, a.endAngle)) { final String d = _arc(c, r, s[0], s[1]); - _b.write(''); + _b.write(''); } final Offset mp = polar(c, r, (a.startAngle + a.endAngle) / 2); _text(mp.dx, mp.dy, '${a.id} ${a.name}', color: _hex(tokens.arcText), size: 12, anchor: 'middle', weight: '700'); diff --git a/lib/render/bar_painter.dart b/lib/render/bar_painter.dart index a425d22..60da9bd 100644 --- a/lib/render/bar_painter.dart +++ b/lib/render/bar_painter.dart @@ -337,15 +337,15 @@ class BarPainter extends CustomPainter { final bool sel = selectedIds.contains(a.id); final bool crit = criticalActions.contains(a.id); canvas.drawRRect( - RRect.fromRectAndRadius(r.shift(const Offset(1.5, 2)), const Radius.circular(8)), + RRect.fromRectAndRadius(r.shift(const Offset(1.5, 2)), const Radius.circular(3)), Paint()..color = tokens.shadow.withValues(alpha: tokens.shadowOp), ); canvas.drawRRect( - RRect.fromRectAndRadius(r, const Radius.circular(8)), + RRect.fromRectAndRadius(r, const Radius.circular(3)), Paint()..color = c.withValues(alpha: 0.92), ); canvas.drawRRect( - RRect.fromRectAndRadius(r, const Radius.circular(8)), + RRect.fromRectAndRadius(r, const Radius.circular(3)), Paint() ..style = PaintingStyle.stroke ..strokeWidth = 1 @@ -353,7 +353,7 @@ class BarPainter extends CustomPainter { ); if (crit) { canvas.drawRRect( - RRect.fromRectAndRadius(r, const Radius.circular(8)), + RRect.fromRectAndRadius(r, const Radius.circular(3)), Paint() ..style = PaintingStyle.stroke ..strokeWidth = 2 @@ -369,7 +369,7 @@ class BarPainter extends CustomPainter { final double wx = layout.xFor(a.endAngle - 360) - layout.plotLeft; final Rect tail = Rect.fromLTWH(layout.plotLeft, r.top, math.max(wx, 2), r.height); canvas.drawRRect( - RRect.fromRectAndRadius(tail, const Radius.circular(8)), + RRect.fromRectAndRadius(tail, const Radius.circular(3)), Paint()..color = c.withValues(alpha: tokens.tailOp), ); _text(canvas, '跨循环延续 ${(a.endAngle - 360).toStringAsFixed(0)}°', diff --git a/lib/render/circular_painter.dart b/lib/render/circular_painter.dart index 309b1aa..967a1ec 100644 --- a/lib/render/circular_painter.dart +++ b/lib/render/circular_painter.dart @@ -310,25 +310,13 @@ class CircularPainter extends CustomPainter { for (int k = 0; k < segs.length; k++) { // 第二段且为跨循环时视为“尾巴”,需淡化处理。 final bool tail = a.wrap && k == 1; - final Path p = arcPath(c, r, segs[k][0], segs[k][1]); + // 方头 + 小圆角:路径角度严格等于真实起止角,弧带长度即真实时长 + //(原来的圆头端帽会在两端各多出半个环宽,造成长度误读)。 + final Path p = _bandPath(c, r, th, segs[k][0], segs[k][1], 3); // 圆周色块不加描边 / 阴影,保持干净。 - canvas.drawPath( - p, - Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = th - ..strokeCap = a.wrap ? StrokeCap.butt : StrokeCap.round - ..color = col.withValues(alpha: tail ? tokens.tailOp : 1), - ); + canvas.drawPath(p, Paint()..color = col.withValues(alpha: tail ? tokens.tailOp : 1)); if (tail) { - canvas.drawPath( - p, - Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = th - ..strokeCap = StrokeCap.butt - ..color = col.withValues(alpha: 0.9), - ); + canvas.drawPath(p, Paint()..color = col.withValues(alpha: 0.9)); } } if (crit) { @@ -377,6 +365,64 @@ class CircularPainter extends CustomPainter { _arcLabel(canvas, c, r, mid, '$step. ${a.id} ${a.name}', tokens.arcText, 11, math.max(arcLen - 12, 20)); } + /// 构造「方头 + 小圆角」的圆环动作带(填充路径)。 + /// + /// 与「圆头描边」不同,路径覆盖的角度范围严格等于 [a0] → [a1](顺时针): + /// 两端为径向直边、四角带 [cornerR] 的小圆角,因此弧带的长度就是动作的 + /// 真实时长,不会再像圆头端帽那样在两端各多出半个环宽造成长度误读。 + Path _bandPath(Offset c, double r, double w, double a0, double a1, double cornerR) { + final double ro = r + w / 2; + final double ri = r - w / 2; + final double rc = math.min(cornerR, w / 2 - 0.5); + final double span = a1 - a0; + final Path p = Path(); + if (rc <= 0.5 || span <= 0.5) { + // 退化情形:直接方头四边形。 + final Offset a = polar(c, ro, a0); + p.moveTo(a.dx, a.dy); + final Offset b = polar(c, ro, a1); + p.lineTo(b.dx, b.dy); + final Offset d = polar(c, ri, a1); + p.lineTo(d.dx, d.dy); + final Offset e = polar(c, ri, a0); + p.lineTo(e.dx, e.dy); + p.close(); + return p; + } + // 小圆角在内 / 外缘占用的角向宽度(度),不超过跨度的 40%。 + final double dOut = math.min(rc / ro * 180 / math.pi, span * 0.4); + final double dIn = math.min(rc / ri * 180 / math.pi, span * 0.4); + final Offset oStart = polar(c, ro, a0 + dOut); + final Offset oEnd = polar(c, ro, a1 - dOut); + final Offset iEnd = polar(c, ri, a1 - dIn); + final Offset iStart = polar(c, ri, a0 + dIn); + p.moveTo(oStart.dx, oStart.dy); + // 外缘弧(顺时针) + p.arcToPoint(oEnd, + radius: Radius.circular(ro), largeArc: span - 2 * dOut > 180, clockwise: true); + // 尾端:外角 → 小圆角 → 端面 → 小圆角 → 内缘 + final Offset co = polar(c, ro, a1); + final Offset fo = polar(c, ro - rc, a1); + p.quadraticBezierTo(co.dx, co.dy, fo.dx, fo.dy); + final Offset fi = polar(c, ri + rc, a1); + p.lineTo(fi.dx, fi.dy); + final Offset ci = polar(c, ri, a1); + p.quadraticBezierTo(ci.dx, ci.dy, iEnd.dx, iEnd.dy); + // 内缘弧(逆时针返回) + p.arcToPoint(iStart, + radius: Radius.circular(ri), largeArc: span - 2 * dIn > 180, clockwise: false); + // 起始端:内角 → 小圆角 → 端面 → 小圆角 → 外角 + final Offset ci0 = polar(c, ri, a0); + final Offset fi0 = polar(c, ri + rc, a0); + p.quadraticBezierTo(ci0.dx, ci0.dy, fi0.dx, fi0.dy); + final Offset fo0 = polar(c, ro - rc, a0); + p.lineTo(fo0.dx, fo0.dy); + final Offset co0 = polar(c, ro, a0); + p.quadraticBezierTo(co0.dx, co0.dy, oStart.dx, oStart.dy); + p.close(); + return p; + } + /// 绘制圆形视图中的依赖连线。 /// /// 路径由四段组成:从源弧末端沿半径到中间半径 [rC] → 沿圆弧走到目标弧 diff --git a/lib/ui/app_shell.dart b/lib/ui/app_shell.dart index 56210b1..940871a 100644 --- a/lib/ui/app_shell.dart +++ b/lib/ui/app_shell.dart @@ -30,6 +30,7 @@ import 'canvas_overlays.dart'; import 'canvas_view.dart'; import 'dialogs.dart'; import 'update_dialog.dart'; +import 'update_icon.dart'; /// 应用外壳组件:承载主界面布局与文件/侧栏等交互逻辑。 class AppShell extends StatefulWidget { @@ -458,15 +459,12 @@ class _AppShellState extends State { } } - /// 更新检查按钮。 - /// - /// 空闲态用环形箭头(检查更新,中文软件的通用语义); - /// 检测到新版本时换成下载图标并叠加红色角标,一眼可辨「有新版本可下载」。 + /// 更新检查按钮:圆环 + 上箭头 + 底座(按 docs/更新.png 的设计绘制); + /// 检测到新版本时叠加红色角标。 Widget _updateBtn(Tokens t) { final UpdateInfo? info = _update; - final Widget btn = _iconBtn( - t, - info == null ? Icons.refresh : Icons.download, + final Widget btn = _iconWidgetBtn( + UpdateIcon(size: 18 * _toolScale, color: t.text), _openUpdate, tooltip: info == null ? '检查更新' : '发现新版本 v${info.version}', ); @@ -889,6 +887,21 @@ class _AppShellState extends State { ); } + /// 自定义图标组件版按钮(用于更新按钮的矢量图标): + /// 尺寸与点按区域与 [_iconBtn] 完全一致。 + Widget _iconWidgetBtn(Widget icon, VoidCallback? onTap, {String? tooltip}) { + final double s = _toolScale; + return IconButton( + onPressed: onTap, + icon: icon, + tooltip: tooltip, + splashRadius: 16 * s, + padding: EdgeInsets.zero, + constraints: BoxConstraints(minWidth: 34 * s, minHeight: 34 * s), + style: IconButton.styleFrom(tapTargetSize: s < 1 ? MaterialTapTargetSize.shrinkWrap : null), + ); + } + // ===================== 侧栏停靠状态机(钉住 / 悬浮 / 轨道) ===================== /// 侧栏标题栏控制按钮:切换钉住状态与隐藏侧栏。 diff --git a/lib/ui/canvas_overlays.dart b/lib/ui/canvas_overlays.dart index ca41fcb..c5db8f7 100644 --- a/lib/ui/canvas_overlays.dart +++ b/lib/ui/canvas_overlays.dart @@ -763,20 +763,21 @@ class _MiniBarPainter extends CustomPainter { final double w = size.width - 4; // 行高按可用高度自适应,保证小预览里也排得下。 final double pitch = n == 0 ? 12 : math.min(12, (size.height - 16) / n); - final double rh = math.max(pitch - 3, 4); + // 缩略图里的动作条只是一条细线(约 2px),并在行内垂直居中。 + final double rh = math.min(2.0, math.max(pitch * 0.5, 1.6)); for (int i = 0; i < n; i++) { final Action a = project.actions[i]; - final double y = i * pitch; + final double y = i * pitch + (pitch - rh) / 2; final double x1 = 2 + a.startAngle / 360 * w; final double x2 = 2 + math.min(a.endAngle, 360) / 360 * w; final RRect r = RRect.fromRectAndRadius( Rect.fromLTWH(x1, y, math.max(x2 - x1, 2), rh), - const Radius.circular(2), + Radius.circular(rh / 2), ); canvas.drawRRect(r, Paint()..color = Color(a.color).withValues(alpha: 0.9)); if (a.wrap) { canvas.drawRRect( - RRect.fromRectAndRadius(Rect.fromLTWH(2, y, (a.endAngle - 360) / 360 * w, rh), const Radius.circular(2)), + RRect.fromRectAndRadius(Rect.fromLTWH(2, y, (a.endAngle - 360) / 360 * w, rh), Radius.circular(rh / 2)), Paint()..color = Color(a.color).withValues(alpha: t.tailOp), ); } @@ -865,7 +866,8 @@ class _MiniCircularPainter extends CustomPainter { final double maxR = math.max(math.min(size.width, size.height) / 2 - 24, 24); final double r0 = n <= 1 ? maxR * 0.6 : maxR * 0.34; final double pitch = n <= 1 ? 0 : (maxR - r0) / (n - 1); - final double pw = (pitch == 0 ? 10.0 : pitch * 0.5).clamp(6.0, 13.0); + // 缩略图里的环与动作弧只需一条细线(约 2px)。 + final double pw = 2.0; canvas.drawCircle(c, r0 + (n - 1) * pitch + pw / 2, Paint()..color = t.dial); for (int i = 0; i < n; i++) { final Action a = project.actions[i]; diff --git a/lib/ui/dialogs.dart b/lib/ui/dialogs.dart index 7431a8c..ff6f012 100644 --- a/lib/ui/dialogs.dart +++ b/lib/ui/dialogs.dart @@ -2124,7 +2124,7 @@ class HelpDialog extends StatelessWidget { Text('时序图设计 · Sequence Diagram Studio', style: TextStyle(color: t.text, fontSize: 15, fontWeight: FontWeight.w700)), const SizedBox(height: 4), - Text('V1.2.0(${android ? '安卓版' : 'Windows 版'})', + Text('V1.2.1(${android ? '安卓版' : 'Windows 版'})', style: TextStyle(color: t.dim, fontSize: 12)), ], ), diff --git a/lib/ui/update_dialog.dart b/lib/ui/update_dialog.dart index c5c441b..36bb6f2 100644 --- a/lib/ui/update_dialog.dart +++ b/lib/ui/update_dialog.dart @@ -17,6 +17,7 @@ import '../theme/tokens.dart'; import '../update/update_service.dart'; import '../version.dart'; import 'dialogs.dart'; +import 'update_icon.dart'; /// 应用内更新对话框。 class UpdateDialog extends StatefulWidget { @@ -197,7 +198,7 @@ class _UpdateDialogState extends State { // 标题 Row( children: [ - Icon(Icons.download, size: 21, color: t.accent), + UpdateIcon(size: 21, color: t.accent), const SizedBox(width: 8), Text('发现新版本 v${info.version}', style: TextStyle(color: t.text, fontSize: 17, fontWeight: FontWeight.w700)), diff --git a/lib/ui/update_icon.dart b/lib/ui/update_icon.dart new file mode 100644 index 0000000..bfc3a66 --- /dev/null +++ b/lib/ui/update_icon.dart @@ -0,0 +1,88 @@ +/// 应用内更新按钮矢量图标。 +/// +/// 造型与设计稿(docs/更新.svg,viewBox 1024)严格对应: +/// 圆环(外径 446 / 内径 386.2)+ 空心向上的箭头 + 底部两条圆头横杠。 +/// 采用归一化坐标矢量绘制,可任意缩放、随主题变色,小尺寸下保持清晰。 +library; + +import 'package:flutter/material.dart'; + +/// 更新图标:圆环 + 空心上箭头 + 底座横杠。 +class UpdateIcon extends StatelessWidget { + /// 构造;[size] 为正方形边长,[color] 为线条颜色。 + const UpdateIcon({super.key, required this.size, required this.color}); + + /// 图标边长(逻辑像素)。 + final double size; + + /// 线条颜色(随主题传入)。 + final Color color; + + @override + Widget build(BuildContext context) { + return CustomPaint( + size: Size.square(size), + painter: _UpdateIconPainter(color), + ); + } +} + +/// 更新图标绘制器:按设计稿坐标换算为归一化路径。 +class _UpdateIconPainter extends CustomPainter { + /// 构造;[color] 线条颜色。 + _UpdateIconPainter(this.color); + + /// 线条颜色。 + final Color color; + + @override + void paint(Canvas canvas, Size size) { + final double s = size.shortestSide; + Offset p(double x, double y) => Offset(x * s, y * s); + final Paint stroke = Paint() + ..style = PaintingStyle.stroke + ..strokeCap = StrokeCap.round + ..strokeJoin = StrokeJoin.round + ..color = color; + + // 1) 外圈圆环:中线半径 0.4064、线宽 0.0584(对应外径 446 / 内径 386.2)。 + stroke.strokeWidth = 0.0584 * s; + canvas.drawCircle(Offset(s / 2, s / 2), 0.4064 * s, stroke); + + // 2) 空心向上的箭头:外轮廓 + 内轮廓(evenOdd 挖空,得到等宽描边效果)。 + final Path arrow = Path()..fillType = PathFillType.evenOdd; + // 外轮廓(顶点 → 右翼尖 → 箭杆 → 左翼尖,坐标取自设计稿 / 1024)。 + arrow.moveTo(0.5 * s, 0.202 * s); + arrow.lineTo(0.7638 * s, 0.4284 * s); + arrow.lineTo(0.7439 * s, 0.4789 * s); + arrow.lineTo(0.6432 * s, 0.4789 * s); + arrow.lineTo(0.6432 * s, 0.5942 * s); + arrow.lineTo(0.6146 * s, 0.6234 * s); + arrow.lineTo(0.3892 * s, 0.6234 * s); + arrow.lineTo(0.36 * s, 0.5942 * s); + arrow.lineTo(0.36 * s, 0.4789 * s); + arrow.lineTo(0.2575 * s, 0.4789 * s); + arrow.lineTo(0.2377 * s, 0.4283 * s); + arrow.close(); + // 内轮廓(挖空)。 + arrow.moveTo(0.5022 * s, 0.2637 * s); + arrow.lineTo(0.3322 * s, 0.4205 * s); + arrow.lineTo(0.3892 * s, 0.4205 * s); + arrow.lineTo(0.4184 * s, 0.4497 * s); + arrow.lineTo(0.4184 * s, 0.565 * s); + arrow.lineTo(0.5848 * s, 0.565 * s); + arrow.lineTo(0.5848 * s, 0.4497 * s); + arrow.lineTo(0.6146 * s, 0.4205 * s); + arrow.lineTo(0.6706 * s, 0.4205 * s); + arrow.close(); + canvas.drawPath(arrow, Paint()..color = color); + + // 3) 底座两条圆头横杠(中线 y=0.6839 / 0.7739,线宽同圆环)。 + canvas.drawLine(p(0.381, 0.6839), p(0.625, 0.6839), stroke); + canvas.drawLine(p(0.381, 0.7739), p(0.625, 0.7739), stroke); + } + + /// 线条颜色变化时需要重绘。 + @override + bool shouldRepaint(covariant _UpdateIconPainter old) => old.color != color; +} diff --git a/lib/version.dart b/lib/version.dart index e773c9e..b3c8909 100644 --- a/lib/version.dart +++ b/lib/version.dart @@ -2,4 +2,4 @@ /// /// 应用内更新检查用它判断服务器发布的版本是否更新; /// **每次发版必须与 pubspec 同步更新**(见 BUILD-NOTES 的发布流程)。 -const String kAppVersion = '1.2.0'; +const String kAppVersion = '1.2.1'; diff --git a/pubspec.yaml b/pubspec.yaml index d2c39c5..1e164ab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.2.0+12 +version: 1.2.1+13 environment: sdk: ^3.13.3 diff --git a/release/RELEASE_NOTES_v1.2.1.md b/release/RELEASE_NOTES_v1.2.1.md new file mode 100644 index 0000000..0e882d4 --- /dev/null +++ b/release/RELEASE_NOTES_v1.2.1.md @@ -0,0 +1,8 @@ +# V1.2.1 更新内容 + +- 更新按钮图标改为全新设计的「升级」样式(圆环 + 上箭头 + 底座横杠), + 与界面整体风格统一,一眼可辨是「检查更新」 +- 更新对话框标题图标同步更新 +- 右下角缩略预览(条形 / 圆周)中的动作线条改细到约 2px,更符合缩略图观感 +- **动作两端改为方头**(带小圆角):条形与圆周视图中的动作长度严格等于 + 真实时长,不再因圆头端帽向外多出而误读;SVG / PNG 导出同步