fix(android): 工具栏整体缩小 60%,一排放下全部操作;统一称「安卓版」

- 触屏平台(安卓)工具栏缩放 0.6:按钮/图标/字号/间距与工具栏高度同步缩小,
  并收紧默认 48dp 点按区域,修复顶部工具栏一行显示不全的问题
- 关于页 /「保存位置」/ 文件对话框:去掉「平板版」等叫法,统一为「安卓版」
- README / BUILD-NOTES:同步更名
This commit is contained in:
2026-10-08 10:48:38 +08:00
parent e780513630
commit dafb0b4ba8
5 changed files with 106 additions and 78 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ class LicenseService {
/// 初始化:读取 MAC 并校验 `license/*.lic`。
///
/// Android 平板版(应用商店分发)不需要授权:非 Windows 平台直接判定为
/// 安卓版(应用商店分发)不需要授权:非 Windows 平台直接判定为
/// 已授权,跳过 MAC 读取与 .lic 校验。
Future<LicenseInfo> init() async {
if (!Platform.isWindows) {
+91 -63
View File
@@ -74,6 +74,13 @@ class _AppShellState extends State<AppShell> {
return math.min(340.0, math.max(240.0, w * 0.26));
}
/// 工具栏整体缩放系数:触屏平台(安卓 / iOS)缩小到 60%,
/// 一排即可放下全部操作且不影响点按;桌面端保持原尺寸。
double get _toolScale => (Platform.isAndroid || Platform.isIOS) ? 0.6 : 1.0;
/// 工具栏字号:随 [_toolScale] 缩放并保底 9,兼顾紧凑与可读。
double _toolFont(double size) => math.max(9.0, size * _toolScale);
/// 左侧栏是否处于停靠(固定)状态。
bool get _leftDocked => _leftVisible && _leftPinned;
/// 右侧栏是否处于停靠(固定)状态。
@@ -427,11 +434,13 @@ class _AppShellState extends State<AppShell> {
// ===================== 工具栏(自适应 / 紧凑) =====================
/// 构建顶部工具栏:左侧为品牌与文件/编辑操作,右侧为导出、缩放、
/// 单位、侧栏开关与主题切换。根据可用宽度在完整布局与紧凑布局间切换。
/// 单位、侧栏开关与主题切换。根据可用宽度在完整布局与紧凑布局间切换;
/// 触屏平台(安卓)整体缩放 [_toolScale],一排放下全部操作。
Widget _toolbar(Tokens t) {
final double s = _toolScale;
return Container(
height: 54,
padding: const EdgeInsets.symmetric(horizontal: 6),
height: 54 * s,
padding: EdgeInsets.symmetric(horizontal: 6 * s),
decoration: BoxDecoration(
color: t.chrome,
border: Border(bottom: BorderSide(color: t.line2)),
@@ -470,41 +479,45 @@ class _AppShellState extends State<AppShell> {
if (!compact) {
// 完整布局:文件 / 编辑操作图标化 + 分段视图切换。
left = <Widget>[
const AppLogo(size: 32),
const SizedBox(width: 10),
AppLogo(size: 32 * s),
SizedBox(width: 10 * s),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('时序图设计器',
style: TextStyle(color: t.text, fontSize: 14, fontWeight: FontWeight.w700, letterSpacing: 1)),
Text('Sequence Diagram Studio', style: TextStyle(color: t.dim, fontSize: 10)),
style: TextStyle(
color: t.text,
fontSize: _toolFont(14),
fontWeight: FontWeight.w700,
letterSpacing: 1 * s)),
Text('Sequence Diagram Studio', style: TextStyle(color: t.dim, fontSize: _toolFont(10))),
],
),
const SizedBox(width: 18),
SizedBox(width: 18 * s),
_iconBtn(t, Icons.note_add_outlined, _newProject, tooltip: '新建 Ctrl+N'),
_iconBtn(t, Icons.folder_open_outlined, _open, tooltip: '打开 Ctrl+O'),
_iconBtn(t, Icons.save_outlined, _save, tooltip: '保存 Ctrl+S'),
const SizedBox(width: 6),
SizedBox(width: 6 * s),
_iconBtn(t, Icons.undo, c.canUndo ? c.undo : null, tooltip: '撤销 Ctrl+Z'),
_iconBtn(t, Icons.redo, c.canRedo ? c.redo : null, tooltip: '重做 Ctrl+Y'),
const SizedBox(width: 6),
SizedBox(width: 6 * s),
_aiBtn(t),
const SizedBox(width: 12),
SizedBox(width: 12 * s),
_segmented(t),
];
right = <Widget>[
// 未授权时导出按钮置灰(授权有效才允许导出)。
_primaryBtn(t, '导出 SVG', c.licensed ? _exportSvg : null),
const SizedBox(width: 6),
SizedBox(width: 6 * s),
_ghost(t, '导出 PNG', c.licensed ? _exportPng : null),
const SizedBox(width: 6),
SizedBox(width: 6 * s),
_zoomBox(t),
const SizedBox(width: 6),
SizedBox(width: 6 * s),
_iconBtn(t, Icons.crop_free, c.fitView, tooltip: '适应视图'),
const SizedBox(width: 8),
SizedBox(width: 8 * s),
_unitDropdown(t),
const SizedBox(width: 8),
SizedBox(width: 8 * s),
sideToggleLeft,
sideToggleRight,
_iconBtn(t, Icons.help_outline, () =>
@@ -514,29 +527,33 @@ class _AppShellState extends State<AppShell> {
} else {
// 紧凑布局:图标化 + 导出合并为菜单,尽量压缩宽度。
left = <Widget>[
const AppLogo(size: 28),
const SizedBox(width: 8),
AppLogo(size: 28 * s),
SizedBox(width: 8 * s),
Text('时序图设计器',
style: TextStyle(color: t.text, fontSize: 13, fontWeight: FontWeight.w700, letterSpacing: 0.5)),
const SizedBox(width: 8),
style: TextStyle(
color: t.text,
fontSize: _toolFont(13),
fontWeight: FontWeight.w700,
letterSpacing: 0.5 * s)),
SizedBox(width: 8 * s),
_iconBtn(t, Icons.note_add_outlined, _newProject, tooltip: '新建 Ctrl+N'),
_iconBtn(t, Icons.folder_open_outlined, _open, tooltip: '打开 Ctrl+O'),
_iconBtn(t, Icons.save_outlined, _save, tooltip: '保存 Ctrl+S'),
const SizedBox(width: 4),
SizedBox(width: 4 * s),
_iconBtn(t, Icons.undo, c.canUndo ? c.undo : null, tooltip: '撤销 Ctrl+Z'),
_iconBtn(t, Icons.redo, c.canRedo ? c.redo : null, tooltip: '重做 Ctrl+Y'),
const SizedBox(width: 4),
SizedBox(width: 4 * s),
// AI 是核心卖点,紧凑布局下也保留「AI 生成」文字,避免认不出。
_aiBtn(t),
const SizedBox(width: 8),
SizedBox(width: 8 * s),
_segmented(t, compact: true),
];
right = <Widget>[
// 导出保持两个独立按钮;未授权时置灰。
_ghost(t, '导出 SVG', c.licensed ? _exportSvg : null),
const SizedBox(width: 4),
SizedBox(width: 4 * s),
_ghost(t, '导出 PNG', c.licensed ? _exportPng : null),
const SizedBox(width: 4),
SizedBox(width: 4 * s),
_zoomBox(t),
_iconBtn(t, Icons.crop_free, c.fitView, tooltip: '适应视图'),
_unitDropdown(t),
@@ -574,8 +591,8 @@ class _AppShellState extends State<AppShell> {
onTap: onTap,
borderRadius: BorderRadius.circular(10),
child: Container(
width: compact ? 96 : 140,
height: 34,
width: (compact ? 96 : 140) * _toolScale,
height: 34 * _toolScale,
alignment: Alignment.center,
decoration: BoxDecoration(
color: active ? t.accent.withValues(alpha: 0.16) : Colors.transparent,
@@ -586,14 +603,14 @@ class _AppShellState extends State<AppShell> {
style: TextStyle(
color: active ? t.accent : t.sub,
fontWeight: active ? FontWeight.w600 : FontWeight.normal,
fontSize: 12,
fontSize: _toolFont(12),
)),
),
);
}
return Container(
padding: const EdgeInsets.all(3),
padding: EdgeInsets.all(3 * _toolScale),
decoration: BoxDecoration(
color: t.panel,
borderRadius: BorderRadius.circular(12),
@@ -610,9 +627,10 @@ class _AppShellState extends State<AppShell> {
/// 缩放控件:显示当前百分比并提供缩小 / 放大按钮。
Widget _zoomBox(Tokens t) {
final double s = _toolScale;
return Container(
height: 34,
padding: const EdgeInsets.symmetric(horizontal: 4),
height: 34 * s,
padding: EdgeInsets.symmetric(horizontal: 4 * s),
decoration: BoxDecoration(
color: t.panel,
borderRadius: BorderRadius.circular(9),
@@ -622,9 +640,9 @@ class _AppShellState extends State<AppShell> {
children: <Widget>[
_miniIcon(t, Icons.remove, () => c.zoomBy(0.9)),
SizedBox(
width: 52,
width: 52 * s,
child: Text('${(c.project.viewState.zoom * 100).round()}%',
textAlign: TextAlign.center, style: TextStyle(color: t.text, fontSize: 11)),
textAlign: TextAlign.center, style: TextStyle(color: t.text, fontSize: _toolFont(11))),
),
_miniIcon(t, Icons.add, () => c.zoomBy(1.1)),
],
@@ -638,17 +656,18 @@ class _AppShellState extends State<AppShell> {
onTap: onTap,
borderRadius: BorderRadius.circular(6),
child: Padding(
padding: const EdgeInsets.all(6),
child: Icon(icon, size: 15, color: t.sub),
padding: EdgeInsets.all(6 * _toolScale),
child: Icon(icon, size: 15 * _toolScale, color: t.sub),
),
);
}
/// 时间单位下拉框:切换 ms / s / min。
Widget _unitDropdown(Tokens t) {
final double s = _toolScale;
return Container(
height: 34,
padding: const EdgeInsets.symmetric(horizontal: 10),
height: 34 * s,
padding: EdgeInsets.symmetric(horizontal: 10 * s),
decoration: BoxDecoration(
color: t.panel,
borderRadius: BorderRadius.circular(9),
@@ -659,8 +678,8 @@ class _AppShellState extends State<AppShell> {
underline: const SizedBox.shrink(),
dropdownColor: t.dialog,
borderRadius: BorderRadius.circular(9),
style: TextStyle(color: t.accent, fontSize: 11, fontWeight: FontWeight.w600),
icon: Icon(Icons.keyboard_arrow_down, color: t.accent, size: 18),
style: TextStyle(color: t.accent, fontSize: _toolFont(11), fontWeight: FontWeight.w600),
icon: Icon(Icons.keyboard_arrow_down, color: t.accent, size: 18 * s),
items: TimeUnit.values
.map((TimeUnit u) => DropdownMenuItem<TimeUnit>(value: u, child: Text(timeUnitLabel(u))))
.toList(),
@@ -679,21 +698,21 @@ class _AppShellState extends State<AppShell> {
onTap: onTap,
borderRadius: BorderRadius.circular(8),
child: Container(
width: 32,
height: 26,
width: 32 * _toolScale,
height: 26 * _toolScale,
alignment: Alignment.center,
decoration: BoxDecoration(
color: active ? t.accent.withValues(alpha: 0.18) : Colors.transparent,
borderRadius: BorderRadius.circular(8),
border: active ? Border.all(color: t.accent, width: 1.2) : null,
),
child: Icon(icon, size: 16, color: active ? t.accent : t.dim),
child: Icon(icon, size: 16 * _toolScale, color: active ? t.accent : t.dim),
),
);
}
return Container(
padding: const EdgeInsets.all(4),
padding: EdgeInsets.all(4 * _toolScale),
decoration: BoxDecoration(
color: t.panel,
borderRadius: BorderRadius.circular(10),
@@ -715,73 +734,82 @@ class _AppShellState extends State<AppShell> {
);
}
/// 次要(幽灵)样式按钮;[onTap] 为 null 时呈禁用态。
/// 次要(幽灵)样式按钮;[onTap] 为 null 时呈禁用态;尺寸随 [_toolScale] 缩放。
Widget _ghost(Tokens t, String label, VoidCallback? onTap, {IconData? icon}) {
final double s = _toolScale;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 3),
padding: EdgeInsets.symmetric(horizontal: 3 * s),
child: TextButton.icon(
onPressed: onTap,
icon: icon == null ? null : Icon(icon, size: 16, color: onTap == null ? t.dim : t.text),
label: Text(label, style: TextStyle(fontSize: 11, color: onTap == null ? t.dim : t.text)),
icon: icon == null ? null : Icon(icon, size: 16 * s, color: onTap == null ? t.dim : t.text),
label: Text(label, style: TextStyle(fontSize: _toolFont(11), color: onTap == null ? t.dim : t.text)),
style: TextButton.styleFrom(
backgroundColor: t.panel,
side: BorderSide(color: t.line2),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(9)),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
minimumSize: const Size(0, 34),
padding: EdgeInsets.symmetric(horizontal: 12 * s, vertical: 10 * s),
minimumSize: Size(0, 34 * s),
tapTargetSize: s < 1 ? MaterialTapTargetSize.shrinkWrap : null,
),
),
);
}
/// 主色填充按钮(用于导出等主要动作);[onTap] 为 null 时禁用(置灰)。
/// 主色填充按钮(用于导出等主要动作);[onTap] 为 null 时禁用(置灰);
/// 尺寸随 [_toolScale] 缩放。
Widget _primaryBtn(Tokens t, String label, VoidCallback? onTap) {
final bool enabled = onTap != null;
final double s = _toolScale;
return FilledButton(
onPressed: onTap,
style: FilledButton.styleFrom(
backgroundColor: enabled ? t.accent2 : t.panel2,
foregroundColor: enabled ? Colors.white : t.dim,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(9)),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
minimumSize: const Size(0, 34),
padding: EdgeInsets.symmetric(horizontal: 16 * s, vertical: 10 * s),
minimumSize: Size(0, 34 * s),
tapTargetSize: s < 1 ? MaterialTapTargetSize.shrinkWrap : null,
),
child: Text(label, style: const TextStyle(fontSize: 11, fontWeight: FontWeight.w600)),
child: Text(label, style: TextStyle(fontSize: _toolFont(11), fontWeight: FontWeight.w600)),
);
}
/// AI 生成按钮:打开「自然语言 → 时序图」对话框。
/// AI 生成按钮:打开「自然语言 → 时序图」对话框;尺寸随 [_toolScale] 缩放。
Widget _aiBtn(Tokens t) {
final double s = _toolScale;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 3),
padding: EdgeInsets.symmetric(horizontal: 3 * s),
child: FilledButton.icon(
onPressed: () => showDialog<void>(
context: context,
builder: (_) => AiGenerateDialog(controller: c),
),
icon: const Icon(Icons.auto_awesome, size: 16),
label: const Text('AI 生成', style: TextStyle(fontSize: 12, fontWeight: FontWeight.w700)),
icon: Icon(Icons.auto_awesome, size: 16 * s),
label: Text('AI 生成', style: TextStyle(fontSize: _toolFont(12), fontWeight: FontWeight.w700)),
style: FilledButton.styleFrom(
backgroundColor: t.accent2,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(9)),
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
minimumSize: const Size(0, 34),
padding: EdgeInsets.symmetric(horizontal: 10 * s, vertical: 8 * s),
minimumSize: Size(0, 34 * s),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
),
);
}
/// 图标按钮,可附带 tooltip 与自定义颜色;尺寸紧凑以节省工具栏宽度。
/// 图标按钮,可附带 tooltip 与自定义颜色;尺寸随 [_toolScale] 缩放,
/// 触屏平台收紧点按区域,避免默认 48dp 目标把工具栏撑满。
Widget _iconBtn(Tokens t, IconData icon, VoidCallback? onTap, {String? tooltip, Color? color}) {
final double s = _toolScale;
return IconButton(
onPressed: onTap,
icon: Icon(icon, size: 18, color: onTap == null ? t.dim : (color ?? t.text)),
icon: Icon(icon, size: 18 * s, color: onTap == null ? t.dim : (color ?? t.text)),
tooltip: tooltip,
splashRadius: 16,
splashRadius: 16 * s,
padding: EdgeInsets.zero,
constraints: const BoxConstraints(minWidth: 34, minHeight: 34),
constraints: BoxConstraints(minWidth: 34 * s, minHeight: 34 * s),
tapTargetSize: s < 1 ? MaterialTapTargetSize.shrinkWrap : null,
);
}
+9 -9
View File
@@ -493,7 +493,7 @@ class _SaveLocationDialogState extends State<SaveLocationDialog> {
),
),
const SizedBox(height: 10),
Text('保存、导出、打开都使用该目录;位于平板「文件管理」可见的公共存储。',
Text('保存、导出、打开都使用该目录;文件位于「文件管理」可见的公共目录。',
style: TextStyle(color: t.dim, fontSize: 11, height: 1.5)),
],
),
@@ -605,7 +605,7 @@ class _AndroidFileDialogState extends State<AndroidFileDialog> {
Icon(Icons.folder_outlined, size: 15, color: t.accent),
const SizedBox(width: 6),
Expanded(
child: Text('平板存储 / ${AndroidDocs.location()} /',
child: Text('保存位置 / ${AndroidDocs.location()} /',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: t.dim, fontSize: 11)),
@@ -2087,7 +2087,7 @@ class HelpDialog extends StatelessWidget {
}
/// 「关于」页:软件信息 + 平台 / 授权状态 + 官网入口;
/// 桌面版追加授权指南(MAC 申请 .lic),平板版展示免授权与保存位置说明。
/// Windows 版追加授权指南(MAC 申请 .lic),安卓版展示免授权与保存位置说明。
Widget _about(BuildContext context, Tokens t) {
final bool android = AndroidDocs.isAvailable;
final LicenseInfo info = LicenseService.instance.info;
@@ -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.2(${android ? 'Android 平板版' : 'Windows 桌面版'})',
Text('V1.0.2(${android ? '安卓版' : 'Windows 版'})',
style: TextStyle(color: t.dim, fontSize: 12)),
],
),
@@ -2135,7 +2135,7 @@ class HelpDialog extends StatelessWidget {
row('设计人', '呆头鹅'),
row(
'授权状态',
android ? '已授权(平板版免授权)' : lic,
android ? '已授权(安卓版免授权)' : lic,
vc: (android || info.valid) ? t.ok : t.danger,
),
if (!android)
@@ -2193,7 +2193,7 @@ class HelpDialog extends StatelessWidget {
),
)
else
// 平板版说明:免授权 + 保存位置 + 反馈方式。
// 安卓版说明:免授权 + 保存位置 + 反馈方式。
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
@@ -2206,14 +2206,14 @@ class HelpDialog extends StatelessWidget {
children: <Widget>[
Row(
children: <Widget>[
Icon(Icons.tablet_android, size: 16, color: t.accent),
Icon(Icons.android, size: 16, color: t.accent),
const SizedBox(width: 6),
Text('平板版说明', style: TextStyle(color: t.accent, fontSize: 12.5, fontWeight: FontWeight.w600)),
Text('安卓版说明', style: TextStyle(color: t.accent, fontSize: 12.5, fontWeight: FontWeight.w600)),
],
),
const SizedBox(height: 8),
guideLine('本版面向应用商店分发,无需授权,全部功能可用。'),
guideLine('保存 / 导出文件位于平板「文件管理」可见的公共目录(默认 Documents/SequenceDiagram,'
guideLine('保存 / 导出文件位于「文件管理」可见的公共目录(默认 Documents/SequenceDiagram,'
'可在保存对话框中更改位置)。'),
guideLine('帮助与反馈:官网 sincos.cc 或邮箱 liuyu65@126.com。'),
],