fix: 安卓全屏(状态栏/导航栏区域融入界面)+ 保存/导出对话框按类型区分后缀并记忆目录
- 全屏:移除全局 SafeArea,系统栏透明;工具栏/底部状态栏底色延伸填满状态栏与导航栏区域,图标亮度随深浅主题切换(桌面端 padding 为 0 无影响) - 文件对话框:保存/导出按类型区分——工程 .seq.json、导出 .svg / .png(默认名=项目名,目录列表只显示对应后缀文件,输入自动补全/替换后缀) - 路径体验:默认目录改为桌面(移动端为应用目录),并跨会话记忆上次使用的目录;此修复同时作用于 Windows exe 与安卓版
This commit is contained in:
+36
-13
@@ -171,7 +171,13 @@ class _AppShellState extends State<AppShell> {
|
||||
|
||||
/// 另存为:选择目标路径后写入文件(同时生成 .bak 备份)。
|
||||
Future<void> _saveAs() async {
|
||||
final String? path = await pickFile(context, save: true, initialPath: c.filePath);
|
||||
final String? path = await pickFile(
|
||||
context,
|
||||
save: true,
|
||||
initialPath: c.filePath,
|
||||
defaultName: c.filePath == null ? '${c.project.name}.seq.json' : null,
|
||||
suffix: '.seq.json',
|
||||
);
|
||||
if (path == null) return;
|
||||
try {
|
||||
await c.saveAs(path);
|
||||
@@ -187,17 +193,21 @@ class _AppShellState extends State<AppShell> {
|
||||
if (mounted) await showMessage(context, '未授权', '未检测到有效授权(license/*.lic),无法导出 SVG。');
|
||||
return;
|
||||
}
|
||||
final String? path = await pickFile(context, save: true, initialPath: c.filePath);
|
||||
final String? path = await pickFile(
|
||||
context,
|
||||
save: true,
|
||||
defaultName: '${c.project.name}.svg',
|
||||
suffix: '.svg',
|
||||
);
|
||||
if (path == null) return;
|
||||
final String svgPath = path.replaceAll(RegExp(r'\.json$'), '.svg');
|
||||
try {
|
||||
final String svg = SvgWriter(
|
||||
project: c.project,
|
||||
tokens: Tokens.of(c.brightness),
|
||||
mode: c.project.viewState.mode,
|
||||
).build();
|
||||
await File(svgPath).writeAsString(svg, flush: true);
|
||||
if (mounted) c.setStatus('已导出 $svgPath');
|
||||
await File(path).writeAsString(svg, flush: true);
|
||||
if (mounted) c.setStatus('已导出 $path');
|
||||
} catch (e) {
|
||||
if (mounted) await showMessage(context, '导出失败', '$e');
|
||||
}
|
||||
@@ -210,17 +220,21 @@ class _AppShellState extends State<AppShell> {
|
||||
if (mounted) await showMessage(context, '未授权', '未检测到有效授权(license/*.lic),无法导出 PNG。');
|
||||
return;
|
||||
}
|
||||
final String? path = await pickFile(context, save: true, initialPath: c.filePath);
|
||||
final String? path = await pickFile(
|
||||
context,
|
||||
save: true,
|
||||
defaultName: '${c.project.name}.png',
|
||||
suffix: '.png',
|
||||
);
|
||||
if (path == null) return;
|
||||
final String pngPath = path.replaceAll(RegExp(r'\.(json|svg)$'), '.png');
|
||||
try {
|
||||
// 抓取画布舞台的渲染对象并转换为图像。
|
||||
final RenderRepaintBoundary boundary =
|
||||
_stageKey.currentContext!.findRenderObject()! as RenderRepaintBoundary;
|
||||
final ui.Image image = await boundary.toImage(pixelRatio: 2);
|
||||
final ByteData? data = await image.toByteData(format: ui.ImageByteFormat.png);
|
||||
await File(pngPath).writeAsBytes(data!.buffer.asUint8List(), flush: true);
|
||||
if (mounted) c.setStatus('已导出 $pngPath');
|
||||
await File(path).writeAsBytes(data!.buffer.asUint8List(), flush: true);
|
||||
if (mounted) c.setStatus('已导出 $path');
|
||||
} catch (e) {
|
||||
if (mounted) await showMessage(context, '导出失败', '$e');
|
||||
}
|
||||
@@ -256,8 +270,13 @@ class _AppShellState extends State<AppShell> {
|
||||
backgroundColor: t.bg,
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
// 顶部:自适应工具栏。
|
||||
_toolbar(t),
|
||||
// 顶部:系统状态栏区域与工具栏同底色,内容在系统栏下方,
|
||||
// 移动端实现真正的全屏(无黑边),桌面端 padding 为 0 无影响。
|
||||
Container(
|
||||
color: t.chrome,
|
||||
padding: EdgeInsets.only(top: MediaQuery.paddingOf(context).top),
|
||||
child: _toolbar(t),
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
// 拉伸交叉轴:保证左右侧栏始终从工具栏一直贯通到底部状态栏。
|
||||
@@ -319,8 +338,12 @@ class _AppShellState extends State<AppShell> {
|
||||
],
|
||||
),
|
||||
),
|
||||
// 底部:状态栏。
|
||||
_statusBar(t),
|
||||
// 底部:系统导航栏区域与状态栏同底色,内容在系统栏上方。
|
||||
Container(
|
||||
color: t.chrome,
|
||||
padding: EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom),
|
||||
child: _statusBar(t),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user