feat(ui): 动作两端改为方头小圆角(长度即真实时长);更新图标按设计稿重绘
- 条形视图:动作条圆角 8→3,两端方头(仅小圆角),长度严格等于真实时长 - 圆周视图:动作弧改为填充弧带(方头 + 小圆角)替代圆头描边, 消除「圆头端帽在两端各多出半个环宽」造成的长度误读 - SVG 导出同步:条块 rx=3、动作弧 stroke-linecap=butt,导出与屏幕一致 - 更新按钮图标按 docs/更新.svg 设计稿矢量重绘(圆环 + 上箭头 + 两条底座横杠), 替换原来的 refresh 图标;更新对话框标题图标同步 - 右下角缩略预览(条形 / 圆周)动作线条细化至约 2px - 版本 1.2.1+13
This commit is contained in:
+20
-7
@@ -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),
|
||||
);
|
||||
}
|
||||
|
||||
// ===================== 侧栏停靠状态机(钉住 / 悬浮 / 轨道) =====================
|
||||
|
||||
/// 侧栏标题栏控制按钮:切换钉住状态与隐藏侧栏。
|
||||
|
||||
@@ -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
@@ -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)),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -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)),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user