feat(ui): 统一两个视图的编辑工具栏;缩小右下角预览卡

- 编辑工具统一为 7 个按钮(添加/编辑/复制/删除/层+/层−/对齐),两视图同一套组件
- 条形视图:位置保持左下角,按钮缩至原 60%(约 40×34,单手可点)
- 圆周视图:工具栏由右中移到右上角,按钮尺寸与条形视图一致,不再遮挡预览
- 右下角预览卡缩小:宽 190→150,圆周预览高 150→112,条形预览行距 12→9
- 版本号 1.0.9+10
This commit is contained in:
2026-10-08 15:27:27 +08:00
parent f1df91782d
commit 0a0ea3c0ec
5 changed files with 73 additions and 122 deletions
+67 -116
View File
@@ -130,12 +130,12 @@ class CanvasOverlays extends StatelessWidget {
? _BarPreviewCard(t: t, c: c)
: _CircularPreviewCard(t: t, c: c),
),
// 圆周视图右侧浮动工具栏(添加/编辑/复制/删除/改层/对齐)。
// 圆周视图右上角浮动工具栏(与条形视图同一套工具与按钮尺寸)。
if (showPanels && circular)
Positioned(
right: right - 2,
top: 120,
child: _FloatingToolbar(t: t, c: c),
right: right,
top: 70,
child: _EditTools(t: t, c: c, vertical: true),
),
],
);
@@ -611,68 +611,88 @@ class _CycleStatsDialog extends StatelessWidget {
}
}
/// 条形视图编辑工具条:添加 / 编辑 / 复制 / 删除 / 对齐。
/// 编辑工具栏(条形 / 圆周视图共用):
/// 添加 / 编辑 / 复制 / 删除 / 层+ / 层− / 对齐。
///
/// - [vertical] 为真时纵向排列(圆周视图右上角),否则横向排列(条形视图左下角);
/// - 按钮尺寸统一为原「编辑工具」条的 60%(约 40×34px),单手可点且尽量不遮挡画布。
class _EditTools extends StatelessWidget {
const _EditTools({required this.t, required this.c});
const _EditTools({required this.t, required this.c, this.vertical = false});
/// 主题令牌。
final Tokens t;
/// 全局应用控制器。
final AppController c;
/// 是否纵向排列(圆周视图用)。
final bool vertical;
/// 渲染一组横向排列的编辑工具按钮。
/// 按钮宽度(像素)——原 66 的 60%。
static const double _bw = 40;
/// 按钮高度(像素)——原 56 的 60%。
static const double _bh = 34;
/// 按钮间距(像素)。
static const double _gap = 5;
/// 渲染工具栏;横向 ↔ 纵向由 [vertical] 决定。
@override
Widget build(BuildContext context) {
return _Card(
t: t,
width: 390,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('编辑工具', style: TextStyle(color: t.sub, fontSize: 12, fontWeight: FontWeight.w600)),
const SizedBox(height: 10),
Row(
children: <Widget>[
_tool(t, Icons.add, '添加动作', t.ok, t.onAccent, () => c.addAction(startAngle: 0)),
const SizedBox(width: 8),
_tool(t, Icons.edit, '编辑', t.accent, t.onAccent, () {
final Action? a = c.selected;
if (a != null) showDialog<void>(context: context, builder: (_) => ActionEditorDialog(controller: c, action: a));
}),
const SizedBox(width: 8),
_tool(t, Icons.copy, '复制', t.panel, t.sub, c.duplicateSelected, border: t.line2),
const SizedBox(width: 8),
_tool(t, Icons.delete_outline, '删除', t.panel, t.sub,
() => c.selectedId != null ? c.deleteAction(c.selectedId!) : null,
border: t.line2),
const SizedBox(width: 8),
_tool(t, Icons.align_horizontal_left, '对齐', t.panel, t.sub, c.alignPhase, border: t.line2),
],
),
],
final List<Widget> buttons = <Widget>[
_tool(Icons.add, '添加', t.ok, t.onAccent, () => c.addAction(startAngle: 0)),
_tool(Icons.edit, '编辑', t.accent, t.onAccent, () {
final Action? a = c.selected;
if (a != null) showDialog<void>(context: context, builder: (_) => ActionEditorDialog(controller: c, action: a));
}),
_tool(Icons.copy, '复制', t.panel, t.sub, c.duplicateSelected, border: t.line2),
_tool(Icons.delete_outline, '删除', t.panel, t.sub,
() => c.selectedId != null ? c.deleteAction(c.selectedId!) : null, border: t.line2),
_tool(Icons.keyboard_arrow_up, '层+', t.panel, t.sub,
() => c.selectedId != null ? c.changeLayer(c.selectedId!, 1) : null, border: t.line2),
_tool(Icons.keyboard_arrow_down, '层−', t.panel, t.sub,
() => c.selectedId != null ? c.changeLayer(c.selectedId!, -1) : null, border: t.line2),
_tool(Icons.align_horizontal_left, '对齐', t.panel, t.sub, c.alignPhase, border: t.line2),
];
final List<Widget> spaced = <Widget>[];
for (int i = 0; i < buttons.length; i++) {
if (i > 0) {
spaced.add(SizedBox(width: vertical ? 0 : _gap, height: vertical ? _gap : 0));
}
spaced.add(buttons[i]);
}
return Container(
padding: const EdgeInsets.all(5),
decoration: BoxDecoration(
color: t.panel.withValues(alpha: 0.96),
borderRadius: BorderRadius.circular(vertical ? 12 : 10),
border: Border.all(color: t.line2),
),
child: vertical
? Column(mainAxisSize: MainAxisSize.min, children: spaced)
: Row(mainAxisSize: MainAxisSize.min, children: spaced),
);
}
/// 渲染单个带图标与文字的工具按钮。
Widget _tool(Tokens t, IconData icon, String label, Color bg, Color fg, VoidCallback onTap, {Color? border}) {
/// 渲染单个工具按钮(图标 + 文字)。
Widget _tool(IconData icon, String label, Color bg, Color fg, VoidCallback onTap, {Color? border}) {
return InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(9),
borderRadius: BorderRadius.circular(8),
child: Container(
width: 66,
height: 56,
width: _bw,
height: _bh,
decoration: BoxDecoration(
color: bg,
borderRadius: BorderRadius.circular(9),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: border ?? bg),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(icon, size: 19, color: fg),
const SizedBox(height: 4),
Text(label, style: TextStyle(color: fg, fontSize: 10, fontWeight: FontWeight.w600)),
Icon(icon, size: 12, color: fg),
const SizedBox(height: 1),
Text(label,
style: TextStyle(color: fg, fontSize: 8.5, fontWeight: FontWeight.w600, height: 1.0)),
],
),
),
@@ -680,75 +700,6 @@ class _EditTools extends StatelessWidget {
}
}
/// 圆周视图右侧浮动工具栏:纵向排列的编辑按钮。
class _FloatingToolbar extends StatelessWidget {
const _FloatingToolbar({required this.t, required this.c});
/// 主题令牌。
final Tokens t;
/// 全局应用控制器。
final AppController c;
/// 渲染纵向排列的浮动工具按钮组。
@override
Widget build(BuildContext context) {
/// 渲染单个浮动工具按钮。
Widget item(IconData icon, String label, Color bg, Color fg, VoidCallback onTap, {Color? border}) {
return Padding(
padding: const EdgeInsets.only(bottom: 6),
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(10),
child: Container(
width: 46,
height: 46,
decoration: BoxDecoration(
color: bg,
borderRadius: BorderRadius.circular(10),
border: Border.all(color: border ?? bg),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(icon, size: 17, color: fg),
const SizedBox(height: 1),
Text(label, style: TextStyle(color: fg, fontSize: 10, fontWeight: FontWeight.w600)),
],
),
),
),
);
}
return Container(
padding: const EdgeInsets.all(6),
decoration: BoxDecoration(
color: t.panel.withValues(alpha: 0.96),
borderRadius: BorderRadius.circular(14),
border: Border.all(color: t.line2),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
item(Icons.add, '添加', t.ok, t.onAccent, () => c.addAction(startAngle: 0)),
item(Icons.edit, '编辑', t.accent, t.onAccent, () {
final Action? a = c.selected;
if (a != null) showDialog<void>(context: context, builder: (_) => ActionEditorDialog(controller: c, action: a));
}),
item(Icons.copy, '复制', t.panel2, t.sub, c.duplicateSelected, border: t.line),
item(Icons.delete_outline, '删除', t.panel2, t.sub,
() => c.selectedId != null ? c.deleteAction(c.selectedId!) : null, border: t.line),
item(Icons.keyboard_arrow_up, '层+', t.panel2, t.sub,
() => c.selectedId != null ? c.changeLayer(c.selectedId!, 1) : null, border: t.line),
item(Icons.keyboard_arrow_down, '层−', t.panel2, t.sub,
() => c.selectedId != null ? c.changeLayer(c.selectedId!, -1) : null, border: t.line),
item(Icons.align_horizontal_left, '对齐', t.panel2, t.sub, c.alignPhase, border: t.line),
],
),
);
}
}
/// 条形节拍缩略预览卡(在圆周视图右下角显示);点击切换到条形视图。
class _BarPreviewCard extends StatelessWidget {
const _BarPreviewCard({required this.t, required this.c});
@@ -767,7 +718,7 @@ class _BarPreviewCard extends StatelessWidget {
borderRadius: BorderRadius.circular(10),
child: _Card(
t: t,
width: 190,
width: 150,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
@@ -783,7 +734,7 @@ class _BarPreviewCard extends StatelessWidget {
const SizedBox(height: 6),
SizedBox(
width: double.infinity,
height: project.actions.length * 12.0 + 14,
height: project.actions.length * 9.0 + 12,
child: CustomPaint(
size: Size.infinite,
painter: _MiniBarPainter(project, t),
@@ -867,7 +818,7 @@ class _CircularPreviewCard extends StatelessWidget {
borderRadius: BorderRadius.circular(10),
child: _Card(
t: t,
width: 190,
width: 150,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
@@ -883,7 +834,7 @@ class _CircularPreviewCard extends StatelessWidget {
const SizedBox(height: 6),
SizedBox(
width: double.infinity,
height: 150,
height: 112,
child: CustomPaint(
size: Size.infinite,
painter: _MiniCircularPainter(project, t),
+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.0.8(${android ? '安卓版' : 'Windows 版'})',
Text('V1.0.9(${android ? '安卓版' : 'Windows 版'})',
style: TextStyle(color: t.dim, fontSize: 12)),
],
),