feat(android): 平板版适配(1280×800dp,免授权,应用商店分发)

- flutter create 增加 android 平台:包名 cc.sincos.sequence_diagram,应用名「时序图设计器」,minSdk 24 / targetSdk 36

- 多分辨率动态兼容:触屏侧栏默认贴边把手(点把手直接停靠),面板宽度随屏宽压缩,窄屏双侧栏停靠不溢出

- 免授权:LicenseService 非 Windows 平台直接判定已授权

- 移动端存储/文件浏览器适配(无 APPDATA/盘符/桌面);edge-to-edge + SafeArea + 文本缩放固定 1.0

- launcher 图标沿用「环序」标志(tools/gen-android-icons.py);Gradle 腾讯镜像 + Maven 阿里镜像

- 自测:7 种分辨率无溢出回归(test/tablet_layout_test.dart)+ 平板截图(demo/tablet-*.png)

- 产物:release/sequence_diagram_tablet_v1.0.1_release.apk(universal,50.3MB)
This commit is contained in:
admin
2026-10-06 21:04:38 +08:00
parent f5412ee99d
commit fad82a30d8
37 changed files with 772 additions and 42 deletions
+59
View File
@@ -0,0 +1,59 @@
// 测试辅助:构造演示工程与加载中文字体(用于平板布局测试与截图生成)。
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:sequence_diagram/model/models.dart';
/// 构造一个动作较多、含依赖与相位分区的演示工程。
Project demoTiming() {
return Project(
name: '装配线节拍',
cycle: const Cycle(durationMs: 2400),
stations: const <Station>[
Station(id: 'ST1', name: '上料工位', order: 0, color: 0xFF4CC9F0),
Station(id: 'ST2', name: '加工工位', order: 1, color: 0xFFFFD166),
Station(id: 'ST3', name: '检测工位', order: 2, color: 0xFF34D399),
],
actions: <Action>[
const Action(id: 'A1', name: '上料', stationId: 'ST1', driver: '气缸 Y1', startAngle: 0, durationAngle: 45, layer: 0, color: 0xFF4CC9F0),
const Action(id: 'A2', name: '定位夹紧', stationId: 'ST1', driver: '气缸 Y2', startAngle: 50, durationAngle: 55, layer: 0, color: 0xFF7BD88F,
deps: <Dependency>[Dependency(fromId: 'A1', toId: 'A2', type: DepType.fs)]),
const Action(id: 'A3', name: '伺服下压', stationId: 'ST2', driver: '伺服 M1', startAngle: 90, durationAngle: 70, layer: 1, color: 0xFFFFD166,
deps: <Dependency>[Dependency(fromId: 'A2', toId: 'A3', type: DepType.fs)]),
const Action(id: 'A4', name: '超声焊接', stationId: 'ST2', driver: '超声 U1', startAngle: 100, durationAngle: 50, layer: 2, color: 0xFFF472B6,
deps: <Dependency>[Dependency(fromId: 'A3', toId: 'A4', type: DepType.ss, offsetAngle: 10)]),
const Action(id: 'A5', name: '视觉检测', stationId: 'ST3', driver: '相机 C1', startAngle: 160, durationAngle: 70, layer: 1, color: 0xFF7C5CFF,
deps: <Dependency>[Dependency(fromId: 'A4', toId: 'A5', type: DepType.fs)]),
const Action(id: 'A6', name: '分选下料', stationId: 'ST3', driver: '气缸 Y3', startAngle: 200, durationAngle: 70, layer: 2, color: 0xFFFF9F7C,
deps: <Dependency>[Dependency(fromId: 'A5', toId: 'A6', type: DepType.fs)]),
const Action(id: 'A7', name: '清洁吹气', stationId: 'ST1', driver: '电磁阀 V1', startAngle: 240, durationAngle: 80, layer: 3, color: 0xFF34D399,
deps: <Dependency>[Dependency(fromId: 'A6', toId: 'A7', type: DepType.fs)]),
],
units: const UnitSettings(timeUnit: TimeUnit.s),
viewState: const ViewState(mode: ViewMode.bar),
phaseZones: const <PhaseZone>[
PhaseZone(name: '上料相位', startAngle: 0, endAngle: 70),
PhaseZone(name: '加工相位', startAngle: 70, endAngle: 200),
PhaseZone(name: '检测相位', startAngle: 200, endAngle: 300),
PhaseZone(name: '下料相位', startAngle: 300, endAngle: 360),
],
);
}
/// 从系统字体加载中文字体,使测试截图中的中文正常渲染。
Future<void> loadZhFonts() async {
const List<String> candidates = <String>[
r'C:\Windows\Fonts\simhei.ttf',
r'C:\Windows\Fonts\msyh.ttf',
r'C:\Windows\Fonts\msyh.ttc',
r'C:\Windows\Fonts\simsun.ttc',
];
for (final String path in candidates) {
final File f = File(path);
if (!f.existsSync()) continue;
final ByteData bytes = ByteData.sublistView(await f.readAsBytes());
final FontLoader loader = FontLoader('Microsoft YaHei UI')..addFont(Future<ByteData>.value(bytes));
await loader.load();
return;
}
}
+79
View File
@@ -0,0 +1,79 @@
// 平板/多分辨率布局回归测试:在多种分辨率、主题、视图模式下泵出整个外壳,
// 并展开/停靠侧栏,确保无溢出异常(RenderFlex overflow 会导致测试失败)。
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sequence_diagram/model/models.dart';
import 'package:sequence_diagram/state/app_controller.dart';
import 'package:sequence_diagram/theme/tokens.dart';
import 'package:sequence_diagram/ui/app_shell.dart';
import 'helpers.dart';
void main() {
const List<(String, Size, double)> cases = <(String, Size, double)>[
('tablet-landscape', Size(1280, 800), 1.0),
('tablet-landscape-2x', Size(1280, 800), 2.0), // 物理 2560×1600
('wide-1920', Size(1920, 1080), 1.0),
('small-960', Size(960, 600), 1.0),
('phone-landscape-800', Size(800, 480), 1.0),
('portrait-800x1280', Size(800, 1280), 1.0),
('portrait-600x960', Size(600, 960), 1.0),
];
for (final (String name, Size size, double dpr) in cases) {
testWidgets('layout @ $name ${size.width}x${size.height} dpr=$dpr 无溢出', (WidgetTester tester) async {
tester.view.physicalSize = size * dpr;
tester.view.devicePixelRatio = dpr;
addTearDown(tester.view.reset);
final AppController c = AppController(project: demoTiming());
addTearDown(c.dispose);
await tester.pumpWidget(MaterialApp(
theme: buildTheme(Tokens.light),
home: AppShell(controller: c),
));
await tester.pump();
// 条形视图:深浅主题各渲染一次。
c.toggleTheme();
await tester.pump();
c.toggleTheme();
await tester.pump();
// 展开左侧栏(浮层)并钉住(停靠,压缩画布宽度)。
if (tester.any(find.byIcon(Icons.chevron_right))) {
await tester.tap(find.byIcon(Icons.chevron_right).first);
await tester.pump();
}
if (tester.any(find.byIcon(Icons.push_pin_outlined))) {
await tester.tap(find.byIcon(Icons.push_pin_outlined).first);
await tester.pump();
}
// 展开右侧栏(浮层)并钉住。
if (tester.any(find.byIcon(Icons.chevron_left))) {
await tester.tap(find.byIcon(Icons.chevron_left).first);
await tester.pump();
}
if (tester.any(find.byIcon(Icons.push_pin_outlined))) {
await tester.tap(find.byIcon(Icons.push_pin_outlined).first);
await tester.pump();
}
// 圆周视图 + 深色主题 + 缩放。
c.setViewMode(ViewMode.circular);
await tester.pump();
c.toggleTheme();
await tester.pump();
c.setZoom(1.4);
await tester.pump();
// 回到条形视图,选中一个动作(右侧栏渲染属性面板)。
c.setViewMode(ViewMode.bar);
c.select('A3');
await tester.pump();
c.toggleTheme();
await tester.pump();
});
}
}
+67
View File
@@ -0,0 +1,67 @@
// 平板版演示截图生成:把整个应用外壳在 1280×800(平板横屏基准)下渲染为 PNG。
// 运行方式:flutter test --update-goldens test\tablet_screenshots_test.dart
// 输出:demo/tablet-*.png
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sequence_diagram/model/models.dart';
import 'package:sequence_diagram/state/app_controller.dart';
import 'package:sequence_diagram/theme/tokens.dart';
import 'package:sequence_diagram/ui/app_shell.dart';
import 'helpers.dart';
void main() {
testWidgets('generate tablet demo screenshots', (WidgetTester tester) async {
await tester.runAsync(() => loadZhFonts());
tester.view.physicalSize = const Size(1280, 800);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.reset);
final AppController c = AppController(project: demoTiming());
addTearDown(c.dispose);
Widget shell(Tokens t) => RepaintBoundary(
key: const ValueKey<String>('shot'),
child: MaterialApp(
theme: buildTheme(t),
home: AppShell(controller: c),
),
);
Future<void> shot(String path) async {
await tester.pump();
await expectLater(find.byKey(const ValueKey<String>('shot')), matchesGoldenFile(path));
}
await tester.pumpWidget(shell(Tokens.light));
await shot('../demo/tablet-bar-light.png');
// 展开左右侧栏(浮层)并钉住,展示停靠布局。
await tester.tap(find.byIcon(Icons.chevron_right).first);
await tester.pump();
if (tester.any(find.byIcon(Icons.push_pin_outlined))) {
await tester.tap(find.byIcon(Icons.push_pin_outlined).first);
await tester.pump();
}
await tester.tap(find.byIcon(Icons.chevron_left).first);
await tester.pump();
if (tester.any(find.byIcon(Icons.push_pin_outlined))) {
await tester.tap(find.byIcon(Icons.push_pin_outlined).first);
await tester.pump();
}
await shot('../demo/tablet-bar-light-panels.png');
// 圆周视图(浅色,含停靠侧栏)。
c.setViewMode(ViewMode.circular);
await shot('../demo/tablet-circular-light.png');
// 深色主题:条形与圆周。
c.toggleTheme();
await tester.pumpWidget(shell(Tokens.dark));
c.setViewMode(ViewMode.bar);
await shot('../demo/tablet-bar-dark.png');
c.setViewMode(ViewMode.circular);
await shot('../demo/tablet-circular-dark.png');
});
}