feat(ui): 动作两端改为方头小圆角(长度即真实时长);更新图标按设计稿重绘

- 条形视图:动作条圆角 8→3,两端方头(仅小圆角),长度严格等于真实时长
- 圆周视图:动作弧改为填充弧带(方头 + 小圆角)替代圆头描边,
  消除「圆头端帽在两端各多出半个环宽」造成的长度误读
- SVG 导出同步:条块 rx=3、动作弧 stroke-linecap=butt,导出与屏幕一致
- 更新按钮图标按 docs/更新.svg 设计稿矢量重绘(圆环 + 上箭头 + 两条底座横杠),
  替换原来的 refresh 图标;更新对话框标题图标同步
- 右下角缩略预览(条形 / 圆周)动作线条细化至约 2px
- 版本 1.2.1+13
This commit is contained in:
2026-10-09 09:49:23 +08:00
parent c32be46adb
commit 81d0d1768a
15 changed files with 203 additions and 44 deletions
+2 -2
View File
@@ -144,7 +144,7 @@ class SvgWriter {
final Color c = Color(a.color);
_b.write('<g id="${_esc(a.id)}" data-action="${_esc(a.id)}" data-start="${a.startAngle}" '
'data-duration="${a.durationAngle}" data-layer="${a.layer}" data-station="${_esc(a.stationId)}">');
_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('</g>');
@@ -231,7 +231,7 @@ class SvgWriter {
'data-duration="${a.durationAngle}" data-layer="${a.layer}" data-station="${_esc(a.stationId)}">');
for (final List<double> s in splitArcs(a.startAngle, a.endAngle)) {
final String d = _arc(c, r, s[0], s[1]);
_b.write('<path d="$d" fill="none" stroke="${_hex(col)}" stroke-width="$th" stroke-linecap="round"/>');
_b.write('<path d="$d" fill="none" stroke="${_hex(col)}" stroke-width="$th" stroke-linecap="butt"/>');
}
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');
+5 -5
View File
@@ -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)}°',
+63 -17
View File
@@ -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] → 沿圆弧走到目标弧
+20 -7
View File
@@ -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<AppShell> {
}
}
/// 更新检查按钮。
///
/// 空闲态用环形箭头(检查更新,中文软件的通用语义);
/// 检测到新版本时换成下载图标并叠加红色角标,一眼可辨「有新版本可下载」。
/// 更新检查按钮:圆环 + 上箭头 + 底座(按 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<AppShell> {
);
}
/// 自定义图标组件版按钮(用于更新按钮的矢量图标):
/// 尺寸与点按区域与 [_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),
);
}
// ===================== 侧栏停靠状态机(钉住 / 悬浮 / 轨道) =====================
/// 侧栏标题栏控制按钮:切换钉住状态与隐藏侧栏。
+7 -5
View File
@@ -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];
+1 -1
View File
@@ -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)),
],
),
+2 -1
View File
@@ -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<UpdateDialog> {
// 标题
Row(
children: <Widget>[
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)),
+88
View File
@@ -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;
}
+1 -1
View File
@@ -2,4 +2,4 @@
///
/// 应用内更新检查用它判断服务器发布的版本是否更新;
/// **每次发版必须与 pubspec 同步更新**(见 BUILD-NOTES 的发布流程)。
const String kAppVersion = '1.2.0';
const String kAppVersion = '1.2.1';