Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 233a329c0a |
@@ -80,6 +80,9 @@ class AppController extends ChangeNotifier {
|
|||||||
/// 状态栏文本。
|
/// 状态栏文本。
|
||||||
String _status = '就绪';
|
String _status = '就绪';
|
||||||
|
|
||||||
|
/// 控制器是否已释放([dispose] 之后置真,用于拦截迟到的回调)。
|
||||||
|
bool _disposed = false;
|
||||||
|
|
||||||
/// 最近一次保存时间。
|
/// 最近一次保存时间。
|
||||||
DateTime? _lastSavedAt;
|
DateTime? _lastSavedAt;
|
||||||
|
|
||||||
@@ -144,6 +147,7 @@ class AppController extends ChangeNotifier {
|
|||||||
/// 释放资源:取消自动保存定时器并调用父类 dispose。
|
/// 释放资源:取消自动保存定时器并调用父类 dispose。
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_disposed = true;
|
||||||
_autosaveTimer?.cancel();
|
_autosaveTimer?.cancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@@ -317,7 +321,15 @@ class AppController extends ChangeNotifier {
|
|||||||
ViewMode.flow => '流程图视图(只读)',
|
ViewMode.flow => '流程图视图(只读)',
|
||||||
};
|
};
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
// 每次切换视图都自动执行一次「适应窗口」:三个视图的内容范围不同,
|
||||||
|
// 不重置就会沿用上一个视图的缩放 / 平移,画面看起来就「跑了」。
|
||||||
fitView(silent: true);
|
fitView(silent: true);
|
||||||
|
// 再补一帧:画布可能因侧栏开合 / 窗口尺寸在同一批布局中变化,
|
||||||
|
// 等该帧结束后按最新视口再适配一次,确保切换后必定处于适配状态。
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (_disposed || _project.viewState.mode != mode) return;
|
||||||
|
fitView(silent: true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 选中指定动作([id] 为 null 表示清空选中)并刷新。
|
/// 选中指定动作([id] 为 null 表示清空选中)并刷新。
|
||||||
|
|||||||
@@ -529,7 +529,13 @@ class _AppShellState extends State<AppShell> {
|
|||||||
tooltip: info == null ? '检查更新' : '发现新版本 v${info.version}',
|
tooltip: info == null ? '检查更新' : '发现新版本 v${info.version}',
|
||||||
);
|
);
|
||||||
if (info == null) return btn;
|
if (info == null) return btn;
|
||||||
return Badge(backgroundColor: t.danger, smallSize: 8, child: btn);
|
// 红点固定放在按钮左上角(默认是右上角,更醒目也符合「有更新」的提示习惯)。
|
||||||
|
return Badge(
|
||||||
|
backgroundColor: t.danger,
|
||||||
|
smallSize: 8,
|
||||||
|
alignment: Alignment.topLeft,
|
||||||
|
child: btn,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 打开更新对话框:已有检测结果时直接弹出,否则先检查一次。
|
/// 打开更新对话框:已有检测结果时直接弹出,否则先检查一次。
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ import '../state/app_controller.dart';
|
|||||||
import '../theme/tokens.dart';
|
import '../theme/tokens.dart';
|
||||||
import 'dialogs.dart';
|
import 'dialogs.dart';
|
||||||
|
|
||||||
|
/// 条形缩略预览的固定绘制区高度:卡片尺寸不随动作数量变化,
|
||||||
|
/// 动作越多只会在内部压缩行距、把色条画得更细。
|
||||||
|
const double _kMiniBarHeight = 84;
|
||||||
|
|
||||||
/// 画布浮层容器:按响应式断点组合并定位各信息面板。
|
/// 画布浮层容器:按响应式断点组合并定位各信息面板。
|
||||||
class CanvasOverlays extends StatelessWidget {
|
class CanvasOverlays extends StatelessWidget {
|
||||||
/// 创建浮层容器,[controller] 为全局应用控制器。
|
/// 创建浮层容器,[controller] 为全局应用控制器。
|
||||||
@@ -744,9 +748,11 @@ class _BarPreviewCard extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
|
// 预览区固定高度(与动作数量无关):动作再多也不会撑大预览卡,
|
||||||
|
// 只会在内部压缩行距 / 缩小线条(见 _MiniBarPainter)。
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: project.actions.length * 9.0 + 12,
|
height: _kMiniBarHeight,
|
||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
size: Size.infinite,
|
size: Size.infinite,
|
||||||
painter: _MiniBarPainter(project, t),
|
painter: _MiniBarPainter(project, t),
|
||||||
@@ -775,8 +781,9 @@ class _MiniBarPainter extends CustomPainter {
|
|||||||
final double w = size.width - 4;
|
final double w = size.width - 4;
|
||||||
// 行高按可用高度自适应,保证小预览里也排得下。
|
// 行高按可用高度自适应,保证小预览里也排得下。
|
||||||
final double pitch = n == 0 ? 12 : math.min(12, (size.height - 16) / n);
|
final double pitch = n == 0 ? 12 : math.min(12, (size.height - 16) / n);
|
||||||
// 缩略图里的动作条只是一条细线(约 2px),并在行内垂直居中。
|
// 缩略图里的动作条是一条细线(约 2px);动作越多行距越紧、线越细,
|
||||||
final double rh = math.min(2.0, math.max(pitch * 0.5, 1.6));
|
// 下限 0.5px,保证固定高度的预览区内不重叠、不溢出。
|
||||||
|
final double rh = math.min(2.0, math.max(pitch * 0.6, 0.5));
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
final Action a = project.actions[i];
|
final Action a = project.actions[i];
|
||||||
final double y = i * pitch + (pitch - rh) / 2;
|
final double y = i * pitch + (pitch - rh) / 2;
|
||||||
@@ -878,8 +885,9 @@ class _MiniCircularPainter extends CustomPainter {
|
|||||||
final double maxR = math.max(math.min(size.width, size.height) / 2 - 24, 24);
|
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 r0 = n <= 1 ? maxR * 0.6 : maxR * 0.34;
|
||||||
final double pitch = n <= 1 ? 0 : (maxR - r0) / (n - 1);
|
final double pitch = n <= 1 ? 0 : (maxR - r0) / (n - 1);
|
||||||
// 缩略图里的环与动作弧只需一条细线(约 2px)。
|
// 缩略图里的环与动作弧是一条细线;层数越多环距越紧、线宽随之收细,
|
||||||
final double pw = 2.0;
|
// 避免在固定大小的预览框里叠成一团。
|
||||||
|
final double pw = math.min(2.0, math.max(pitch <= 0 ? 2.0 : pitch * 0.7, 0.5));
|
||||||
canvas.drawCircle(c, r0 + (n - 1) * pitch + pw / 2, Paint()..color = t.dial);
|
canvas.drawCircle(c, r0 + (n - 1) * pitch + pw / 2, Paint()..color = t.dial);
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
final Action a = project.actions[i];
|
final Action a = project.actions[i];
|
||||||
|
|||||||
+1
-1
@@ -2124,7 +2124,7 @@ class HelpDialog extends StatelessWidget {
|
|||||||
Text('时序图设计 · Sequence Diagram Studio',
|
Text('时序图设计 · Sequence Diagram Studio',
|
||||||
style: TextStyle(color: t.text, fontSize: 15, fontWeight: FontWeight.w700)),
|
style: TextStyle(color: t.text, fontSize: 15, fontWeight: FontWeight.w700)),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text('V1.3.0(${android ? '安卓版' : 'Windows 版'})',
|
Text('V1.3.1(${android ? '安卓版' : 'Windows 版'})',
|
||||||
style: TextStyle(color: t.dim, fontSize: 12)),
|
style: TextStyle(color: t.dim, fontSize: 12)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
+1
-1
@@ -2,4 +2,4 @@
|
|||||||
///
|
///
|
||||||
/// 应用内更新检查用它判断服务器发布的版本是否更新;
|
/// 应用内更新检查用它判断服务器发布的版本是否更新;
|
||||||
/// **每次发版必须与 pubspec 同步更新**(见 BUILD-NOTES 的发布流程)。
|
/// **每次发版必须与 pubspec 同步更新**(见 BUILD-NOTES 的发布流程)。
|
||||||
const String kAppVersion = '1.3.0';
|
const String kAppVersion = '1.3.1';
|
||||||
|
|||||||
+1
-1
@@ -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
|
# 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
|
# 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.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.3.0+16
|
version: 1.3.1+17
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.13.3
|
sdk: ^3.13.3
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# V1.3.1 更新内容
|
||||||
|
|
||||||
|
- 视图切换强化:每次切换条形 / 圆周 / 流程图都会自动「适应窗口」,
|
||||||
|
不会再沿用上一个视图的缩放与平移(此前切换后画面可能跑偏)
|
||||||
|
- 预览缩略图区域固定尺寸:动作再多也不会撑大「条形预览 / 圆周预览」卡片,
|
||||||
|
只会在内部自动缩小缩略图、把线条画得更细
|
||||||
|
- 更新按钮的「有新版本」红点改为显示在按钮**左上角**
|
||||||
@@ -98,4 +98,42 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text('导出 drawio'), findsOneWidget);
|
expect(find.text('导出 drawio'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('switching views via toolbar auto-fits each view', (WidgetTester tester) async {
|
||||||
|
tester.view.physicalSize = const Size(1920, 1080);
|
||||||
|
tester.view.devicePixelRatio = 1.0;
|
||||||
|
addTearDown(tester.view.reset);
|
||||||
|
|
||||||
|
final AppController controller = AppController(project: Project.demo());
|
||||||
|
addTearDown(controller.dispose);
|
||||||
|
|
||||||
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
theme: buildTheme(Tokens.light),
|
||||||
|
home: AppShell(controller: controller),
|
||||||
|
));
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
// 先把视图手动缩放 / 平移(模拟用户调过画面)。
|
||||||
|
controller.setZoom(0.5);
|
||||||
|
controller.panBy(const Offset(400, 300));
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
// 经工具栏三段切换:每次切换后都应自动回到「适应窗口」状态
|
||||||
|
//(与显式执行 fitView 的结果一致),而不是沿用上一个视图的缩放 / 平移。
|
||||||
|
Future<void> expectFittedAfterSwitch(String label) async {
|
||||||
|
await tester.tap(find.text(label).first);
|
||||||
|
await tester.pump();
|
||||||
|
final double z = controller.project.viewState.zoom;
|
||||||
|
final double px = controller.project.viewState.panX;
|
||||||
|
final double py = controller.project.viewState.panY;
|
||||||
|
controller.fitView();
|
||||||
|
expect(controller.project.viewState.zoom, closeTo(z, 0.0001), reason: '$label 切换后缩放应为适配值');
|
||||||
|
expect(controller.project.viewState.panX, closeTo(px, 0.001), reason: '$label 切换后平移应为适配值');
|
||||||
|
expect(controller.project.viewState.panY, closeTo(py, 0.001), reason: '$label 切换后平移应为适配值');
|
||||||
|
}
|
||||||
|
|
||||||
|
await expectFittedAfterSwitch('圆周节拍');
|
||||||
|
await expectFittedAfterSwitch('流程图');
|
||||||
|
await expectFittedAfterSwitch('条形节拍');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user