PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.
Dart airdrop-alternativeclipboardclipboard-sharingclipboard-synccopy-pastecross-platformend-to-end-encryptionfile-syncfile-transferfluttergolanglinuxmacosnat-traversalp2pself-hostedtailscaleuniversal-clipboardwebrtcwindows
feat(ui): add themes, a pixel theme and appearance settings
baiyuze3f430ecf936e
diff --git a/tools/pixel-theme/build_assets.py b/tools/pixel-theme/build_assets.pynew file mode 100644index 0000000..d22d622--- /dev/null+++ b/tools/pixel-theme/build_assets.py@@ -0,0 +1,117 @@+"""生成像素主题打包进 App 的字体与图标,写到 ui/assets/fonts/。++ python3 tools/pixel-theme/build_assets.py <fusion-pixel 比例字体目录> <fusion-pixel 等宽字体目录> <pixelarticons 目录>++来源(解压后把目录传进来,不要在这些目录里运行脚本):++- 缝合像素字体 Fusion Pixel Font 2026.10.25,OFL-1.1:+ https://github.com/TakWolf/fusion-pixel-font/releases+ fusion-pixel-font-12px-proportional-otf 与 fusion-pixel-font-12px-monospaced-otf 两个 zip+- Pixelarticons 2.4.2,MIT:https://www.npmjs.com/package/pixelarticons(npm 包的 package/ 目录)++产出:++- FusionPixel12.otf:简体中文的比例字体。正文都用它,12px 时一个字形像素正好是一个逻辑像素。+- FusionPixel12Mono.otf:等宽字体,只留拉丁字母、数字和常用符号(配对码、指纹、地址),几 KB。++两个字体的字重都标成 700(字形不变):点阵字体没有粗体,界面里要粗体的地方+Flutter 会把笔画描粗一圈,点阵就糊了。标成粗体后,任何字重都直接用原字形。+- PixelIcons.ttf:界面用到的图标。原字体 16px 时一格是 1.33 个逻辑像素,画出来发虚;+ 这里把字形缩到 0.75 倍,并让格子落在整数位置上,16px 时一格正好一个逻辑像素。+- 两份许可证。++需要 fonttools:pip install fonttools+"""++import os+import re+import shutil+import sys++from fontTools import subset+from fontTools.pens.transformPen import TransformPen+from fontTools.pens.ttGlyphPen import TTGlyphPen+from fontTools.ttLib import TTFont++# AppIcons 里用到的 Pixelarticons 图标,名字见 pixelart-icons-font.css+ICONS = [+ "archive", "arrow-down", "arrow-down-circle", "arrow-up", "article", "cellular-signal-0", "check",+ "checkbox-on", "chevron-down", "chevron-left", "chevron-right", "chevrons-vertical", "circle-info",+ "circle-question", "clipboard-note", "clock", "close", "copy", "corner-down-left", "download", "file",+ "files", "filter", "folder", "gear", "globe", "image", "keyboard", "laptop", "link", "monitor",+ "more-horizontal", "pencil", "plus", "qr-code", "refresh", "reload", "search", "send", "share", "shield",+ "smartphone", "star", "target", "text-align-left", "trash", "user", "user-plus", "users",+ "warning-diamond", "x-solid", "cloud", "brush", "apple", "android", "app-windows", "linux",+]++# 等宽字体保留的字符+MONO_TEXT = "".join(chr(c) for c in range(0x20, 0x7F)) + "".join(chr(c) for c in range(0xA0, 0x100)) + "·•…—–‘’“”←↑→↓"+++def build_icons(src_dir, out_dir):+ css = open(os.path.join(src_dir, "fonts", "pixelart-icons-font.css"), encoding="utf-8").read()+ codepoints = {+ name: int(cp, 16)+ for name, cp in re.findall(r'\.pixelart-icons-font-([a-z0-9-]+)::before \{ content: "\\([0-9a-f]+)"; \}', css)+ }+ missing = [n for n in ICONS if n not in codepoints]+ if missing:+ sys.exit(f"Pixelarticons 里没有这些图标:{missing}")++ font = TTFont(os.path.join(src_dir, "fonts", "pixelart-icons-font.ttf"))+ em = font["head"].unitsPerEm # 1000:24 格的 SVG 网格,一个像素是 2 格+ cell = em / 12+ scale = 0.75+ # 原图标从 cell 处开始;缩放后让它从 3/16 em 开始,16px 时落在第 3 个逻辑像素上+ shift = 3 * em / 16 - cell * scale+ glyphs = font.getGlyphSet()+ cmap = font.getBestCmap()+ for cp in (codepoints[n] for n in ICONS):+ name = cmap[cp]+ pen = TTGlyphPen(glyphs)+ glyphs[name].draw(TransformPen(pen, (scale, 0, 0, scale, shift, shift)))+ font["glyf"][name] = pen.glyph()++ options = subset.Options()+ options.notdef_outline = True+ options.recalc_bounds = True+ sub = subset.Subsetter(options)+ sub.populate(unicodes=[codepoints[n] for n in ICONS])+ sub.subset(font)+ font.save(os.path.join(out_dir, "PixelIcons.ttf"))+ shutil.copy(os.path.join(src_dir, "LICENSE"), os.path.join(out_dir, "PixelIcons-LICENSE.txt"))+ for n in sorted(ICONS):+ print(f" {n}: 0x{codepoints[n]:x}")+++def mark_bold(path):+ font = TTFont(path)+ font["OS/2"].usWeightClass = 700+ font.save(path)+++def main():+ if len(sys.argv) != 4:+ sys.exit(__doc__)+ prop, mono, icons = sys.argv[1:]+ out = os.path.join(os.path.dirname(__file__), "..", "..", "ui", "assets", "fonts")+ os.makedirs(out, exist_ok=True)++ shutil.copy(os.path.join(prop, "fusion-pixel-12px-proportional-zh_hans.otf"), os.path.join(out, "FusionPixel12.otf"))+ mark_bold(os.path.join(out, "FusionPixel12.otf"))+ shutil.copy(os.path.join(prop, "OFL.txt"), os.path.join(out, "FusionPixel-OFL.txt"))++ options = subset.Options()+ options.layout_features = ["*"]+ font = TTFont(os.path.join(mono, "fusion-pixel-12px-monospaced-latin.otf"))+ sub = subset.Subsetter(options)+ sub.populate(text=MONO_TEXT)+ sub.subset(font)+ font.save(os.path.join(out, "FusionPixel12Mono.otf"))+ mark_bold(os.path.join(out, "FusionPixel12Mono.otf"))++ build_icons(icons, out)+++if __name__ == "__main__":+ main()diff --git a/ui/assets/fonts/FusionPixel-OFL.txt b/ui/assets/fonts/FusionPixel-OFL.txtnew file mode 100644index 0000000..0427d1d--- /dev/null+++ b/ui/assets/fonts/FusionPixel-OFL.txt@@ -0,0 +1,96 @@+Fusion Pixel Font+https://github.com/TakWolf/fusion-pixel-font++Copyright (c) 2022, TakWolf (https://takwolf.com).++This Font Software is licensed under the SIL Open Font License, Version 1.1.+This license is copied below, and is also available with a FAQ at:+https://openfontlicense.org+++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/ui/assets/fonts/FusionPixel12.otf b/ui/assets/fonts/FusionPixel12.otfnew file mode 100644index 0000000..42435beBinary files /dev/null and b/ui/assets/fonts/FusionPixel12.otf differdiff --git a/ui/assets/fonts/FusionPixel12Mono.otf b/ui/assets/fonts/FusionPixel12Mono.otfnew file mode 100644index 0000000..f244abdBinary files /dev/null and b/ui/assets/fonts/FusionPixel12Mono.otf differdiff --git a/ui/assets/fonts/PixelIcons-LICENSE.txt b/ui/assets/fonts/PixelIcons-LICENSE.txtnew file mode 100644index 0000000..4be35e8--- /dev/null+++ b/ui/assets/fonts/PixelIcons-LICENSE.txt@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2019 Gerrit Halfmann++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/ui/assets/fonts/PixelIcons.ttf b/ui/assets/fonts/PixelIcons.ttfnew file mode 100644index 0000000..ad342acBinary files /dev/null and b/ui/assets/fonts/PixelIcons.ttf differdiff --git a/ui/lib/app_state.dart b/ui/lib/app_state.dartindex d248260..4b0616f 100644--- a/ui/lib/app_state.dart+++ b/ui/lib/app_state.dart@@ -8,6 +8,7 @@ import 'background_service.dart';import 'daemon_client.dart';import 'i18n.dart';import 'quick_paste_service.dart';+import 'theme_controller.dart';import 'gen/pasteferry/v1/daemon.pb.dart';import 'gen/pasteferry/v1/daemon.pbgrpc.dart' show DaemonServiceClient;import 'widgets/record_hover.dart' show RecordDetails;@@ -64,6 +65,9 @@ class AppState extends ChangeNotifier implements RecordDetails {final Future<DaemonConnection> Function() _connectDaemon;+ /// 主题与深浅模式,见 theme_controller.dart+ final theme = ThemeController();+DaemonConnection? _conn;StreamSubscription<Event>? _events;Timer? _retry;@@ -371,6 +375,7 @@ class AppState extends ChangeNotifier implements RecordDetails {_favoriteSearch.dispose();_events?.cancel();_conn?.close();+ theme.dispose();super.dispose();}@@ -427,6 +432,7 @@ class AppState extends ChangeNotifier implements RecordDetails {(results[3] as ListHistoryResponse).records.where((r) => r.favorite),);await Future.wait([+ theme.attach(conn.client, _config!),_loadQuickPasteStatus(),_loadDevices(),_loadFriends(),@@ -701,6 +707,7 @@ class AppState extends ChangeNotifier implements RecordDetails {_events = null;_conn?.close();_conn = null;+ theme.detach();_setLink(LinkState.offline, message);// daemon 可能正在重启,自动重连省去用户手动操作_retry = Timer(const Duration(seconds: 3), connect);@@ -745,6 +752,10 @@ class AppState extends ChangeNotifier implements RecordDetails {case Event_Payload.configChanged:// 别处(快捷窗口、另一个界面窗口)改了设置_config = ev.configChanged;+ theme.applyConfig(ev.configChanged);++ case Event_Payload.themesChanged:+ theme.onThemesChanged(ev.themesChanged);case Event_Payload.quickPasteChanged:_quickPaste = ev.quickPasteChanged;diff --git a/ui/lib/icons.dart b/ui/lib/icons.dartindex bb78255..86b6d1a 100644--- a/ui/lib/icons.dart+++ b/ui/lib/icons.dart@@ -1,6 +1,7 @@import 'dart:io';import 'package:flutter/cupertino.dart';+import 'package:flutter/material.dart' show Icons;import 'package:fluentui_system_icons/fluentui_system_icons.dart';/// 界面用到的图标:Mac 上是 Cupertino 图标,Windows 上是微软的 Fluent 图标,@@ -8,76 +9,145 @@ import 'package:fluentui_system_icons/fluentui_system_icons.dart';abstract final class AppIcons {static final bool _win = !Platform.isMacOS;- static IconData _pick(IconData mac, IconData windows) => _win ? windows : mac;+ /// 当前主题用像素图标([AppThemeSpec.pixelIcons])。界面最外层按主题设置,换主题时整个界面重建+ static bool pixel = false;- static IconData get clock => _pick(CupertinoIcons.clock, FluentIcons.history_24_regular);- static IconData get deviceLaptop => _pick(CupertinoIcons.device_laptop, FluentIcons.laptop_24_regular);- static IconData get desktopComputer => _pick(CupertinoIcons.desktopcomputer, FluentIcons.desktop_24_regular);- static IconData get gear => _pick(CupertinoIcons.gear, FluentIcons.settings_24_regular);+ static IconData _pick(IconData mac, IconData windows, IconData pixelIcon) =>+ pixel ? pixelIcon : (_win ? windows : mac);++ static IconData get clock => _pick(CupertinoIcons.clock, FluentIcons.history_24_regular, PixelIcons.clock);+ static IconData get deviceLaptop => _pick(CupertinoIcons.device_laptop, FluentIcons.laptop_24_regular, PixelIcons.laptop);+ static IconData get desktopComputer => _pick(CupertinoIcons.desktopcomputer, FluentIcons.desktop_24_regular, PixelIcons.monitor);+ static IconData get gear => _pick(CupertinoIcons.gear, FluentIcons.settings_24_regular, PixelIcons.gear);static IconData get exclamationmarkCircle =>- _pick(CupertinoIcons.exclamationmark_circle, FluentIcons.error_circle_24_regular);- static IconData get trash => _pick(CupertinoIcons.trash, FluentIcons.delete_24_regular);- static IconData get checkmark => _pick(CupertinoIcons.checkmark, FluentIcons.checkmark_24_regular);+ _pick(CupertinoIcons.exclamationmark_circle, FluentIcons.error_circle_24_regular, PixelIcons.warningDiamond);+ static IconData get trash => _pick(CupertinoIcons.trash, FluentIcons.delete_24_regular, PixelIcons.trash);+ static IconData get checkmark => _pick(CupertinoIcons.checkmark, FluentIcons.checkmark_24_regular, PixelIcons.check);static IconData get checkmarkCircle =>- _pick(CupertinoIcons.checkmark_circle, FluentIcons.checkmark_circle_24_regular);- static IconData get xmark => _pick(CupertinoIcons.xmark, FluentIcons.dismiss_24_regular);- static IconData get search => _pick(CupertinoIcons.search, FluentIcons.search_24_regular);+ _pick(CupertinoIcons.checkmark_circle, FluentIcons.checkmark_circle_24_regular, PixelIcons.checkboxOn);+ static IconData get xmark => _pick(CupertinoIcons.xmark, FluentIcons.dismiss_24_regular, PixelIcons.close);+ static IconData get search => _pick(CupertinoIcons.search, FluentIcons.search_24_regular, PixelIcons.search);static IconData get arrowDownCircle =>- _pick(CupertinoIcons.arrow_down_circle, FluentIcons.arrow_circle_down_24_regular);- static IconData get pencil => _pick(CupertinoIcons.pencil, FluentIcons.edit_24_regular);+ _pick(CupertinoIcons.arrow_down_circle, FluentIcons.arrow_circle_down_24_regular, PixelIcons.arrowDownCircle);+ static IconData get pencil => _pick(CupertinoIcons.pencil, FluentIcons.edit_24_regular, PixelIcons.pencil);static IconData get arrowClockwise =>- _pick(CupertinoIcons.arrow_clockwise, FluentIcons.arrow_clockwise_24_regular);+ _pick(CupertinoIcons.arrow_clockwise, FluentIcons.arrow_clockwise_24_regular, PixelIcons.reload);// 搜索框里的清除按钮:实心圆里一个叉,与系统的搜索框一致static IconData get clearField =>- _pick(CupertinoIcons.xmark_circle_fill, FluentIcons.dismiss_circle_20_filled);+ _pick(CupertinoIcons.xmark_circle_fill, FluentIcons.dismiss_circle_20_filled, PixelIcons.xSolid);static IconData get textAlignLeft =>- _pick(CupertinoIcons.text_alignleft, FluentIcons.text_align_left_24_regular);+ _pick(CupertinoIcons.text_alignleft, FluentIcons.text_align_left_24_regular, PixelIcons.textAlignLeft);static IconData get questionCircle =>- _pick(CupertinoIcons.question_circle, FluentIcons.question_circle_24_regular);- static IconData get plus => _pick(CupertinoIcons.plus, FluentIcons.add_24_regular);+ _pick(CupertinoIcons.question_circle, FluentIcons.question_circle_24_regular, PixelIcons.circleQuestion);+ static IconData get plus => _pick(CupertinoIcons.plus, FluentIcons.add_24_regular, PixelIcons.plus);static IconData get radar =>- _pick(CupertinoIcons.dot_radiowaves_left_right, FluentIcons.radar_20_regular);- static IconData get photo => _pick(CupertinoIcons.photo, FluentIcons.image_24_regular);- static IconData get lockShield => _pick(CupertinoIcons.lock_shield, FluentIcons.shield_lock_24_regular);+ _pick(CupertinoIcons.dot_radiowaves_left_right, FluentIcons.radar_20_regular, PixelIcons.target);+ static IconData get photo => _pick(CupertinoIcons.photo, FluentIcons.image_24_regular, PixelIcons.image);+ static IconData get lockShield => _pick(CupertinoIcons.lock_shield, FluentIcons.shield_lock_24_regular, PixelIcons.shield);static IconData get filter =>- _pick(CupertinoIcons.line_horizontal_3_decrease, FluentIcons.filter_24_regular);- static IconData get folder => _pick(CupertinoIcons.folder, FluentIcons.folder_24_regular);- static IconData get ellipsis => _pick(CupertinoIcons.ellipsis, FluentIcons.more_horizontal_24_regular);+ _pick(CupertinoIcons.line_horizontal_3_decrease, FluentIcons.filter_24_regular, PixelIcons.filter);+ static IconData get folder => _pick(CupertinoIcons.folder, FluentIcons.folder_24_regular, PixelIcons.folder);+ static IconData get ellipsis => _pick(CupertinoIcons.ellipsis, FluentIcons.more_horizontal_24_regular, PixelIcons.moreHorizontal);static IconData get docRichtext =>- _pick(CupertinoIcons.doc_richtext, FluentIcons.document_text_24_regular);- static IconData get docOnDoc => _pick(CupertinoIcons.doc_on_doc, FluentIcons.copy_24_regular);+ _pick(CupertinoIcons.doc_richtext, FluentIcons.document_text_24_regular, PixelIcons.article);+ static IconData get docOnDoc => _pick(CupertinoIcons.doc_on_doc, FluentIcons.copy_24_regular, PixelIcons.files);static IconData get docOnClipboard =>- _pick(CupertinoIcons.doc_on_clipboard, FluentIcons.clipboard_paste_24_regular);- static IconData get doc => _pick(CupertinoIcons.doc, FluentIcons.document_24_regular);- static IconData get chevronLeft => _pick(CupertinoIcons.chevron_left, FluentIcons.chevron_left_24_regular);- static IconData get chevronRight => _pick(CupertinoIcons.chevron_right, FluentIcons.chevron_right_24_regular);- static IconData get chevronDown => _pick(CupertinoIcons.chevron_down, FluentIcons.chevron_down_24_regular);- static IconData get person => _pick(CupertinoIcons.person, FluentIcons.person_24_regular);- static IconData get people => _pick(CupertinoIcons.person_2, FluentIcons.people_24_regular);- static IconData get personAdd => _pick(CupertinoIcons.person_badge_plus, FluentIcons.person_add_24_regular);+ _pick(CupertinoIcons.doc_on_clipboard, FluentIcons.clipboard_paste_24_regular, PixelIcons.clipboardNote);+ static IconData get doc => _pick(CupertinoIcons.doc, FluentIcons.document_24_regular, PixelIcons.file);+ static IconData get chevronLeft => _pick(CupertinoIcons.chevron_left, FluentIcons.chevron_left_24_regular, PixelIcons.chevronLeft);+ static IconData get chevronRight => _pick(CupertinoIcons.chevron_right, FluentIcons.chevron_right_24_regular, PixelIcons.chevronRight);+ static IconData get chevronDown => _pick(CupertinoIcons.chevron_down, FluentIcons.chevron_down_24_regular, PixelIcons.chevronDown);+ static IconData get person => _pick(CupertinoIcons.person, FluentIcons.person_24_regular, PixelIcons.user);+ static IconData get people => _pick(CupertinoIcons.person_2, FluentIcons.people_24_regular, PixelIcons.users);+ static IconData get personAdd => _pick(CupertinoIcons.person_badge_plus, FluentIcons.person_add_24_regular, PixelIcons.userPlus);static IconData get chevronUpDown =>- _pick(CupertinoIcons.chevron_up_chevron_down, FluentIcons.chevron_up_down_24_regular);- static IconData get link => _pick(CupertinoIcons.link, FluentIcons.link_24_regular);+ _pick(CupertinoIcons.chevron_up_chevron_down, FluentIcons.chevron_up_down_24_regular, PixelIcons.chevronsVertical);+ static IconData get link => _pick(CupertinoIcons.link, FluentIcons.link_24_regular, PixelIcons.link);// 设置首页各类别- static IconData get globe => _pick(CupertinoIcons.globe, FluentIcons.globe_24_regular);- static IconData get sync => _pick(CupertinoIcons.arrow_2_circlepath, FluentIcons.arrow_sync_24_regular);- static IconData get archive => _pick(CupertinoIcons.archivebox, FluentIcons.archive_24_regular);- static IconData get info => _pick(CupertinoIcons.info_circle, FluentIcons.info_24_regular);- static IconData get star => _pick(CupertinoIcons.star, FluentIcons.star_24_regular);- static IconData get starFill => _pick(CupertinoIcons.star_fill, FluentIcons.star_24_filled);- static IconData get keyboard => _pick(CupertinoIcons.keyboard, FluentIcons.keyboard_24_regular);+ static IconData get globe => _pick(CupertinoIcons.globe, FluentIcons.globe_24_regular, PixelIcons.globe);+ static IconData get sync => _pick(CupertinoIcons.arrow_2_circlepath, FluentIcons.arrow_sync_24_regular, PixelIcons.refresh);+ static IconData get archive => _pick(CupertinoIcons.archivebox, FluentIcons.archive_24_regular, PixelIcons.archive);+ static IconData get info => _pick(CupertinoIcons.info_circle, FluentIcons.info_24_regular, PixelIcons.circleInfo);+ static IconData get star => _pick(CupertinoIcons.star, FluentIcons.star_24_regular, PixelIcons.star);+ static IconData get starFill => _pick(CupertinoIcons.star_fill, FluentIcons.star_24_filled, PixelIcons.star);+ static IconData get keyboard => _pick(CupertinoIcons.keyboard, FluentIcons.keyboard_24_regular, PixelIcons.keyboard);// 回车键:快捷窗口底栏的按键提示里用。字符 ↩ 在 Mac 上会被画成彩色 emoji,所以用图标// 隔空传送:侧边栏的纸飞机,列表里收到(向下)与发出(向上)- static IconData get send => _pick(CupertinoIcons.paperplane, FluentIcons.send_24_regular);- static IconData get arrowDown => _pick(CupertinoIcons.arrow_down, FluentIcons.arrow_down_24_regular);- static IconData get arrowUp => _pick(CupertinoIcons.arrow_up, FluentIcons.arrow_up_24_regular);- static IconData get returnKey => _pick(CupertinoIcons.return_icon, FluentIcons.arrow_enter_left_20_regular);+ static IconData get send => _pick(CupertinoIcons.paperplane, FluentIcons.send_24_regular, PixelIcons.send);+ static IconData get arrowDown => _pick(CupertinoIcons.arrow_down, FluentIcons.arrow_down_24_regular, PixelIcons.arrowDown);+ static IconData get arrowUp => _pick(CupertinoIcons.arrow_up, FluentIcons.arrow_up_24_regular, PixelIcons.arrowUp);+ static IconData get returnKey => _pick(CupertinoIcons.return_icon, FluentIcons.arrow_enter_left_20_regular, PixelIcons.cornerDownLeft);// 手机网页传输- static IconData get phone => _pick(CupertinoIcons.device_phone_portrait, FluentIcons.phone_24_regular);- static IconData get qrCode => _pick(CupertinoIcons.qrcode, FluentIcons.qr_code_24_regular);+ static IconData get phone => _pick(CupertinoIcons.device_phone_portrait, FluentIcons.phone_24_regular, PixelIcons.smartphone);+ static IconData get qrCode => _pick(CupertinoIcons.qrcode, FluentIcons.qr_code_24_regular, PixelIcons.qrCode);// Android App- static IconData get copy => _pick(CupertinoIcons.doc_on_doc, FluentIcons.copy_24_regular);- static IconData get share => _pick(CupertinoIcons.share, FluentIcons.share_android_24_regular);- static IconData get download => _pick(CupertinoIcons.arrow_down_to_line, FluentIcons.arrow_download_24_regular);- static IconData get wifiOff => _pick(CupertinoIcons.wifi_slash, FluentIcons.wifi_off_24_regular);+ static IconData get copy => _pick(CupertinoIcons.doc_on_doc, FluentIcons.copy_24_regular, PixelIcons.copy);+ static IconData get share => _pick(CupertinoIcons.share, FluentIcons.share_android_24_regular, PixelIcons.share);+ static IconData get download => _pick(CupertinoIcons.arrow_down_to_line, FluentIcons.arrow_download_24_regular, PixelIcons.download);+ // 设置里的「外观」+ static IconData get paint =>+ _pick(CupertinoIcons.paintbrush, FluentIcons.paint_brush_24_regular, PixelIcons.brush);+ // 侧边栏的「服务」:两个平台都用 Material 的云+ static IconData get cloud => pixel ? PixelIcons.cloud : Icons.cloud_outlined;+ static IconData get wifiOff => _pick(CupertinoIcons.wifi_slash, FluentIcons.wifi_off_24_regular, PixelIcons.cellularSignal0);+}++/// 像素主题的图标:Pixelarticons(MIT),由 tools/pixel-theme/build_assets.py 挑出界面用到的几十个,+/// 缩放到 16px 时一格正好一个逻辑像素。+abstract final class PixelIcons {+ static const _family = 'PixelIcons';++ static const archive = IconData(0xea58, fontFamily: _family);+ static const arrowDown = IconData(0xea6d, fontFamily: _family);+ static const arrowDownCircle = IconData(0xea67, fontFamily: _family);+ static const arrowUp = IconData(0xea7a, fontFamily: _family);+ static const article = IconData(0xea7e, fontFamily: _family);+ static const cellularSignal0 = IconData(0xeafa, fontFamily: _family);+ static const check = IconData(0xeb0a, fontFamily: _family);+ static const checkboxOn = IconData(0xeb0c, fontFamily: _family);+ static const chevronDown = IconData(0xeb12, fontFamily: _family);+ static const chevronLeft = IconData(0xeb14, fontFamily: _family);+ static const chevronRight = IconData(0xeb16, fontFamily: _family);+ static const chevronsVertical = IconData(0xeb1c, fontFamily: _family);+ static const circleInfo = IconData(0xeb20, fontFamily: _family);+ static const circleQuestion = IconData(0xeb24, fontFamily: _family);+ static const clipboardNote = IconData(0xeb2c, fontFamily: _family);+ static const clock = IconData(0xeb2f, fontFamily: _family);+ static const brush = IconData(0xead5, fontFamily: _family);+ static const close = IconData(0xeb30, fontFamily: _family);+ static const cloud = IconData(0xeb34, fontFamily: _family);+ static const copy = IconData(0xeb49, fontFamily: _family);+ static const cornerDownLeft = IconData(0xeb4b, fontFamily: _family);+ static const download = IconData(0xeb7f, fontFamily: _family);+ static const file = IconData(0xeb9a, fontFamily: _family);+ static const files = IconData(0xeb9c, fontFamily: _family);+ static const filter = IconData(0xeb9d, fontFamily: _family);+ static const folder = IconData(0xebad, fontFamily: _family);+ static const gear = IconData(0xebb7, fontFamily: _family);+ static const globe = IconData(0xebc6, fontFamily: _family);+ static const image = IconData(0xebfb, fontFamily: _family);+ static const keyboard = IconData(0xec15, fontFamily: _family);+ static const laptop = IconData(0xec1e, fontFamily: _family);+ static const link = IconData(0xec5f, fontFamily: _family);+ static const monitor = IconData(0xeca0, fontFamily: _family);+ static const moreHorizontal = IconData(0xeca3, fontFamily: _family);+ static const pencil = IconData(0xecc5, fontFamily: _family);+ static const plus = IconData(0xecd8, fontFamily: _family);+ static const qrCode = IconData(0xece9, fontFamily: _family);+ static const refresh = IconData(0xecf8, fontFamily: _family);+ static const reload = IconData(0xecfa, fontFamily: _family);+ static const search = IconData(0xed18, fontFamily: _family);+ static const send = IconData(0xed1e, fontFamily: _family);+ static const share = IconData(0xed27, fontFamily: _family);+ static const shield = IconData(0xed29, fontFamily: _family);+ static const smartphone = IconData(0xed41, fontFamily: _family);+ static const star = IconData(0xed6d, fontFamily: _family);+ static const target = IconData(0xed8a, fontFamily: _family);+ static const textAlignLeft = IconData(0xeda0, fontFamily: _family);+ static const trash = IconData(0xedbe, fontFamily: _family);+ static const user = IconData(0xeddf, fontFamily: _family);+ static const userPlus = IconData(0xeddb, fontFamily: _family);+ static const users = IconData(0xede1, fontFamily: _family);+ static const warningDiamond = IconData(0xedf6, fontFamily: _family);+ static const xSolid = IconData(0xee05, fontFamily: _family);}diff --git a/ui/lib/l10n/app_en.arb b/ui/lib/l10n/app_en.arbindex f0fefca..60b5929 100644--- a/ui/lib/l10n/app_en.arb+++ b/ui/lib/l10n/app_en.arb@@ -1766,5 +1766,40 @@"mMultiSelectHint": "Select several photos at once. In Files, touch and hold an item to select more.","webSendFiles": "Send files","webFilesQueued": "Added to web transfers. Open Send Files on your phone to download.",- "webFilesLimit": "Web downloads support up to 200 MB per file and 64 files per batch."+ "webFilesLimit": "Web downloads support up to 200 MB per file and 64 files per batch.",+ "appearance": "Appearance",+ "settingsAppearanceSummary": "Theme, light and dark",+ "themeTitle": "Theme",+ "themeDefault": "Default",+ "themePixel": "Pixel",+ "themeMode": "Light and dark",+ "themeModeSystem": "Match system",+ "themeModeLight": "Light",+ "themeModeDark": "Dark",+ "themeCustom": "Custom",+ "themeDelete": "Delete theme",+ "themeDeleteConfirm": "Delete the theme “{name}”?",+ "themeLowContrast": "Some text in this theme may be hard to read",+ "themeFootnote": "Themes apply only to this device, including Quick Paste. They are not synced to other devices.",+ "@themeDeleteConfirm": {"placeholders": {"name": {"type": "String"}}},+ "themeBuiltinGroup": "Built in",+ "themeCustomGroup": "Custom",+ "themeUse": "Use",+ "themeDuplicate": "Duplicate",+ "themeCopyName": "{name} copy",+ "themeExport": "Export…",+ "themeImport": "Import theme…",+ "themeImported": "Imported “{name}”",+ "themeImportedWarn": "Imported “{name}”. {count} text colors may be hard to read.",+ "themeExported": "Theme exported",+ "themeCustomEmpty": "No custom themes yet. Duplicate a built-in theme, import one, or ask an AI to make one.",+ "themeAskAi": "Ask AI to make a theme",+ "themeAskAiBody": "Add this MCP server to an AI app such as Claude or Cursor, then ask for a theme, for example “Make me a cyberpunk theme”. The AI reads the theme format, picks colors, checks contrast and applies the theme.",+ "themeAskAiCopy": "Copy configuration",+ "themeAskAiCopied": "Configuration copied",+ "themeScanlines": "Scanlines",+ "themeScanlinesDesc": "Overlay faint CRT scanlines on the window. Pixel themes only.",+ "@themeCopyName": {"placeholders": {"name": {"type": "String"}}},+ "@themeImported": {"placeholders": {"name": {"type": "String"}}},+ "@themeImportedWarn": {"placeholders": {"name": {"type": "String"}, "count": {"type": "int"}}}}diff --git a/ui/lib/l10n/app_ja.arb b/ui/lib/l10n/app_ja.arbindex 7e9bd1e..9cb3d27 100644--- a/ui/lib/l10n/app_ja.arb+++ b/ui/lib/l10n/app_ja.arb@@ -709,5 +709,36 @@"mMultiSelectHint": "写真は一度に複数選べます。ファイルは長押ししてから、ほかの項目も選択できます。","webSendFiles": "ファイルを送信","webFilesQueued": "Web 転送に追加しました。スマートフォンの「ファイル転送」でダウンロードできます。",- "webFilesLimit": "Web受信は1ファイル最大200 MB、1回64ファイルまでです。"+ "webFilesLimit": "Web受信は1ファイル最大200 MB、1回64ファイルまでです。",+ "appearance": "外観",+ "settingsAppearanceSummary": "テーマ、ライトとダーク",+ "themeTitle": "テーマ",+ "themeDefault": "デフォルト",+ "themePixel": "ピクセル",+ "themeMode": "ライトとダーク",+ "themeModeSystem": "システムに合わせる",+ "themeModeLight": "ライト",+ "themeModeDark": "ダーク",+ "themeCustom": "カスタム",+ "themeDelete": "テーマを削除",+ "themeDeleteConfirm": "テーマ「{name}」を削除しますか?",+ "themeLowContrast": "このテーマでは一部の文字が読みにくい場合があります",+ "themeFootnote": "テーマはこのデバイス(クイックペーストを含む)にのみ適用され、他のデバイスには同期されません。",+ "themeBuiltinGroup": "内蔵",+ "themeCustomGroup": "カスタム",+ "themeUse": "使用",+ "themeDuplicate": "複製",+ "themeCopyName": "{name} のコピー",+ "themeExport": "書き出す…",+ "themeImport": "テーマを読み込む…",+ "themeImported": "「{name}」を読み込みました",+ "themeImportedWarn": "「{name}」を読み込みました。{count} か所の文字色が読みにくい可能性があります",+ "themeExported": "テーマを書き出しました",+ "themeCustomEmpty": "カスタムテーマはまだありません。内蔵テーマを複製するか、読み込むか、AI に作ってもらいましょう。",+ "themeAskAi": "AI にテーマを作ってもらう",+ "themeAskAiBody": "この MCP サーバーを Claude や Cursor などの AI アプリに追加して、「サイバーパンク風のテーマを作って」のように頼んでください。AI がテーマの形式を読み、配色を決め、コントラストを確認して適用します。",+ "themeAskAiCopy": "設定をコピー",+ "themeAskAiCopied": "設定をコピーしました",+ "themeScanlines": "走査線",+ "themeScanlinesDesc": "ウインドウ全体に薄い CRT 走査線を重ねます。ピクセルテーマのみ"}diff --git a/ui/lib/l10n/app_localizations.dart b/ui/lib/l10n/app_localizations.dartindex c6efeea..e73d525 100644--- a/ui/lib/l10n/app_localizations.dart+++ b/ui/lib/l10n/app_localizations.dart@@ -4369,6 +4369,192 @@ abstract class AppLocalizations {/// In en, this message translates to:/// **'Web downloads support up to 200 MB per file and 64 files per batch.'**String get webFilesLimit;++ /// No description provided for @appearance.+ ///+ /// In en, this message translates to:+ /// **'Appearance'**+ String get appearance;++ /// No description provided for @settingsAppearanceSummary.+ ///+ /// In en, this message translates to:+ /// **'Theme, light and dark'**+ String get settingsAppearanceSummary;++ /// No description provided for @themeTitle.+ ///+ /// In en, this message translates to:+ /// **'Theme'**+ String get themeTitle;++ /// No description provided for @themeDefault.+ ///+ /// In en, this message translates to:+ /// **'Default'**+ String get themeDefault;++ /// No description provided for @themePixel.+ ///+ /// In en, this message translates to:+ /// **'Pixel'**+ String get themePixel;++ /// No description provided for @themeMode.+ ///+ /// In en, this message translates to:+ /// **'Light and dark'**+ String get themeMode;++ /// No description provided for @themeModeSystem.+ ///+ /// In en, this message translates to:+ /// **'Match system'**+ String get themeModeSystem;++ /// No description provided for @themeModeLight.+ ///+ /// In en, this message translates to:+ /// **'Light'**+ String get themeModeLight;++ /// No description provided for @themeModeDark.+ ///+ /// In en, this message translates to:+ /// **'Dark'**+ String get themeModeDark;++ /// No description provided for @themeCustom.+ ///+ /// In en, this message translates to:+ /// **'Custom'**+ String get themeCustom;++ /// No description provided for @themeDelete.+ ///+ /// In en, this message translates to:+ /// **'Delete theme'**+ String get themeDelete;++ /// No description provided for @themeDeleteConfirm.+ ///+ /// In en, this message translates to:+ /// **'Delete the theme “{name}”?'**+ String themeDeleteConfirm(String name);++ /// No description provided for @themeLowContrast.+ ///+ /// In en, this message translates to:+ /// **'Some text in this theme may be hard to read'**+ String get themeLowContrast;++ /// No description provided for @themeFootnote.+ ///+ /// In en, this message translates to:+ /// **'Themes apply only to this device, including Quick Paste. They are not synced to other devices.'**+ String get themeFootnote;++ /// No description provided for @themeBuiltinGroup.+ ///+ /// In en, this message translates to:+ /// **'Built in'**+ String get themeBuiltinGroup;++ /// No description provided for @themeCustomGroup.+ ///+ /// In en, this message translates to:+ /// **'Custom'**+ String get themeCustomGroup;++ /// No description provided for @themeUse.+ ///+ /// In en, this message translates to:+ /// **'Use'**+ String get themeUse;++ /// No description provided for @themeDuplicate.+ ///+ /// In en, this message translates to:+ /// **'Duplicate'**+ String get themeDuplicate;++ /// No description provided for @themeCopyName.+ ///+ /// In en, this message translates to:+ /// **'{name} copy'**+ String themeCopyName(String name);++ /// No description provided for @themeExport.+ ///+ /// In en, this message translates to:+ /// **'Export…'**+ String get themeExport;++ /// No description provided for @themeImport.+ ///+ /// In en, this message translates to:+ /// **'Import theme…'**+ String get themeImport;++ /// No description provided for @themeImported.+ ///+ /// In en, this message translates to:+ /// **'Imported “{name}”'**+ String themeImported(String name);++ /// No description provided for @themeImportedWarn.+ ///+ /// In en, this message translates to:+ /// **'Imported “{name}”. {count} text colors may be hard to read.'**+ String themeImportedWarn(String name, int count);++ /// No description provided for @themeExported.+ ///+ /// In en, this message translates to:+ /// **'Theme exported'**+ String get themeExported;++ /// No description provided for @themeCustomEmpty.+ ///+ /// In en, this message translates to:+ /// **'No custom themes yet. Duplicate a built-in theme, import one, or ask an AI to make one.'**+ String get themeCustomEmpty;++ /// No description provided for @themeAskAi.+ ///+ /// In en, this message translates to:+ /// **'Ask AI to make a theme'**+ String get themeAskAi;++ /// No description provided for @themeAskAiBody.+ ///+ /// In en, this message translates to:+ /// **'Add this MCP server to an AI app such as Claude or Cursor, then ask for a theme, for example “Make me a cyberpunk theme”. The AI reads the theme format, picks colors, checks contrast and applies the theme.'**+ String get themeAskAiBody;++ /// No description provided for @themeAskAiCopy.+ ///+ /// In en, this message translates to:+ /// **'Copy configuration'**+ String get themeAskAiCopy;++ /// No description provided for @themeAskAiCopied.+ ///+ /// In en, this message translates to:+ /// **'Configuration copied'**+ String get themeAskAiCopied;++ /// No description provided for @themeScanlines.+ ///+ /// In en, this message translates to:+ /// **'Scanlines'**+ String get themeScanlines;++ /// No description provided for @themeScanlinesDesc.+ ///+ /// In en, this message translates to:+ /// **'Overlay faint CRT scanlines on the window. Pixel themes only.'**+ String get themeScanlinesDesc;}class _AppLocalizationsDelegatediff --git a/ui/lib/l10n/app_localizations_en.dart b/ui/lib/l10n/app_localizations_en.dartindex bfe1e2a..700d493 100644--- a/ui/lib/l10n/app_localizations_en.dart+++ b/ui/lib/l10n/app_localizations_en.dart@@ -2672,4 +2672,109 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get webFilesLimit =>'Web downloads support up to 200 MB per file and 64 files per batch.';++ @override+ String get appearance => 'Appearance';++ @override+ String get settingsAppearanceSummary => 'Theme, light and dark';++ @override+ String get themeTitle => 'Theme';++ @override+ String get themeDefault => 'Default';++ @override+ String get themePixel => 'Pixel';++ @override+ String get themeMode => 'Light and dark';++ @override+ String get themeModeSystem => 'Match system';++ @override+ String get themeModeLight => 'Light';++ @override+ String get themeModeDark => 'Dark';++ @override+ String get themeCustom => 'Custom';++ @override+ String get themeDelete => 'Delete theme';++ @override+ String themeDeleteConfirm(String name) {+ return 'Delete the theme “$name”?';+ }++ @override+ String get themeLowContrast => 'Some text in this theme may be hard to read';++ @override+ String get themeFootnote =>+ 'Themes apply only to this device, including Quick Paste. They are not synced to other devices.';++ @override+ String get themeBuiltinGroup => 'Built in';++ @override+ String get themeCustomGroup => 'Custom';++ @override+ String get themeUse => 'Use';++ @override+ String get themeDuplicate => 'Duplicate';++ @override+ String themeCopyName(String name) {+ return '$name copy';+ }++ @override+ String get themeExport => 'Export…';++ @override+ String get themeImport => 'Import theme…';++ @override+ String themeImported(String name) {+ return 'Imported “$name”';+ }++ @override+ String themeImportedWarn(String name, int count) {+ return 'Imported “$name”. $count text colors may be hard to read.';+ }++ @override+ String get themeExported => 'Theme exported';++ @override+ String get themeCustomEmpty =>+ 'No custom themes yet. Duplicate a built-in theme, import one, or ask an AI to make one.';++ @override+ String get themeAskAi => 'Ask AI to make a theme';++ @override+ String get themeAskAiBody =>+ 'Add this MCP server to an AI app such as Claude or Cursor, then ask for a theme, for example “Make me a cyberpunk theme”. The AI reads the theme format, picks colors, checks contrast and applies the theme.';++ @override+ String get themeAskAiCopy => 'Copy configuration';++ @override+ String get themeAskAiCopied => 'Configuration copied';++ @override+ String get themeScanlines => 'Scanlines';++ @override+ String get themeScanlinesDesc =>+ 'Overlay faint CRT scanlines on the window. Pixel themes only.';}diff --git a/ui/lib/l10n/app_localizations_ja.dart b/ui/lib/l10n/app_localizations_ja.dartindex c49e624..e17641d 100644--- a/ui/lib/l10n/app_localizations_ja.dart+++ b/ui/lib/l10n/app_localizations_ja.dart@@ -2483,4 +2483,107 @@ class AppLocalizationsJa extends AppLocalizations {@overrideString get webFilesLimit => 'Web受信は1ファイル最大200 MB、1回64ファイルまでです。';++ @override+ String get appearance => '外観';++ @override+ String get settingsAppearanceSummary => 'テーマ、ライトとダーク';++ @override+ String get themeTitle => 'テーマ';++ @override+ String get themeDefault => 'デフォルト';++ @override+ String get themePixel => 'ピクセル';++ @override+ String get themeMode => 'ライトとダーク';++ @override+ String get themeModeSystem => 'システムに合わせる';++ @override+ String get themeModeLight => 'ライト';++ @override+ String get themeModeDark => 'ダーク';++ @override+ String get themeCustom => 'カスタム';++ @override+ String get themeDelete => 'テーマを削除';++ @override+ String themeDeleteConfirm(String name) {+ return 'テーマ「$name」を削除しますか?';+ }++ @override+ String get themeLowContrast => 'このテーマでは一部の文字が読みにくい場合があります';++ @override+ String get themeFootnote => 'テーマはこのデバイス(クイックペーストを含む)にのみ適用され、他のデバイスには同期されません。';++ @override+ String get themeBuiltinGroup => '内蔵';++ @override+ String get themeCustomGroup => 'カスタム';++ @override+ String get themeUse => '使用';++ @override+ String get themeDuplicate => '複製';++ @override+ String themeCopyName(String name) {+ return '$name のコピー';+ }++ @override+ String get themeExport => '書き出す…';++ @override+ String get themeImport => 'テーマを読み込む…';++ @override+ String themeImported(String name) {+ return '「$name」を読み込みました';+ }++ @override+ String themeImportedWarn(String name, int count) {+ return '「$name」を読み込みました。$count か所の文字色が読みにくい可能性があります';+ }++ @override+ String get themeExported => 'テーマを書き出しました';++ @override+ String get themeCustomEmpty =>+ 'カスタムテーマはまだありません。内蔵テーマを複製するか、読み込むか、AI に作ってもらいましょう。';++ @override+ String get themeAskAi => 'AI にテーマを作ってもらう';++ @override+ String get themeAskAiBody =>+ 'この MCP サーバーを Claude や Cursor などの AI アプリに追加して、「サイバーパンク風のテーマを作って」のように頼んでください。AI がテーマの形式を読み、配色を決め、コントラストを確認して適用します。';++ @override+ String get themeAskAiCopy => '設定をコピー';++ @override+ String get themeAskAiCopied => '設定をコピーしました';++ @override+ String get themeScanlines => '走査線';++ @override+ String get themeScanlinesDesc => 'ウインドウ全体に薄い CRT 走査線を重ねます。ピクセルテーマのみ';}diff --git a/ui/lib/l10n/app_localizations_zh.dart b/ui/lib/l10n/app_localizations_zh.dartindex 9b6b34d..6f19fa0 100644--- a/ui/lib/l10n/app_localizations_zh.dart+++ b/ui/lib/l10n/app_localizations_zh.dart@@ -2455,6 +2455,108 @@ class AppLocalizationsZh extends AppLocalizations {@overrideString get webFilesLimit => '网页收取单个文件上限 200 MB,一次最多 64 个文件。';++ @override+ String get appearance => '外观';++ @override+ String get settingsAppearanceSummary => '主题、浅色与深色';++ @override+ String get themeTitle => '主题';++ @override+ String get themeDefault => '默认';++ @override+ String get themePixel => '像素';++ @override+ String get themeMode => '浅色与深色';++ @override+ String get themeModeSystem => '跟随系统';++ @override+ String get themeModeLight => '浅色';++ @override+ String get themeModeDark => '深色';++ @override+ String get themeCustom => '自定义';++ @override+ String get themeDelete => '删除主题';++ @override+ String themeDeleteConfirm(String name) {+ return '删除主题「$name」?';+ }++ @override+ String get themeLowContrast => '这个主题里有些文字可能看不清';++ @override+ String get themeFootnote => '主题只用于这台设备(包括快捷粘贴窗口),不会同步到其他设备。';++ @override+ String get themeBuiltinGroup => '软件自带';++ @override+ String get themeCustomGroup => '自定义';++ @override+ String get themeUse => '使用';++ @override+ String get themeDuplicate => '复制一份';++ @override+ String themeCopyName(String name) {+ return '$name 副本';+ }++ @override+ String get themeExport => '导出…';++ @override+ String get themeImport => '导入主题…';++ @override+ String themeImported(String name) {+ return '已导入「$name」';+ }++ @override+ String themeImportedWarn(String name, int count) {+ return '已导入「$name」,有 $count 处文字颜色可能看不清';+ }++ @override+ String get themeExported => '主题已导出';++ @override+ String get themeCustomEmpty => '还没有自定义主题。复制一份自带主题,或者导入、让 AI 帮你做一套。';++ @override+ String get themeAskAi => '让 AI 帮你做主题';++ @override+ String get themeAskAiBody =>+ '把下面这个 MCP 服务加到 Claude、Cursor 等 AI 应用里,然后直接说「帮我做一套赛博朋克风的主题」。AI 会读取主题格式、配色、检查对比度,再把主题应用上。';++ @override+ String get themeAskAiCopy => '复制配置';++ @override+ String get themeAskAiCopied => '配置已复制';++ @override+ String get themeScanlines => '扫描线';++ @override+ String get themeScanlinesDesc => '整个窗口叠一层很淡的 CRT 扫描线,只在像素主题里有效';}/// The translations for Chinese, as used in Hong Kong, using the Han script (`zh_Hant_HK`).@@ -4908,6 +5010,108 @@ class AppLocalizationsZhHantHk extends AppLocalizationsZh {@overrideString get webFilesLimit => '網頁接收單一檔案上限 200 MB,一次最多 64 個檔案。';++ @override+ String get appearance => '外觀';++ @override+ String get settingsAppearanceSummary => '主題、淺色與深色';++ @override+ String get themeTitle => '主題';++ @override+ String get themeDefault => '預設';++ @override+ String get themePixel => '像素';++ @override+ String get themeMode => '淺色與深色';++ @override+ String get themeModeSystem => '跟隨系統';++ @override+ String get themeModeLight => '淺色';++ @override+ String get themeModeDark => '深色';++ @override+ String get themeCustom => '自訂';++ @override+ String get themeDelete => '刪除主題';++ @override+ String themeDeleteConfirm(String name) {+ return '刪除主題「$name」?';+ }++ @override+ String get themeLowContrast => '這個主題裡有些文字可能看不清楚';++ @override+ String get themeFootnote => '主題只用於這部裝置(包括快速貼上視窗),不會同步到其他裝置。';++ @override+ String get themeBuiltinGroup => '內置';++ @override+ String get themeCustomGroup => '自訂';++ @override+ String get themeUse => '使用';++ @override+ String get themeDuplicate => '複製一份';++ @override+ String themeCopyName(String name) {+ return '$name 副本';+ }++ @override+ String get themeExport => '匯出…';++ @override+ String get themeImport => '匯入主題…';++ @override+ String themeImported(String name) {+ return '已匯入「$name」';+ }++ @override+ String themeImportedWarn(String name, int count) {+ return '已匯入「$name」,有 $count 處文字顏色可能看不清楚';+ }++ @override+ String get themeExported => '主題已匯出';++ @override+ String get themeCustomEmpty => '還沒有自訂主題。複製一份內置主題,或者匯入、讓 AI 幫你做一套。';++ @override+ String get themeAskAi => '讓 AI 幫你做主題';++ @override+ String get themeAskAiBody =>+ '把下面這個 MCP 服務加到 Claude、Cursor 等 AI 應用程式裏,然後直接說「幫我做一套賽博朋克風的主題」。AI 會讀取主題格式、配色、檢查對比度,再把主題套用上。';++ @override+ String get themeAskAiCopy => '複製設定';++ @override+ String get themeAskAiCopied => '設定已複製';++ @override+ String get themeScanlines => '掃描線';++ @override+ String get themeScanlinesDesc => '整個視窗疊一層很淡的 CRT 掃描線,只在像素主題裏有效';}/// The translations for Chinese, as used in Taiwan, using the Han script (`zh_Hant_TW`).@@ -7361,4 +7565,106 @@ class AppLocalizationsZhHantTw extends AppLocalizationsZh {@overrideString get webFilesLimit => '網頁接收單一檔案上限 200 MB,一次最多 64 個檔案。';++ @override+ String get appearance => '外觀';++ @override+ String get settingsAppearanceSummary => '主題、淺色與深色';++ @override+ String get themeTitle => '主題';++ @override+ String get themeDefault => '預設';++ @override+ String get themePixel => '像素';++ @override+ String get themeMode => '淺色與深色';++ @override+ String get themeModeSystem => '跟隨系統';++ @override+ String get themeModeLight => '淺色';++ @override+ String get themeModeDark => '深色';++ @override+ String get themeCustom => '自訂';++ @override+ String get themeDelete => '刪除主題';++ @override+ String themeDeleteConfirm(String name) {+ return '刪除主題「$name」?';+ }++ @override+ String get themeLowContrast => '這個主題裡有些文字可能看不清楚';++ @override+ String get themeFootnote => '主題只用於這台裝置(包括快速貼上視窗),不會同步到其他裝置。';++ @override+ String get themeBuiltinGroup => '內建';++ @override+ String get themeCustomGroup => '自訂';++ @override+ String get themeUse => '使用';++ @override+ String get themeDuplicate => '複製一份';++ @override+ String themeCopyName(String name) {+ return '$name 副本';+ }++ @override+ String get themeExport => '匯出…';++ @override+ String get themeImport => '匯入主題…';++ @override+ String themeImported(String name) {+ return '已匯入「$name」';+ }++ @override+ String themeImportedWarn(String name, int count) {+ return '已匯入「$name」,有 $count 處文字顏色可能看不清楚';+ }++ @override+ String get themeExported => '主題已匯出';++ @override+ String get themeCustomEmpty => '還沒有自訂主題。複製一份內建主題,或者匯入、讓 AI 幫你做一套。';++ @override+ String get themeAskAi => '讓 AI 幫你做主題';++ @override+ String get themeAskAiBody =>+ '把下面這個 MCP 服務加到 Claude、Cursor 等 AI 應用程式裡,然後直接說「幫我做一套賽博龐克風的主題」。AI 會讀取主題格式、配色、檢查對比度,再把主題套用上。';++ @override+ String get themeAskAiCopy => '複製設定';++ @override+ String get themeAskAiCopied => '設定已複製';++ @override+ String get themeScanlines => '掃描線';++ @override+ String get themeScanlinesDesc => '整個視窗疊一層很淡的 CRT 掃描線,只在像素主題裡有效';}diff --git a/ui/lib/l10n/app_zh.arb b/ui/lib/l10n/app_zh.arbindex c0f9c49..93a5832 100644--- a/ui/lib/l10n/app_zh.arb+++ b/ui/lib/l10n/app_zh.arb@@ -709,5 +709,36 @@"mMultiSelectHint": "照片可以一次多选;文件可长按一项后,再勾选其他项。","webSendFiles": "发送文件","webFilesQueued": "已加入网页传输,请到手机的「隔空传送」下载。",- "webFilesLimit": "网页收取单个文件上限 200 MB,一次最多 64 个文件。"+ "webFilesLimit": "网页收取单个文件上限 200 MB,一次最多 64 个文件。",+ "appearance": "外观",+ "settingsAppearanceSummary": "主题、浅色与深色",+ "themeTitle": "主题",+ "themeDefault": "默认",+ "themePixel": "像素",+ "themeMode": "浅色与深色",+ "themeModeSystem": "跟随系统",+ "themeModeLight": "浅色",+ "themeModeDark": "深色",+ "themeCustom": "自定义",+ "themeDelete": "删除主题",+ "themeDeleteConfirm": "删除主题「{name}」?",+ "themeLowContrast": "这个主题里有些文字可能看不清",+ "themeFootnote": "主题只用于这台设备(包括快捷粘贴窗口),不会同步到其他设备。",+ "themeBuiltinGroup": "软件自带",+ "themeCustomGroup": "自定义",+ "themeUse": "使用",+ "themeDuplicate": "复制一份",+ "themeCopyName": "{name} 副本",+ "themeExport": "导出…",+ "themeImport": "导入主题…",+ "themeImported": "已导入「{name}」",+ "themeImportedWarn": "已导入「{name}」,有 {count} 处文字颜色可能看不清",+ "themeExported": "主题已导出",+ "themeCustomEmpty": "还没有自定义主题。复制一份自带主题,或者导入、让 AI 帮你做一套。",+ "themeAskAi": "让 AI 帮你做主题",+ "themeAskAiBody": "把下面这个 MCP 服务加到 Claude、Cursor 等 AI 应用里,然后直接说「帮我做一套赛博朋克风的主题」。AI 会读取主题格式、配色、检查对比度,再把主题应用上。",+ "themeAskAiCopy": "复制配置",+ "themeAskAiCopied": "配置已复制",+ "themeScanlines": "扫描线",+ "themeScanlinesDesc": "整个窗口叠一层很淡的 CRT 扫描线,只在像素主题里有效"}diff --git a/ui/lib/l10n/app_zh_Hant_HK.arb b/ui/lib/l10n/app_zh_Hant_HK.arbindex 131d9f0..0b1deb5 100644--- a/ui/lib/l10n/app_zh_Hant_HK.arb+++ b/ui/lib/l10n/app_zh_Hant_HK.arb@@ -709,5 +709,36 @@"mMultiSelectHint": "相片可以一次多選;檔案可長按一個項目後,再勾選其他項目。","webSendFiles": "傳送檔案","webFilesQueued": "已加入網頁傳輸,請到手機的「隔空傳送」下載。",- "webFilesLimit": "網頁接收單一檔案上限 200 MB,一次最多 64 個檔案。"+ "webFilesLimit": "網頁接收單一檔案上限 200 MB,一次最多 64 個檔案。",+ "appearance": "外觀",+ "settingsAppearanceSummary": "主題、淺色與深色",+ "themeTitle": "主題",+ "themeDefault": "預設",+ "themePixel": "像素",+ "themeMode": "淺色與深色",+ "themeModeSystem": "跟隨系統",+ "themeModeLight": "淺色",+ "themeModeDark": "深色",+ "themeCustom": "自訂",+ "themeDelete": "刪除主題",+ "themeDeleteConfirm": "刪除主題「{name}」?",+ "themeLowContrast": "這個主題裡有些文字可能看不清楚",+ "themeFootnote": "主題只用於這部裝置(包括快速貼上視窗),不會同步到其他裝置。",+ "themeBuiltinGroup": "內置",+ "themeCustomGroup": "自訂",+ "themeUse": "使用",+ "themeDuplicate": "複製一份",+ "themeCopyName": "{name} 副本",+ "themeExport": "匯出…",+ "themeImport": "匯入主題…",+ "themeImported": "已匯入「{name}」",+ "themeImportedWarn": "已匯入「{name}」,有 {count} 處文字顏色可能看不清楚",+ "themeExported": "主題已匯出",+ "themeCustomEmpty": "還沒有自訂主題。複製一份內置主題,或者匯入、讓 AI 幫你做一套。",+ "themeAskAi": "讓 AI 幫你做主題",+ "themeAskAiBody": "把下面這個 MCP 服務加到 Claude、Cursor 等 AI 應用程式裏,然後直接說「幫我做一套賽博朋克風的主題」。AI 會讀取主題格式、配色、檢查對比度,再把主題套用上。",+ "themeAskAiCopy": "複製設定",+ "themeAskAiCopied": "設定已複製",+ "themeScanlines": "掃描線",+ "themeScanlinesDesc": "整個視窗疊一層很淡的 CRT 掃描線,只在像素主題裏有效"}diff --git a/ui/lib/l10n/app_zh_Hant_TW.arb b/ui/lib/l10n/app_zh_Hant_TW.arbindex e79b26a..5116648 100644--- a/ui/lib/l10n/app_zh_Hant_TW.arb+++ b/ui/lib/l10n/app_zh_Hant_TW.arb@@ -709,5 +709,36 @@"mMultiSelectHint": "照片可以一次多選;檔案可長按一個項目後,再勾選其他項目。","webSendFiles": "傳送檔案","webFilesQueued": "已加入網頁傳輸,請到手機的「隔空傳送」下載。",- "webFilesLimit": "網頁接收單一檔案上限 200 MB,一次最多 64 個檔案。"+ "webFilesLimit": "網頁接收單一檔案上限 200 MB,一次最多 64 個檔案。",+ "appearance": "外觀",+ "settingsAppearanceSummary": "主題、淺色與深色",+ "themeTitle": "主題",+ "themeDefault": "預設",+ "themePixel": "像素",+ "themeMode": "淺色與深色",+ "themeModeSystem": "跟隨系統",+ "themeModeLight": "淺色",+ "themeModeDark": "深色",+ "themeCustom": "自訂",+ "themeDelete": "刪除主題",+ "themeDeleteConfirm": "刪除主題「{name}」?",+ "themeLowContrast": "這個主題裡有些文字可能看不清楚",+ "themeFootnote": "主題只用於這台裝置(包括快速貼上視窗),不會同步到其他裝置。",+ "themeBuiltinGroup": "內建",+ "themeCustomGroup": "自訂",+ "themeUse": "使用",+ "themeDuplicate": "複製一份",+ "themeCopyName": "{name} 副本",+ "themeExport": "匯出…",+ "themeImport": "匯入主題…",+ "themeImported": "已匯入「{name}」",+ "themeImportedWarn": "已匯入「{name}」,有 {count} 處文字顏色可能看不清楚",+ "themeExported": "主題已匯出",+ "themeCustomEmpty": "還沒有自訂主題。複製一份內建主題,或者匯入、讓 AI 幫你做一套。",+ "themeAskAi": "讓 AI 幫你做主題",+ "themeAskAiBody": "把下面這個 MCP 服務加到 Claude、Cursor 等 AI 應用程式裡,然後直接說「幫我做一套賽博龐克風的主題」。AI 會讀取主題格式、配色、檢查對比度,再把主題套用上。",+ "themeAskAiCopy": "複製設定",+ "themeAskAiCopied": "設定已複製",+ "themeScanlines": "掃描線",+ "themeScanlinesDesc": "整個視窗疊一層很淡的 CRT 掃描線,只在像素主題裡有效"}diff --git a/ui/lib/main.dart b/ui/lib/main.dartindex 205595f..e7cb660 100644--- a/ui/lib/main.dart+++ b/ui/lib/main.dart@@ -26,6 +26,7 @@ import 'widgets/incoming_dialog.dart';import 'widgets/update_dialog.dart';import 'icons.dart';import 'notices.dart';+import 'pixel_art.dart';/// 带 --picker 启动的是快捷粘贴窗口进程,见 picker/picker_main.dart。void main(List<String> args) {@@ -78,7 +79,7 @@ class _PasteFerryAppState extends State<PasteFerryApp> {state: _state,// 语言设置存在后台服务的配置里,配置变了要重建 MaterialApp 才会换语言child: ListenableBuilder(- listenable: _state,+ listenable: Listenable.merge([_state, _state.theme]),builder: (context, _) {final locale = localeFromSetting(_state.config?.language ?? '');// zh、zh-Hant-TW、zh-Hant-HK、en、ja:Windows 与 Linux 上按它挑汉字字体@@ -88,11 +89,13 @@ class _PasteFerryAppState extends State<PasteFerryApp> {WidgetsBinding.instance.platformDispatcher.locales,)).toLanguageTag();+ final theme = _state.theme;+ final spec = theme.spec;final (light, dark) = _themes.putIfAbsent(- language,+ '$language#${theme.revision}',() => (- buildTheme(Brightness.light, language: language),- buildTheme(Brightness.dark, language: language),+ buildTheme(Brightness.light, spec: spec, language: language),+ buildTheme(Brightness.dark, spec: spec, language: language),),);return MaterialApp(@@ -101,6 +104,7 @@ class _PasteFerryAppState extends State<PasteFerryApp> {debugShowCheckedModeBanner: false,theme: light,darkTheme: dark,+ themeMode: theme.mode,locale: locale,supportedLocales: supportedLocales,localizationsDelegates: AppLocalizations.localizationsDelegates,@@ -108,7 +112,7 @@ class _PasteFerryAppState extends State<PasteFerryApp> {resolveLocale(preferred),builder: (context, child) {appL10n = context.l10n;- return child!;+ return ThemeTextScale(child: PixelScanlinesLayer(on: theme.scanlines, child: child!));},home: const Shell(),);@@ -354,17 +358,25 @@ class _ShellState extends State<Shell> with WidgetsBindingObserver {onSelect: (s) => setState(() => _section = s),),Expanded(- child: needsService- ? const ServicePage()- : switch (_section) {- Section.history => const HistoryPage(),- Section.favorites => const FavoritesPage(),- Section.send => const SendPage(),- Section.friends => const FriendsPage(),- Section.devices => const DevicesPage(),- Section.official => const OfficialServicePage(),- Section.settings => const SettingsPage(),- },+ // 像素主题:页面顶部垫一块场景(夜里的远山、白天的云),其他主题不画+ child: Stack(+ children: [+ if (context.shape.pixel) const Positioned(left: 0, right: 0, top: 0, child: PixelScene()),+ Positioned.fill(+ child: needsService+ ? const ServicePage()+ : switch (_section) {+ Section.history => const HistoryPage(),+ Section.favorites => const FavoritesPage(),+ Section.send => const SendPage(),+ Section.friends => const FriendsPage(),+ Section.devices => const DevicesPage(),+ Section.official => const OfficialServicePage(),+ Section.settings => const SettingsPage(),+ },+ ),+ ],+ ),),],),@@ -456,7 +468,7 @@ class _Sidebar extends StatelessWidget {),if (state.officialEnabled)_NavItem(- icon: Icons.cloud_outlined,+ icon: AppIcons.cloud,label: l.officialService,selected: current == Section.official,onTap: () => onSelect(Section.official),@@ -469,6 +481,8 @@ class _Sidebar extends StatelessWidget {),const Spacer(),const _UpdateHint(),+ // 像素主题:底下一小块营地(深色是帐篷与篝火,浅色是小房子与花)+ if (context.shape.pixel) const PixelCamp(),const _ConnectionFooter(),],),@@ -504,6 +518,8 @@ class _NavItemState extends State<_NavItem> {Widget build(BuildContext context) {final p = context.palette;final selected = widget.selected;+ // 像素主题:选中项不整块填色,左边一条强调色竖条+ final bar = context.shape.pixel && selected;return Padding(padding: const EdgeInsets.symmetric(horizontal: Insets.sm, vertical: 1),@@ -513,38 +529,50 @@ class _NavItemState extends State<_NavItem> {onExit: (_) => setState(() => _hovered = false),child: GestureDetector(onTap: widget.onTap,- child: Container(- height: 30,- padding: const EdgeInsets.symmetric(horizontal: 10),- decoration: BoxDecoration(+ // 像素主题:选中项左边一个一闪一闪的 ▶,像游戏菜单的光标+ child: bar+ ? Stack(clipBehavior: Clip.none, children: [_navBox(context, p, selected, bar), const Positioned(left: -9, top: 10, child: PixelCursor())])+ : _navBox(context, p, selected, bar),+ ),+ ),+ );+ }++ Widget _navBox(BuildContext context, AppPalette p, bool selected, bool bar) {+ return Container(+ height: 30,+ padding: EdgeInsets.only(left: bar ? 6 : 10, right: 10),+ decoration: bar+ ? BoxDecoration(+ color: p.selection,+ border: Border(left: BorderSide(color: p.accent, width: 4)),+ )+ : context.shape.box(color: selected? p.selection: (_hovered ? p.hover : Colors.transparent),- borderRadius: BorderRadius.circular(Radii.sm),+ radius: context.shape.sm,),- child: Row(- children: [- Icon(- widget.icon,- size: 16,- color: selected ? p.accent : p.textDim,- ),- const SizedBox(width: 10),- Expanded(- child: Text(- widget.label,- style: context.text.labelLarge?.copyWith(- fontWeight: selected ? FontWeight.w600 : FontWeight.w500,- ),- ),- ),- if (widget.trailing != null)- Text(widget.trailing!, style: context.text.labelSmall),- ?widget.trailingWidget,- ],+ child: Row(+ children: [+ Icon(+ widget.icon,+ size: 16,+ color: selected ? p.accent : p.textDim,+ ),+ const SizedBox(width: 10),+ Expanded(+ child: Text(+ widget.label,+ style: context.text.labelLarge?.copyWith(+ fontWeight: selected ? FontWeight.w600 : FontWeight.w500,+ ),),),- ),+ if (widget.trailing != null)+ Text(widget.trailing!, style: context.text.labelSmall),+ ?widget.trailingWidget,+ ],),);}@@ -582,7 +610,7 @@ class _SendBadge extends StatelessWidget {message: lines.join('\n'),child: SizedBox.square(dimension: 12,- child: CircularProgressIndicator(+ child: ThemedSpinner(strokeWidth: 1.6,value: state.transferProgress,),@@ -664,7 +692,7 @@ class _ConnectionFooter extends StatelessWidget {Container(width: 7,height: 7,- decoration: BoxDecoration(color: color, shape: BoxShape.circle),+ decoration: context.shape.circle(color: color),),const SizedBox(width: Insets.sm),Expanded(diff --git a/ui/lib/mobile/devices_tab.dart b/ui/lib/mobile/devices_tab.dartindex 5553f7a..c9615d3 100644--- a/ui/lib/mobile/devices_tab.dart+++ b/ui/lib/mobile/devices_tab.dart@@ -127,7 +127,7 @@ Future<void> _showDeviceSheet(BuildContext context, Device d) => showModalBottomText(d.online ? connectionLabel(d) : l.offline, style: ctx.text.bodySmall, textAlign: TextAlign.center),const SizedBox(height: Insets.lg),Container(- decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(Radii.md)),+ decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(context.shape.md)),child: MobileTile(title: l.peerRealtimeSync,trailing: Switch(diff --git a/ui/lib/mobile/mobile_app.dart b/ui/lib/mobile/mobile_app.dartindex 23bd7c1..3f48d83 100644--- a/ui/lib/mobile/mobile_app.dart+++ b/ui/lib/mobile/mobile_app.dart@@ -20,6 +20,7 @@ import 'send_tab.dart';import 'settings_tab.dart';import 'transfers_tab.dart';import 'ui.dart';+import '../pixel_art.dart';/// Android 的入口:先让宿主拉起 Go 核心、告诉界面数据目录,再像桌面一样经 gRPC 连上去。void runMobile() {@@ -79,14 +80,15 @@ class _MobileAppState extends State<MobileApp> with WidgetsBindingObserver {return AppScope(state: _state,child: ListenableBuilder(- listenable: _state,+ listenable: Listenable.merge([_state, _state.theme]),builder: (context, _) {final locale = localeFromSetting(_state.config?.language ?? '');final language =(locale ?? resolveLocale(WidgetsBinding.instance.platformDispatcher.locales)).toLanguageTag();+ final spec = _state.theme.spec;final (light, dark) = _themes.putIfAbsent(- language,- () => (buildMobileTheme(Brightness.light), buildMobileTheme(Brightness.dark)),+ '$language#${_state.theme.revision}',+ () => (buildMobileTheme(Brightness.light, spec: spec), buildMobileTheme(Brightness.dark, spec: spec)),);return MaterialApp(title: 'PasteFerry',@@ -94,13 +96,14 @@ class _MobileAppState extends State<MobileApp> with WidgetsBindingObserver {debugShowCheckedModeBanner: false,theme: light,darkTheme: dark,+ themeMode: _state.theme.mode,locale: locale,supportedLocales: supportedLocales,localizationsDelegates: AppLocalizations.localizationsDelegates,localeListResolutionCallback: (preferred, _) => resolveLocale(preferred),builder: (context, child) {appL10n = context.l10n;- return ToastScope(top: true, child: child!);+ return ThemeTextScale(child: ToastScope(top: true, child: child!));},home: MobileShell(startError: _startError, onRetry: _start),);@@ -112,10 +115,11 @@ class _MobileAppState extends State<MobileApp> with WidgetsBindingObserver {/// 手机上的字号与触控尺寸:配色、圆角沿用桌面的设计系统(theme.dart),/// 字号放大一档、控件高 48,和网页传输的页面(web/phone)一致。-ThemeData buildMobileTheme(Brightness brightness) {- final base = buildTheme(brightness);- final p = base.extension<AppPalette>()!;- final text = TextTheme(+ThemeData buildMobileTheme(Brightness brightness, {AppThemeSpec spec = AppThemeSpec.standard}) {+ final base = buildTheme(brightness, spec: spec);+ final p = spec.palette(brightness);+ final r = spec.shape;+ var text = TextTheme(headlineMedium: TextStyle(fontSize: 30, fontWeight: FontWeight.w700, color: p.text, letterSpacing: -0.6),headlineSmall: TextStyle(fontSize: 22, fontWeight: FontWeight.w600, color: p.text, letterSpacing: -0.4),titleLarge: TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: p.text, letterSpacing: -0.3),@@ -128,7 +132,10 @@ ThemeData buildMobileTheme(Brightness brightness) {labelMedium: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: p.textDim),labelSmall: TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: p.textDim),);- final shape = RoundedRectangleBorder(borderRadius: BorderRadius.circular(Radii.md));+ // 主题自带字体(像素字体)时换上它;字号由 ThemeTextScale 吸附到点阵字号+ final family = spec.typography.family;+ if (family != null) text = text.apply(fontFamily: family);+ final shape = RoundedRectangleBorder(borderRadius: BorderRadius.circular(r.md));const padding = EdgeInsets.symmetric(horizontal: 18, vertical: 12);return base.copyWith(textTheme: text,@@ -140,9 +147,9 @@ ThemeData buildMobileTheme(Brightness brightness) {filledButtonTheme: FilledButtonThemeData(style: FilledButton.styleFrom(backgroundColor: p.accent,- foregroundColor: Colors.white,+ foregroundColor: p.onAccent,disabledBackgroundColor: p.accent.withValues(alpha: 0.4),- disabledForegroundColor: Colors.white.withValues(alpha: 0.8),+ disabledForegroundColor: p.onAccent.withValues(alpha: 0.8),shape: shape,padding: padding,minimumSize: const Size(0, 48),@@ -175,13 +182,13 @@ ThemeData buildMobileTheme(Brightness brightness) {isDense: false,contentPadding: const EdgeInsets.symmetric(horizontal: 14, vertical: 14),hintStyle: text.bodyLarge?.copyWith(color: p.textFaint),- border: OutlineInputBorder(borderRadius: BorderRadius.circular(Radii.md), borderSide: BorderSide(color: p.border)),+ border: OutlineInputBorder(borderRadius: BorderRadius.circular(r.md), borderSide: BorderSide(color: p.border)),enabledBorder: OutlineInputBorder(- borderRadius: BorderRadius.circular(Radii.md),+ borderRadius: BorderRadius.circular(r.md),borderSide: BorderSide(color: p.border),),focusedBorder: OutlineInputBorder(- borderRadius: BorderRadius.circular(Radii.md),+ borderRadius: BorderRadius.circular(r.md),borderSide: BorderSide(color: p.accent, width: 1.5),),),@@ -192,7 +199,7 @@ ThemeData buildMobileTheme(Brightness brightness) {surfaceTintColor: Colors.transparent,showDragHandle: true,dragHandleColor: p.border,- shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(Radii.lg))),+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(r.lg))),),);}@@ -266,7 +273,7 @@ class _MobileShellState extends State<MobileShell> {if (widget.startError != null) {body = _StartFailed(error: widget.startError!, onRetry: widget.onRetry);} else if (state.link == LinkState.connecting && state.config == null) {- body = const Center(child: CircularProgressIndicator(strokeWidth: 2.5));+ body = const Center(child: ThemedSpinner(strokeWidth: 2.5));} else {body = IndexedStack(index: _tab.index,diff --git a/ui/lib/mobile/records_tab.dart b/ui/lib/mobile/records_tab.dartindex 7322952..5893c89 100644--- a/ui/lib/mobile/records_tab.dart+++ b/ui/lib/mobile/records_tab.dart@@ -10,6 +10,7 @@ import '../main.dart' show AppScope;import '../records.dart';import '../theme.dart';import '../widgets/common.dart';+import '../pixel_theme.dart';import 'ui.dart';import 'record_actions.dart';@@ -77,13 +78,13 @@ class _RecordsTabState extends State<RecordsTab> {sliver: DecoratedSliver(decoration: BoxDecoration(color: p.surface,- borderRadius: BorderRadius.circular(Radii.lg),+ borderRadius: BorderRadius.circular(context.shape.lg),border: Border.all(color: p.border),),sliver: SliverList.separated(itemCount: records.length,// 分隔线从文字处开始:左边距 16 + 图标 40 + 间距 12- separatorBuilder: (_, _) => const Divider(indent: 68, height: 1),+ separatorBuilder: (_, _) => const ThemedDivider(indent: 68, height: 1),itemBuilder: (context, i) => _RecordRow(record: records[i],first: i == 0,@@ -120,8 +121,8 @@ class _RecordRow extends StatelessWidget {final media = isMedia(r);return InkWell(borderRadius: BorderRadius.vertical(- top: first ? const Radius.circular(Radii.lg) : Radius.zero,- bottom: last ? const Radius.circular(Radii.lg) : Radius.zero,+ top: first ? Radius.circular(context.shape.lg) : Radius.zero,+ bottom: last ? Radius.circular(context.shape.lg) : Radius.zero,),onTap: () => showRecordSheet(context, r),onLongPress: () => confirmDelete(context, r),@@ -174,7 +175,7 @@ class _RecordRow extends StatelessWidget {),if (r.status == ClipStatus.CLIP_STATUS_FETCHING) ...[const SizedBox(height: 6),- LinearProgressIndicator(value: progress, minHeight: 3, borderRadius: BorderRadius.circular(2)),+ ThemedProgressBar(value: progress, minHeight: 3, borderRadius: BorderRadius.circular(context.shape.scaled(2))),],],),@@ -230,7 +231,7 @@ class RecordThumb extends StatelessWidget {return SizedBox.square(dimension: size,child: ClipRRect(- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),child: image ? _Preview(clipId: r.id, fallback: Center(child: icon)) : Center(child: icon),),);@@ -350,7 +351,7 @@ class _RecordSheet extends StatelessWidget {],if (busy) ...[const SizedBox(height: Insets.sm),- LinearProgressIndicator(value: state.progressOf(r.id), minHeight: 3),+ ThemedProgressBar(value: state.progressOf(r.id), minHeight: 3),],const SizedBox(height: Insets.lg),FilledButton.icon(@@ -419,7 +420,7 @@ class _FullText extends StatelessWidget {children: [Container(padding: const EdgeInsets.all(Insets.md),- decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(Radii.md)),+ decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(context.shape.md)),child: SelectableText(text, style: const TextStyle(fontSize: 16, height: 1.6)),),if (d != null && d.textLength > text.runes.length) ...[@@ -453,7 +454,7 @@ class _MediaBody extends StatelessWidget {if (r.status == ClipStatus.CLIP_STATUS_READY && r.imageCount > 0) ...[Center(child: ClipRRect(- borderRadius: BorderRadius.circular(Radii.md),+ borderRadius: BorderRadius.circular(context.shape.md),child: ConstrainedBox(constraints: const BoxConstraints(maxHeight: 224),child: _Preview(clipId: r.id, fallback: const SizedBox.shrink()),@@ -466,13 +467,13 @@ class _MediaBody extends StatelessWidget {clipBehavior: Clip.antiAlias,decoration: BoxDecoration(color: p.surface,- borderRadius: BorderRadius.circular(Radii.lg),+ borderRadius: BorderRadius.circular(context.shape.lg),border: Border.all(color: p.border),),child: Column(children: [for (var i = 0; i < items.length; i++) ...[- if (i > 0) const Divider(indent: Insets.lg, height: 1),+ if (i > 0) const ThemedDivider(indent: Insets.lg, height: 1),Padding(padding: const EdgeInsets.symmetric(horizontal: Insets.lg, vertical: Insets.md),child: Row(diff --git a/ui/lib/mobile/send_tab.dart b/ui/lib/mobile/send_tab.dartindex bc23f87..d2a3af1 100644--- a/ui/lib/mobile/send_tab.dart+++ b/ui/lib/mobile/send_tab.dart@@ -9,10 +9,12 @@ import '../icons.dart';import '../main.dart' show AppScope;import '../theme.dart';import '../widgets/common.dart';+import '../pixel_theme.dart';import 'record_actions.dart';import 'file_picker.dart';import 'records_tab.dart' show showRecordSheet;import 'ui.dart';+import '../pixel_art.dart';/// 发送页(design/phone-sync.md 3.2.3 节):手机上的文字发给在线的设备。///@@ -147,15 +149,15 @@ class _SendTabState extends State<SendTab> with WidgetsBindingObserver {hintText: l.mSendHint,fillColor: p.surface,border: OutlineInputBorder(- borderRadius: BorderRadius.circular(Radii.lg),+ borderRadius: BorderRadius.circular(context.shape.lg),borderSide: BorderSide(color: p.border),),enabledBorder: OutlineInputBorder(- borderRadius: BorderRadius.circular(Radii.lg),+ borderRadius: BorderRadius.circular(context.shape.lg),borderSide: BorderSide(color: p.border),),focusedBorder: OutlineInputBorder(- borderRadius: BorderRadius.circular(Radii.lg),+ borderRadius: BorderRadius.circular(context.shape.lg),borderSide: BorderSide(color: p.accent),),contentPadding: const EdgeInsets.symmetric(horizontal: Insets.lg, vertical: Insets.md),@@ -188,9 +190,9 @@ class _SendTabState extends State<SendTab> with WidgetsBindingObserver {child: FilledButton.icon(onPressed: canSend ? _send : null,icon: _sending- ? const SizedBox.square(+ ? SizedBox.square(dimension: 18,- child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),+ child: ThemedSpinner(strokeWidth: 2, color: context.palette.onAccent),): Icon(AppIcons.send, size: 20),label: Text(l.mSendAction),@@ -271,13 +273,13 @@ class _SentRecords extends StatelessWidget {DecoratedBox(decoration: BoxDecoration(color: p.surface,- borderRadius: BorderRadius.circular(Radii.lg),+ borderRadius: BorderRadius.circular(context.shape.lg),border: Border.all(color: p.border),),child: Column(children: [for (var i = 0; i < shown.length; i++) ...[- if (i > 0) const Divider(height: 1, indent: 52),+ if (i > 0) const ThemedDivider(height: 1, indent: 52),ListTile(dense: true,leading: Icon(isMedia(shown[i]) ? AppIcons.folder : AppIcons.docOnClipboard, size: 20, color: p.textDim),@@ -333,7 +335,7 @@ Future<void> showSentRecordsSheet(BuildContext context, List<ClipRecord> sent) {child: ListView.separated(shrinkWrap: true,itemCount: sent.length,- separatorBuilder: (_, _) => const Divider(height: 1, indent: 52),+ separatorBuilder: (_, _) => const ThemedDivider(height: 1, indent: 52),itemBuilder: (_, i) {final r = sent[i];return ListTile(diff --git a/ui/lib/mobile/settings_tab.dart b/ui/lib/mobile/settings_tab.dartindex 73fb135..12e38c2 100644--- a/ui/lib/mobile/settings_tab.dart+++ b/ui/lib/mobile/settings_tab.dart@@ -11,6 +11,7 @@ import 'host.dart';import 'update_check.dart';import 'send_tab.dart' show sentRetentionDays;import 'ui.dart';+import '../pixel_art.dart';/// 设置页:本机名称、收到文字后写不写剪贴板、后台保持连接与相关的系统权限、版本。class SettingsTab extends StatefulWidget {@@ -148,6 +149,51 @@ class _SettingsTabState extends State<SettingsTab> with WidgetsBindingObserver {),],),+ // 外观:选主题、浅色与深色(只在这台手机上,不同步)+ ListenableBuilder(+ listenable: state.theme,+ builder: (context, _) {+ final theme = state.theme;+ final current = theme.themes.where((t) => t.id == theme.id).firstOrNull;+ return MobileGroup(+ title: l.appearance,+ children: [+ MobileTile(+ title: l.themeTitle,+ subtitle: current?.displayName(l) ?? l.themeDefault,+ trailing: Icon(Icons.chevron_right, color: p.textFaint),+ onTap: () => _pick<String>(+ context,+ l.themeTitle,+ [for (final t in theme.themes) (t.id, t.displayName(l))],+ theme.id,+ theme.select,+ ),+ ),+ MobileTile(+ title: l.themeMode,+ subtitle: switch (theme.mode) {+ ThemeMode.light => l.themeModeLight,+ ThemeMode.dark => l.themeModeDark,+ ThemeMode.system => l.themeModeSystem,+ },+ trailing: Icon(Icons.chevron_right, color: p.textFaint),+ onTap: () => _pick<ThemeMode>(+ context,+ l.themeMode,+ [+ (ThemeMode.system, l.themeModeSystem),+ (ThemeMode.light, l.themeModeLight),+ (ThemeMode.dark, l.themeModeDark),+ ],+ theme.mode,+ theme.setMode,+ ),+ ),+ ],+ );+ },+ ),MobileGroup(title: l.mSectionBackground,children: [@@ -206,6 +252,44 @@ class _SettingsTabState extends State<SettingsTab> with WidgetsBindingObserver {}}+/// 底部弹出的单选列表:选主题、选浅色深色+Future<void> _pick<T>(+ BuildContext context,+ String title,+ List<(T, String)> options,+ T current,+ Future<void> Function(T) onPick,+) async {+ final picked = await showModalBottomSheet<T>(+ context: context,+ builder: (ctx) => SafeArea(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Padding(+ padding: const EdgeInsets.fromLTRB(Insets.lg, 0, Insets.lg, Insets.sm),+ child: Text(title, style: ctx.text.titleMedium),+ ),+ for (final (value, label) in options)+ MobileTile(+ title: label,+ trailing: value == current ? Icon(Icons.check, color: ctx.palette.accent) : null,+ onTap: () => Navigator.pop(ctx, value),+ ),+ const SizedBox(height: Insets.md),+ ],+ ),+ ),+ );+ if (picked == null || picked == current) return;+ try {+ await onPick(picked);+ } catch (e) {+ if (context.mounted) showToast(context, AppState.describeError(e), error: true);+ }+}+/// 检查更新:版本号从更新清单里读(地址固定),有新版就在浏览器里下 APK。class _UpdateTile extends StatefulWidget {const _UpdateTile({required this.current});@@ -251,7 +335,7 @@ class _UpdateTileState extends State<_UpdateTile> {OutlinedButton(onPressed: _busy ? null : _check,child: _busy- ? const SizedBox.square(dimension: 16, child: CircularProgressIndicator(strokeWidth: 2))+ ? const SizedBox.square(dimension: 16, child: ThemedSpinner(strokeWidth: 2)): Text(l.mCheckUpdate),),if (_error != null) ...[diff --git a/ui/lib/mobile/transfers_tab.dart b/ui/lib/mobile/transfers_tab.dartindex 70339da..95d4a4d 100644--- a/ui/lib/mobile/transfers_tab.dart+++ b/ui/lib/mobile/transfers_tab.dart@@ -8,6 +8,7 @@ import '../main.dart' show AppScope;import '../theme.dart';import '../widgets/common.dart';import '../widgets/send_dialog.dart';+import '../pixel_theme.dart';import 'host.dart';import 'file_picker.dart';import 'ui.dart';@@ -199,7 +200,7 @@ class _TransfersTabState extends State<TransfersTab> {minimumSize: const Size(40, 40),padding: const EdgeInsets.all(8),shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(Radii.md),+ borderRadius: BorderRadius.circular(context.shape.md),),),);@@ -307,7 +308,7 @@ class MobileTransferCard extends StatelessWidget {padding: const EdgeInsets.all(8),decoration: BoxDecoration(color: p.fill,- borderRadius: BorderRadius.circular(Radii.md),+ borderRadius: BorderRadius.circular(context.shape.md),),child: Icon(transferIcon(t), size: 22, color: p.textDim),),@@ -340,9 +341,9 @@ class MobileTransferCard extends StatelessWidget {),if (active) ...[const SizedBox(height: 4),- LinearProgressIndicator(+ ThemedProgressBar(minHeight: 3,- borderRadius: BorderRadius.circular(2),+ borderRadius: BorderRadius.circular(context.shape.scaled(2)),value: t.totalBytes > 0? (t.doneBytes.toDouble() / t.totalBytes.toDouble()).clamp(0, 1)diff --git a/ui/lib/mobile/ui.dart b/ui/lib/mobile/ui.dartindex 8e17430..f4c6c15 100644--- a/ui/lib/mobile/ui.dart+++ b/ui/lib/mobile/ui.dart@@ -7,6 +7,7 @@ import '../i18n.dart';import '../icons.dart';import '../main.dart' show AppScope;import '../theme.dart';+import '../pixel_theme.dart';import 'host.dart';/// 手机 App 的界面部件。样子与手机网页传输(web/phone/src/ui.tsx、App.tsx)一一对应,@@ -161,7 +162,7 @@ class _MobileSearchFieldState extends State<MobileSearchField> {return Container(height: 40,padding: const EdgeInsets.symmetric(horizontal: Insets.md),- decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(Radii.md)),+ decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(context.shape.md)),child: Row(children: [Icon(AppIcons.search, size: 18, color: p.textDim),@@ -215,7 +216,7 @@ class MobileSegmented<T> extends StatelessWidget {final dark = Theme.of(context).brightness == Brightness.dark;return Container(padding: const EdgeInsets.all(2),- decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(Radii.md)),+ decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(context.shape.md)),child: Row(children: [for (final (v, label) in segments)@@ -224,14 +225,15 @@ class MobileSegmented<T> extends StatelessWidget {behavior: HitTestBehavior.opaque,onTap: () => onChanged(v),child: AnimatedContainer(- duration: const Duration(milliseconds: 150),+ duration: context.motion.duration(const Duration(milliseconds: 150)),+ curve: context.motion.curve(Curves.linear),height: 30,alignment: Alignment.center,decoration: BoxDecoration(color: v == value ? (dark ? p.border : p.surface) : Colors.transparent,- borderRadius: BorderRadius.circular(7),+ borderRadius: BorderRadius.circular(context.shape.scaled(7)),boxShadow: v == value- ? const [BoxShadow(color: Color(0x14000000), blurRadius: 2, offset: Offset(0, 1))]+ ? context.shape.shadows(const Color(0x14000000), blur: 2, offset: const Offset(0, 1)): null,),child: Text(@@ -280,7 +282,7 @@ class MobileGroup extends StatelessWidget {clipBehavior: Clip.antiAlias,decoration: BoxDecoration(color: p.surface,- borderRadius: BorderRadius.circular(Radii.lg),+ borderRadius: BorderRadius.circular(context.shape.lg),border: Border.all(color: p.border),),child: Material(@@ -288,7 +290,7 @@ class MobileGroup extends StatelessWidget {child: Column(children: [for (var i = 0; i < children.length; i++) ...[- if (i > 0) Divider(indent: inset, height: 1),+ if (i > 0) ThemedDivider(indent: inset, height: 1),children[i],],],@@ -456,7 +458,7 @@ class _LanNoticeState extends State<LanNotice> with WidgetsBindingObserver {padding: const EdgeInsets.all(Insets.lg),decoration: BoxDecoration(color: p.surface,- borderRadius: BorderRadius.circular(Radii.lg),+ borderRadius: BorderRadius.circular(context.shape.lg),border: Border.all(color: p.border),),child: Row(diff --git a/ui/lib/pages/appearance_settings.dart b/ui/lib/pages/appearance_settings.dartnew file mode 100644index 0000000..617c353--- /dev/null+++ b/ui/lib/pages/appearance_settings.dart@@ -0,0 +1,441 @@+import 'dart:convert';+import 'dart:io';++import 'package:file_selector/file_selector.dart';+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';++import '../app_state.dart';+import '../i18n.dart';+import '../icons.dart';+import '../main.dart';+import '../theme.dart';+import '../theme_controller.dart';+import '../widgets/common.dart';++/// 设置页的「外观」:主题管理(软件自带的与自定义的)、浅色与深色、像素主题的扫描线。+/// 见 design/themes.md 第 6 节。+///+/// 主题存在后台服务里,主窗口、快捷粘贴窗口、手机 App 一起换,不同步到其他设备。+/// 自定义主题可以复制自带主题得到、从文件导入,或者让 AI 通过 MCP 做(design/mcp.md)。+class AppearanceSection extends StatelessWidget {+ const AppearanceSection({super.key});++ @override+ Widget build(BuildContext context) {+ final theme = AppScope.of(context).theme;+ return ListenableBuilder(+ listenable: theme,+ builder: (context, _) {+ final l = context.l10n;+ final p = context.palette;+ final builtin = theme.themes.where((t) => t.builtin).toList();+ final custom = theme.themes.where((t) => !t.builtin).toList();+ Widget cards(List<ThemeChoice> list) => Wrap(+ spacing: Insets.lg,+ runSpacing: Insets.lg,+ children: [+ for (final t in list) _ThemeCard(choice: t, selected: t.id == theme.id),+ ],+ );+ return Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ GroupSection(title: l.themeBuiltinGroup, child: cards(builtin)),+ GroupSection(+ title: l.themeCustomGroup,+ footnote: l.themeFootnote,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ if (custom.isEmpty)+ Padding(+ padding: const EdgeInsets.only(bottom: Insets.md),+ child: Text(l.themeCustomEmpty, style: context.text.bodySmall),+ )+ else ...[+ cards(custom),+ const SizedBox(height: Insets.lg),+ ],+ Wrap(+ spacing: Insets.sm,+ runSpacing: Insets.sm,+ children: [+ OutlinedButton.icon(+ onPressed: () => _import(context, theme),+ icon: Icon(AppIcons.download, size: 14),+ label: Text(l.themeImport),+ ),+ TextButton.icon(+ onPressed: () => showDialog<void>(context: context, builder: (_) => const _AskAiDialog()),+ icon: Icon(AppIcons.questionCircle, size: 14, color: p.accent),+ label: Text(l.themeAskAi),+ ),+ ],+ ),+ ],+ ),+ ),+ GroupSection(+ title: '',+ child: GroupBox(+ children: [+ SettingRow(+ title: l.themeMode,+ child: Segmented<ThemeMode>(+ value: theme.mode,+ segments: [+ (ThemeMode.system, l.themeModeSystem),+ (ThemeMode.light, l.themeModeLight),+ (ThemeMode.dark, l.themeModeDark),+ ],+ onChanged: (m) => _run(context, () => theme.setMode(m)),+ ),+ ),+ if (theme.spec.shape.pixel)+ SettingRow(+ title: l.themeScanlines,+ description: l.themeScanlinesDesc,+ child: SmallSwitch(+ value: theme.scanlines,+ onChanged: (v) => _run(context, () => theme.setScanlines(v)),+ ),+ ),+ ],+ ),+ ),+ ],+ );+ },+ );+ }++ static Future<void> _import(BuildContext context, ThemeController theme) async {+ final l = context.l10n;+ final file = await openFile(acceptedTypeGroups: const [+ XTypeGroup(label: 'theme', extensions: ['json']),+ ]);+ if (file == null || !context.mounted) return;+ try {+ final res = await theme.save(await file.readAsString());+ await theme.select(res.id);+ if (!context.mounted) return;+ final name = theme.themes.where((t) => t.id == res.id).firstOrNull?.displayName(l) ?? res.id;+ showToast(+ context,+ res.warnings.isEmpty ? l.themeImported(name) : l.themeImportedWarn(name, res.warnings.length),+ error: res.warnings.isNotEmpty,+ );+ } catch (e) {+ if (context.mounted) showToast(context, AppState.describeError(e), error: true);+ }+ }+}++/// 改主题出错时给个提示(后台服务没连上、主题被别处删了)+Future<void> _run(BuildContext context, Future<void> Function() action) async {+ try {+ await action();+ } catch (e) {+ if (context.mounted) showToast(context, AppState.describeError(e), error: true);+ }+}++/// 一张主题卡片:上面是用这套主题真实渲染的缩略界面,下面是名字;悬停时右边出现「⋯」菜单+class _ThemeCard extends StatefulWidget {+ const _ThemeCard({required this.choice, required this.selected});++ final ThemeChoice choice;+ final bool selected;++ @override+ State<_ThemeCard> createState() => _ThemeCardState();+}++class _ThemeCardState extends State<_ThemeCard> {+ bool _hover = false;++ @override+ Widget build(BuildContext context) {+ final p = context.palette;+ final s = context.shape;+ final l = context.l10n;+ final theme = AppScope.of(context).theme;+ final t = widget.choice;+ final brightness = Theme.of(context).brightness;+ return MouseRegion(+ cursor: SystemMouseCursors.click,+ onEnter: (_) => setState(() => _hover = true),+ onExit: (_) => setState(() => _hover = false),+ child: GestureDetector(+ onTap: () => _run(context, () => theme.select(t.id)),+ child: SizedBox(+ width: 188,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Container(+ padding: const EdgeInsets.all(3),+ decoration: s.box(+ color: Colors.transparent,+ border: widget.selected ? p.accent : (_hover ? p.borderStrong : p.border),+ radius: s.md + 3,+ ),+ child: ThemePreview(spec: t.spec, brightness: brightness),+ ),+ const SizedBox(height: Insets.sm),+ Row(+ children: [+ if (widget.selected) ...[+ Icon(AppIcons.checkmark, size: 13, color: p.accent),+ const SizedBox(width: 4),+ ],+ Expanded(+ child: Text(+ t.displayName(l),+ style: context.text.labelLarge,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ ),+ SizedBox(+ width: 22,+ height: 18,+ child: Opacity(opacity: _hover ? 1 : 0, child: _menu(context, theme, t)),+ ),+ ],+ ),+ ],+ ),+ ),+ ),+ );+ }++ Widget _menu(BuildContext context, ThemeController theme, ThemeChoice t) {+ final l = context.l10n;+ return PopupMenuButton<String>(+ tooltip: '',+ padding: EdgeInsets.zero,+ iconSize: 16,+ style: const ButtonStyle(tapTargetSize: MaterialTapTargetSize.shrinkWrap, visualDensity: VisualDensity.compact),+ icon: Icon(AppIcons.ellipsis, size: 16, color: context.palette.textDim),+ onSelected: (v) => switch (v) {+ 'use' => _run(context, () => theme.select(t.id)),+ 'duplicate' => _run(context, () async {+ final id = await theme.duplicate(t, l.themeCopyName, l);+ await theme.select(id);+ }),+ 'export' => _export(context, theme, t),+ 'delete' => _delete(context, theme, t),+ _ => null,+ },+ itemBuilder: (_) => [+ if (!widget.selected) PopupMenuItem(value: 'use', height: 34, child: Text(l.themeUse)),+ PopupMenuItem(value: 'duplicate', height: 34, child: Text(l.themeDuplicate)),+ PopupMenuItem(value: 'export', height: 34, child: Text(l.themeExport)),+ if (!t.builtin) ...[+ const PopupMenuDivider(height: 9),+ PopupMenuItem(value: 'delete', height: 34, child: Text(l.themeDelete)),+ ],+ ],+ );+ }++ Future<void> _export(BuildContext context, ThemeController theme, ThemeChoice t) async {+ final l = context.l10n;+ final location = await getSaveLocation(suggestedName: '${t.id}.pasteferry-theme.json');+ if (location == null || !context.mounted) return;+ await _run(context, () async {+ await File(location.path).writeAsString(await theme.exportJson(t.id));+ if (context.mounted) showToast(context, l.themeExported);+ });+ }++ Future<void> _delete(BuildContext context, ThemeController theme, ThemeChoice t) async {+ final l = context.l10n;+ final ok = await showDialog<bool>(+ context: context,+ builder: (ctx) => AlertDialog(+ title: Text(l.themeDeleteConfirm(t.displayName(l))),+ actions: [+ TextButton(onPressed: () => Navigator.pop(ctx, false), child: Text(l.cancel)),+ FilledButton(onPressed: () => Navigator.pop(ctx, true), child: Text(l.themeDelete)),+ ],+ ),+ );+ if (ok == true && context.mounted) await _run(context, () => theme.delete(t.id));+ }+}++/// 「让 AI 帮你做主题」:MCP 服务的配置,复制到 Claude、Cursor 等应用里+class _AskAiDialog extends StatelessWidget {+ const _AskAiDialog();++ /// 本机的 pasteferry-cli:Mac 在 App 包的 Helpers 里,Windows 与 Linux 在程序旁边;找不到时假定在命令路径里+ static String cliPath() {+ final exe = File(Platform.resolvedExecutable);+ final candidates = [+ if (Platform.isMacOS) '${exe.parent.parent.path}/Helpers/pasteferry-cli',+ if (Platform.isWindows) '${exe.parent.path}\\pasteferry-cli.exe',+ if (Platform.isLinux) '${exe.parent.path}/pasteferry-cli',+ ];+ return candidates.where((c) => File(c).existsSync()).firstOrNull ?? 'pasteferry-cli';+ }++ @override+ Widget build(BuildContext context) {+ final l = context.l10n;+ final p = context.palette;+ final config = const JsonEncoder.withIndent(' ').convert({+ 'mcpServers': {+ 'pasteferry': {+ 'command': cliPath(),+ 'args': ['mcp'],+ },+ },+ });+ return AlertDialog(+ title: Text(l.themeAskAi),+ content: SizedBox(+ width: 460,+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Text(l.themeAskAiBody),+ const SizedBox(height: Insets.md),+ Container(+ padding: const EdgeInsets.all(Insets.md),+ decoration: context.shape.box(color: p.fill, border: p.border, radius: context.shape.sm),+ child: SelectableText(+ config,+ style: TextStyle(fontFamily: context.typography.mono, fontSize: 12, color: p.text, height: 1.5),+ ),+ ),+ ],+ ),+ ),+ actions: [+ TextButton(onPressed: () => Navigator.pop(context), child: Text(l.close)),+ FilledButton(+ onPressed: () {+ Clipboard.setData(ClipboardData(text: config));+ showToast(context, l.themeAskAiCopied);+ },+ child: Text(l.themeAskAiCopy),+ ),+ ],+ );+ }+}++/// 缩略界面:侧边栏、一个分组、一个主按钮,都用 [spec] 自己的颜色、形状与字体画。+/// 「外观」的主题卡片与宣传截图都用它+class ThemePreview extends StatelessWidget {+ const ThemePreview({super.key, required this.spec, required this.brightness, this.width = 176, this.height = 104});++ final AppThemeSpec spec;+ final Brightness brightness;+ final double width;+ final double height;++ @override+ Widget build(BuildContext context) {+ // 用系统字体的主题:沿用外面的字体回退顺序(像素主题把原来的字体放在回退里)+ final fallback = Theme.of(context).textTheme.bodyMedium?.fontFamilyFallback ?? const [];+ final system = spec.typography.family == null && fallback.isNotEmpty;+ return Theme(+ data: buildTheme(+ brightness,+ spec: spec,+ fontFamily: system ? fallback.first : null,+ fontFamilyFallback: system ? fallback.skip(1).toList() : null,+ ),+ child: Builder(+ builder: (context) {+ final p = context.palette;+ final s = context.shape;+ Widget line(double w, Color c) => Container(width: w, height: 4, color: c);+ // 「Aa」用这套主题自己的字体,不继承外面的+ return DefaultTextStyle(+ style: Theme.of(context).textTheme.bodyMedium!,+ child: ClipRect(+ child: SizedBox(+ width: width,+ height: height,+ child: Row(+ children: [+ Container(+ width: width / 4,+ color: p.sidebar,+ padding: const EdgeInsets.fromLTRB(6, 10, 6, 0),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Container(+ height: 10,+ decoration: s.box(color: p.selection, radius: s.sm),+ padding: const EdgeInsets.only(left: 3),+ alignment: Alignment.centerLeft,+ child: line(width / 11, p.accent),+ ),+ const SizedBox(height: 6),+ line(width / 8, p.textFaint),+ const SizedBox(height: 6),+ line(width / 10, p.textFaint),+ ],+ ),+ ),+ Expanded(+ child: Container(+ color: p.background,+ padding: const EdgeInsets.all(8),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text('Aa', style: TextStyle(fontSize: 12, height: 1, color: p.text)),+ const SizedBox(height: 6),+ Expanded(+ child: Container(+ width: double.infinity,+ padding: const EdgeInsets.all(6),+ decoration: s.box(color: p.surface, border: p.border, radius: s.sm),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ line(width / 3, p.text),+ const SizedBox(height: 4),+ line(width / 4.4, p.textDim),+ const Spacer(),+ Align(+ alignment: Alignment.bottomRight,+ child: Container(+ width: 34,+ height: 12,+ decoration: s.box(+ color: p.accent,+ border: s.pixel ? p.borderStrong : null,+ radius: s.sm,+ bevel: (p.bevelLight, p.bevelDark),+ ),+ ),+ ),+ ],+ ),+ ),+ ),+ ],+ ),+ ),+ ),+ ],+ ),+ ),+ ),+ );+ },+ ),+ );+ }+}diff --git a/ui/lib/pages/devices_page.dart b/ui/lib/pages/devices_page.dartindex 7c9e710..1ef7661 100644--- a/ui/lib/pages/devices_page.dart+++ b/ui/lib/pages/devices_page.dart@@ -12,6 +12,7 @@ import '../widgets/pairing_dialog.dart';import '../widgets/web_share.dart';import '../icons.dart';import '../platform.dart';+import '../pixel_art.dart';class DevicesPage extends StatelessWidget {const DevicesPage({super.key});@@ -150,7 +151,7 @@ class _DeviceRow extends StatelessWidget {: device.publicKeyFingerprint,// 等宽:用户要逐字符比对,等宽能显著降低看错的概率style: context.text.bodySmall?.copyWith(- fontFamily: monoFamily,+ fontFamily: context.typography.mono,letterSpacing: 0.4,),),@@ -195,7 +196,7 @@ class _DeviceRow extends StatelessWidget {const SizedBox(width: 12,height: 12,- child: CircularProgressIndicator(strokeWidth: 2),+ child: ThemedSpinner(strokeWidth: 2),),const SizedBox(width: Insets.xs + 2),Text(context.l10n.reconnecting, style: context.text.bodySmall),@@ -332,7 +333,7 @@ class _DeviceMenu extends StatelessWidget {TextField(controller: controller,autofocus: true,- style: TextStyle(fontFamily: monoFamily, fontSize: 14),+ style: TextStyle(fontFamily: context.typography.mono, fontSize: 14),decoration: const InputDecoration(hintText: '192.168.1.20'),onSubmitted: (v) => Navigator.pop(ctx, v),),diff --git a/ui/lib/pages/favorites_page.dart b/ui/lib/pages/favorites_page.dartindex 9ed9788..3423694 100644--- a/ui/lib/pages/favorites_page.dart+++ b/ui/lib/pages/favorites_page.dart@@ -14,6 +14,8 @@ import '../widgets/common.dart';import '../widgets/favorite_actions.dart';import '../widgets/image_preview_dialog.dart';import '../widgets/record_hover.dart';+import '../pixel_theme.dart';+import '../pixel_art.dart';/// 收藏:另存的一份,不会被自动清理。见 design/quick-paste-and-favorites.md 第 3 节。///@@ -112,14 +114,14 @@ class _FavoritesPageState extends State<FavoritesPage> {sliver: DecoratedSliver(decoration: BoxDecoration(color: context.palette.surface,- borderRadius: BorderRadius.circular(Radii.md),+ borderRadius: BorderRadius.circular(context.shape.md),border: Border.all(color: context.palette.border),),sliver: SliverPadding(padding: const EdgeInsets.all(Insets.xs),sliver: SliverList.separated(itemCount: records.length,- separatorBuilder: (_, _) => const Divider(indent: 44, endIndent: 8),+ separatorBuilder: (_, _) => const ThemedDivider(indent: 44, endIndent: 8),itemBuilder: (_, i) => _FavoriteRow(key: ValueKey(records[i].id),record: records[i],@@ -181,13 +183,13 @@ class _FavoriteRowState extends State<_FavoriteRow> {onExit: (_) => setState(() => _hovered = false),child: InkWell(onTap: previewable ? () => showImagePreview(context, r.id) : null,- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),child: Container(constraints: const BoxConstraints(minHeight: 52),padding: const EdgeInsets.symmetric(horizontal: Insets.md, vertical: Insets.sm),decoration: BoxDecoration(color: _hovered ? p.hover : Colors.transparent,- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),),child: Row(children: [@@ -238,7 +240,7 @@ class _FavoriteRowState extends State<_FavoriteRow> {Widget _trailing(BuildContext context, ClipRecord r) {final l = context.l10n;if (_busy) {- return const SizedBox(width: 16, height: 16, child: CircularProgressIndicator(strokeWidth: 2));+ return const SizedBox(width: 16, height: 16, child: ThemedSpinner(strokeWidth: 2));}final unfavorite = IconAction(icon: AppIcons.starFill,@@ -263,7 +265,7 @@ class _FavoriteRowState extends State<_FavoriteRow> {return Row(mainAxisSize: MainAxisSize.min,children: [- const SizedBox(width: 72, child: LinearProgressIndicator(minHeight: 3)),+ const SizedBox(width: 72, child: ThemedProgressBar(minHeight: 3)),const SizedBox(width: Insets.sm),rename,unfavorite,diff --git a/ui/lib/pages/friends_page.dart b/ui/lib/pages/friends_page.dartindex f60ba0e..5b9697e 100644--- a/ui/lib/pages/friends_page.dart+++ b/ui/lib/pages/friends_page.dart@@ -112,7 +112,7 @@ class _FriendsPageState extends State<FriendsPage> {child: Container(decoration: BoxDecoration(color: p.surface,- borderRadius: BorderRadius.circular(Radii.md),+ borderRadius: BorderRadius.circular(context.shape.md),border: Border.all(color: p.border),),padding: const EdgeInsets.fromLTRB(Insets.xl, Insets.lg, Insets.md, Insets.md),@@ -168,7 +168,7 @@ class _FriendListRowState extends State<_FriendListRow> {padding: const EdgeInsets.symmetric(horizontal: Insets.sm, vertical: 7),decoration: BoxDecoration(color: widget.selected ? p.selection : (_hover ? p.hover : Colors.transparent),- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),),child: Row(children: [@@ -201,8 +201,8 @@ class _FriendListRowState extends State<_FriendListRow> {if (asking > 0)Container(padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),- decoration: BoxDecoration(color: p.accent, borderRadius: BorderRadius.circular(9)),- child: Text('$asking', style: context.text.labelSmall?.copyWith(color: Colors.white)),+ decoration: BoxDecoration(color: p.accent, borderRadius: BorderRadius.circular(context.shape.scaled(9))),+ child: Text('$asking', style: context.text.labelSmall?.copyWith(color: p.onAccent)),),],),@@ -248,7 +248,7 @@ class _DropToFriendState extends State<_DropToFriend> {child: Container(decoration: BoxDecoration(color: p.accent.withValues(alpha: 0.08),- borderRadius: BorderRadius.circular(Radii.md),+ borderRadius: BorderRadius.circular(context.shape.md),border: Border.all(color: p.accent, width: 2),),alignment: Alignment.center,diff --git a/ui/lib/pages/history_page.dart b/ui/lib/pages/history_page.dartindex 03a0bac..3bee538 100644--- a/ui/lib/pages/history_page.dart+++ b/ui/lib/pages/history_page.dart@@ -15,6 +15,8 @@ import '../widgets/image_preview_dialog.dart';import '../widgets/record_hover.dart';import '../icons.dart';import '../platform.dart';+import '../pixel_theme.dart';+import '../pixel_art.dart';export '../records.dart' show kindIcon, recordTitle, highlightMatches;@@ -136,14 +138,14 @@ class _HistoryPageState extends State<HistoryPage> {sliver: DecoratedSliver(decoration: BoxDecoration(color: context.palette.surface,- borderRadius: BorderRadius.circular(Radii.md),+ borderRadius: BorderRadius.circular(context.shape.md),border: Border.all(color: context.palette.border),),sliver: SliverPadding(padding: const EdgeInsets.all(Insets.xs),sliver: SliverList.separated(itemCount: records.length,- separatorBuilder: (_, _) => const Divider(indent: 44, endIndent: 8),+ separatorBuilder: (_, _) => const ThemedDivider(indent: 44, endIndent: 8),itemBuilder: (_, i) =>_RecordRow(record: records[i], highlight: searching ? state.searchQuery : null),),@@ -275,16 +277,18 @@ class _RecordRowState extends State<_RecordRow> {onExit: (_) => setState(() => _hovered = false),child: InkWell(onTap: previewable ? () => showImagePreview(context, r.id) : null,- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),child: Container(constraints: const BoxConstraints(minHeight: 52),padding: const EdgeInsets.symmetric(horizontal: Insets.md, vertical: Insets.sm),decoration: BoxDecoration(color: _hovered ? p.hover : Colors.transparent,- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),),child: Row(children: [+ // 像素主题:悬停的一行左边出现闪动的 ▶+ if (context.shape.pixel) SizedBox(width: 10, child: _hovered ? const PixelCursor() : null),Icon(kindIcon(r), size: 18, color: p.textDim),const SizedBox(width: Insets.md),Expanded(@@ -357,7 +361,7 @@ class _RecordRowState extends State<_RecordRow> {return const SizedBox(width: 16,height: 16,- child: CircularProgressIndicator(strokeWidth: 2),+ child: ThemedSpinner(strokeWidth: 2),);}switch (r.status) {@@ -378,7 +382,7 @@ class _RecordRowState extends State<_RecordRow> {// 知道总量时显示真实进度,否则显示不确定进度return SizedBox(width: 72,- child: LinearProgressIndicator(+ child: ThemedProgressBar(minHeight: 3,value: AppScope.of(context).progressOf(r.id),),diff --git a/ui/lib/pages/official_service_page.dart b/ui/lib/pages/official_service_page.dartindex 666744e..00e8bb0 100644--- a/ui/lib/pages/official_service_page.dart+++ b/ui/lib/pages/official_service_page.dart@@ -5,6 +5,7 @@ import '../i18n.dart';import '../main.dart';import '../theme.dart';import '../widgets/common.dart';+import '../pixel_theme.dart';import 'devices_page.dart' show connectionLabel, platformIcon;/// 官方服务:今日中转额度、各设备走直连还是中转、本机设备 ID。@@ -91,7 +92,7 @@ class OfficialServicePage extends StatelessWidget {Expanded(child: SelectableText(state.status?.deviceId ?? state.self?.id ?? '',- style: context.text.bodyMedium?.copyWith(fontFamily: monoFamily),+ style: context.text.bodyMedium?.copyWith(fontFamily: context.typography.mono),),),IconButton(@@ -206,8 +207,8 @@ class OfficialServicePage extends StatelessWidget {const SizedBox(height: Insets.md),// 条的长度是剩余额度:满格表示今天还没用ClipRRect(- borderRadius: BorderRadius.circular(3),- child: LinearProgressIndicator(+ borderRadius: BorderRadius.circular(context.shape.scaled(3)),+ child: ThemedProgressBar(value: limit > 0 ? (remaining / limit).clamp(0.0, 1.0) : 0,minHeight: 6,color: low ? p.warning : p.accent,diff --git a/ui/lib/pages/quick_paste_settings.dart b/ui/lib/pages/quick_paste_settings.dartindex f295092..57ad96c 100644--- a/ui/lib/pages/quick_paste_settings.dart+++ b/ui/lib/pages/quick_paste_settings.dart@@ -128,7 +128,7 @@ class _KeyCap extends StatelessWidget {padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),decoration: BoxDecoration(color: p.surface,- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),border: Border.all(color: active ? p.accent : p.border, width: active ? 1.5 : 1),),child: Text(text, textAlign: TextAlign.center, style: context.text.labelLarge),diff --git a/ui/lib/pages/send_page.dart b/ui/lib/pages/send_page.dartindex caf6bff..a0b97bf 100644--- a/ui/lib/pages/send_page.dart+++ b/ui/lib/pages/send_page.dart@@ -12,6 +12,7 @@ import '../i18n.dart';import '../icons.dart';import '../main.dart';import '../platform.dart';+import '../pixel_theme.dart';import '../theme.dart';import '../widgets/avatar.dart';import '../widgets/common.dart';@@ -23,6 +24,7 @@ import '../widgets/radar.dart';import '../widgets/record_hover.dart';import '../widgets/send_dialog.dart';import 'devices_page.dart' show platformIcon;+import '../pixel_art.dart';/// 隔空传送:雷达上是已配对的设备,把文件拖到一台上,或者点它在弹出的窗口里拖,就直接发过去。/// 下面是收到的和发出的列表。见 design/send-files.md。@@ -427,6 +429,7 @@ class _SendPageState extends State<SendPage> with SingleTickerProviderStateMixinhighlight: _dragging,innerGaps: innerGaps,outerGaps: outerGaps,+ pixel: context.shape.pixel ? context.shape.unit * 2 : 0,),),),@@ -595,6 +598,7 @@ class _SendRadarPainter extends CustomPainter {required this.highlight,this.innerGaps = const [],this.outerGaps = const [],+ this.pixel = 0,}) : super(repaint: pulse);final Animation<double> pulse;@@ -609,10 +613,23 @@ class _SendRadarPainter extends CustomPainter {final List<(double, double)> innerGaps;final List<(double, double)> outerGaps;+ /// 大于 0 时按这么大的方格画(像素主题):轨道是点线,波纹一圈圈跳着往外走+ final double pixel;+@overridevoid paint(Canvas canvas, Size size) {final c = size.center(Offset.zero);Rect oval(double rx, double ry) => Rect.fromCenter(center: c, width: rx * 2, height: ry * 2);+ if (pixel > 0) {+ final t = (pulse.value * 8).floorToDouble() / 8;+ final k = Curves.easeOut.transform(t);+ drawPixelOval(canvas, oval(30 + (outer.width - 30) * k, 30 + (outer.height - 30) * k),+ wave.withValues(alpha: 0.6 * (1 - t)), pixel);+ final ringColor = highlight ? wave : ring;+ drawPixelOval(canvas, oval(inner.width, inner.height), ringColor, pixel, gaps: innerGaps, dashed: true);+ drawPixelOval(canvas, oval(outer.width, outer.height), ringColor, pixel, gaps: outerGaps, dashed: true);+ return;+ }// 扩散的光带:边缘最亮,向里渐隐,越往外越淡final t = pulse.value;@@ -665,6 +682,7 @@ class _SendRadarPainter extends CustomPainter {old.inner != inner ||old.outer != outer ||old.highlight != highlight ||+ old.pixel != pixel ||old.innerGaps.toString() != innerGaps.toString() ||old.outerGaps.toString() != outerGaps.toString();}@@ -723,6 +741,15 @@ class _SendNode extends StatefulWidget {class _SendNodeState extends State<_SendNode> {bool _hover = false;+ /// 发完一批加一:像素主题里在设备上迸一圈星星+ int _finished = 0;++ @override+ void didUpdateWidget(_SendNode old) {+ super.didUpdateWidget(old);+ if (old.sending && !widget.sending) _finished++;+ }+@overrideWidget build(BuildContext context) {final p = context.palette;@@ -734,47 +761,58 @@ class _SendNodeState extends State<_SendNode> {? p.accent.withValues(alpha: widget.dropTarget || _hover ? 1 : 0.6): p.border;+ final pixel = context.shape.pixel;final node = Column(mainAxisSize: MainAxisSize.min,children: [AnimatedScale(- scale: widget.dropTarget ? 1.08 : 1,- duration: const Duration(milliseconds: 120),- child: SizedBox.square(- dimension: _SendNode.avatar,- child: Stack(- clipBehavior: Clip.none,- alignment: Alignment.center,- children: [- AnimatedContainer(- duration: const Duration(milliseconds: 120),- decoration: BoxDecoration(- shape: BoxShape.circle,- color: widget.dropTarget ? Color.alphaBlend(p.accent.withValues(alpha: 0.08), p.surface) : p.surface,- border: Border.all(color: border, width: highlight || widget.dropping ? 1.5 : 1),- boxShadow: const [BoxShadow(color: Color(0x14000000), blurRadius: 8, offset: Offset(0, 2))],- ),- ),- Icon(platformIcon(d.platform), size: 24, color: highlight ? p.accent : p.textDim),- if (widget.sending)- SizedBox.expand(- child: CircularProgressIndicator(strokeWidth: 2, value: widget.progress),+ // 像素主题不放大,改成一格一格上下跳+ scale: widget.dropTarget && !pixel ? 1.08 : 1,+ duration: context.motion.duration(const Duration(milliseconds: 120)),+ curve: context.motion.curve(Curves.linear),+ child: PixelBounce(+ active: pixel && widget.dropTarget,+ child: SizedBox.square(+ dimension: _SendNode.avatar,+ child: Stack(+ clipBehavior: Clip.none,+ alignment: Alignment.center,+ children: [+ AnimatedContainer(+ duration: context.motion.duration(const Duration(milliseconds: 120)),+ curve: context.motion.curve(Curves.linear),+ decoration: context.shape.circle(+ color: widget.dropTarget ? Color.alphaBlend(p.accent.withValues(alpha: 0.08), p.surface) : p.surface,+ border: border,+ borderWidth: highlight || widget.dropping ? 1.5 : 1,+ shadows: context.shape.shadows(const Color(0x14000000), blur: 8, offset: const Offset(0, 2)),+ ),),- if (widget.dot != null)- Positioned(- right: 2,- bottom: 2,- child: Container(- width: 12,- height: 12,- decoration: BoxDecoration(- color: widget.dot,- shape: BoxShape.circle,- border: Border.all(color: p.background, width: 2),+ Icon(platformIcon(d.platform), size: 24, color: highlight ? p.accent : p.textDim),+ if (widget.sending)+ SizedBox.expand(+ child: ThemedSpinner(strokeWidth: 2, value: widget.progress),+ ),+ if (widget.dot != null)+ Positioned(+ right: 2,+ bottom: 2,+ child: Container(+ width: 12,+ height: 12,+ decoration: context.shape.circle(color: widget.dot, border: p.background, borderWidth: 2),),),- ),- ],+ // 像素主题:发送中一架纸飞机往设备飞,发完迸一圈星星+ if (pixel && widget.sending) const Positioned(left: -30, top: -18, child: PixelPlane()),+ if (pixel && _finished > 0)+ Positioned(+ left: -30,+ top: -30,+ child: PixelBurst(key: ValueKey(_finished), size: _SendNode.avatar + 60),+ ),+ ],+ ),),),),@@ -960,7 +998,7 @@ class _TransferRowState extends State<_TransferRow> {padding: const EdgeInsets.symmetric(horizontal: Insets.md, vertical: Insets.sm),decoration: BoxDecoration(color: _hovered ? p.hover : Colors.transparent,- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),),child: Row(children: [@@ -998,7 +1036,7 @@ class _TransferRowState extends State<_TransferRow> {Text(l.transferRenamed(t.renamedFiles.toInt()), style: context.text.bodySmall),if (active) ...[const SizedBox(height: 4),- LinearProgressIndicator(+ ThemedProgressBar(minHeight: 3,value: t.totalBytes > 0 ? t.doneBytes.toInt() / t.totalBytes.toInt() : null,),@@ -1029,7 +1067,7 @@ class _TransferRowState extends State<_TransferRow> {final path = t.thumbs.where((x) => x.isNotEmpty).firstOrNull;if (path == null || !File(path).existsSync()) return null;return ClipRRect(- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),child: Image.file(File(path), width: 36, height: 36, fit: BoxFit.cover, cacheWidth: 72),);}@@ -1317,14 +1355,15 @@ class _PersonNodeState extends State<_PersonNode> {children: [AnimatedScale(scale: _dropping ? 1.08 : 1,- duration: const Duration(milliseconds: 120),+ duration: context.motion.duration(const Duration(milliseconds: 120)),+ curve: context.motion.curve(Curves.linear),child: Stack(alignment: Alignment.center,children: [DecoratedBox(- decoration: BoxDecoration(- shape: BoxShape.circle,- border: Border.all(color: highlight ? p.accent : Colors.transparent, width: 2),+ decoration: context.shape.circle(+ border: highlight ? p.accent : Colors.transparent,+ borderWidth: 2,),child: Padding(padding: const EdgeInsets.all(2),@@ -1340,7 +1379,7 @@ class _PersonNodeState extends State<_PersonNode> {if (sending != null)SizedBox.square(dimension: 52,- child: CircularProgressIndicator(+ child: ThemedSpinner(strokeWidth: 2,value: sending.status == 'active' && sending.totalBytes > 0? sending.doneBytes.toInt() / sending.totalBytes.toInt()diff --git a/ui/lib/pages/service_page.dart b/ui/lib/pages/service_page.dartindex 274d93f..0c2e235 100644--- a/ui/lib/pages/service_page.dart+++ b/ui/lib/pages/service_page.dart@@ -8,6 +8,7 @@ import '../i18n.dart';import '../main.dart';import '../theme.dart';import '../widgets/common.dart';+import '../pixel_art.dart';/// 后台服务没装、没在跑时的引导页。///@@ -82,10 +83,10 @@ class _ServicePageState extends State<ServicePage> {FilledButton(onPressed: _busy ? null : () => _run(state.enableService),child: _busy- ? const SizedBox(+ ? SizedBox(width: 14,height: 14,- child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),+ child: ThemedSpinner(strokeWidth: 2, color: context.palette.onAccent),): Text(button),),diff --git a/ui/lib/pages/settings_page.dart b/ui/lib/pages/settings_page.dartindex eecf5f7..4d08fd0 100644--- a/ui/lib/pages/settings_page.dart+++ b/ui/lib/pages/settings_page.dart@@ -16,8 +16,10 @@ import '../widgets/feedback_dialog.dart';import '../widgets/update_dialog.dart';import '../icons.dart';import '../platform.dart';+import 'appearance_settings.dart';import 'quick_paste_settings.dart';import 'send_settings.dart';+import '../pixel_art.dart';class SettingsPage extends StatefulWidget {const SettingsPage({super.key});@@ -85,7 +87,7 @@ class _SettingsPageState extends State<SettingsPage> {),);}- return const Center(child: CircularProgressIndicator(strokeWidth: 2.5));+ return const Center(child: ThemedSpinner(strokeWidth: 2.5));}_syncControllers(cfg);// 好友连不上时点「打开服务…」等:直接进到某一类@@ -251,7 +253,7 @@ class _SettingsPageState extends State<SettingsPage> {child: TextField(controller: _serverController,style: context.text.bodyMedium?.copyWith(- fontFamily: monoFamily,+ fontFamily: context.typography.mono,fontSize: 12,),decoration: InputDecoration(@@ -432,6 +434,7 @@ class _SettingsPageState extends State<SettingsPage> {),),],+ _Category.appearance: [const AppearanceSection()],_Category.quickPaste: [QuickPasteSection(config: cfg,@@ -819,7 +822,7 @@ class _Dropdown<T> extends StatelessWidget {padding: const EdgeInsets.fromLTRB(10, 5, 8, 5),decoration: BoxDecoration(color: p.surface,- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),border: Border.all(color: p.border),),child: Row(@@ -838,6 +841,7 @@ class _Dropdown<T> extends StatelessWidget {/// 设置的类别:首页列出来,点进去是各自的一页enum _Category {general,+ appearance,connection,sync,quickPaste,@@ -850,6 +854,7 @@ enum _Category {String title(AppLocalizations l) => switch (this) {general => l.general,+ appearance => l.appearance,connection => l.settingsConnection,sync => l.sync,quickPaste => l.quickPaste,@@ -860,6 +865,7 @@ enum _Category {String summary(AppLocalizations l) => switch (this) {general => l.settingsGeneralSummary,+ appearance => l.settingsAppearanceSummary,connection => l.settingsConnectionSummary,sync => l.settingsSyncSummary,quickPaste => l.settingsQuickPasteSummary,@@ -870,6 +876,7 @@ enum _Category {IconData get icon => switch (this) {general => AppIcons.gear,+ appearance => AppIcons.paint,connection => AppIcons.globe,sync => AppIcons.sync,quickPaste => AppIcons.keyboard,@@ -892,7 +899,7 @@ class _CategoryList extends StatelessWidget {final String version;static const _groups = [- [_Category.general, _Category.connection],+ [_Category.general, _Category.appearance, _Category.connection],[_Category.sync, _Category.quickPaste, _Category.send],[_Category.storage, _Category.about],];diff --git a/ui/lib/picker/picker_state.dart b/ui/lib/picker/picker_state.dartindex 842735f..24062ad 100644--- a/ui/lib/picker/picker_state.dart+++ b/ui/lib/picker/picker_state.dart@@ -11,6 +11,7 @@ import '../gen/pasteferry/v1/daemon.pb.dart';import '../gen/pasteferry/v1/daemon.pbgrpc.dart' show DaemonServiceClient;import '../hotkey.dart';import '../records.dart';+import '../theme_controller.dart';import '../widgets/record_hover.dart';import 'picker_host.dart';@@ -51,6 +52,9 @@ class PickerState extends ChangeNotifier implements RecordDetails {/// 界面语言跟着设置走,单独通知,免得每次列表变化都重建 MaterialAppfinal language = ValueNotifier<String>('');+ /// 主题与深浅模式,跟主窗口用同一份配置+ final theme = ThemeController();+bool _connected = false;bool get connected => _connected;Config? get config => _config;@@ -150,6 +154,7 @@ class PickerState extends ChangeNotifier implements RecordDetails {..addAll((results[1] as ListHistoryResponse).records.where((r) => r.favorite));_config = results[2] as Config;language.value = _config!.language;+ await theme.attach(conn.client, _config!);_events = conn.client.subscribe(SubscribeRequest()).listen(_onEvent,onError: (_) => _lost(),@@ -266,7 +271,10 @@ class PickerState extends ChangeNotifier implements RecordDetails {case Event_Payload.configChanged:_config = ev.configChanged;language.value = _config!.language;+ theme.applyConfig(ev.configChanged);_applyConfig();+ case Event_Payload.themesChanged:+ theme.onThemesChanged(ev.themesChanged);case Event_Payload.progress:final p = ev.progress;if (p.total > 0) _progress[p.clipId] = (p.transferred.toInt() / p.total.toInt()).clamp(0.0, 1.0);diff --git a/ui/lib/picker/picker_view.dart b/ui/lib/picker/picker_view.dartindex 95e2c98..91bacb3 100644--- a/ui/lib/picker/picker_view.dart+++ b/ui/lib/picker/picker_view.dart@@ -12,6 +12,7 @@ import '../records.dart';import '../theme.dart';import '../widgets/common.dart' show committedText, humanBytes, relativeTime;import '../widgets/record_hover.dart';+import '../pixel_theme.dart';import 'picker_state.dart';/// 快捷粘贴窗口。窗口本身由原生外壳创建(Mac 上是不抢焦点的 NSPanel),大小固定,这里画满整个窗口。@@ -23,12 +24,13 @@ class PickerApp extends StatelessWidget {@overrideWidget build(BuildContext context) {- return ValueListenableBuilder<String>(- valueListenable: state.language,- builder: (context, language, _) {- final locale = localeFromSetting(language);+ return ListenableBuilder(+ listenable: Listenable.merge([state.language, state.theme]),+ builder: (context, _) {+ final locale = localeFromSetting(state.language.value);final tag = (locale ?? resolveLocale(WidgetsBinding.instance.platformDispatcher.locales)).toLanguageTag();- ThemeData theme(Brightness b) => buildTheme(b, language: tag).copyWith(+ final spec = state.theme.spec;+ ThemeData theme(Brightness b) => buildTheme(b, spec: spec, language: tag).copyWith(// 窗口是透明的,圆角外面要透出桌面(Mac)scaffoldBackgroundColor: Colors.transparent,canvasColor: Colors.transparent,@@ -39,13 +41,14 @@ class PickerApp extends StatelessWidget {color: Colors.transparent,theme: theme(Brightness.light),darkTheme: theme(Brightness.dark),+ themeMode: state.theme.mode,locale: locale,supportedLocales: supportedLocales,localizationsDelegates: AppLocalizations.localizationsDelegates,localeListResolutionCallback: (preferred, _) => resolveLocale(preferred),builder: (context, child) {appL10n = context.l10n;- return child!;+ return ThemeTextScale(child: child!);},home: PickerView(state: state),);@@ -220,12 +223,15 @@ class _PickerViewState extends State<PickerView> {onKeyEvent: _onKey,child: Container(clipBehavior: Clip.antiAlias,- decoration: BoxDecoration(- color: p.surface,- // Mac 上窗口透明,自己画圆角;Windows 11 的圆角由系统画,Linux 用直角- borderRadius: _mac ? BorderRadius.circular(Radii.lg) : null,- border: Border.all(color: p.border),- ),+ // 像素主题:切角粗边的窗口+ decoration: context.shape.pixel+ ? context.shape.box(color: p.surface, border: p.borderStrong)+ : BoxDecoration(+ color: p.surface,+ // Mac 上窗口透明,自己画圆角;Windows 11 的圆角由系统画,Linux 用直角+ borderRadius: _mac ? BorderRadius.circular(context.shape.lg) : null,+ border: Border.all(color: p.border),+ ),child: ListenableBuilder(listenable: s,builder: (context, _) => Column(@@ -301,7 +307,7 @@ class _PickerViewState extends State<PickerView> {alignment: Alignment.center,decoration: BoxDecoration(color: t == s.tab ? p.fill : Colors.transparent,- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),),child: Text(label(t),@@ -464,7 +470,7 @@ class _KeyHint extends StatelessWidget {alignment: Alignment.center,decoration: BoxDecoration(color: p.fill,- borderRadius: BorderRadius.circular(4),+ borderRadius: BorderRadius.circular(context.shape.scaled(4)),border: Border.all(color: p.border, width: 0.5),),child: k.enter ? Icon(AppIcons.returnKey, size: 10, color: p.textDim) : Text(k.text, style: capStyle),@@ -502,9 +508,11 @@ class _PickerRow extends StatelessWidget {final p = context.palette;final r = record;final enabled = PickerState.selectable(r);- final onAccent = selected && enabled;- final fg = !enabled ? p.textFaint : (onAccent ? Colors.white : p.text);- final sub = onAccent ? Colors.white.withValues(alpha: 0.8) : p.textFaint;+ // 像素主题:选中行不填强调色,左边一条强调色竖条+ final bar = context.shape.pixel && selected && enabled;+ final onAccent = selected && enabled && !bar;+ final fg = !enabled ? p.textFaint : (onAccent ? p.onAccent : p.text);+ final sub = onAccent ? p.onAccent.withValues(alpha: 0.8) : p.textFaint;final pending = state.pendingId == r.id;final isImage = r.kind == ClipKind.CLIP_KIND_IMAGE || (r.kind == ClipKind.CLIP_KIND_FILE && r.imageCount == 1 && r.items.length == 1);if (isImage) state.loadThumbnail(r);@@ -529,29 +537,31 @@ class _PickerRow extends StatelessWidget {child: Container(margin: const EdgeInsets.symmetric(horizontal: Insets.xs),padding: const EdgeInsets.symmetric(horizontal: Insets.sm),- decoration: BoxDecoration(- color: onAccent ? p.accent : (selected ? p.hover : Colors.transparent),- borderRadius: BorderRadius.circular(Radii.sm),- ),+ decoration: bar+ ? BoxDecoration(color: p.selection, border: Border(left: BorderSide(color: p.accent, width: 4)))+ : BoxDecoration(+ color: onAccent ? p.accent : (selected ? p.hover : Colors.transparent),+ borderRadius: BorderRadius.circular(context.shape.sm),+ ),child: Row(children: [SizedBox(width: Platform.isMacOS ? 26 : 40,child: number == null? null- : Text(number!, style: context.text.labelMedium?.copyWith(color: onAccent ? Colors.white : dim)),+ : Text(number!, style: context.text.labelMedium?.copyWith(color: onAccent ? p.onAccent : dim)),),SizedBox(width: 22,height: 22,child: thumb != null && thumb.isNotEmpty? ClipRRect(- borderRadius: BorderRadius.circular(3),+ borderRadius: BorderRadius.circular(context.shape.scaled(3)),child: Image.file(File(thumb), fit: BoxFit.cover, cacheWidth: 64,errorBuilder: (_, _, _) => Icon(kindIcon(r), size: 16, color: sub)),): Icon(r.status == ClipStatus.CLIP_STATUS_REMOTE_ONLY ? AppIcons.arrowDownCircle : kindIcon(r),- size: 16, color: onAccent ? Colors.white : p.textDim),+ size: 16, color: onAccent ? p.onAccent : p.textDim),),const SizedBox(width: Insets.sm),Expanded(@@ -564,13 +574,13 @@ class _PickerRow extends StatelessWidget {),if (!favoritesTab && r.favorited) ...[const SizedBox(width: Insets.xs),- Icon(AppIcons.starFill, size: 12, color: onAccent ? Colors.white : p.accent),+ Icon(AppIcons.starFill, size: 12, color: onAccent ? p.onAccent : p.accent),],const SizedBox(width: Insets.sm),if (pending)SizedBox(width: 60,- child: LinearProgressIndicator(minHeight: 3, value: state.progressOf(r.id)),+ child: ThemedProgressBar(minHeight: 3, value: state.progressOf(r.id)),)elseConstrainedBox(diff --git a/ui/lib/pixel_art.dart b/ui/lib/pixel_art.dartnew file mode 100644index 0000000..95784e0--- /dev/null+++ b/ui/lib/pixel_art.dart@@ -0,0 +1,792 @@+import 'dart:math' as math;++import 'package:flutter/foundation.dart' show ValueListenable;+import 'package:flutter/material.dart';+import 'package:flutter/scheduler.dart';++import 'icons.dart';+import 'theme.dart';++// 像素主题的画面与动效:页眉场景、侧边栏的营地、空状态插画、菜单光标、四格加载、星星迸开、+// 上下跳、纸飞机、扫描线。设计见 design/pixel-theme.md 第 12 节,样稿 design/pixel-theme-art-mockup.html。+//+// 都由程序按规则画,不打包图片:山脊是几条正弦叠加,星星、树按坐标算伪随机数,插画用方块拼。+// 只在像素主题里出现;系统开了「减少动态效果」时只画静止的一帧。++/// 画面里一格是几个逻辑像素+const _u = 2.0;++/// 按坐标算的伪随机数,同一个位置每次都一样,窗口大小变了也不会闪+int _hash(int v) {+ var x = (v ^ 0x5bd1e995) & 0x7fffffff;+ x = ((x ^ (x >> 15)) * 0x2c1b3c6d) & 0x7fffffff;+ x = ((x ^ (x >> 12)) * 0x297a2d39) & 0x7fffffff;+ return x ^ (x >> 15);+}++double _rand(int seed) => (_hash(seed) % 10000) / 10000;++/// 4×4 的 Bayer 抖动矩阵:场景底部按它一格一格渐隐进背景色+const _bayer = [+ [0, 8, 2, 10],+ [12, 4, 14, 6],+ [3, 11, 1, 9],+ [15, 7, 13, 5],+];++void _cell(Canvas c, double x, double y, double w, double h, Color color) =>+ c.drawRect(Rect.fromLTWH(x * _u, y * _u, w * _u, h * _u), Paint()..color = color);++bool _still(BuildContext context) => MediaQuery.maybeDisableAnimationsOf(context) ?? false;++/// 按固定帧率走的计数器:场景里的星星、萤火虫、篝火都用它,[fps] 帧每秒。+/// 减少动态效果时停在第 0 帧。+mixin _Frames<T extends StatefulWidget> on State<T>, SingleTickerProviderStateMixin<T> {+ final frame = ValueNotifier<int>(0);+ Ticker? _ticker;++ int get fps;++ void syncTicker(bool run) {+ if (run && _ticker == null) {+ _ticker = createTicker((d) => frame.value = d.inMilliseconds * fps ~/ 1000)..start();+ } else if (!run && _ticker != null) {+ _ticker!.dispose();+ _ticker = null;+ frame.value = 0;+ }+ }++ @override+ void dispose() {+ _ticker?.dispose();+ frame.dispose();+ super.dispose();+ }+}++// ───────────────────────────── 页眉场景 ─────────────────────────────++/// 内容区顶部的场景:深色是夜里的远山、松树、月亮、星星和萤火虫,浅色是太阳、方块云与丘陵。+/// 底部渐隐进背景色,标题叠在上面照样清楚。只在像素主题里画。+class PixelScene extends StatefulWidget {+ const PixelScene({super.key, this.height = 180});++ final double height;++ @override+ State<PixelScene> createState() => _PixelSceneState();+}++class _PixelSceneState extends State<PixelScene> with SingleTickerProviderStateMixin, _Frames {+ @override+ int get fps => 2;++ @override+ Widget build(BuildContext context) {+ final shape = context.shape;+ syncTicker(shape.pixel && !_still(context) && TickerMode.valuesOf(context).enabled);+ if (!shape.pixel) return const SizedBox.shrink();+ final night = Theme.of(context).brightness == Brightness.dark;+ final bg = context.palette.background;+ return SizedBox(+ height: widget.height,+ width: double.infinity,+ child: Stack(+ fit: StackFit.expand,+ children: [+ // 不动的部分单独一层,只在窗口大小或配色变了时重画+ RepaintBoundary(child: CustomPaint(painter: _SceneStatic(night, bg))),+ CustomPaint(painter: _SceneLive(night, frame)),+ ],+ ),+ );+ }+}++class _ScenePalette {+ const _ScenePalette(this.sky, this.far, this.mid, this.near, this.tree);++ final List<Color> sky;+ final Color far, mid, near, tree;++ static const night = _ScenePalette(+ [Color(0xFF0E1014), Color(0xFF101318), Color(0xFF12161C), Color(0xFF151A21)],+ Color(0xFF1B2131),+ Color(0xFF222A3B),+ Color(0xFF29334A),+ Color(0xFF313D57),+ );+ static const day = _ScenePalette(+ [Color(0xFFEEF3F4), Color(0xFFEAF0F2), Color(0xFFE5EDF0), Color(0xFFE0E9EC)],+ Color(0xFFD3DFDC),+ Color(0xFFC2D3CA),+ Color(0xFFB2C8BB),+ Color(0xFF9BB7A6),+ );+}++class _SceneStatic extends CustomPainter {+ _SceneStatic(this.night, this.background);++ final bool night;+ final Color background;++ @override+ void paint(Canvas canvas, Size size) {+ final w = (size.width / _u).ceil(), h = (size.height / _u).floor();+ if (w <= 0 || h <= 0) return;+ final p = night ? _ScenePalette.night : _ScenePalette.day;+ final skyH = (h * 0.7).floor();+ for (var i = 0; i < 4; i++) {+ _cell(canvas, 0, (skyH * i / 4).floorToDouble(), w.toDouble(), (skyH / 4).ceilToDouble() + 1, p.sky[i]);+ }+ _cell(canvas, 0, skyH.toDouble(), w.toDouble(), (h - skyH).toDouble(), p.sky[3]);++ // 月亮(弯月:一个圆被天色的圆挡掉一角)或太阳+ final mx = (w * 0.82).floorToDouble(), my = (h * 0.28).floorToDouble();+ _disc(canvas, mx, my, 7, night ? const Color(0xFFE9E5D2) : const Color(0xFFF3E3A6));+ if (night) _disc(canvas, mx + 3, my - 2, 6, p.sky[1]);+ if (!night) {+ for (final (fx, fy, cw) in const [(0.12, 0.18, 14.0), (0.42, 0.1, 10.0), (0.62, 0.3, 16.0)]) {+ final cx = (w * fx).floorToDouble(), cy = (h * fy).floorToDouble();+ _cell(canvas, cx, cy + 2, cw, 3, Colors.white);+ _cell(canvas, cx + 3, cy, cw - 6, 2, Colors.white);+ _cell(canvas, cx + 5, cy - 1, 4, 1, Colors.white);+ _cell(canvas, cx + 1, cy + 5, cw - 2, 1, const Color(0xFFE3ECEE));+ }+ }++ _ridge(canvas, w, h, h * 0.6, h * 0.16, 0.016, p.far, 3);+ _ridge(canvas, w, h, h * 0.47, h * 0.11, 0.028, p.mid, 5);+ _ridge(canvas, w, h, h * 0.36, h * 0.06, 0.05, p.near, 9);++ // 松树:近处山脊上稀稀拉拉的三角+ var i = 0, k = 0;+ while (i < w) {+ final r = _rand(k * 31 + 11);+ if (r >= 0.5) {+ final th = 4 + (_hash(k * 7 + 3) % 6);+ final ty = (h - h * 0.34 - _rand(k * 13) * 3).floorToDouble();+ for (var j = 0; j < th; j++) {+ final half = ((th - j) / 2.2).floor();+ _cell(canvas, (i - half).toDouble(), ty - j, half * 2 + 1, 1, p.tree);+ }+ _cell(canvas, i.toDouble(), ty + 1, 1, 2, p.tree);+ }+ i += 3 + (_hash(k * 17 + 5) % 9);+ k++;+ }++ // 底部抖动渐隐+ final fade = (h * 0.18).floor(), start = h - fade;+ final paint = Paint()..color = background;+ for (var y = start; y < h; y++) {+ final t = (y - start) / fade;+ for (var x = 0; x < w; x++) {+ if (_bayer[y % 4][x % 4] / 16 < t) canvas.drawRect(Rect.fromLTWH(x * _u, y * _u, _u, _u), paint);+ }+ }+ // 最后一行之下直接是背景色,不留缝+ canvas.drawRect(Rect.fromLTWH(0, h * _u, size.width, size.height - h * _u), paint);+ }++ void _disc(Canvas c, double cx, double cy, int r, Color color) {+ for (var y = -r; y <= r; y++) {+ for (var x = -r; x <= r; x++) {+ if (x * x + y * y <= r * r + r * 0.8) _cell(c, cx + x, cy + y, 1, 1, color);+ }+ }+ }++ void _ridge(Canvas c, int w, int h, double base, double amp, double freq, Color color, int seed) {+ final ph = [_rand(seed) * 10, _rand(seed + 1) * 10, _rand(seed + 2) * 10];+ for (var x = 0; x < w; x++) {+ final hh = base ++ amp *+ (math.sin(x * freq + ph[0]) * 0.6 ++ math.sin(x * freq * 2.3 + ph[1]) * 0.3 ++ math.sin(x * freq * 5.1 + ph[2]) * 0.1);+ _cell(c, x.toDouble(), (h - hh).floorToDouble(), 1, hh.ceilToDouble(), color);+ }+ }++ @override+ bool shouldRepaint(_SceneStatic old) => old.night != night || old.background != background;+}++/// 会动的部分:星星一颗颗地闪,萤火虫一明一灭(深色)+class _SceneLive extends CustomPainter {+ _SceneLive(this.night, this.frame) : super(repaint: frame);++ final bool night;+ final ValueListenable<int> frame;++ @override+ void paint(Canvas canvas, Size size) {+ if (!night) return;+ final w = (size.width / _u).ceil(), h = (size.height / _u).floor();+ final f = frame.value;+ const star = [Color(0xFFC9D1E0), Color(0xFF8C96A8), Color(0xFF3DDC97)];+ final n = (w * h * 0.45 / 260).round();+ for (var i = 0; i < n; i++) {+ if ((f + i) % 7 == 0) continue;+ final sx = (_rand(i * 3 + 1) * w).floorToDouble(), sy = (_rand(i * 3 + 2) * h * 0.45).floorToDouble();+ final k = _rand(i * 3 + 3);+ final c = k < 0.08 ? star[2] : (k < 0.4 ? star[0] : star[1]);+ _cell(canvas, sx, sy, 1, 1, c);+ if (k > 0.97) {+ _cell(canvas, sx - 1, sy, 3, 1, c);+ _cell(canvas, sx, sy - 1, 1, 3, c);+ }+ }+ for (var i = 0; i < 14; i++) {+ if ((f + i) % 3 == 0) continue;+ _cell(canvas, (_rand(i * 5 + 101) * w).floorToDouble(), (h * 0.5 + _rand(i * 5 + 102) * h * 0.2).floorToDouble(), 1, 1,+ const Color(0xFF3DDC97));+ }+ }++ @override+ bool shouldRepaint(_SceneLive old) => old.night != night;+}++// ───────────────────────────── 侧边栏营地 ─────────────────────────────++/// 侧边栏底下的一小块地:深色是草地、帐篷和篝火(火苗会跳),浅色是草地、小房子和花+class PixelCamp extends StatefulWidget {+ const PixelCamp({super.key, this.height = 64});++ final double height;++ @override+ State<PixelCamp> createState() => _PixelCampState();+}++class _PixelCampState extends State<PixelCamp> with SingleTickerProviderStateMixin, _Frames {+ @override+ int get fps => 4;++ @override+ Widget build(BuildContext context) {+ final night = Theme.of(context).brightness == Brightness.dark;+ syncTicker(night && !_still(context) && TickerMode.valuesOf(context).enabled);+ return SizedBox(+ height: widget.height,+ width: double.infinity,+ child: CustomPaint(painter: _CampPainter(night, frame)),+ );+ }+}++class _CampPainter extends CustomPainter {+ _CampPainter(this.night, this.frame) : super(repaint: frame);++ final bool night;+ final ValueListenable<int> frame;++ @override+ void paint(Canvas canvas, Size size) {+ final w = (size.width / _u).ceil(), h = (size.height / _u).floor();+ final grass = night+ ? const [Color(0xFF1D2A24), Color(0xFF22332B), Color(0xFF18231E)]+ : const [Color(0xFFCFDCCB), Color(0xFFC2D3BE), Color(0xFFB6CAB1)];+ final dirt = night+ ? const [Color(0xFF1A1712), Color(0xFF211C16), Color(0xFF15120E)]+ : const [Color(0xFFD9CDB8), Color(0xFFCFC2AB), Color(0xFFE2D7C4)];+ final ground = h - 10;+ for (var x = 0; x < w; x++) {+ final top = ground + _hash(x * 7) % 2;+ for (var y = top; y < h; y++) {+ _cell(canvas, x.toDouble(), y.toDouble(), 1, 1, (y < top + 3 ? grass : dirt)[_hash(x * 131 + y * 17) % 3]);+ }+ if (_hash(x * 29) % 4 == 0) _cell(canvas, x.toDouble(), top - 1.0 - _hash(x) % 2, 1, 1, grass[1]);+ }+ if (night) {+ // 帐篷+ final tx = (w * 0.28).floorToDouble(), ty = ground.toDouble();+ for (var k = 0; k < 8; k++) {+ _cell(canvas, tx - k, ty - 8 + k, 2.0 * k + 1, 1, k.isOdd ? const Color(0xFF2B3A52) : const Color(0xFF33456A));+ }+ _cell(canvas, tx, ty - 4, 1, 4, const Color(0xFF141A26));+ // 篝火:两根柴,火苗每帧换一个样子,火星往上飘+ final fx = (w * 0.64).floorToDouble(), fy = ground - 1.0;+ final f = frame.value;+ _cell(canvas, fx - 3, fy + 1, 7, 1, const Color(0xFF5A3A22));+ _cell(canvas, fx - 2, fy, 5, 1, const Color(0xFF6E4A2C));+ final sway = f.isOdd ? 1.0 : 0.0;+ for (final (dx, dy) in const [(0, -1), (1, -1), (-1, -1), (0, -2), (1, -2), (0, -3)]) {+ _cell(canvas, fx + dx + (dy < -1 ? sway : 0), fy + dy, 1, 1, const Color(0xFFFFB547));+ }+ for (final (dx, dy) in const [(-1, 0), (0, 0), (1, 0), (0, -1)]) {+ _cell(canvas, fx + dx, fy + dy, 1, 1, const Color(0xFFFF6B3D));+ }+ _cell(canvas, fx, fy - 1, 1, 1, const Color(0xFFFFE48A));+ for (var i = 0; i < 3; i++) {+ _cell(canvas, fx + (i - 1) * 2, fy - 5 - (f + i * 3) % 8, 1, 1, const Color(0xFFFFB547));+ }+ } else {+ // 小房子和花+ final tx = (w * 0.3).floorToDouble(), ty = ground.toDouble();+ _cell(canvas, tx - 6, ty - 7, 13, 7, const Color(0xFFF1E6D3));+ for (var k = 0; k < 5; k++) {+ _cell(canvas, tx - 7 + k, ty - 8 - k, 15.0 - 2 * k, 1, const Color(0xFFC9785A));+ }+ _cell(canvas, tx - 1, ty - 4, 3, 4, const Color(0xFF8C5A43));+ _cell(canvas, tx + 3, ty - 6, 2, 2, const Color(0xFF9CC9F0));+ const petals = [Color(0xFFF2A7B5), Color(0xFFF6D06B), Color(0xFF9CC9F0)];+ for (var i = 0; i < 7; i++) {+ final x = 4 + (_rand(i * 9 + 1) * (w - 8)).floorToDouble();+ if ((x - tx).abs() < 9) continue;+ _cell(canvas, x, ty - 2, 1, 2, const Color(0xFF7FA77A));+ _cell(canvas, x, ty - 3, 1, 1, petals[i % 3]);+ }+ }+ }++ @override+ bool shouldRepaint(_CampPainter old) => old.night != night;+}++// ───────────────────────────── 插画 ─────────────────────────────++/// 空状态、引导、出错时的像素插画+enum PixelArtKind {+ clipboard,+ devices,+ plane,+ chest,+ cloud,+ friends,+ laptop,+ desktop,+ phone;++ /// 空状态原来用的图标对应哪张插画;没有对应的返回 null,照旧显示图标+ static PixelArtKind? forIcon(IconData icon) {+ if (icon == AppIcons.clock || icon == AppIcons.star || icon == AppIcons.starFill || icon == AppIcons.docOnClipboard) {+ return clipboard;+ }+ if (icon == AppIcons.deviceLaptop || icon == AppIcons.desktopComputer || icon == AppIcons.radar) return devices;+ if (icon == AppIcons.send) return plane;+ if (icon == AppIcons.people || icon == AppIcons.personAdd || icon == AppIcons.person) return friends;+ if (icon == AppIcons.wifiOff || icon == AppIcons.exclamationmarkCircle || icon == AppIcons.cloud) return cloud;+ if (icon == AppIcons.phone) return phone;+ return null;+ }+}++/// 一张像素插画,每格 [scale] 个逻辑像素+class PixelArt extends StatelessWidget {+ const PixelArt(this.kind, {super.key, this.scale = 4});++ final PixelArtKind kind;+ final double scale;++ static const _sizes = {+ PixelArtKind.clipboard: Size(24, 26),+ PixelArtKind.devices: Size(28, 16),+ PixelArtKind.plane: Size(24, 14),+ PixelArtKind.chest: Size(24, 20),+ PixelArtKind.cloud: Size(24, 18),+ PixelArtKind.friends: Size(23, 14),+ PixelArtKind.laptop: Size(18, 12),+ PixelArtKind.desktop: Size(18, 15),+ PixelArtKind.phone: Size(16, 16),+ };++ @override+ Widget build(BuildContext context) {+ final s = _sizes[kind]!;+ final p = context.palette;+ final dark = Theme.of(context).brightness == Brightness.dark;+ return SizedBox(+ width: s.width * scale,+ height: s.height * scale,+ child: CustomPaint(painter: _ArtPainter(kind, scale, p, dark)),+ );+ }+}++class _ArtPainter extends CustomPainter {+ _ArtPainter(this.kind, this.scale, this.p, this.dark);++ final PixelArtKind kind;+ final double scale;+ final AppPalette p;+ final bool dark;++ @override+ void paint(Canvas canvas, Size size) {+ final k = dark ? const Color(0xFF0A0B0D) : const Color(0xFF1C1D20);+ const paper = Color(0xFFF4F4F1), gray = Color(0xFFC9CCD2), gold = Color(0xFFF6C744), wood = Color(0xFF8C6A4A);+ void r(double x, double y, double w, double h, Color c) =>+ canvas.drawRect(Rect.fromLTWH(x * scale, y * scale, w * scale, h * scale), Paint()..color = c);+ void box(double x, double y, double w, double h, Color fill) {+ r(x, y, w, h, k);+ r(x + 1, y + 1, w - 2, h - 2, fill);+ }++ switch (kind) {+ case PixelArtKind.clipboard:+ box(2, 3, 20, 22, wood);+ box(4, 6, 16, 17, paper);+ box(8, 1, 8, 5, gray);+ r(10, 2, 4, 1, p.textFaint);+ for (final (y, w) in const [(10.0, 10.0), (13.0, 8.0), (16.0, 10.0), (19.0, 5.0)]) {+ r(7, y, w, 1, gray);+ }+ r(20, 15, 1, 3, p.accent);+ r(19, 16, 3, 1, p.accent);+ r(22, 9, 1, 1, gold);+ case PixelArtKind.devices:+ for (final x in const [0.0, 17.0]) {+ box(x, 4, 11, 8, p.surface);+ r(x + 2, 6, 7, 4, p.textDim);+ r(x + 4, 12, 3, 2, k);+ r(x + 2, 14, 7, 1, k);+ }+ for (var x = 12.0; x < 17; x += 2) {+ r(x, 8, 1, 1, p.accent);+ }+ r(13, 2, 2, 1, gold);+ r(13, 1, 1, 1, gold);+ case PixelArtKind.plane:+ const rows = [+ '..............kk',+ '...........kkkwk',+ '........kkkwwwk.',+ '.....kkkwwwwwk..',+ '..kkkwwwwwwwk...',+ 'kkwwwwwwwaak....',+ '..kkkwwwaak.....',+ '.....kkaak......',+ '.......kak......',+ '........k.......',+ ];+ for (var y = 0; y < rows.length; y++) {+ for (var x = 0; x < rows[y].length; x++) {+ final ch = rows[y][x];+ if (ch != '.') r(x + 8.0, y + 2.0, 1, 1, ch == 'k' ? k : (ch == 'a' ? p.accent : paper));+ }+ }+ for (var x = 0.0; x < 8; x += 2) {+ r(x, x > 3 ? 10 : 9, 1, 1, p.textFaint);+ }+ case PixelArtKind.chest:+ box(2, 8, 20, 12, wood);+ box(2, 4, 20, 6, const Color(0xFFA57E57));+ r(3, 9, 18, 1, k);+ box(10, 7, 4, 5, gold);+ r(11, 9, 2, 1, k);+ for (final (x, y) in const [(1.0, 1.0), (6.0, 0.0), (18.0, 0.0), (23.0, 2.0), (0.0, 5.0)]) {+ r(x, y, 1, 1, gold);+ }+ r(12, 0, 1, 2, p.accent);+ case PixelArtKind.cloud:+ r(4, 4, 14, 6, k);+ r(2, 6, 20, 6, k);+ r(7, 2, 8, 3, k);+ r(5, 5, 12, 5, gray);+ r(3, 7, 18, 4, gray);+ r(8, 3, 6, 2, gray);+ for (final (x, y) in const [(9.0, 13.0), (10.0, 14.0), (11.0, 15.0), (12.0, 16.0), (13.0, 17.0), (13.0, 13.0), (12.0, 14.0), (10.0, 16.0), (9.0, 17.0)]) {+ r(x, y, 1, 1, p.danger);+ }+ case PixelArtKind.friends:+ for (final (x, shirt) in [(0.0, p.accent), (13.0, const Color(0xFF7AA2F7))]) {+ box(x + 2, 0, 6, 6, const Color(0xFFF2C9A0));+ r(x + 3, 2, 1, 1, k);+ r(x + 6, 2, 1, 1, k);+ box(x, 6, 10, 8, shirt);+ }+ r(11, 3, 2, 2, p.danger);+ case PixelArtKind.laptop:+ box(2, 0, 14, 10, p.surface);+ r(4, 2, 10, 6, p.textDim);+ r(0, 10, 18, 2, k);+ r(1, 10, 16, 1, gray);+ case PixelArtKind.desktop:+ box(0, 0, 18, 12, p.surface);+ r(2, 2, 14, 8, p.textDim);+ r(7, 12, 4, 2, k);+ r(5, 14, 8, 1, k);+ case PixelArtKind.phone:+ box(3, 0, 10, 16, p.surface);+ r(5, 2, 6, 10, p.textDim);+ r(7, 13, 2, 1, k);+ }+ }++ @override+ bool shouldRepaint(_ArtPainter old) => old.kind != kind || old.scale != scale || old.p != p || old.dark != dark;+}++// ───────────────────────────── 动效 ─────────────────────────────++/// 菜单光标:一个一闪一闪的 ▶,像游戏里的选项光标+class PixelCursor extends StatefulWidget {+ const PixelCursor({super.key, this.color});++ final Color? color;++ @override+ State<PixelCursor> createState() => _PixelCursorState();+}++class _PixelCursorState extends State<PixelCursor> with SingleTickerProviderStateMixin, _Frames {+ @override+ int get fps => 2;++ @override+ Widget build(BuildContext context) {+ syncTicker(!_still(context));+ final color = widget.color ?? context.palette.accent;+ return ValueListenableBuilder<int>(+ valueListenable: frame,+ builder: (_, f, _) => SizedBox(+ width: 6,+ height: 10,+ child: f.isOdd ? null : CustomPaint(painter: _ArrowPainter(color)),+ ),+ );+ }+}++class _ArrowPainter extends CustomPainter {+ const _ArrowPainter(this.color);++ final Color color;++ @override+ void paint(Canvas canvas, Size size) {+ final paint = Paint()..color = color;+ for (var i = 0; i < 3; i++) {+ canvas.drawRect(Rect.fromLTWH(i * 2.0, i * 2.0, 2, 10 - i * 4.0), paint);+ }+ }++ @override+ bool shouldRepaint(_ArrowPainter old) => old.color != color;+}++/// 加载中。默认主题是转圈;像素主题是四个方格依次点亮。给了 [value] 时照旧画进度环+class ThemedSpinner extends StatefulWidget {+ const ThemedSpinner({super.key, this.strokeWidth, this.color, this.value});++ final double? strokeWidth;+ final Color? color;+ final double? value;++ @override+ State<ThemedSpinner> createState() => _ThemedSpinnerState();+}++class _ThemedSpinnerState extends State<ThemedSpinner> with SingleTickerProviderStateMixin, _Frames {+ @override+ int get fps => 6;++ @override+ Widget build(BuildContext context) {+ final pixel = context.shape.pixel && widget.value == null;+ syncTicker(pixel && !_still(context));+ if (!pixel) {+ return CircularProgressIndicator(strokeWidth: widget.strokeWidth, color: widget.color, value: widget.value);+ }+ final on = widget.color ?? context.palette.accent;+ final off = context.palette.textFaint.withValues(alpha: 0.35);+ return LayoutBuilder(+ builder: (context, c) {+ final side = math.min(c.maxWidth.isFinite ? c.maxWidth : 16.0, c.maxHeight.isFinite ? c.maxHeight : 16.0);+ return Center(+ child: SizedBox.square(+ dimension: side,+ child: ValueListenableBuilder<int>(+ valueListenable: frame,+ builder: (_, f, _) => CustomPaint(painter: _FourSquares(f % 4, on, off)),+ ),+ ),+ );+ },+ );+ }+}++class _FourSquares extends CustomPainter {+ const _FourSquares(this.lit, this.on, this.off);++ final int lit;+ final Color on;+ final Color off;++ @override+ void paint(Canvas canvas, Size size) {+ // 每格是边长的 3/7,取整到 2 的倍数,格间留一格的空+ final cell = math.max(2.0, (size.width * 3 / 7 / 2).floorToDouble() * 2);+ final gap = math.max(2.0, size.width - cell * 2);+ final o = (size.width - cell * 2 - gap) / 2;+ const order = [(0, 0), (1, 0), (1, 1), (0, 1)]; // 顺时针+ for (var i = 0; i < 4; i++) {+ final (x, y) = order[i];+ canvas.drawRect(+ Rect.fromLTWH(o + x * (cell + gap), o + y * (cell + gap), cell, cell),+ Paint()..color = i == lit ? on : off,+ );+ }+ }++ @override+ bool shouldRepaint(_FourSquares old) => old.lit != lit || old.on != on || old.off != off;+}++/// 一圈像素星星从中间迸开,放一遍就停(传送完成、配对成功)+class PixelBurst extends StatefulWidget {+ const PixelBurst({super.key, required this.size});++ final double size;++ @override+ State<PixelBurst> createState() => _PixelBurstState();+}++class _PixelBurstState extends State<PixelBurst> with SingleTickerProviderStateMixin {+ late final _c = AnimationController(vsync: this, duration: const Duration(milliseconds: 900))..forward();++ @override+ void dispose() {+ _c.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ if (_still(context)) return const SizedBox.shrink();+ return IgnorePointer(+ child: SizedBox.square(+ dimension: widget.size,+ child: CustomPaint(painter: _BurstPainter(_c, context.palette.accent)),+ ),+ );+ }+}++class _BurstPainter extends CustomPainter {+ _BurstPainter(this.t, this.accent) : super(repaint: t);++ final Animation<double> t;+ final Color accent;++ @override+ void paint(Canvas canvas, Size size) {+ if (t.value >= 1) return;+ final step = (t.value * 6).floor(); // 6 帧+ final c = size.center(Offset.zero);+ final colors = [const Color(0xFFF6C744), accent, const Color(0xFFF4F4F1)];+ for (var i = 0; i < 8; i++) {+ final a = i * math.pi / 4;+ final d = size.width * 0.18 + step * size.width * 0.06;+ final x = ((c.dx + math.cos(a) * d) / 2).roundToDouble() * 2, y = ((c.dy + math.sin(a) * d) / 2).roundToDouble() * 2;+ final paint = Paint()..color = colors[i % 3];+ canvas.drawRect(Rect.fromLTWH(x, y, 4, 4), paint);+ if (step < 3) {+ canvas+ ..drawRect(Rect.fromLTWH(x - 2, y + 1, 8, 2), paint)+ ..drawRect(Rect.fromLTWH(x + 1, y - 2, 2, 8), paint);+ }+ }+ }++ @override+ bool shouldRepaint(_BurstPainter old) => old.accent != accent;+}++/// 一格一格上下跳:拖着文件经过的设备,等你松手+class PixelBounce extends StatefulWidget {+ const PixelBounce({super.key, required this.active, required this.child});++ final bool active;+ final Widget child;++ @override+ State<PixelBounce> createState() => _PixelBounceState();+}++class _PixelBounceState extends State<PixelBounce> with SingleTickerProviderStateMixin, _Frames {+ @override+ int get fps => 3;++ @override+ Widget build(BuildContext context) {+ syncTicker(widget.active && !_still(context));+ return ValueListenableBuilder<int>(+ valueListenable: frame,+ builder: (_, f, child) => Transform.translate(offset: Offset(0, widget.active && f.isOdd ? -4 : 0), child: child),+ child: widget.child,+ );+ }+}++/// 发送中的纸飞机:在设备左上方一格一格往设备飞,到了再从头飞+class PixelPlane extends StatefulWidget {+ const PixelPlane({super.key});++ @override+ State<PixelPlane> createState() => _PixelPlaneState();+}++class _PixelPlaneState extends State<PixelPlane> with SingleTickerProviderStateMixin, _Frames {+ @override+ int get fps => 6;++ @override+ Widget build(BuildContext context) {+ syncTicker(!_still(context));+ return IgnorePointer(+ child: ValueListenableBuilder<int>(+ valueListenable: frame,+ builder: (_, f, child) {+ final step = f % 8;+ return Transform.translate(offset: Offset(step * 4.0, step * 2.0), child: Opacity(opacity: step < 7 ? 1 : 0, child: child));+ },+ child: const PixelArt(PixelArtKind.plane, scale: 1),+ ),+ );+ }+}++/// 像素主题里打开了扫描线时,在 [child] 上叠一层(设置 › 外观;默认关)+class PixelScanlinesLayer extends StatelessWidget {+ const PixelScanlinesLayer({super.key, required this.on, required this.child});++ final bool on;+ final Widget child;++ @override+ Widget build(BuildContext context) {+ if (!on || !context.shape.pixel) return child;+ return Stack(children: [child, const Positioned.fill(child: PixelScanlines())]);+ }+}++/// 整窗叠一层很淡的 CRT 扫描线+class PixelScanlines extends StatelessWidget {+ const PixelScanlines({super.key});++ @override+ Widget build(BuildContext context) => const IgnorePointer(child: CustomPaint(painter: _ScanlinePainter(), size: Size.infinite));+}++class _ScanlinePainter extends CustomPainter {+ const _ScanlinePainter();++ @override+ void paint(Canvas canvas, Size size) {+ final paint = Paint()..color = const Color(0x14000000);+ for (var y = 0.0; y < size.height; y += 3) {+ canvas.drawRect(Rect.fromLTWH(0, y, size.width, 1), paint);+ }+ }++ @override+ bool shouldRepaint(_ScanlinePainter old) => false;+}diff --git a/ui/lib/pixel_theme.dart b/ui/lib/pixel_theme.dartnew file mode 100644index 0000000..9964bc6--- /dev/null+++ b/ui/lib/pixel_theme.dart@@ -0,0 +1,480 @@+import 'dart:math' as math;++import 'package:flutter/material.dart';++import 'theme.dart';++// 像素主题:结构像素化,颜色现代化。设计说明见 design/pixel-theme.md。+//+// - 文字用缝合像素字体(12px 点阵),字号只有 12 与 24 两档;+// - 颜色是中性灰分层(深色「石墨」、浅色「纸」),强调色是像素绿,只用在主按钮、选中、进度、链接上;+// - 边框都是 2px、四角留空一格,分三级:容器淡边;按钮、输入框强边加斜面(按钮凸起、输入框凹下);+// 只有浮层(对话框、菜单、悬停预览)有错开的实心投影;+// - 图标用 Pixelarticons,动画逐帧跳变。+//+// 字体与图标由 tools/pixel-theme/build_assets.py 生成,在 ui/assets/fonts/。++const pixelTheme = AppThemeSpec(+ id: 'pixel',+ // 「纸」:暖白底,按钮、输入框、浮层描深色边+ light: AppPalette(+ accent: Color(0xFF08875B),+ background: Color(0xFFF5F5F2),+ sidebar: Color(0xFFECECE7),+ surface: Color(0xFFFFFFFF),+ border: Color(0xFFDCDCD5),+ borderStrong: Color(0xFF1C1D20),+ separator: Color(0xFFE2E2DC),+ text: Color(0xFF1C1D20),+ textDim: Color(0xFF5E626A),+ textFaint: Color(0xFF9A9DA4),+ selection: Color(0xFFFAFAF8),+ hover: Color(0x0A1C1D20),+ fill: Color(0xFFEFEFEA),+ online: Color(0xFF15803D),+ warning: Color(0xFFB45309),+ danger: Color(0xFFDC2626),+ inverse: Color(0xFF1C1D20),+ onInverse: Color(0xFFF5F5F2),+ bevelLight: Color(0xB3FFFFFF),+ bevelDark: Color(0x2E000000),+ shadow: Color(0xE61C1D20),+ ),+ // 「石墨」:近黑的冷灰分三层,边框低对比+ dark: AppPalette(+ accent: Color(0xFF3DDC97),+ background: Color(0xFF111215),+ sidebar: Color(0xFF0C0D0F),+ surface: Color(0xFF17191D),+ border: Color(0xFF2A2D34),+ borderStrong: Color(0xFF3C414B),+ separator: Color(0xFF25282E),+ text: Color(0xFFE6E8EB),+ textDim: Color(0xFF9AA0AA),+ textFaint: Color(0xFF5F6570),+ selection: Color(0xFF1F2227),+ hover: Color(0x0AFFFFFF),+ fill: Color(0xFF0D0E11),+ online: Color(0xFF4ADE80),+ warning: Color(0xFFFBBF24),+ danger: Color(0xFFF87171),+ onAccent: Color(0xFF0C0D0F),+ inverse: Color(0xFFE6E8EB),+ onInverse: Color(0xFF111215),+ bevelLight: Color(0x14FFFFFF),+ bevelDark: Color(0x59000000),+ shadow: Color(0x80000000),+ ),+ shape: AppShape(+ sm: 0,+ md: 0,+ lg: 0,+ corner: CornerStyle.pixel,+ borderWidth: 2,+ unit: 2,+ shadow: ShadowStyle.hard,+ ),+ typography: AppTypography(family: 'FusionPixel', mono: 'FusionPixelMono', sizes: [12, 24]),+ motion: AppMotion(style: MotionStyle.stepped),+ pixelIcons: true,+);++/// 像素角:四角各切掉 [steps] 级台阶,每级 [unit] 见方。一级是点阵窗口的缺角,三级看起来像像素画的圆。+///+/// - [side] 只画外圈,里面的底是直角矩形,和点阵游戏里的窗口一样;+/// - [topLeft]、[bottomRight] 是边框里面一格宽的斜面:上亮下暗是凸起的按钮,反过来是凹下的输入框;+/// - [drop] 是向右下错开两格的实心投影,浮层才有。+class PixelBorder extends OutlinedBorder {+ const PixelBorder({super.side, this.unit = 2, this.steps = 1, this.topLeft, this.bottomRight, this.drop});++ final double unit;+ final int steps;+ final Color? topLeft;+ final Color? bottomRight;+ final Color? drop;++ /// 按下的按钮:斜面明暗互换+ PixelBorder get pressed => PixelBorder(side: side, unit: unit, steps: steps, topLeft: bottomRight, bottomRight: topLeft, drop: drop);++ /// 方块太小放不下这么多级台阶时少切几级+ int _fit(Rect r, int n) => math.max(0, math.min(n, (math.min(r.width, r.height) / (2 * unit)).floor()));++ Path _path(Rect r, int n) {+ n = _fit(r, n);+ if (n == 0) return Path()..addRect(r);+ // 左上角的台阶:从左边 (0, n) 走到上边 (n, 0),其余三个角翻过去+ final stair = <Offset>[+ for (var i = 0; i < n; i++) ...[Offset(i * unit, (n - i) * unit), Offset((i + 1) * unit, (n - i) * unit)],+ Offset(n * unit, 0),+ ];+ return Path()+ ..addPolygon([+ for (final o in stair) Offset(r.left + o.dx, r.top + o.dy),+ for (final o in stair.reversed) Offset(r.right - o.dx, r.top + o.dy),+ for (final o in stair) Offset(r.right - o.dx, r.bottom - o.dy),+ for (final o in stair.reversed) Offset(r.left + o.dx, r.bottom - o.dy),+ ], true);+ }++ @override+ EdgeInsetsGeometry get dimensions => EdgeInsets.all(side.width);++ @override+ Path getOuterPath(Rect rect, {TextDirection? textDirection}) => _path(rect, steps);++ @override+ Path getInnerPath(Rect rect, {TextDirection? textDirection}) => _path(rect.deflate(side.width), steps - 1);++ @override+ void paint(Canvas canvas, Rect rect, {TextDirection? textDirection}) {+ final outer = getOuterPath(rect);+ if (drop != null) {+ canvas.drawPath(+ Path.combine(PathOperation.difference, outer.shift(Offset(unit, unit) * 2), outer),+ Paint()..color = drop!,+ );+ }+ final inner = rect.deflate(side.width);+ if (topLeft != null && inner.width > 2 * unit && inner.height > 2 * unit) {+ final light = Paint()..color = topLeft!;+ final dark = Paint()..color = bottomRight ?? const Color(0x00000000);+ canvas+ ..drawRect(Rect.fromLTWH(inner.left, inner.top, inner.width, unit), light)+ ..drawRect(Rect.fromLTWH(inner.left, inner.top, unit, inner.height), light)+ ..drawRect(Rect.fromLTWH(inner.left, inner.bottom - unit, inner.width, unit), dark)+ ..drawRect(Rect.fromLTWH(inner.right - unit, inner.top, unit, inner.height), dark);+ }+ if (side.style == BorderStyle.none || side.width == 0) return;+ canvas.drawPath(Path.combine(PathOperation.difference, outer, getInnerPath(rect)), Paint()..color = side.color);+ }++ @override+ PixelBorder copyWith({BorderSide? side, double? unit, int? steps}) => PixelBorder(+ side: side ?? this.side,+ unit: unit ?? this.unit,+ steps: steps ?? this.steps,+ topLeft: topLeft,+ bottomRight: bottomRight,+ drop: drop,+ );++ @override+ ShapeBorder scale(double t) =>+ PixelBorder(side: side.scale(t), unit: unit * t, steps: steps, topLeft: topLeft, bottomRight: bottomRight, drop: drop);++ @override+ bool operator ==(Object other) =>+ other is PixelBorder &&+ other.side == side &&+ other.unit == unit &&+ other.steps == steps &&+ other.topLeft == topLeft &&+ other.bottomRight == bottomRight &&+ other.drop == drop;++ @override+ int get hashCode => Object.hash(side, unit, steps, topLeft, bottomRight, drop);+}++/// 输入框的像素边框:凹下去的槽(上、左暗,下、右亮),聚焦时边框换成强调色。+class PixelInputBorder extends InputBorder {+ const PixelInputBorder({super.borderSide, this.unit = 2, this.topLeft, this.bottomRight});++ final double unit;+ final Color? topLeft;+ final Color? bottomRight;++ PixelBorder get _border => PixelBorder(side: borderSide, unit: unit, topLeft: topLeft, bottomRight: bottomRight);++ @override+ bool get isOutline => true;++ @override+ EdgeInsetsGeometry get dimensions => EdgeInsets.all(borderSide.width);++ @override+ PixelInputBorder copyWith({BorderSide? borderSide}) =>+ PixelInputBorder(borderSide: borderSide ?? this.borderSide, unit: unit, topLeft: topLeft, bottomRight: bottomRight);++ @override+ ShapeBorder scale(double t) =>+ PixelInputBorder(borderSide: borderSide.scale(t), unit: unit * t, topLeft: topLeft, bottomRight: bottomRight);++ @override+ Path getInnerPath(Rect rect, {TextDirection? textDirection}) => _border.getInnerPath(rect);++ @override+ Path getOuterPath(Rect rect, {TextDirection? textDirection}) => _border.getOuterPath(rect);++ @override+ void paint(Canvas canvas, Rect rect,+ {double? gapStart, double gapExtent = 0.0, double gapPercentage = 0.0, TextDirection? textDirection}) =>+ _border.paint(canvas, rect);++ @override+ bool operator ==(Object other) =>+ other is PixelInputBorder &&+ other.borderSide == borderSide &&+ other.unit == unit &&+ other.topLeft == topLeft &&+ other.bottomRight == bottomRight;++ @override+ int get hashCode => Object.hash(borderSide, unit, topLeft, bottomRight);+}++/// 列表、分组里行与行之间的分隔线。默认主题就是 Divider;像素主题是隔一格画一格的点线+class ThemedDivider extends StatelessWidget {+ const ThemedDivider({super.key, this.height, this.indent, this.endIndent, this.color});++ final double? height;+ final double? indent;+ final double? endIndent;+ final Color? color;++ @override+ Widget build(BuildContext context) {+ final s = context.shape;+ if (!s.pixel) return Divider(height: height, indent: indent, endIndent: endIndent, color: color);+ return SizedBox(+ height: math.max(height ?? s.borderWidth, s.borderWidth),+ child: Center(+ child: Padding(+ padding: EdgeInsets.only(left: indent ?? 0, right: endIndent ?? 0),+ child: SizedBox(+ height: s.borderWidth,+ width: double.infinity,+ child: CustomPaint(painter: _DashPainter(color ?? context.palette.separator, s.unit)),+ ),+ ),+ ),+ );+ }+}++class _DashPainter extends CustomPainter {+ const _DashPainter(this.color, this.unit);++ final Color color;+ final double unit;++ @override+ void paint(Canvas canvas, Size size) {+ final paint = Paint()..color = color;+ for (var x = 0.0; x < size.width; x += unit * 2) {+ canvas.drawRect(Rect.fromLTWH(x, 0, unit, size.height), paint);+ }+ }++ @override+ bool shouldRepaint(_DashPainter old) => old.color != color || old.unit != unit;+}++/// 按 [unit] 见方的点画椭圆:雷达的圈与波纹在像素主题里都用它。+///+/// [gaps] 里的几段不画(起始角度、跨过的角度,弧度,顺时针从正右方算,与 Canvas.drawArc 相同);+/// [dashed] 时隔一格画一格,像点阵游戏里的虚线。+void drawPixelOval(Canvas canvas, Rect oval, Color color, double unit,+ {List<(double, double)> gaps = const [], bool dashed = false}) {+ final c = oval.center;+ final rx = oval.width / 2, ry = oval.height / 2;+ final paint = Paint()..color = color;+ final seen = <(int, int)>{};+ bool inGap(double a) => gaps.any((g) {+ final d = ((a - g.$1) % (2 * math.pi) + 2 * math.pi) % (2 * math.pi);+ return d < g.$2;+ });+ // 相邻两个采样点不超过半格,圈上不会断开+ final n = math.max(16, (math.pi * (rx + ry) / (unit / 2)).ceil());+ var drawn = 0;+ for (var i = 0; i < n; i++) {+ final a = 2 * math.pi * i / n;+ final gx = ((c.dx + rx * math.cos(a)) / unit).floor();+ final gy = ((c.dy + ry * math.sin(a)) / unit).floor();+ if (!seen.add((gx, gy)) || inGap(a)) continue;+ if (!dashed || drawn.isEven) canvas.drawRect(Rect.fromLTWH(gx * unit, gy * unit, unit, unit), paint);+ drawn++;+ }+}++/// 把子组件裁成圆形;像素主题里裁成切掉三级台阶的方块(头像)+class ThemedClipOval extends StatelessWidget {+ const ThemedClipOval({super.key, required this.child});++ final Widget child;++ @override+ Widget build(BuildContext context) {+ final s = context.shape;+ if (!s.pixel) return ClipOval(child: child);+ return ClipPath(clipper: ShapeBorderClipper(shape: PixelBorder(unit: s.unit, steps: 3)), child: child);+ }+}++/// 进度条。默认主题就是 LinearProgressIndicator;像素主题里是凹槽里一格一格点亮的方块,+/// 不知道进度时三格亮块一跳一跳地往右走。+class ThemedProgressBar extends StatefulWidget {+ const ThemedProgressBar({super.key, this.value, this.minHeight, this.color, this.backgroundColor, this.borderRadius});++ final double? value;+ final double? minHeight;+ final Color? color;+ final Color? backgroundColor;+ final BorderRadiusGeometry? borderRadius;++ @override+ State<ThemedProgressBar> createState() => _ThemedProgressBarState();+}++class _ThemedProgressBarState extends State<ThemedProgressBar> with SingleTickerProviderStateMixin {+ AnimationController? _march;++ @override+ void dispose() {+ _march?.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final s = context.shape;+ if (!s.pixel) {+ return LinearProgressIndicator(+ value: widget.value,+ minHeight: widget.minHeight,+ color: widget.color,+ backgroundColor: widget.backgroundColor,+ borderRadius: widget.borderRadius,+ );+ }+ final p = context.palette;+ final indeterminate = widget.value == null;+ if (indeterminate) {+ _march ??= AnimationController(vsync: this, duration: const Duration(milliseconds: 1600))..repeat();+ } else {+ _march?.dispose();+ _march = null;+ }+ // 边框本身就让出了 borderWidth 的内边距+ return Container(+ height: s.borderWidth * 2 + s.unit * 5,+ decoration: s.box(color: widget.backgroundColor ?? p.fill, border: p.borderStrong, bevel: (p.bevelDark, p.bevelLight)),+ child: CustomPaint(+ size: Size.infinite,+ painter: _CellsPainter(+ value: widget.value,+ march: _march,+ color: widget.color ?? p.accent,+ unit: s.unit,+ ),+ ),+ );+ }+}++class _CellsPainter extends CustomPainter {+ _CellsPainter({required this.value, required this.march, required this.color, required this.unit})+ : super(repaint: march);++ final double? value;+ final Animation<double>? march;+ final Color color;+ final double unit;++ @override+ void paint(Canvas canvas, Size size) {+ // 每格 3 个单位宽,格间空 1 个单位;整条从里面留出 1 个单位的边+ final cell = unit * 3, gap = unit;+ final inner = Rect.fromLTWH(unit, unit, size.width - 2 * unit, size.height - 2 * unit);+ if (inner.width <= 0 || inner.height <= 0) return;+ final n = math.max(1, ((inner.width + gap) / (cell + gap)).floor());+ final paint = Paint()..color = color;+ void lit(int i) => canvas.drawRect(Rect.fromLTWH(inner.left + i * (cell + gap), inner.top, cell, inner.height), paint);+ if (value != null) {+ final on = (value!.clamp(0.0, 1.0) * n).round();+ for (var i = 0; i < on; i++) {+ lit(i);+ }+ return;+ }+ final head = ((march?.value ?? 0) * (n + 3)).floor();+ for (var i = head - 3; i < head; i++) {+ if (i >= 0 && i < n) lit(i);+ }+ }++ @override+ bool shouldRepaint(_CellsPainter old) => old.value != value || old.color != color || old.unit != unit;+}++/// 像素版的 App 图标:16×16 的点阵画,和正式图标一样是一页纸叠在另一页上,前面那页用强调色。+/// 只按整数倍放大,画在 [size] 见方的格子正中。+class PixelAppMark extends StatelessWidget {+ const PixelAppMark({super.key, required this.size});++ final double size;++ // O 底板的描边,T 底板,S 前页的投影,K 后页的轮廓与文字,W 后页的纸,A 前页,H 前页上的文字,. 透明+ static const _sprite = [+ '.OOOOOOOOOOOOOO.',+ 'OTTTTTTTTTTTTTTO',+ 'OTKKKKKKKTTTTTTO',+ 'OTKWWWWWKTTTTTTO',+ 'OTKWKKKWKTTTTTTO',+ 'OTKWWWWWKTTTTTTO',+ 'OTKWKKAAAAAAATTO',+ 'OTKWWWAHHHHAATTO',+ 'OTKWKKAAAAAAATTO',+ 'OTKWWWAHHHAAATTO',+ 'OTKWWWAAAAAAATTO',+ 'OTKKKKAHHAAAATTO',+ 'OTTTTTAAAAAAATTO',+ 'OTTTTTTSSSSSSSTO',+ 'OTTTTTTTTTTTTTTO',+ '.OOOOOOOOOOOOOO.',+ ];++ @override+ Widget build(BuildContext context) {+ final p = context.palette;+ final colors = {+ 'O': p.borderStrong,+ 'T': const Color(0xFFF2F2EF),+ 'S': const Color(0xFFC9C9C4),+ 'K': const Color(0xFF2B2C30),+ 'W': const Color(0xFFFFFFFF),+ 'A': p.accent,+ 'H': p.onAccent,+ };+ return SizedBox.square(+ dimension: size,+ child: CustomPaint(painter: _SpritePainter(_sprite, colors)),+ );+ }+}++class _SpritePainter extends CustomPainter {+ _SpritePainter(this.rows, this.colors);++ final List<String> rows;+ final Map<String, Color> colors;++ @override+ void paint(Canvas canvas, Size size) {+ final n = rows.length;+ final cell = math.max(1, (size.shortestSide / n).floor()).toDouble();+ final origin = Offset(((size.width - cell * n) / 2).roundToDouble(), ((size.height - cell * n) / 2).roundToDouble());+ final paint = Paint();+ for (var y = 0; y < n; y++) {+ for (var x = 0; x < rows[y].length; x++) {+ final c = colors[rows[y][x]];+ if (c == null) continue;+ paint.color = c;+ canvas.drawRect(Rect.fromLTWH(origin.dx + x * cell, origin.dy + y * cell, cell, cell), paint);+ }+ }+ }++ @override+ bool shouldRepaint(_SpritePainter old) => old.colors.toString() != colors.toString();+}diff --git a/ui/lib/theme.dart b/ui/lib/theme.dartindex a7fe08e..ba9458b 100644--- a/ui/lib/theme.dart+++ b/ui/lib/theme.dart@@ -1,7 +1,11 @@import 'dart:io';+import 'dart:math' as math;+import 'package:flutter/foundation.dart' show listEquals;import 'package:flutter/material.dart';+import 'pixel_theme.dart';+/// PasteFerry 的设计系统。////// 这是一个常驻后台的系统工具,界面要像 macOS 自带的应用一样安静:@@ -24,13 +28,53 @@ abstract final class Insets {static const xxl = 32.0;}-/// 圆角按层级区分:控件小、分组容器中、对话框大。+/// 默认主题的圆角:控件小、分组容器中、对话框大。+/// 页面里不直接用它们,用 `context.shape`:换了主题,圆角跟着变。abstract final class Radii {static const sm = 6.0;static const md = 10.0;static const lg = 14.0;}+/// 一套主题:浅色、深色两种配色,加上形状、文字与动效。默认主题是 [AppThemeSpec.standard]。+///+/// 页面只读 `context.palette`、`context.shape`、`context.typography`、`context.motion`,+/// 不判断当前是哪一套主题。格式与分期见 design/themes.md。+@immutable+class AppThemeSpec {+ const AppThemeSpec({+ required this.id,+ required this.light,+ required this.dark,+ this.shape = AppShape.standard,+ this.typography = AppTypography.standard,+ this.motion = AppMotion.standard,+ this.pixelIcons = false,+ });++ final String id;+ final AppPalette light;+ final AppPalette dark;+ final AppShape shape;+ final AppTypography typography;+ final AppMotion motion;++ /// 用像素图标([AppIcons] 里的 Pixelarticons),而不是系统风格的图标+ final bool pixelIcons;++ AppPalette palette(Brightness brightness) => brightness == Brightness.dark ? dark : light;++ static const standard = AppThemeSpec(id: 'default', light: AppPalette.light, dark: AppPalette.dark);++ /// 软件自带的主题,按在「外观」里的顺序。加一套自带主题:在这里登记,+ /// 再把同样的定义写进 client-core/internal/theme/builtin/ 下以 id 命名的 JSON(后台服务据此校验与合并),+ /// test/builtin_themes_test.dart 会核对两边一致。+ static const builtins = {'default': standard, 'pixel': pixelTheme};++ /// 内置主题,按 id 取;不认识的 id 用默认主题+ static AppThemeSpec byId(String id) => builtins[id] ?? standard;+}+/// 语义化的颜色角色。页面代码只用这些名字,不判断亮暗模式。@immutableclass AppPalette extends ThemeExtension<AppPalette> {@@ -50,6 +94,13 @@ class AppPalette extends ThemeExtension<AppPalette> {required this.online,required this.warning,required this.danger,+ this.onAccent = Colors.white,+ required this.inverse,+ this.onInverse = Colors.white,+ this._borderStrong,+ this.bevelLight = const Color(0x00000000),+ this.bevelDark = const Color(0x00000000),+ this.shadow = const Color(0x40000000),});final Color accent;@@ -67,6 +118,16 @@ class AppPalette extends ThemeExtension<AppPalette> {final Color online;final Color warning;final Color danger;+ final Color onAccent; // 强调色底上的文字、图标+ final Color inverse; // 提示条、工具提示这类反色的底+ final Color onInverse;+ final Color? _borderStrong;+ final Color bevelLight; // 凸起控件上、左两边的亮边;凹槽是下、右两边。默认主题没有斜面+ final Color bevelDark; // 凸起控件下、右两边的暗边;凹槽是上、左两边+ final Color shadow; // 浮层(对话框、菜单、悬停预览)的硬投影++ /// 按钮、输入框、浮层的边框,比容器的 [border] 醒目。默认主题与 [border] 相同+ Color get borderStrong => _borderStrong ?? border;static const light = AppPalette(accent: AppColors.accent,@@ -85,6 +146,7 @@ class AppPalette extends ThemeExtension<AppPalette> {online: Color(0xFF248A3D),warning: Color(0xFFB25000),danger: Color(0xFFD70015),+ inverse: Color(0xFF2C2C2E),);static const dark = AppPalette(@@ -103,6 +165,7 @@ class AppPalette extends ThemeExtension<AppPalette> {online: Color(0xFF32D74B),warning: Color(0xFFFF9F0A),danger: Color(0xFFFF453A),+ inverse: Color(0xFF3A3A3C),);@override@@ -128,13 +191,134 @@ class AppPalette extends ThemeExtension<AppPalette> {online: l(online, other.online),warning: l(warning, other.warning),danger: l(danger, other.danger),+ onAccent: l(onAccent, other.onAccent),+ inverse: l(inverse, other.inverse),+ borderStrong: l(borderStrong, other.borderStrong),+ bevelLight: l(bevelLight, other.bevelLight),+ bevelDark: l(bevelDark, other.bevelDark),+ shadow: l(shadow, other.shadow),+ onInverse: l(onInverse, other.onInverse),);}}-extension PaletteAccess on BuildContext {- AppPalette get palette => Theme.of(this).extension<AppPalette>()!;- TextTheme get text => Theme.of(this).textTheme;+/// 投影的画法:[soft] 是现在的柔和投影;[hard] 是不模糊、向右下错开的实心投影(像素主题);+/// [none] 不画投影,只靠边框区分层级。+enum ShadowStyle { soft, hard, none }++/// 角的画法:[round] 是圆角;[pixel] 是像素角,四角切掉台阶状的方格,见 [PixelBorder]。+enum CornerStyle { round, pixel }++/// 圆角、边框与投影。+@immutable+class AppShape extends ThemeExtension<AppShape> {+ const AppShape({+ this.sm = Radii.sm,+ this.md = Radii.md,+ this.lg = Radii.lg,+ this.shadow = ShadowStyle.soft,+ this.corner = CornerStyle.round,+ this.borderWidth = 1,+ this.unit = 2,+ this.hardShadowColor = const Color(0xFF000000),+ });++ final double sm; // 控件+ final double md; // 分组容器、卡片+ final double lg; // 对话框、大面板+ final ShadowStyle shadow;+ final CornerStyle corner;+ final double borderWidth; // 容器、按钮、输入框的边框+ final double unit; // 像素角的一格,也是硬投影错开的距离+ final Color hardShadowColor;++ bool get pixel => corner == CornerStyle.pixel;++ static const standard = AppShape();++ /// 进度条、角标这类小装饰写死的圆角 [r],按 [sm] 与默认值的比例缩放:直角主题里一起变成直角。+ double scaled(double r) => r * sm / Radii.sm;++ /// 一层投影。默认主题原样返回,[ShadowStyle.none] 时没有投影。+ /// 硬投影只给浮层([blur] 不小于 12 的大投影,比如悬停预览):错开两格、不模糊;+ /// 按钮、设备节点这类小投影在硬投影的主题里不画,立体感交给斜面。+ List<BoxShadow> shadows(Color color, {required double blur, required Offset offset}) => switch (shadow) {+ ShadowStyle.soft => [BoxShadow(color: color, blurRadius: blur, offset: offset)],+ ShadowStyle.hard when blur >= 12 => [BoxShadow(color: hardShadowColor, offset: Offset(unit, unit) * 2)],+ ShadowStyle.hard || ShadowStyle.none => const [],+ };++ /// 按钮、对话框、菜单的外形。[radius] 默认是 [sm]。+ /// 像素主题里可以加斜面 [bevel](上左、下右两色)和浮层投影 [drop];默认主题忽略它们+ OutlinedBorder outline({BorderSide side = BorderSide.none, double? radius, (Color, Color)? bevel, Color? drop}) => pixel+ ? PixelBorder(side: side, unit: unit, topLeft: bevel?.$1, bottomRight: bevel?.$2, drop: drop)+ : RoundedRectangleBorder(side: side, borderRadius: BorderRadius.circular(radius ?? sm));++ /// 容器的底、边框与投影。默认主题是带圆角 [radius](默认 [md])的 BoxDecoration,+ /// 像素主题换成切角、粗边框的 ShapeDecoration,可以加斜面 [bevel](上左、下右两色)。+ Decoration box({Color? color, Color? border, double? radius, List<BoxShadow>? shadows, (Color, Color)? bevel}) => pixel+ ? ShapeDecoration(+ color: color,+ shadows: shadows,+ shape: PixelBorder(+ side: border == null ? BorderSide.none : BorderSide(color: border, width: borderWidth),+ unit: unit,+ topLeft: bevel?.$1,+ bottomRight: bevel?.$2,+ ),+ )+ : BoxDecoration(+ color: color,+ borderRadius: BorderRadius.circular(radius ?? md),+ border: border == null ? null : Border.all(color: border),+ boxShadow: shadows,+ );++ /// 圆形的底(设备节点、状态点)。像素主题里是切掉三级台阶的方块,看起来像像素画的圆。+ Decoration circle({Color? color, Color? border, double borderWidth = 1, List<BoxShadow>? shadows}) => pixel+ ? ShapeDecoration(+ color: color,+ shadows: shadows,+ shape: PixelBorder(+ side: border == null ? BorderSide.none : BorderSide(color: border, width: math.max(borderWidth, this.borderWidth)),+ unit: unit,+ steps: 3,+ ),+ )+ : BoxDecoration(+ shape: BoxShape.circle,+ color: color,+ border: border == null ? null : Border.all(color: border, width: borderWidth),+ boxShadow: shadows,+ );++ @override+ AppShape copyWith({double? sm, double? md, double? lg, ShadowStyle? shadow, Color? hardShadowColor}) => AppShape(+ sm: sm ?? this.sm,+ md: md ?? this.md,+ lg: lg ?? this.lg,+ shadow: shadow ?? this.shadow,+ corner: corner,+ borderWidth: borderWidth,+ unit: unit,+ hardShadowColor: hardShadowColor ?? this.hardShadowColor,+ );++ @override+ AppShape lerp(AppShape? other, double t) {+ if (other == null) return this;+ double l(double a, double b) => a + (b - a) * t;+ return AppShape(+ sm: l(sm, other.sm),+ md: l(md, other.md),+ lg: l(lg, other.lg),+ shadow: t < 0.5 ? shadow : other.shadow,+ corner: t < 0.5 ? corner : other.corner,+ borderWidth: l(borderWidth, other.borderWidth),+ unit: t < 0.5 ? unit : other.unit,+ hardShadowColor: Color.lerp(hardShadowColor, other.hardShadowColor, t)!,+ );+ }}/// 等宽字体:配对码、指纹、服务器地址这类需要逐字符核对的内容。@@ -146,6 +330,120 @@ final monoFamily = Platform.isWindows? 'monospace': 'Menlo';+/// 主题指定的字体。正文字体 [family] 由 [buildTheme] 写进 TextTheme;页面要单独取的是等宽字体 [mono]。+@immutable+class AppTypography extends ThemeExtension<AppTypography> {+ const AppTypography({this.family, this._mono, this.sizes = const []});++ /// 正文字体。为空时跟随系统+ final String? family;++ final String? _mono;++ /// 允许的字号。不为空时,界面上所有文字的字号都吸附到其中最近的一个(见 [ThemeTextScale]):+ /// 点阵字体只有在设计字号的整数倍上才清晰。+ final List<double> sizes;++ /// 主题没指定时用系统的等宽字体 [monoFamily]+ String get mono => _mono ?? monoFamily;++ static const standard = AppTypography();++ @override+ AppTypography copyWith({String? family, String? mono, List<double>? sizes}) =>+ AppTypography(family: family ?? this.family, mono: mono ?? _mono, sizes: sizes ?? this.sizes);++ @override+ AppTypography lerp(AppTypography? other, double t) => t < 0.5 || other == null ? this : other;+}++/// 动画的节奏:[smooth] 是现在的平滑过渡;[stepped] 逐帧跳变(像素主题);[reduced] 不做动画。+enum MotionStyle { smooth, stepped, reduced }++/// 动效。页面里的过渡动画经 [duration] 与 [curve] 取值,换主题时节奏跟着变。+@immutable+class AppMotion extends ThemeExtension<AppMotion> {+ const AppMotion({this.style = MotionStyle.smooth, this.steps = 4});++ final MotionStyle style;++ /// [MotionStyle.stepped] 时一段动画分几帧+ final int steps;++ static const standard = AppMotion();++ Duration duration(Duration d) => style == MotionStyle.reduced ? Duration.zero : d;++ Curve curve(Curve c) => style == MotionStyle.stepped ? _SteppedCurve(c, steps) : c;++ @override+ AppMotion copyWith({MotionStyle? style, int? steps}) =>+ AppMotion(style: style ?? this.style, steps: steps ?? this.steps);++ @override+ AppMotion lerp(AppMotion? other, double t) => t < 0.5 || other == null ? this : other;+}++/// 把 [base] 量化成 [steps] 档:动画一格一格地跳,不连续过渡。+class _SteppedCurve extends Curve {+ const _SteppedCurve(this.base, this.steps);++ final Curve base;+ final int steps;++ @override+ double transformInternal(double t) => (base.transform(t) * steps).floorToDouble() / steps;+}++/// 把字号吸附到 [sizes] 里最近的一个,系统的文字缩放先算进去。+class SnapTextScaler extends TextScaler {+ const SnapTextScaler(this.base, this.sizes);++ final TextScaler base;+ final List<double> sizes;++ @override+ double scale(double fontSize) {+ final s = base.scale(fontSize);+ return sizes.reduce((a, b) => (s - a).abs() <= (s - b).abs() ? a : b);+ }++ @override+ // ignore: deprecated_member_use+ double get textScaleFactor => base.textScaleFactor;++ @override+ bool operator ==(Object other) =>+ other is SnapTextScaler && other.base == base && listEquals(other.sizes, sizes);++ @override+ int get hashCode => Object.hash(base, Object.hashAll(sizes));+}++/// 主题规定了字号阶梯时(像素字体),给下面的文字换上 [SnapTextScaler]。+/// 放在 MaterialApp.builder 里,主窗口、快捷粘贴窗口、手机都要放。+class ThemeTextScale extends StatelessWidget {+ const ThemeTextScale({super.key, required this.child});++ final Widget child;++ @override+ Widget build(BuildContext context) {+ final sizes = context.typography.sizes;+ if (sizes.isEmpty) return child;+ final mq = MediaQuery.of(context);+ return MediaQuery(data: mq.copyWith(textScaler: SnapTextScaler(mq.textScaler, sizes)), child: child);+ }+}++extension PaletteAccess on BuildContext {+ AppPalette get palette => Theme.of(this).extension<AppPalette>()!;+ TextTheme get text => Theme.of(this).textTheme;+ AppShape get shape => Theme.of(this).extension<AppShape>()!;+ AppTypography get typography => Theme.of(this).extension<AppTypography>()!;+ AppMotion get motion => Theme.of(this).extension<AppMotion>()!;+}+/// Windows 上汉字用哪些字体,按界面语言 [language] 排先后。////// Flutter 在 Windows 上默认只认 Segoe UI,汉字交给系统逐字回退:中日共用的字常落到@@ -169,8 +467,13 @@ List<String> linuxFontFallback(String language) => switch (language) {/// [fontFamily] 只给截图渲染用:App 本身不指定。Mac 上跟随系统字体(SF Pro 与苹方),/// Windows 上用 Segoe UI,汉字按 [language] 用 [windowsFontFallback] 里的字体;/// Linux 上主字体跟随系统,汉字用 [linuxFontFallback] 里的字体。+///+/// 桌面主窗口、快捷粘贴窗口、手机(在它上面调整字号与触控尺寸)都由这里按同一套主题 [spec] 生成。ThemeData buildTheme(Brightness brightness,- {String? fontFamily, List<String>? fontFamilyFallback, String language = 'zh'}) {+ {AppThemeSpec spec = AppThemeSpec.standard,+ String? fontFamily,+ List<String>? fontFamilyFallback,+ String language = 'zh'}) {if (fontFamily == null && fontFamilyFallback == null) {if (Platform.isWindows) {fontFamily = 'Segoe UI';@@ -179,12 +482,26 @@ ThemeData buildTheme(Brightness brightness,fontFamilyFallback = linuxFontFallback(language);}}+ // 主题自带的字体(像素字体)优先;它没有的字形(⌥ 这类符号、emoji)交给原来的字体+ final themeFamily = spec.typography.family;+ if (themeFamily != null) {+ fontFamilyFallback = [?fontFamily, ...?fontFamilyFallback];+ fontFamily = themeFamily;+ }final dark = brightness == Brightness.dark;- final p = dark ? AppPalette.dark : AppPalette.light;+ final p = spec.palette(brightness);+ // 浮层的硬投影跟着亮暗模式取色+ final shape = spec.shape.copyWith(hardShadowColor: p.shadow);+ final flat = shape.shadow != ShadowStyle.soft;+ // 像素主题:按钮、输入框、浮层描强边框;按钮凸起(上左亮、下右暗),输入框凹下,浮层有错开的投影。+ // 默认主题里 borderStrong 就是 border,斜面与投影都不画+ final strong = BorderSide(color: p.borderStrong, width: shape.borderWidth);+ final raised = (p.bevelLight, p.bevelDark);+ final drop = shape.pixel ? p.shadow : null;final scheme = ColorScheme.fromSeed(seedColor: p.accent, brightness: brightness).copyWith(primary: p.accent,- onPrimary: Colors.white,+ onPrimary: p.onAccent,surface: p.background,onSurface: p.text,error: p.danger,@@ -206,13 +523,55 @@ ThemeData buildTheme(Brightness brightness,labelMedium: TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: p.textDim),labelSmall: TextStyle(fontSize: 11, fontWeight: FontWeight.w500, color: p.textDim),);+ if (spec.typography.sizes.isNotEmpty) {+ // 点阵字体:字号只有阶梯里的几档(ThemeTextScale 负责吸附),字距为 0,行高取整数像素。+ // 层级靠字号与颜色区分+ final big = spec.typography.sizes.last;+ final base = spec.typography.sizes.first;+ textTheme = TextTheme(+ headlineSmall: TextStyle(fontSize: big, color: p.text, height: 1.25),+ titleMedium: TextStyle(fontSize: base, fontWeight: FontWeight.w600, color: p.text, height: 1.5),+ titleSmall: TextStyle(fontSize: base, fontWeight: FontWeight.w600, color: p.text, height: 1.5),+ bodyLarge: TextStyle(fontSize: base, color: p.text, height: 1.5),+ bodyMedium: TextStyle(fontSize: base, color: p.text, height: 1.5),+ bodySmall: TextStyle(fontSize: base, color: p.textDim, height: 1.5),+ labelLarge: TextStyle(fontSize: base, color: p.text),+ labelMedium: TextStyle(fontSize: base, color: p.textDim),+ labelSmall: TextStyle(fontSize: base, color: p.textDim),+ );+ }if (fontFamily != null || fontFamilyFallback != null) {textTheme = textTheme.apply(fontFamily: fontFamily, fontFamilyFallback: fontFamilyFallback);}- final controlShape = RoundedRectangleBorder(borderRadius: BorderRadius.circular(Radii.sm));+ final controlShape = shape.outline();const controlPadding = EdgeInsets.symmetric(horizontal: 14, vertical: 9);+ /// 像素主题的按钮是凸起的,按下时斜面明暗互换、文字下沉 2px,像按下一个实体按键+ ButtonStyle pressable(ButtonStyle style) {+ if (!shape.pixel) return style;+ final up = shape.outline(side: strong, bevel: raised) as PixelBorder;+ final sink = EdgeInsets.only(top: shape.unit, bottom: -shape.unit);+ return style.copyWith(+ shape: WidgetStateProperty.resolveWith((s) => s.contains(WidgetState.pressed) ? up.pressed : up),+ padding: WidgetStateProperty.resolveWith(+ (s) => s.contains(WidgetState.pressed) ? controlPadding + sink : controlPadding),+ );+ }++ /// 输入框的边框:像素主题是凹下去的槽+ InputBorder field(Color color, {double? width}) => shape.pixel+ ? PixelInputBorder(+ borderSide: BorderSide(color: color, width: shape.borderWidth),+ unit: shape.unit,+ topLeft: p.bevelDark,+ bottomRight: p.bevelLight,+ )+ : OutlineInputBorder(+ borderRadius: BorderRadius.circular(shape.sm),+ borderSide: BorderSide(color: color, width: width ?? shape.borderWidth),+ );+return ThemeData(useMaterial3: true,brightness: brightness,@@ -222,35 +581,36 @@ ThemeData buildTheme(Brightness brightness,textTheme: textTheme,fontFamily: fontFamily,fontFamilyFallback: fontFamilyFallback,- extensions: [p],+ extensions: [p, shape, spec.typography, spec.motion],splashFactory: NoSplash.splashFactory, // 桌面端没有触摸涟漪highlightColor: Colors.transparent,hoverColor: p.hover,- dividerTheme: DividerThemeData(color: p.separator, thickness: 1, space: 1),+ dividerTheme: DividerThemeData(color: p.separator, thickness: shape.borderWidth, space: shape.borderWidth),iconTheme: IconThemeData(color: p.textDim, size: 16),filledButtonTheme: FilledButtonThemeData(- style: FilledButton.styleFrom(+ style: pressable(FilledButton.styleFrom(backgroundColor: p.accent,- foregroundColor: Colors.white,+ foregroundColor: p.onAccent,disabledBackgroundColor: p.fill,disabledForegroundColor: p.textFaint,shape: controlShape,+ side: shape.pixel ? strong : null,padding: controlPadding,minimumSize: const Size(0, 32),textStyle: textTheme.labelLarge,elevation: 0,- ),+ )),),outlinedButtonTheme: OutlinedButtonThemeData(- style: OutlinedButton.styleFrom(+ style: pressable(OutlinedButton.styleFrom(foregroundColor: p.text,- backgroundColor: p.surface,+ backgroundColor: shape.pixel ? p.selection : p.surface,shape: controlShape,padding: controlPadding,minimumSize: const Size(0, 32),textStyle: textTheme.labelLarge,- side: BorderSide(color: p.border),- ),+ side: strong,+ )),),textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(@@ -259,29 +619,31 @@ ThemeData buildTheme(Brightness brightness,padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),minimumSize: const Size(0, 30),textStyle: textTheme.labelLarge,+ ).copyWith(+ // 像素主题:文字按钮没有边框,悬停时出现一条点线下划线+ textStyle: shape.pixel+ ? WidgetStateProperty.resolveWith((s) => s.contains(WidgetState.hovered)+ ? textTheme.labelLarge?.copyWith(+ decoration: TextDecoration.underline,+ decorationStyle: TextDecorationStyle.dotted,+ decorationThickness: shape.borderWidth,+ )+ : textTheme.labelLarge)+ : null,),),inputDecorationTheme: InputDecorationTheme(isDense: true,filled: true,- fillColor: p.surface,+ fillColor: shape.pixel ? p.fill : p.surface,contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 9),- border: OutlineInputBorder(- borderRadius: BorderRadius.circular(Radii.sm),- borderSide: BorderSide(color: p.border),- ),- enabledBorder: OutlineInputBorder(- borderRadius: BorderRadius.circular(Radii.sm),- borderSide: BorderSide(color: p.border),- ),- focusedBorder: OutlineInputBorder(- borderRadius: BorderRadius.circular(Radii.sm),- borderSide: BorderSide(color: p.accent, width: 1.5),- ),+ border: field(p.borderStrong),+ enabledBorder: field(p.borderStrong),+ focusedBorder: field(p.accent, width: 1.5),hintStyle: textTheme.bodyMedium?.copyWith(color: p.textFaint),),switchTheme: SwitchThemeData(- thumbColor: const WidgetStatePropertyAll(Colors.white),+ thumbColor: WidgetStatePropertyAll(p.onAccent),trackColor: WidgetStateProperty.resolveWith((s) => s.contains(WidgetState.selected) ? p.accent : p.selection),trackOutlineColor: const WidgetStatePropertyAll(Colors.transparent),@@ -292,36 +654,30 @@ ThemeData buildTheme(Brightness brightness,dialogTheme: DialogThemeData(backgroundColor: p.surface,surfaceTintColor: Colors.transparent,- elevation: 18,+ elevation: flat ? 0 : 18,shadowColor: Color(dark ? 0x99000000 : 0x40000000),- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(Radii.lg)),+ shape: shape.outline(radius: shape.lg, side: shape.pixel ? strong : BorderSide.none, drop: drop),titleTextStyle: textTheme.titleMedium,contentTextStyle: textTheme.bodyMedium?.copyWith(color: p.textDim),),popupMenuTheme: PopupMenuThemeData(color: p.surface,surfaceTintColor: Colors.transparent,- elevation: 8,+ elevation: flat ? 0 : 8,shadowColor: Color(dark ? 0x99000000 : 0x33000000),textStyle: textTheme.bodyMedium,- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(Radii.md),- side: BorderSide(color: p.border),- ),+ shape: shape.outline(radius: shape.md, side: strong, drop: drop),),snackBarTheme: SnackBarThemeData(behavior: SnackBarBehavior.floating,- backgroundColor: dark ? const Color(0xFF3A3A3C) : const Color(0xFF2C2C2E),- contentTextStyle: const TextStyle(fontSize: 13, color: Colors.white),- elevation: 6,- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(Radii.md)),+ backgroundColor: p.inverse,+ contentTextStyle: TextStyle(fontSize: 13, color: p.onInverse),+ elevation: flat ? 0 : 6,+ shape: shape.outline(radius: shape.md, drop: drop),),tooltipTheme: TooltipThemeData(- decoration: BoxDecoration(- color: dark ? const Color(0xFF3A3A3C) : const Color(0xFF2C2C2E),- borderRadius: BorderRadius.circular(Radii.sm),- ),- textStyle: const TextStyle(fontSize: 12, color: Colors.white),+ decoration: shape.box(color: p.inverse, radius: shape.sm),+ textStyle: TextStyle(fontSize: 12, color: p.onInverse),waitDuration: const Duration(milliseconds: 500),),progressIndicatorTheme: ProgressIndicatorThemeData(@@ -330,8 +686,8 @@ ThemeData buildTheme(Brightness brightness,circularTrackColor: Colors.transparent,),scrollbarTheme: ScrollbarThemeData(- thickness: const WidgetStatePropertyAll(6),- radius: const Radius.circular(3),+ thickness: WidgetStatePropertyAll(shape.pixel ? 8 : 6),+ radius: Radius.circular(shape.scaled(3)),thumbColor: WidgetStatePropertyAll(p.textFaint.withValues(alpha: 0.5)),),);diff --git a/ui/lib/theme_controller.dart b/ui/lib/theme_controller.dartnew file mode 100644index 0000000..f8dc3b7--- /dev/null+++ b/ui/lib/theme_controller.dart@@ -0,0 +1,221 @@+import 'dart:convert';++import 'package:flutter/material.dart';++import 'gen/pasteferry/v1/daemon.pb.dart' as pb;+import 'gen/pasteferry/v1/daemon.pbgrpc.dart' show DaemonServiceClient;+import 'icons.dart';+import 'l10n/app_localizations.dart';+import 'theme.dart';+import 'theme_json.dart';++/// 「外观」里的一项主题:软件自带的或自定义的+class ThemeChoice {+ const ThemeChoice({required this.id, required this.names, required this.builtin, required this.spec});++ final String id;++ /// 界面语言代码到名字,比如 {'zh-Hans': '像素', 'en': 'Pixel'}+ final Map<String, String> names;+ final bool builtin;+ final AppThemeSpec spec;++ String displayName(AppLocalizations l) {+ if (id == 'default') return l.themeDefault;+ if (id == 'pixel') return l.themePixel;+ final lang = l.localeName.replaceAll('_', '-');+ return names[lang] ??+ names[lang == 'zh' ? 'zh-Hans' : lang] ??+ names[lang.split('-').first] ??+ names['en'] ??+ names.values.firstOrNull ??+ id;+ }+}++/// 现在用的主题与主题列表。主窗口、快捷粘贴窗口、手机 App 各有一个,数据都来自后台服务:+/// 配置里的 theme_id、theme_mode、theme_scanlines 决定用哪套,自定义主题的内容按需取来解析。+///+/// 配置变了(configChanged)或主题内容变了(themesChanged)时刷新,所有窗口一起换。+class ThemeController extends ChangeNotifier {+ DaemonServiceClient? _client;+ String _id = '';+ pb.ThemeMode _mode = pb.ThemeMode.THEME_MODE_UNSPECIFIED;+ bool _scanlines = false;+ List<ThemeChoice> _themes = [+ for (final e in AppThemeSpec.builtins.entries) ThemeChoice(id: e.key, names: const {}, builtin: true, spec: e.value),+ ];+ final _custom = <String, AppThemeSpec>{};++ /// 每换一次主题加一;界面按它决定要不要重建缓存的 ThemeData+ int revision = 0;++ /// 现在的主题 id;默认主题是 'default'+ String get id => _id.isEmpty ? 'default' : _id;++ AppThemeSpec get spec => AppThemeSpec.builtins[id] ?? _custom[id] ?? AppThemeSpec.standard;++ ThemeMode get mode => switch (_mode) {+ pb.ThemeMode.THEME_MODE_LIGHT => ThemeMode.light,+ pb.ThemeMode.THEME_MODE_DARK => ThemeMode.dark,+ _ => ThemeMode.system,+ };++ bool get scanlines => _scanlines;++ List<ThemeChoice> get themes => _themes;++ /// 连上后台服务后调用:取主题列表,配置里指定的自定义主题也取来+ Future<void> attach(DaemonServiceClient client, pb.Config config) async {+ _client = client;+ await refreshList();+ await applyConfig(config);+ }++ void detach() => _client = null;++ /// 配置变了:换主题、深浅模式或扫描线+ Future<void> applyConfig(pb.Config config) async {+ final changed = config.themeId != _id || config.themeMode != _mode || config.themeScanlines != _scanlines;+ _id = config.themeId;+ _mode = config.themeMode;+ _scanlines = config.themeScanlines;+ if (!AppThemeSpec.builtins.containsKey(id) && !_custom.containsKey(id)) await _load(id);+ if (changed) _changed();+ }++ /// 有主题被保存或删掉:重新取列表,正在用的那套内容也重新取+ Future<void> onThemesChanged(pb.ThemesChanged ev) async {+ for (final i in ev.ids) {+ _custom.remove(i);+ }+ await refreshList();+ if (ev.ids.contains(id) || ev.ids.isEmpty) _changed();+ }++ Future<void> refreshList() async {+ final client = _client;+ if (client == null) return;+ try {+ final res = await client.listThemes(pb.Empty());+ final list = <ThemeChoice>[];+ for (final t in res.themes) {+ final spec = AppThemeSpec.builtins[t.id] ?? _custom[t.id] ?? await _load(t.id);+ if (spec == null) continue;+ list.add(ThemeChoice(id: t.id, names: Map.of(t.name), builtin: t.builtin, spec: spec));+ }+ if (list.isNotEmpty) _themes = list;+ notifyListeners();+ } catch (_) {+ // 旧版后台服务没有主题接口:只有自带的主题+ }+ }++ Future<AppThemeSpec?> _load(String themeId) async {+ final client = _client;+ if (client == null || AppThemeSpec.builtins.containsKey(themeId)) return AppThemeSpec.builtins[themeId];+ try {+ final res = await client.getTheme(pb.GetThemeRequest(id: themeId, resolved: true));+ return _custom[themeId] = parseTheme(res.json, base: AppThemeSpec.standard);+ } catch (_) {+ return null;+ }+ }++ void _changed() {+ revision++;+ final icons = spec.pixelIcons;+ notifyListeners();+ if (AppIcons.pixel != icons) {+ AppIcons.pixel = icons;+ // 图标是页面直接取的,不随 Theme 变:整棵树重建一遍,页面状态(当前在哪一页)不丢+ WidgetsBinding.instance.addPostFrameCallback((_) {+ void mark(Element e) {+ e.markNeedsBuild();+ e.visitChildren(mark);+ }++ WidgetsBinding.instance.rootElement?.visitChildren(mark);+ });+ }+ }++ // ── 修改:都经后台服务,结果由事件推回来 ──++ Future<pb.Config> _update(pb.Config Function(pb.Config) edit) async {+ final client = _client!;+ final cfg = await client.getConfig(pb.Empty());+ return client.updateConfig(edit(cfg));+ }++ Future<void> select(String themeId) async {+ final cfg = await _update((c) => c..themeId = themeId == 'default' ? '' : themeId);+ await applyConfig(cfg);+ }++ Future<void> setMode(ThemeMode m) async {+ final cfg = await _update((c) => c+ ..themeMode = switch (m) {+ ThemeMode.light => pb.ThemeMode.THEME_MODE_LIGHT,+ ThemeMode.dark => pb.ThemeMode.THEME_MODE_DARK,+ ThemeMode.system => pb.ThemeMode.THEME_MODE_UNSPECIFIED,+ });+ await applyConfig(cfg);+ }++ Future<void> setScanlines(bool on) async {+ final cfg = await _update((c) => c..themeScanlines = on);+ await applyConfig(cfg);+ }++ /// 保存一份主题 JSON,返回它的 id 与对比度警告。格式不对时后台服务报错,消息可以直接给用户看+ Future<pb.PutThemeResponse> save(String json) async {+ final res = await _client!.putTheme(pb.PutThemeRequest(json: json));+ _custom.remove(res.id);+ await refreshList();+ return res;+ }++ /// 主题的原始 JSON(导出用)。[resolved] 时合并 base,得到能单独使用的完整主题+ Future<String> exportJson(String themeId, {bool resolved = true}) async {+ final res = await _client!.getTheme(pb.GetThemeRequest(id: themeId, resolved: resolved));+ return const JsonEncoder.withIndent(' ').convert(jsonDecode(res.json));+ }++ /// 以 [from] 为底新建一份自定义主题,返回新主题的 id+ Future<String> duplicate(ThemeChoice from, String Function(String name) copyName, AppLocalizations l) async {+ final taken = _themes.map((t) => t.id).toSet();+ var n = 1;+ String newId() => n == 1 ? '${from.id}-copy' : '${from.id}-copy-$n';+ while (taken.contains(newId())) {+ n++;+ }+ final m = jsonDecode(await exportJson(from.id)) as Map<String, dynamic>;+ final name = copyName(from.displayName(l));+ m+ ..['id'] = newId()+ ..['base'] = from.builtin ? from.id : (m['base'] ?? 'default')+ ..['name'] = {for (final lang in const ['zh-Hans', 'zh-Hant-TW', 'zh-Hant-HK', 'en', 'ja']) lang: name};+ await save(jsonEncode(m));+ return newId();+ }++ /// 测试与截图用:直接填入主题列表与当前主题,不连接后台服务+ @visibleForTesting+ void debugSeed({List<ThemeChoice>? themes, String? id}) {+ if (themes != null) {+ _themes = themes;+ for (final t in themes) {+ if (!t.builtin) _custom[t.id] = t.spec;+ }+ }+ if (id != null) _id = id == 'default' ? '' : id;+ notifyListeners();+ }++ Future<void> delete(String themeId) async {+ await _client!.deleteTheme(pb.ThemeRef(id: themeId));+ _custom.remove(themeId);+ await refreshList();+ }+}diff --git a/ui/lib/theme_json.dart b/ui/lib/theme_json.dartnew file mode 100644index 0000000..162a75e--- /dev/null+++ b/ui/lib/theme_json.dart@@ -0,0 +1,168 @@+import 'dart:convert';++import 'package:flutter/material.dart';++import 'theme.dart';++// 主题的 JSON 格式(design/themes.md 第 3 节)与 AppThemeSpec 之间的转换。+//+// 后台服务负责校验、合并 base 链;这里拿到的可能是完整主题,也可能只写了要改的字段:+// 没写的一律从 base(内置主题)补齐,所以只改一个强调色也能用。++/// 颜色角色的名字,与 AppPalette 的字段一一对应+const paletteRoles = [+ 'accent', 'background', 'sidebar', 'surface', 'border', 'borderStrong', 'separator', 'text', 'textDim',+ 'textFaint', 'selection', 'hover', 'fill', 'online', 'warning', 'danger', 'onAccent', 'inverse', 'onInverse',+ 'bevelLight', 'bevelDark', 'shadow',+];++/// 主题可以用的字体:App 自带的,或者跟随系统(null)+const _fonts = {'FusionPixel': 'FusionPixelMono'};++/// 解析一份主题。[json] 可以是字符串或已经解码的 Map;没写的字段从 [base] 补齐,+/// [base] 为空时按 JSON 里的 `base` 取内置主题。格式不对时抛 FormatException。+AppThemeSpec parseTheme(Object json, {AppThemeSpec? base}) {+ final m = (json is String ? jsonDecode(json) : json) as Map<String, dynamic>;+ final b = base ?? AppThemeSpec.byId(m['base'] as String? ?? 'default');+ final modes = (m['modes'] as Map?)?.cast<String, dynamic>() ?? const {};+ final shape = (m['shape'] as Map?)?.cast<String, dynamic>() ?? const {};+ final radius = (shape['radius'] as Map?)?.cast<String, dynamic>() ?? const {};+ final typo = (m['typography'] as Map?)?.cast<String, dynamic>() ?? const {};+ final motion = m['motion'];++ double? num_(Object? v) => (v as num?)?.toDouble();+ T pick<T extends Enum>(List<T> values, Object? name, T fallback) =>+ values.where((v) => v.name == name).firstOrNull ?? fallback;++ // 'system' 与 null 都表示跟随系统+ String? font(Object? v) => v == null || v == 'system' ? null : v as String;+ final family = typo.containsKey('family') ? font(typo['family']) : b.typography.family;+ if (family != null && !_fonts.containsKey(family)) throw FormatException('不认识的字体:$family');+ final sizes = (typo['sizes'] as List?)?.map((e) => (e as num).toDouble()).toList() ?? b.typography.sizes;+ final motionMap = motion is Map ? motion.cast<String, dynamic>() : const <String, dynamic>{};+ final motionStyle = motion is String ? motion : motionMap['style'];++ return AppThemeSpec(+ id: m['id'] as String? ?? b.id,+ light: _palette(modes['light'], b.light),+ dark: _palette(modes['dark'], b.dark),+ shape: AppShape(+ sm: num_(radius['sm']) ?? b.shape.sm,+ md: num_(radius['md']) ?? b.shape.md,+ lg: num_(radius['lg']) ?? b.shape.lg,+ shadow: pick(ShadowStyle.values, shape['shadow'], b.shape.shadow),+ corner: pick(CornerStyle.values, shape['corner'], b.shape.corner),+ borderWidth: num_(shape['borderWidth']) ?? b.shape.borderWidth,+ unit: num_(shape['unit']) ?? b.shape.unit,+ ),+ typography: AppTypography(+ family: family,+ mono: typo.containsKey('mono')+ ? font(typo['mono'])+ : (family == b.typography.family ? b.typography.mono : _fonts[family]),+ sizes: sizes,+ ),+ motion: AppMotion(+ style: pick(MotionStyle.values, motionStyle, b.motion.style),+ steps: (motionMap['steps'] as num?)?.toInt() ?? b.motion.steps,+ ),+ pixelIcons: m.containsKey('icons') ? m['icons'] == 'pixel' : b.pixelIcons,+ );+}++/// 只写了部分颜色时,其余取 [base]+AppPalette _palette(Object? json, AppPalette base) {+ final m = (json as Map?)?.cast<String, dynamic>() ?? const {};+ Color c(String role, Color fallback) {+ final v = m[role];+ return v == null ? fallback : parseColor(v as String);+ }++ return AppPalette(+ accent: c('accent', base.accent),+ background: c('background', base.background),+ sidebar: c('sidebar', base.sidebar),+ surface: c('surface', base.surface),+ border: c('border', base.border),+ borderStrong: c('borderStrong', base.borderStrong),+ separator: c('separator', base.separator),+ text: c('text', base.text),+ textDim: c('textDim', base.textDim),+ textFaint: c('textFaint', base.textFaint),+ selection: c('selection', base.selection),+ hover: c('hover', base.hover),+ fill: c('fill', base.fill),+ online: c('online', base.online),+ warning: c('warning', base.warning),+ danger: c('danger', base.danger),+ onAccent: c('onAccent', base.onAccent),+ inverse: c('inverse', base.inverse),+ onInverse: c('onInverse', base.onInverse),+ bevelLight: c('bevelLight', base.bevelLight),+ bevelDark: c('bevelDark', base.bevelDark),+ shadow: c('shadow', base.shadow),+ );+}++/// `#RRGGBB` 或 `#AARRGGBB`+Color parseColor(String s) {+ final hex = s.startsWith('#') ? s.substring(1) : s;+ final v = int.tryParse(hex, radix: 16);+ if (v == null || (hex.length != 6 && hex.length != 8)) throw FormatException('颜色格式不对:$s');+ return Color(hex.length == 6 ? 0xFF000000 | v : v);+}++String formatColor(Color c) {+ final argb = c.toARGB32();+ return c.a == 1+ ? '#${(argb & 0xFFFFFF).toRadixString(16).padLeft(6, '0').toUpperCase()}'+ : '#${argb.toRadixString(16).padLeft(8, '0').toUpperCase()}';+}++/// 完整的 JSON:导出、交给 AI 改写时用+Map<String, Object?> themeToJson(AppThemeSpec s, {Map<String, String> name = const {}}) {+ Map<String, String> palette(AppPalette p) => {+ 'accent': formatColor(p.accent),+ 'background': formatColor(p.background),+ 'sidebar': formatColor(p.sidebar),+ 'surface': formatColor(p.surface),+ 'border': formatColor(p.border),+ 'borderStrong': formatColor(p.borderStrong),+ 'separator': formatColor(p.separator),+ 'text': formatColor(p.text),+ 'textDim': formatColor(p.textDim),+ 'textFaint': formatColor(p.textFaint),+ 'selection': formatColor(p.selection),+ 'hover': formatColor(p.hover),+ 'fill': formatColor(p.fill),+ 'online': formatColor(p.online),+ 'warning': formatColor(p.warning),+ 'danger': formatColor(p.danger),+ 'onAccent': formatColor(p.onAccent),+ 'inverse': formatColor(p.inverse),+ 'onInverse': formatColor(p.onInverse),+ 'bevelLight': formatColor(p.bevelLight),+ 'bevelDark': formatColor(p.bevelDark),+ 'shadow': formatColor(p.shadow),+ };+ return {+ 'schema': 1,+ 'id': s.id,+ if (name.isNotEmpty) 'name': name,+ 'modes': {'light': palette(s.light), 'dark': palette(s.dark)},+ 'typography': {+ 'family': s.typography.family ?? 'system',+ 'mono': s.typography.family == null ? 'system' : s.typography.mono,+ 'sizes': s.typography.sizes,+ },+ 'shape': {+ 'radius': {'sm': s.shape.sm, 'md': s.shape.md, 'lg': s.shape.lg},+ 'corner': s.shape.corner.name,+ 'borderWidth': s.shape.borderWidth,+ 'unit': s.shape.unit,+ 'shadow': s.shape.shadow.name,+ },+ 'motion': s.motion.style.name,+ 'icons': s.pixelIcons ? 'pixel' : 'system',+ };+}diff --git a/ui/lib/widgets/avatar.dart b/ui/lib/widgets/avatar.dartindex 3770db5..3420950 100644--- a/ui/lib/widgets/avatar.dart+++ b/ui/lib/widgets/avatar.dart@@ -11,6 +11,7 @@ import '../app_state.dart';import '../i18n.dart';import '../main.dart';import '../theme.dart';+import '../pixel_theme.dart';import 'common.dart';// 头像:好友看到的本机头像、好友的头像,见 design/friends-send.md 第 4.4 节。@@ -81,7 +82,7 @@ class PersonAvatar extends StatelessWidget {),);}- return ClipOval(+ return ThemedClipOval(child: SizedBox(width: size,height: size,@@ -179,10 +180,7 @@ class _SelfAvatarButtonState extends State<SelfAvatarButton> {],],child: DecoratedBox(- decoration: BoxDecoration(- shape: BoxShape.circle,- border: Border.all(color: _dragging ? context.palette.accent : Colors.transparent, width: 2),- ),+ decoration: context.shape.circle(border: _dragging ? context.palette.accent : Colors.transparent, borderWidth: 2),child: avatar,),),@@ -365,7 +363,7 @@ class _CropDialogState extends State<_CropDialog> {const SizedBox(width: Insets.xl),Padding(padding: const EdgeInsets.only(top: Insets.xl),- child: ClipOval(child: _image(96)),+ child: ThemedClipOval(child: _image(96)),),],),diff --git a/ui/lib/widgets/common.dart b/ui/lib/widgets/common.dartindex b3580f5..0228c88 100644--- a/ui/lib/widgets/common.dart+++ b/ui/lib/widgets/common.dart@@ -3,9 +3,11 @@ import 'dart:async';import 'package:flutter/material.dart';import 'package:flutter/services.dart';+import '../pixel_theme.dart';import '../theme.dart';import '../i18n.dart';import '../icons.dart';+import '../pixel_art.dart';/// 页面统一的标题区。保证各页视觉节奏一致。class PageHeader extends StatelessWidget {@@ -100,16 +102,12 @@ class GroupBox extends StatelessWidget {Widget build(BuildContext context) {return Container(clipBehavior: Clip.antiAlias,- decoration: BoxDecoration(- color: context.palette.surface,- borderRadius: BorderRadius.circular(Radii.md),- border: Border.all(color: context.palette.border),- ),+ decoration: context.shape.box(color: context.palette.surface, border: context.palette.border),child: Column(crossAxisAlignment: CrossAxisAlignment.stretch,children: [for (var i = 0; i < children.length; i++) ...[- if (i > 0) Divider(indent: dividerIndent),+ if (i > 0) ThemedDivider(indent: dividerIndent),children[i],],],@@ -136,7 +134,14 @@ class GroupSection extends StatelessWidget {if (title.isNotEmpty)Padding(padding: const EdgeInsets.only(left: 2, bottom: Insets.sm),- child: Text(title, style: context.text.titleSmall),+ // 像素主题:像游戏菜单的小标题,前面一个强调色小方块,字用次要色+ child: context.shape.pixel+ ? Row(children: [+ Container(width: 4, height: 4, color: context.palette.accent),+ const SizedBox(width: 6),+ Expanded(child: Text(title, style: context.text.titleSmall?.copyWith(color: context.palette.textDim))),+ ])+ : Text(title, style: context.text.titleSmall),),child,if (footnote != null)@@ -200,6 +205,7 @@ class SmallSwitch extends StatelessWidget {@overrideWidget build(BuildContext context) {+ if (context.shape.pixel) return _PixelSwitch(value: value, onChanged: onChanged);return SizedBox(height: 24,child: FittedBox(@@ -209,6 +215,42 @@ class SmallSwitch extends StatelessWidget {}}+/// 像素主题的开关:粗边框的槽里一个方块,开时方块在右、槽是强调色+class _PixelSwitch extends StatelessWidget {+ const _PixelSwitch({required this.value, required this.onChanged});++ final bool value;+ final ValueChanged<bool>? onChanged;++ @override+ Widget build(BuildContext context) {+ final p = context.palette;+ final s = context.shape;+ final enabled = onChanged != null;+ return MouseRegion(+ cursor: enabled ? SystemMouseCursors.click : MouseCursor.defer,+ child: GestureDetector(+ onTap: enabled ? () => onChanged!(!value) : null,+ child: Opacity(+ opacity: enabled ? 1 : 0.5,+ child: Container(+ width: 36,+ height: 20,+ padding: const EdgeInsets.all(4),+ alignment: value ? Alignment.centerRight : Alignment.centerLeft,+ decoration: s.box(color: value ? p.accent : p.fill, border: p.borderStrong, bevel: (p.bevelDark, p.bevelLight)),+ child: Container(+ width: 12,+ height: 12,+ decoration: s.box(color: value ? p.onAccent : p.textFaint, bevel: (p.bevelLight, p.bevelDark)),+ ),+ ),+ ),+ ),+ );+ }+}+/// 分段控件,对应 macOS 的 NSSegmentedControl:浅灰轨道,选中段浮起为白色。class Segmented<T> extends StatelessWidget {const Segmented({@@ -227,9 +269,12 @@ class Segmented<T> extends StatelessWidget {final p = context.palette;return Container(padding: const EdgeInsets.all(2),- decoration: BoxDecoration(+ // 像素主题:凹下去的槽,选中的一段是凸起的按键+ decoration: context.shape.box(color: p.fill,- borderRadius: BorderRadius.circular(Radii.sm + 1),+ border: context.shape.pixel ? p.borderStrong : null,+ radius: context.shape.scaled(7),+ bevel: (p.bevelDark, p.bevelLight),),child: Row(mainAxisSize: MainAxisSize.min,@@ -240,18 +285,21 @@ class Segmented<T> extends StatelessWidget {child: GestureDetector(onTap: () => onChanged(v),child: AnimatedContainer(- duration: const Duration(milliseconds: 120),+ duration: context.motion.duration(const Duration(milliseconds: 120)),+ curve: context.motion.curve(Curves.linear),padding: const EdgeInsets.symmetric(horizontal: Insets.md, vertical: 4),- decoration: BoxDecoration(- color: v == value ? p.surface : Colors.transparent,- borderRadius: BorderRadius.circular(Radii.sm - 1),- boxShadow: v == value- ? const [- BoxShadow(- color: Color(0x1A000000), blurRadius: 2, offset: Offset(0, 1)),- ]- : null,- ),+ // 比轨道小一圈:轨道留了 2px 内边距,圆角也小 2px,两者同心。+ decoration: context.shape.pixel+ ? (v == value+ ? context.shape.box(color: p.selection, bevel: (p.bevelLight, p.bevelDark))+ : const BoxDecoration())+ : BoxDecoration(+ color: v == value ? p.surface : Colors.transparent,+ borderRadius: BorderRadius.circular(context.shape.scaled(5)),+ boxShadow: v == value+ ? context.shape.shadows(const Color(0x1A000000), blur: 2, offset: const Offset(0, 1))+ : null,+ ),child: Text(label,style: context.text.labelMedium?.copyWith(@@ -337,10 +385,18 @@ class _SearchFieldState extends State<SearchField> {final controller = widget.controller;final focusNode = widget.focusNode;final p = context.palette;- final round = OutlineInputBorder(- borderRadius: BorderRadius.circular(Radii.sm),- borderSide: BorderSide.none,- );+ // 像素主题:凹下去的槽+ final InputBorder round = context.shape.pixel+ ? PixelInputBorder(+ borderSide: BorderSide(color: p.borderStrong, width: context.shape.borderWidth),+ unit: context.shape.unit,+ topLeft: p.bevelDark,+ bottomRight: p.bevelLight,+ )+ : OutlineInputBorder(+ borderRadius: BorderRadius.circular(context.shape.sm),+ borderSide: BorderSide.none,+ );return SizedBox(width: widget.width,height: 28,@@ -369,7 +425,8 @@ class _SearchFieldState extends State<SearchField> {contentPadding: EdgeInsets.zero,border: round,enabledBorder: round,- focusedBorder: round.copyWith(borderSide: BorderSide(color: p.accent, width: 1.5)),+ focusedBorder: round.copyWith(+ borderSide: BorderSide(color: p.accent, width: context.shape.pixel ? context.shape.borderWidth : 1.5)),prefixIcon: Icon(AppIcons.search, size: 14, color: p.textFaint),prefixIconConstraints: const BoxConstraints(minWidth: 28, minHeight: 0),suffixIcon: controller.text.isEmpty@@ -414,7 +471,11 @@ class EmptyState extends StatelessWidget {child: Column(mainAxisSize: MainAxisSize.min,children: [- Icon(icon, size: 36, color: context.palette.textFaint),+ // 像素主题:换成对应的像素插画+ if (context.shape.pixel && PixelArtKind.forIcon(icon) != null)+ PixelArt(PixelArtKind.forIcon(icon)!, scale: 3)+ else+ Icon(icon, size: 36, color: context.palette.textFaint),const SizedBox(height: Insets.lg),Text(title, style: context.text.titleMedium, textAlign: TextAlign.center),if (description != null) ...[@@ -455,11 +516,7 @@ class Notice extends StatelessWidget {final icon = this.icon ?? AppIcons.exclamationmarkCircle;return Container(padding: const EdgeInsets.fromLTRB(Insets.lg, Insets.md, Insets.md, Insets.md),- decoration: BoxDecoration(- color: p.surface,- borderRadius: BorderRadius.circular(Radii.md),- border: Border.all(color: p.border),- ),+ decoration: context.shape.box(color: p.surface, border: p.border),child: Row(children: [Icon(icon, size: 18, color: iconColor ?? p.warning),@@ -497,7 +554,7 @@ class StatusDot extends StatelessWidget {Container(width: 7,height: 7,- decoration: BoxDecoration(color: color, shape: BoxShape.circle),+ decoration: context.shape.circle(color: color),),const SizedBox(width: 6),Text(label, style: context.text.bodySmall?.copyWith(color: labelColor)),@@ -514,6 +571,7 @@ class AppMark extends StatelessWidget {@overrideWidget build(BuildContext context) {+ if (context.shape.pixel) return PixelAppMark(size: size);return Image.asset('assets/app_icon.png',width: size,@@ -557,7 +615,7 @@ class _IconActionState extends State<IconAction> {height: 28,decoration: BoxDecoration(color: _hovered ? p.hover : Colors.transparent,- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),),child: Icon(widget.icon, size: 16, color: widget.color ?? (_hovered ? p.text : p.textDim)),),@@ -720,8 +778,9 @@ class _ToastState extends State<_Toast> with SingleTickerProviderStateMixin {child: IgnorePointer(ignoring: widget.top && widget.onAction == null,child: Center(- child: FadeTransition(- opacity: _fade,+ child: _ToastIn(+ animation: _fade,+ top: widget.top,child: Material(color: theme.backgroundColor,elevation: widget.top ? 3 : (theme.elevation ?? 6),@@ -774,6 +833,32 @@ class _ToastState extends State<_Toast> with SingleTickerProviderStateMixin {}}+/// 提示条出现的方式:默认淡入;像素主题里分几帧滑进来,不淡入+class _ToastIn extends StatelessWidget {+ const _ToastIn({required this.animation, required this.top, required this.child});++ final Animation<double> animation;+ final bool top;+ final Widget child;++ @override+ Widget build(BuildContext context) {+ if (!context.shape.pixel) return FadeTransition(opacity: animation, child: child);+ final curve = context.motion.curve(Curves.easeOut);+ return AnimatedBuilder(+ animation: animation,+ builder: (context, child) {+ final t = curve.transform(animation.value);+ return Opacity(+ opacity: animation.value == 0 ? 0 : 1,+ child: Transform.translate(offset: Offset(0, (1 - t) * (top ? -12 : 12)), child: child),+ );+ },+ child: child,+ );+ }+}+/// 提示条是深色底,浅色模式下的深绿、深红在上面看不清,换成亮色版本。abstract final class PaletteColors {static Color onDark(Color c) {diff --git a/ui/lib/widgets/feedback_dialog.dart b/ui/lib/widgets/feedback_dialog.dartindex 9c9a266..216941d 100644--- a/ui/lib/widgets/feedback_dialog.dart+++ b/ui/lib/widgets/feedback_dialog.dart@@ -11,6 +11,7 @@ import '../main.dart';import '../platform.dart';import '../theme.dart';import 'common.dart';+import '../pixel_art.dart';/// 新建 issue 的地址:用仓库里的问题模板(.github/ISSUE_TEMPLATE/bug_report.yml),版本号预先填好const _newIssue = 'https://github.com/baiyuze/pasteferry/issues/new?template=bug_report.yml';@@ -136,7 +137,7 @@ class _FeedbackDialogState extends State<FeedbackDialog> {height: 220,decoration: BoxDecoration(color: p.fill,- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),),child: Stack(children: [@@ -213,14 +214,14 @@ class _FeedbackDialogState extends State<FeedbackDialog> {);}if (_report == null) {- return const Center(child: SizedBox(width: 16, height: 16, child: CircularProgressIndicator(strokeWidth: 2)));+ return const Center(child: SizedBox(width: 16, height: 16, child: ThemedSpinner(strokeWidth: 2)));}return Scrollbar(child: SingleChildScrollView(padding: const EdgeInsets.fromLTRB(Insets.md, Insets.sm, 36, Insets.sm),child: SelectableText(_report!,- style: context.text.bodySmall?.copyWith(fontFamily: monoFamily, fontSize: 11, height: 1.45, color: context.palette.text),+ style: context.text.bodySmall?.copyWith(fontFamily: context.typography.mono, fontSize: 11, height: 1.45, color: context.palette.text),),),);diff --git a/ui/lib/widgets/friend_send_dialog.dart b/ui/lib/widgets/friend_send_dialog.dartindex d7c40b1..76e919e 100644--- a/ui/lib/widgets/friend_send_dialog.dart+++ b/ui/lib/widgets/friend_send_dialog.dart@@ -14,6 +14,7 @@ import 'avatar.dart';import 'common.dart';import 'friends_dialog.dart';import 'send_dialog.dart';+import '../pixel_art.dart';// 发给好友或「所有人」模式下附近的陌生设备:先选好文件(拖入、选择、粘贴),可以写一句备注,点「发送」。// 对方点「接受」后才开始传。见 design/friends-send.md 第 6 节。@@ -224,6 +225,7 @@ class _FriendSendDialogState extends State<FriendSendDialog> {color: _dragging ? p.accent : p.textFaint,dashed: !_dragging,fill: _dragging ? p.accent.withValues(alpha: 0.06) : Colors.transparent,+ radius: context.shape.md,),child: Padding(padding: EdgeInsets.symmetric(@@ -298,7 +300,7 @@ class _FriendSendDialogState extends State<FriendSendDialog> {FilledButton(onPressed: _staged.isEmpty || _sending ? null : _send,child: _sending- ? const SizedBox(width: 14, height: 14, child: CircularProgressIndicator(strokeWidth: 2))+ ? const SizedBox(width: 14, height: 14, child: ThemedSpinner(strokeWidth: 2)): Text(l.sendAction),),],diff --git a/ui/lib/widgets/friends_dialog.dart b/ui/lib/widgets/friends_dialog.dartindex 706e0fb..ed087fd 100644--- a/ui/lib/widgets/friends_dialog.dart+++ b/ui/lib/widgets/friends_dialog.dart@@ -10,10 +10,12 @@ import '../icons.dart';import '../main.dart';import '../platform.dart';import '../theme.dart';+import '../pixel_theme.dart';import 'avatar.dart';import 'common.dart';import 'friend_send_dialog.dart';import 'send_dialog.dart';+import '../pixel_art.dart';// 好友:列表、加好友、确认框、和某个好友的传输记录、连不上时的提示。见 design/friends-send.md 第 5、8、9.2 节。@@ -130,7 +132,7 @@ class FriendsDialog extends StatelessWidget {shrinkWrap: true,padding: const EdgeInsets.only(right: Insets.md),itemCount: friends.length,- separatorBuilder: (_, _) => Divider(height: 1, color: p.separator),+ separatorBuilder: (_, _) => ThemedDivider(height: 1, color: p.separator),itemBuilder: (_, i) => _FriendRow(friend: friends[i]),),),@@ -390,7 +392,7 @@ class _AddFriendDialogState extends State<AddFriendDialog> {if (_loading)const Padding(padding: EdgeInsets.all(Insets.xl),- child: Center(child: CircularProgressIndicator(strokeWidth: 2)),+ child: Center(child: ThemedSpinner(strokeWidth: 2)),)else if (_error != null)Notice(title: l.codeFailedTitle, message: _error!)@@ -404,14 +406,14 @@ class _AddFriendDialogState extends State<AddFriendDialog> {},child: Container(padding: const EdgeInsets.symmetric(vertical: Insets.lg),- decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(Radii.md)),+ decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(context.shape.md)),child: Text(expired ? '—' : _formatCode(_code ?? ''),textAlign: TextAlign.center,style: TextStyle(fontSize: 30,fontWeight: FontWeight.w600,- fontFamily: monoFamily,+ fontFamily: context.typography.mono,letterSpacing: 6,color: p.text,),@@ -464,7 +466,7 @@ class _AddFriendDialogState extends State<AddFriendDialog> {FilledButton(onPressed: _redeeming ? null : _redeem,child: _redeeming- ? const SizedBox(width: 14, height: 14, child: CircularProgressIndicator(strokeWidth: 2))+ ? const SizedBox(width: 14, height: 14, child: ThemedSpinner(strokeWidth: 2)): Text(l.friendCodeAdd),),],@@ -592,14 +594,14 @@ class _FriendConfirmDialogState extends State<FriendConfirmDialog> {const SizedBox(height: Insets.sm),Container(padding: const EdgeInsets.all(Insets.md),- decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(Radii.md)),+ decoration: BoxDecoration(color: p.fill, borderRadius: BorderRadius.circular(context.shape.md)),child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [for (final fp in ([r.fingerprint, r.selfFingerprint]..sort()))Text(fp,- style: TextStyle(fontFamily: monoFamily, fontSize: 18, letterSpacing: 2, color: p.text),+ style: TextStyle(fontFamily: context.typography.mono, fontSize: 18, letterSpacing: 2, color: p.text),),const SizedBox(height: Insets.sm),Text(l.friendSafetyHint, style: context.text.bodySmall),@@ -611,7 +613,7 @@ class _FriendConfirmDialogState extends State<FriendConfirmDialog> {if (_waiting)Row(children: [- const SizedBox(width: 14, height: 14, child: CircularProgressIndicator(strokeWidth: 2)),+ const SizedBox(width: 14, height: 14, child: ThemedSpinner(strokeWidth: 2)),const SizedBox(width: Insets.sm),Expanded(child: Text(l.friendWaitingPeer, style: context.text.bodySmall)),TextButton(onPressed: () => Navigator.pop(context), child: Text(l.close)),@@ -690,7 +692,7 @@ class FriendDetail extends StatelessWidget {shrinkWrap: inDialog,padding: const EdgeInsets.only(right: Insets.md),itemCount: list.length,- separatorBuilder: (_, _) => Divider(height: 1, color: p.separator),+ separatorBuilder: (_, _) => ThemedDivider(height: 1, color: p.separator),itemBuilder: (_, i) => _HistoryRow(key: ValueKey(list[i].id), transfer: list[i]),);return Column(diff --git a/ui/lib/widgets/image_preview_dialog.dart b/ui/lib/widgets/image_preview_dialog.dartindex ae28332..c7dab64 100644--- a/ui/lib/widgets/image_preview_dialog.dart+++ b/ui/lib/widgets/image_preview_dialog.dart@@ -9,6 +9,7 @@ import '../i18n.dart';import '../icons.dart';import '../main.dart';import '../theme.dart';+import '../pixel_art.dart';Future<void> showImagePreview(BuildContext context, String clipId) =>showDialog<void>(@@ -187,7 +188,7 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {child: Column(mainAxisSize: MainAxisSize.min,children: [- CircularProgressIndicator(+ ThemedSpinner(value: state.progressOf(record.id),strokeWidth: 2,),@@ -225,7 +226,7 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {);}if (!snapshot.hasData) {- return const Center(child: CircularProgressIndicator(strokeWidth: 2));+ return const Center(child: ThemedSpinner(strokeWidth: 2));}return InteractiveViewer(transformationController: _transform,@@ -249,7 +250,7 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {frame != null || synchronous? child: const Center(- child: CircularProgressIndicator(strokeWidth: 2),+ child: ThemedSpinner(strokeWidth: 2),),errorBuilder: (_, _, _) => _message(context.l10n.previewUnreadable),),diff --git a/ui/lib/widgets/nearby_dialog.dart b/ui/lib/widgets/nearby_dialog.dartindex d453b06..aed4a6d 100644--- a/ui/lib/widgets/nearby_dialog.dart+++ b/ui/lib/widgets/nearby_dialog.dart@@ -15,6 +15,7 @@ import '../theme.dart';import 'common.dart';import 'pairing_dialog.dart';import 'radar.dart';+import '../pixel_art.dart';Future<void> showNearbyDialog(BuildContext context) =>pushPairingSetupRoute(context, (_) => const NearbyDialog());@@ -248,7 +249,12 @@ class _NearbyDialogState extends State<NearbyDialog> with SingleTickerProviderStPositioned.fill(child: RepaintBoundary(child: CustomPaint(- painter: RadarPainter(pulse: _pulse, ring: p.separator, wave: p.accent),+ painter: RadarPainter(+ pulse: _pulse,+ ring: p.separator,+ wave: p.accent,+ pixel: context.shape.pixel ? context.shape.unit * 2 : 0,+ ),),),),@@ -315,16 +321,17 @@ class _NearbyNodeState extends State<_NearbyNode> {alignment: Alignment.center,children: [AnimatedContainer(- duration: const Duration(milliseconds: 120),- decoration: BoxDecoration(- shape: BoxShape.circle,+ duration: context.motion.duration(const Duration(milliseconds: 120)),+ curve: context.motion.curve(Curves.linear),+ decoration: context.shape.circle(color: p.surface,- border: Border.all(color: highlight ? p.accent : p.border, width: highlight ? 1.5 : 1),- boxShadow: const [BoxShadow(color: Color(0x14000000), blurRadius: 6, offset: Offset(0, 2))],+ border: highlight ? p.accent : p.border,+ borderWidth: highlight ? 1.5 : 1,+ shadows: context.shape.shadows(const Color(0x14000000), blur: 6, offset: const Offset(0, 2)),),),Icon(platformIcon(d.platform), size: 22, color: highlight ? p.accent : p.textDim),- if (widget.busy) const SizedBox.expand(child: CircularProgressIndicator(strokeWidth: 1.5)),+ if (widget.busy) const SizedBox.expand(child: ThemedSpinner(strokeWidth: 1.5)),],),),@@ -343,8 +350,8 @@ class _NearbyNodeState extends State<_NearbyNode> {// 新出现的设备从小到大淡入return TweenAnimationBuilder<double>(tween: Tween(begin: 0, end: 1),- duration: const Duration(milliseconds: 260),- curve: Curves.easeOut,+ duration: context.motion.duration(const Duration(milliseconds: 260)),+ curve: context.motion.curve(Curves.easeOut),builder: (context, v, child) => Opacity(opacity: v,child: Transform.scale(scale: 0.7 + 0.3 * v, child: child),diff --git a/ui/lib/widgets/pairing_dialog.dart b/ui/lib/widgets/pairing_dialog.dartindex 3343229..cb91578 100644--- a/ui/lib/widgets/pairing_dialog.dart+++ b/ui/lib/widgets/pairing_dialog.dart@@ -9,6 +9,7 @@ import '../theme.dart';import 'common.dart';import '../icons.dart';import '../platform.dart';+import '../pixel_art.dart';// 保存“添加设备”或“搜索附近设备”这条路由。配对请求到达时只移除它,不误关上层的确认框。final _pairingSetupRoutes = Expando<DialogRoute<void>>();@@ -134,7 +135,7 @@ class _GenerateTabState extends State<_GenerateTab> {final p = context.palette;final l = context.l10n;if (_loading) {- return const Center(child: CircularProgressIndicator(strokeWidth: 2));+ return const Center(child: ThemedSpinner(strokeWidth: 2));}if (_error != null) {return Padding(@@ -168,7 +169,7 @@ class _GenerateTabState extends State<_GenerateTab> {padding: const EdgeInsets.symmetric(vertical: Insets.lg),decoration: BoxDecoration(color: p.fill,- borderRadius: BorderRadius.circular(Radii.md),+ borderRadius: BorderRadius.circular(context.shape.md),),child: Text(_code ?? '',@@ -176,7 +177,7 @@ class _GenerateTabState extends State<_GenerateTab> {style: TextStyle(fontSize: 34,fontWeight: FontWeight.w600,- fontFamily: monoFamily,+ fontFamily: context.typography.mono,letterSpacing: 10,color: p.text,),@@ -236,7 +237,7 @@ class _AddressLine extends StatelessWidget {TextSpan(text: '${l.localAddress} ', style: context.text.bodySmall),TextSpan(text: addresses.join(' · '),- style: TextStyle(fontFamily: monoFamily, fontSize: 13, color: p.text),+ style: TextStyle(fontFamily: context.typography.mono, fontSize: 13, color: p.text),),]),textAlign: TextAlign.center,@@ -332,7 +333,7 @@ class _JoinTabState extends State<_JoinTab> {style: TextStyle(fontSize: 28,fontWeight: FontWeight.w600,- fontFamily: monoFamily,+ fontFamily: context.typography.mono,letterSpacing: 10,),inputFormatters: [@@ -355,7 +356,7 @@ class _JoinTabState extends State<_JoinTab> {TextField(controller: _addressController,textAlign: TextAlign.center,- style: TextStyle(fontFamily: monoFamily, fontSize: 14),+ style: TextStyle(fontFamily: context.typography.mono, fontSize: 14),decoration: InputDecoration(labelText: l.peerAddress,hintText: '192.168.1.20',@@ -383,10 +384,10 @@ class _JoinTabState extends State<_JoinTab> {FilledButton(onPressed: _busy ? null : _submit,child: _busy- ? const SizedBox(+ ? SizedBox(width: 14,height: 14,- child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),+ child: ThemedSpinner(strokeWidth: 2, color: context.palette.onAccent),): Text(l.continueAction),),@@ -494,7 +495,7 @@ class _PairingConfirmDialogState extends State<PairingConfirmDialog> {padding: const EdgeInsets.symmetric(horizontal: Insets.lg, vertical: Insets.md),decoration: BoxDecoration(color: p.fill,- borderRadius: BorderRadius.circular(Radii.md),+ borderRadius: BorderRadius.circular(context.shape.md),),child: Column(children: [@@ -508,7 +509,7 @@ class _PairingConfirmDialogState extends State<PairingConfirmDialog> {style: TextStyle(fontSize: 21,fontWeight: FontWeight.w600,- fontFamily: monoFamily,+ fontFamily: context.typography.mono,letterSpacing: 1.5,color: p.text,),@@ -545,10 +546,10 @@ class _PairingConfirmDialogState extends State<PairingConfirmDialog> {child: FilledButton(onPressed: _busy ? null : () => _respond(true),child: _busy- ? const SizedBox(+ ? SizedBox(width: 14,height: 14,- child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),+ child: ThemedSpinner(strokeWidth: 2, color: context.palette.onAccent),): Text(l.confirmMatch),),diff --git a/ui/lib/widgets/radar.dart b/ui/lib/widgets/radar.dartindex b272500..54e029b 100644--- a/ui/lib/widgets/radar.dart+++ b/ui/lib/widgets/radar.dart@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';import '../pages/devices_page.dart' show platformIcon;import '../platform.dart';+import '../pixel_theme.dart';import '../theme.dart';// 雷达:「搜索附近设备」与隔空传送页共用的底图和中间的本机。@@ -11,7 +12,7 @@ import '../theme.dart';/// 给了 [orbits](每圈的横向、纵向半径)时,按它们画椭圆,与设备所在的轨道重合,/// 波纹扩散到最外一圈;没给时画三圈正圆,铺满短边。class RadarPainter extends CustomPainter {- RadarPainter({required this.pulse, required this.ring, required this.wave, this.orbits})+ RadarPainter({required this.pulse, required this.ring, required this.wave, this.orbits, this.pixel = 0}): super(repaint: pulse);final Animation<double> pulse;@@ -19,10 +20,32 @@ class RadarPainter extends CustomPainter {final Color wave;final List<Size>? orbits;+ /// 大于 0 时按这么大的方格画(像素主题)+ final double pixel;+@overridevoid paint(Canvas canvas, Size size) {final c = size.center(Offset.zero);final maxR = size.shortestSide / 2;+ if (pixel > 0) {+ final orbits = this.orbits ?? [for (final f in const [0.36, 0.68, 1.0]) Size(maxR * f, maxR * f)];+ for (final o in orbits) {+ drawPixelOval(canvas, Rect.fromCenter(center: c, width: o.width * 2, height: o.height * 2), ring, pixel,+ dashed: true);+ }+ final outer = orbits.last;+ for (final offset in const [0.0, 0.5]) {+ final t = (((pulse.value + offset) % 1.0) * 8).floorToDouble() / 8;+ final k = Curves.easeOut.transform(t);+ drawPixelOval(+ canvas,+ Rect.fromCenter(center: c, width: (28 + (outer.width - 28) * k) * 2, height: (28 + (outer.height - 28) * k) * 2),+ wave.withValues(alpha: 0.6 * (1 - t)),+ pixel,+ );+ }+ return;+ }final rings = Paint()..style = PaintingStyle.stroke..strokeWidth = 1@@ -48,7 +71,8 @@ class RadarPainter extends CustomPainter {}@override- bool shouldRepaint(RadarPainter old) => old.ring != ring || old.wave != wave || old.orbits != orbits;+ bool shouldRepaint(RadarPainter old) =>+ old.ring != ring || old.wave != wave || old.orbits != orbits || old.pixel != pixel;}/// 雷达中间的本机。@@ -67,11 +91,7 @@ class RadarSelfNode extends StatelessWidget {Container(width: size,height: size,- decoration: BoxDecoration(- shape: BoxShape.circle,- color: p.surface,- border: Border.all(color: p.accent, width: 1.5),- ),+ decoration: context.shape.circle(color: p.surface, border: p.accent, borderWidth: 1.5),child: Icon(platformIcon(platform), size: 22, color: p.accent),),const SizedBox(height: 6),diff --git a/ui/lib/widgets/record_hover.dart b/ui/lib/widgets/record_hover.dartindex 089f5d5..14475fd 100644--- a/ui/lib/widgets/record_hover.dart+++ b/ui/lib/widgets/record_hover.dart@@ -141,11 +141,10 @@ class _HoverCard extends StatelessWidget {type: MaterialType.transparency,child: Container(padding: const EdgeInsets.all(Insets.md),- decoration: BoxDecoration(+ decoration: context.shape.box(color: p.surface,- borderRadius: BorderRadius.circular(Radii.md),- border: Border.all(color: p.border),- boxShadow: const [BoxShadow(color: Color(0x26000000), blurRadius: 16, offset: Offset(0, 4))],+ border: p.borderStrong,+ shadows: context.shape.shadows(const Color(0x26000000), blur: 16, offset: const Offset(0, 4)),),child: body,),@@ -269,7 +268,7 @@ class _ImageBodyState extends State<_ImageBody> {child: data == null? const SizedBox(width: 120, height: 60): ClipRRect(- borderRadius: BorderRadius.circular(Radii.sm),+ borderRadius: BorderRadius.circular(context.shape.sm),child: Image.file(File(data.$1),fit: BoxFit.contain,diff --git a/ui/lib/widgets/send_dialog.dart b/ui/lib/widgets/send_dialog.dartindex b94ac50..42f047c 100644--- a/ui/lib/widgets/send_dialog.dart+++ b/ui/lib/widgets/send_dialog.dart@@ -12,6 +12,7 @@ import '../i18n.dart';import '../icons.dart';import '../main.dart';import '../theme.dart';+import '../pixel_theme.dart';import 'common.dart';// 隔空传送的发送:点设备弹出的窗口,以及隔空传送页与窗口共用的发送逻辑。见 design/send-files.md 第 2 节。@@ -303,6 +304,7 @@ class _SendDialogState extends State<SendDialog> {color: _dragging ? p.accent : p.textFaint,dashed: !_dragging,fill: _dragging ? p.accent.withValues(alpha: 0.06) : Colors.transparent,+ radius: context.shape.md,),child: Padding(padding: EdgeInsets.symmetric(@@ -425,7 +427,7 @@ class TransferBatchRow extends StatelessWidget {),if (active) ...[const SizedBox(height: 4),- LinearProgressIndicator(+ ThemedProgressBar(minHeight: 3,value: t.totalBytes > 0 ? t.doneBytes.toInt() / t.totalBytes.toInt() : null,),@@ -511,15 +513,16 @@ String transferReason(AppLocalizations l, Transfer t) {/// 拖放区的边框:平时是虚线,拖着文件经过时变成实线。class DropZonePainter extends CustomPainter {- DropZonePainter({required this.color, required this.dashed, required this.fill});+ DropZonePainter({required this.color, required this.dashed, required this.fill, required this.radius});final Color color;final bool dashed;final Color fill;+ final double radius;@overridevoid paint(Canvas canvas, Size size) {- final rect = RRect.fromRectAndRadius(Offset.zero & size, const Radius.circular(Radii.md));+ final rect = RRect.fromRectAndRadius(Offset.zero & size, Radius.circular(radius));canvas.drawRRect(rect, Paint()..color = fill);final paint = Paint()..color = color@@ -538,5 +541,5 @@ class DropZonePainter extends CustomPainter {}@override- bool shouldRepaint(DropZonePainter old) => old.color != color || old.dashed != dashed || old.fill != fill;+ bool shouldRepaint(DropZonePainter old) => old.color != color || old.dashed != dashed || old.fill != fill || old.radius != radius;}diff --git a/ui/lib/widgets/update_dialog.dart b/ui/lib/widgets/update_dialog.dartindex a9ad662..f580433 100644--- a/ui/lib/widgets/update_dialog.dart+++ b/ui/lib/widgets/update_dialog.dart@@ -9,7 +9,9 @@ import '../i18n.dart';import '../main.dart';import '../platform.dart';import '../theme.dart';+import '../pixel_theme.dart';import 'common.dart';+import '../pixel_art.dart';/// 打开更新窗口:先检查,有新版本时列出各版的更新日志,用户确认后下载、校验、安装并自动重新打开。Future<void> showUpdateDialog(BuildContext context) => showDialog<void>(@@ -178,8 +180,8 @@ class _UpdateDialogState extends State<UpdateDialog> {Text(l.updateDownloading(humanBytes(_done), humanBytes(_total)), style: context.text.bodyMedium),const SizedBox(height: Insets.md),ClipRRect(- borderRadius: BorderRadius.circular(3),- child: LinearProgressIndicator(value: fraction, minHeight: 6, color: p.accent, backgroundColor: p.fill),+ borderRadius: BorderRadius.circular(context.shape.scaled(3)),+ child: ThemedProgressBar(value: fraction, minHeight: 6, color: p.accent, backgroundColor: p.fill),),],);@@ -196,7 +198,7 @@ class _UpdateDialogState extends State<UpdateDialog> {Widget _busy(BuildContext context, String text) => Row(children: [- const SizedBox(width: 18, height: 18, child: CircularProgressIndicator(strokeWidth: 2)),+ const SizedBox(width: 18, height: 18, child: ThemedSpinner(strokeWidth: 2)),const SizedBox(width: Insets.md),Expanded(child: Text(text, style: context.text.bodyMedium)),],diff --git a/ui/lib/widgets/web_share.dart b/ui/lib/widgets/web_share.dartindex 5cd3dab..71f357f 100644--- a/ui/lib/widgets/web_share.dart+++ b/ui/lib/widgets/web_share.dart@@ -11,6 +11,7 @@ import '../icons.dart';import '../main.dart';import '../theme.dart';import 'common.dart';+import '../pixel_art.dart';/// 设备页里的「手机网页传输」:开关、显示二维码、已登记的手机(design/phone-sync.md 第 2 节)。/// 旧版后台服务没有这个功能时不显示。@@ -408,7 +409,7 @@ class _WebShareDialogState extends State<WebShareDialog> {// 二维码一律深色画在白底上:深色模式下也是,反色的码很多扫码器认不出decoration: BoxDecoration(color: Colors.white,- borderRadius: BorderRadius.circular(Radii.lg),+ borderRadius: BorderRadius.circular(context.shape.lg),border: Border.all(color: p.border),),child: _invite == null@@ -417,7 +418,7 @@ class _WebShareDialogState extends State<WebShareDialog> {? const SizedBox(width: 20,height: 20,- child: CircularProgressIndicator(+ child: ThemedSpinner(strokeWidth: 2,),)@@ -442,7 +443,7 @@ class _WebShareDialogState extends State<WebShareDialog> {_invite!.url.split('#').first,textAlign: TextAlign.center,style: context.text.bodySmall?.copyWith(- fontFamily: monoFamily,+ fontFamily: context.typography.mono,),),if (addresses.length > 1) ...[@@ -463,7 +464,7 @@ class _WebShareDialogState extends State<WebShareDialog> {underline: const SizedBox.shrink(),style: context.text.bodySmall?.copyWith(color: p.text,- fontFamily: monoFamily,+ fontFamily: context.typography.mono,),items: [for (final a in addresses)diff --git a/ui/pubspec.yaml b/ui/pubspec.yamlindex f23f8b5..aa14d32 100644--- a/ui/pubspec.yaml+++ b/ui/pubspec.yaml@@ -71,6 +71,18 @@ flutter:assets:- assets/app_icon.png+ # 像素主题的字体与图标,见 tools/pixel-theme/build_assets.py。许可证在同一目录+ fonts:+ - family: FusionPixel+ fonts:+ - asset: assets/fonts/FusionPixel12.otf+ - family: FusionPixelMono+ fonts:+ - asset: assets/fonts/FusionPixel12Mono.otf+ - family: PixelIcons+ fonts:+ - asset: assets/fonts/PixelIcons.ttf+# To add assets to your application, add an assets section, like this:# assets:# - images/a_dot_burr.jpegdiff --git a/ui/test/builtin_themes_test.dart b/ui/test/builtin_themes_test.dartnew file mode 100644index 0000000..3d081a8--- /dev/null+++ b/ui/test/builtin_themes_test.dart@@ -0,0 +1,33 @@+import 'dart:io';++import 'package:flutter_test/flutter_test.dart';++import 'package:pasteferry_ui/theme.dart';+import 'package:pasteferry_ui/theme_json.dart';++/// 自带主题在两处定义:界面里的 AppThemeSpec.builtins,与后台服务校验、合并用的+/// client-core/internal/theme/builtin/ 下的 JSON。两边必须一致,改了一边就要改另一边。+void main() {+ final dir = Directory('../client-core/internal/theme/builtin');++ test('每个自带主题两边都有', () {+ final files = dir.listSync().whereType<File>().where((f) => f.path.endsWith('.json'));+ final ids = files.map((f) => f.uri.pathSegments.last.replaceAll('.json', '')).toSet();+ expect(ids, AppThemeSpec.builtins.keys.toSet());+ });++ for (final MapEntry(key: id, value: spec) in AppThemeSpec.builtins.entries) {+ test('自带主题 $id 与后台服务的定义一致', () {+ final json = File('${dir.path}/$id.json').readAsStringSync();+ // 用一个和谁都不一样的底,确保每个字段都是 JSON 里写的+ final parsed = parseTheme(json, base: AppThemeSpec.standard);+ final want = themeToJson(spec);+ final got = themeToJson(parsed);+ expect(got['modes'], want['modes'], reason: '颜色');+ expect(got['shape'], want['shape'], reason: '形状');+ expect(got['typography'], want['typography'], reason: '字体');+ expect(got['motion'], want['motion'], reason: '动效');+ expect(got['icons'], want['icons'], reason: '图标');+ });+ }+}diff --git a/ui/test/i18n_test.dart b/ui/test/i18n_test.dartindex ce9ac1b..1159bfe 100644--- a/ui/test/i18n_test.dart+++ b/ui/test/i18n_test.dart@@ -191,6 +191,7 @@ void main() {// 设置首页列出各类,逐个点进去、拉到底,再回到首页final pages = <String, String>{l.general: l.language,+ l.appearance: l.themeMode,l.settingsConnection: l.lanDiscovery,l.sync: l.syncImages,// 辅助功能授权只有 Mac 上有@@ -200,10 +201,15 @@ void main() {l.about: l.updateAuto,};for (final MapEntry(key: title, value: last) in pages.entries) {- await tester.dragUntilVisible(find.text(title).last, find.byType(ListView).last, const Offset(0, -100));- await tester.tap(find.text(title).last);+ // 只在设置的列表里找:「隔空传送」这些标题侧边栏里也有;列表下面的项没滚到时还没建出来+ final row = find.descendant(of: find.byType(ListView).last, matching: find.text(title));+ await tester.dragUntilVisible(row, find.byType(ListView).last, const Offset(0, -100));+ await tester.ensureVisible(row);await tester.pump();- await tester.dragUntilVisible(find.text(last), find.byType(ListView).last, const Offset(0, -100));+ await tester.tap(row);+ await tester.pump();+ final end = find.descendant(of: find.byType(ListView).last, matching: find.text(last));+ await tester.dragUntilVisible(end, find.byType(ListView).last, const Offset(0, -100));await tester.tap(find.text(l.navSettings).last);await tester.pump();}diff --git a/ui/test/theme_json_test.dart b/ui/test/theme_json_test.dartnew file mode 100644index 0000000..ecf059e--- /dev/null+++ b/ui/test/theme_json_test.dart@@ -0,0 +1,60 @@+import 'dart:convert';++import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';++import 'package:pasteferry_ui/pixel_theme.dart';+import 'package:pasteferry_ui/theme.dart';+import 'package:pasteferry_ui/theme_json.dart';++void main() {+ test('内置主题导出再读回来不变', () {+ for (final spec in [AppThemeSpec.standard, pixelTheme]) {+ final back = parseTheme(jsonEncode(themeToJson(spec)), base: AppThemeSpec.standard);+ expect(back.light.accent, spec.light.accent);+ expect(back.dark.borderStrong, spec.dark.borderStrong);+ expect(back.dark.shadow, spec.dark.shadow);+ expect(back.shape.corner, spec.shape.corner);+ expect(back.shape.borderWidth, spec.shape.borderWidth);+ expect(back.typography.family, spec.typography.family);+ expect(back.typography.mono, spec.typography.mono);+ expect(back.typography.sizes, spec.typography.sizes);+ expect(back.motion.style, spec.motion.style);+ expect(back.pixelIcons, spec.pixelIcons);+ }+ });++ test('只改强调色:其余从 base 补齐', () {+ final s = parseTheme({+ 'schema': 1,+ 'id': 'mint',+ 'base': 'pixel',+ 'modes': {+ 'dark': {'accent': '#FF8A5B'},+ },+ });+ expect(s.id, 'mint');+ expect(s.dark.accent, const Color(0xFFFF8A5B));+ expect(s.dark.background, pixelTheme.dark.background);+ expect(s.light.accent, pixelTheme.light.accent);+ expect(s.shape.corner, CornerStyle.pixel);+ expect(s.typography.family, 'FusionPixel');+ });++ test('改回系统字体时等宽字体也跟着回到系统的', () {+ final s = parseTheme({+ 'base': 'pixel',+ 'typography': {'family': null, 'sizes': []},+ });+ expect(s.typography.family, isNull);+ expect(s.typography.mono, monoFamily);+ });++ test('格式不对时报错', () {+ expect(() => parseColor('#12345'), throwsFormatException);+ expect(() => parseTheme({'typography': {'family': 'Comic Sans'}}), throwsFormatException);+ expect(parseColor('#80FFFFFF'), const Color(0x80FFFFFF));+ expect(formatColor(const Color(0x80FFFFFF)), '#80FFFFFF');+ expect(formatColor(const Color(0xFF3DDC97)), '#3DDC97');+ });+}diff --git a/ui/test/theme_test.dart b/ui/test/theme_test.dartnew file mode 100644index 0000000..4445d3e--- /dev/null+++ b/ui/test/theme_test.dart@@ -0,0 +1,146 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';++import 'package:pasteferry_ui/icons.dart';+import 'package:pasteferry_ui/pixel_theme.dart';+import 'package:pasteferry_ui/theme.dart';+import 'package:pasteferry_ui/widgets/common.dart';++/// 直角、无投影、逐帧动画的主题:检查页面与控件跟着主题走,而不是写死默认值+const _square = AppThemeSpec(+ id: 'square',+ light: AppPalette.light,+ dark: AppPalette.dark,+ shape: AppShape(sm: 0, md: 0, lg: 0, shadow: ShadowStyle.none),+ motion: AppMotion(style: MotionStyle.stepped, steps: 4),+);++void main() {+ test('默认主题保持原来的配色与圆角', () {+ for (final b in Brightness.values) {+ final t = buildTheme(b);+ final p = t.extension<AppPalette>()!;+ expect(p, same(b == Brightness.dark ? AppPalette.dark : AppPalette.light));+ expect(t.colorScheme.onPrimary, Colors.white);+ expect(t.snackBarTheme.backgroundColor, b == Brightness.dark ? const Color(0xFF3A3A3C) : const Color(0xFF2C2C2E));+ expect(t.dialogTheme.elevation, 18);+ expect(t.extension<AppShape>()!.md, Radii.md);+ final shape = t.filledButtonTheme.style!.shape!.resolve({}) as RoundedRectangleBorder;+ expect(shape.borderRadius, BorderRadius.circular(Radii.sm));+ }+ });++ test('默认主题的投影与动效原样返回', () {+ const shape = AppShape.standard;+ expect(shape.scaled(3), 3);+ expect(shape.shadows(const Color(0x14000000), blur: 8, offset: const Offset(0, 2)),+ [const BoxShadow(color: Color(0x14000000), blurRadius: 8, offset: Offset(0, 2))]);+ const motion = AppMotion.standard;+ expect(motion.curve(Curves.easeOut), same(Curves.easeOut));+ expect(motion.duration(const Duration(milliseconds: 120)), const Duration(milliseconds: 120));+ });++ test('直角主题:控件圆角为 0,没有投影', () {+ final t = buildTheme(Brightness.light, spec: _square);+ final shape = t.filledButtonTheme.style!.shape!.resolve({}) as RoundedRectangleBorder;+ expect(shape.borderRadius, BorderRadius.zero);+ expect(t.dialogTheme.elevation, 0);+ expect(_square.shape.scaled(9), 0);+ expect(_square.shape.shadows(const Color(0x14000000), blur: 8, offset: const Offset(0, 2)), isEmpty);+ });++ test('逐帧动画把曲线量化成几档,起点终点不变', () {+ final c = _square.motion.curve(Curves.linear);+ expect(c.transform(0), 0);+ expect(c.transform(0.3), 0.25);+ expect(c.transform(0.6), 0.5);+ expect(c.transform(1), 1);+ expect(const AppMotion(style: MotionStyle.reduced).duration(const Duration(milliseconds: 260)), Duration.zero);+ });++ test('主题之间可以过渡', () {+ final mid = AppShape.standard.lerp(_square.shape, 0.5);+ expect(mid.md, Radii.md / 2);+ expect(mid.shadow, ShadowStyle.none);+ final p = AppPalette.light.lerp(AppPalette.dark, 1);+ expect(p.inverse, AppPalette.dark.inverse);+ });++ testWidgets('分段控件按主题画圆角与投影', (tester) async {+ Future<BoxDecoration> selectedDecoration(AppThemeSpec spec) async {+ await tester.pumpWidget(MaterialApp(+ theme: buildTheme(Brightness.light, spec: spec),+ home: Scaffold(+ body: Segmented<int>(value: 0, segments: const [(0, 'A'), (1, 'B')], onChanged: (_) {}),+ ),+ ));+ await tester.pumpAndSettle();+ final box = tester.widget<AnimatedContainer>(find.ancestor(of: find.text('A'), matching: find.byType(AnimatedContainer)));+ return box.decoration! as BoxDecoration;+ }++ final standard = await selectedDecoration(AppThemeSpec.standard);+ expect(standard.borderRadius, BorderRadius.circular(5));+ expect(standard.boxShadow, hasLength(1));++ final square = await selectedDecoration(_square);+ expect(square.borderRadius, BorderRadius.zero);+ expect(square.boxShadow, isEmpty);+ });++ test('像素主题:点阵字体、切角粗边、硬投影', () {+ final t = buildTheme(Brightness.light, spec: pixelTheme);+ expect(t.textTheme.bodyMedium!.fontFamily, 'FusionPixel');+ expect(t.extension<AppTypography>()!.mono, 'FusionPixelMono');+ final shape = t.filledButtonTheme.style!.shape!.resolve({});+ expect(shape, isA<PixelBorder>());+ expect(t.dividerTheme.thickness, 2);+ });++ test('像素主题:按钮凸起、按下凹进,只有浮层有投影', () {+ final t = buildTheme(Brightness.dark, spec: pixelTheme);+ final p = pixelTheme.dark;+ final shape = t.filledButtonTheme.style!.shape!;+ final up = shape.resolve({}) as PixelBorder;+ final down = shape.resolve({WidgetState.pressed}) as PixelBorder;+ expect((up.topLeft, up.bottomRight), (p.bevelLight, p.bevelDark));+ expect((down.topLeft, down.bottomRight), (p.bevelDark, p.bevelLight));+ expect((t.dialogTheme.shape! as PixelBorder).drop, p.shadow);+ // 悬停预览这类大投影是错开两格的实心投影,按钮、节点的小投影不画+ final s = t.extension<AppShape>()!;+ final big = s.shadows(const Color(0x26000000), blur: 16, offset: const Offset(0, 4)).single;+ expect((big.blurRadius, big.offset, big.color), (0, const Offset(4, 4), p.shadow));+ expect(s.shadows(const Color(0x14000000), blur: 8, offset: const Offset(0, 2)), isEmpty);+ // 默认主题:强边框就是普通边框,没有斜面+ expect(AppPalette.dark.borderStrong, AppPalette.dark.border);+ });++ test('字号吸附到点阵字号上,系统缩放先算进去', () {+ const s = SnapTextScaler(TextScaler.noScaling, [12, 24]);+ expect(s.scale(11), 12);+ expect(s.scale(15), 12);+ expect(s.scale(22), 24);+ expect(const SnapTextScaler(TextScaler.linear(2), [12, 24]).scale(13), 24);+ });++ test('像素角切掉台阶,放不下时少切几级', () {+ const rect = Rect.fromLTWH(0, 0, 40, 20);+ final one = const PixelBorder(unit: 2).getOuterPath(rect);+ expect(one.contains(const Offset(0.5, 0.5)), isFalse); // 角上缺一格+ expect(one.contains(const Offset(2.5, 2.5)), isTrue);+ final three = const PixelBorder(unit: 2, steps: 3).getOuterPath(rect);+ expect(three.contains(const Offset(2.5, 2.5)), isFalse);+ expect(three.contains(const Offset(6.5, 6.5)), isTrue);+ // 6px 的点只够切一级+ final dot = const PixelBorder(unit: 2, steps: 3).getOuterPath(const Rect.fromLTWH(0, 0, 6, 6));+ expect(dot.contains(const Offset(2.5, 2.5)), isTrue);+ });++ test('图标随主题换成像素图标', () {+ addTearDown(() => AppIcons.pixel = false);+ final normal = AppIcons.gear;+ AppIcons.pixel = true;+ expect(AppIcons.gear, PixelIcons.gear);+ expect(AppIcons.gear, isNot(normal));+ });+}diff --git a/ui/tool/screenshots/screenshots_test.dart b/ui/tool/screenshots/screenshots_test.dartindex c81a292..6095a00 100644--- a/ui/tool/screenshots/screenshots_test.dart+++ b/ui/tool/screenshots/screenshots_test.dart@@ -19,6 +19,8 @@ import 'package:pasteferry_ui/picker/picker_state.dart';import 'package:pasteferry_ui/picker/picker_view.dart';import 'package:pasteferry_ui/icons.dart';import 'package:pasteferry_ui/theme.dart';+import 'package:pasteferry_ui/theme_controller.dart';+import 'package:pasteferry_ui/theme_json.dart';import 'package:pasteferry_ui/widgets/avatar.dart';import 'package:pasteferry_ui/widgets/friend_send_dialog.dart';import 'package:pasteferry_ui/widgets/friends_dialog.dart';@@ -40,6 +42,24 @@ final _locale = switch (_lang) { 'zh-tw' => zhHantTW, 'zh-hk' => zhHantHK, _ =>String _t(String zh, String en, String ja, {required String tw, required String hk}) =>switch (_lang) { 'en' => en, 'ja' => ja, 'zh-tw' => tw, 'zh-hk' => hk, _ => zh };+/// 截图用哪套主题:SCREENSHOT_THEME=pixel 渲染像素主题,不设时是默认主题;+/// SCREENSHOT_THEME_FILE 指向一份主题 JSON 时用它(宣传片里展示自定义主题)+final AppThemeSpec _spec = switch (Platform.environment['SCREENSHOT_THEME_FILE']) {+ final String file => parseTheme(File(file).readAsStringSync()),+ null => AppThemeSpec.byId(Platform.environment['SCREENSHOT_THEME'] ?? ''),+};++ThemeData _theme(Brightness brightness) =>+ buildTheme(brightness, spec: _spec, fontFamily: 'SF', fontFamilyFallback: _cjk);++/// 与 App 一样,主题规定了字号阶梯时把字号吸附上去。像素主题的场景与光标会一直动,+/// 截图时按「减少动态效果」只画静止的一帧,否则等不到画面静止+Widget _textScale(BuildContext context, Widget? child) {+ final scaled = ThemeTextScale(child: child!);+ if (!_spec.shape.pixel) return scaled;+ return MediaQuery(data: MediaQuery.of(context).copyWith(disableAnimations: true), child: scaled);+}+/// 汉字的字形跟着语言走:日文界面用冬青黑体,繁体用苹方的台湾、香港字形,否则用简体的苹方final _cjk = switch (_lang) {'ja' => const ['Hiragino', 'PingFang'],@@ -119,6 +139,14 @@ Future<void> _loadFonts() async {// 官方服务等少数地方用的是 Material 图标final material = FontLoader('MaterialIcons')..addFont(rootBundle.load('fonts/MaterialIcons-Regular.otf'));await material.load();+ // 像素主题的字体与图标(App 自带的资源)+ for (final (name, file) in const [+ ('FusionPixel', 'FusionPixel12.otf'),+ ('FusionPixelMono', 'FusionPixel12Mono.otf'),+ ('PixelIcons', 'PixelIcons.ttf'),+ ]) {+ await (FontLoader(name)..addFont(rootBundle.load('assets/fonts/$file'))).load();+ }}final _now = DateTime.now();@@ -431,13 +459,14 @@ Future<void> _render(required bool settle,}) async {- final theme = buildTheme(brightness, fontFamily: 'SF', fontFamilyFallback: _cjk);+ final theme = _theme(brightness);await tester.pumpWidget(RepaintBoundary(key: _boundary,child: AppScope(state: state,child: MaterialApp(debugShowCheckedModeBanner: false,+ builder: _textScale,theme: theme,locale: _locale,supportedLocales: supportedLocales,@@ -466,7 +495,8 @@ Future<void> _capture(WidgetTester tester, String name) async {await tester.runAsync(() async {final image = await boundary.toImage(pixelRatio: 2);final png = await image.toByteData(format: ImageByteFormat.png);- File('tool/screenshots/out/$name.png')+ // SCREENSHOT_OUT:另一个流程(宣传片)同时在渲染时,各写各的目录+ File('${Platform.environment['SCREENSHOT_OUT'] ?? 'tool/screenshots/out'}/$name.png')..createSync(recursive: true)..writeAsBytesSync(png!.buffer.asUint8List());});@@ -476,6 +506,7 @@ void main() {setUpAll(() async {TestWidgetsFlutterBinding.ensureInitialized();appL10n = lookupAppLocalizations(_locale);+ AppIcons.pixel = _spec.pixelIcons;await _loadFonts();});@@ -755,6 +786,41 @@ void main() {await _shoot(tester, 'settings', state: _demo(), section: Section.settings);});+ // 「外观」:自带的两套主题加两套演示用的自定义主题+ AppState appearanceDemo() {+ final state = _demo()..requestPage('settings:appearance');+ final sunset = parseTheme({+ 'id': 'sunset-pixel',+ 'base': 'pixel',+ 'modes': {+ 'dark': {'accent': '#FF8A5B', 'background': '#16110F', 'sidebar': '#100C0A', 'surface': '#1E1714', 'selection': '#2A201B', 'border': '#3A2D27'},+ 'light': {'accent': '#C2410C'},+ },+ });+ final mint = parseTheme({+ 'id': 'mint',+ 'base': 'default',+ 'modes': {+ 'dark': {'accent': '#34D399'},+ 'light': {'accent': '#047857'},+ },+ });+ state.theme.debugSeed(themes: [+ for (final e in AppThemeSpec.builtins.entries) ThemeChoice(id: e.key, names: const {}, builtin: true, spec: e.value),+ ThemeChoice(id: 'sunset-pixel', names: {'zh-Hans': '落日像素', 'en': 'Sunset Pixel', 'ja': 'サンセット', 'zh-Hant-TW': '落日像素', 'zh-Hant-HK': '落日像素'}, builtin: false, spec: sunset),+ ThemeChoice(id: 'mint', names: {'zh-Hans': '薄荷', 'en': 'Mint', 'ja': 'ミント', 'zh-Hant-TW': '薄荷', 'zh-Hant-HK': '薄荷'}, builtin: false, spec: mint),+ ], id: _spec.id);+ return state;+ }++ testWidgets('appearance', (tester) async {+ await _shoot(tester, 'appearance', state: appearanceDemo(), section: Section.settings);+ });++ testWidgets('appearance-dark', (tester) async {+ await _shoot(tester, 'appearance-dark', state: appearanceDemo(), section: Section.settings, brightness: Brightness.dark);+ });+AppState officialDemo() {final state = _demo();final bjt = _now.toUtc().add(const Duration(hours: 8));@@ -861,7 +927,8 @@ void main() {state: _demo(),child: MaterialApp(debugShowCheckedModeBanner: false,- theme: buildTheme(brightness, fontFamily: 'SF', fontFamilyFallback: _cjk),+ builder: _textScale,+ theme: _theme(brightness),locale: _locale,supportedLocales: supportedLocales,localizationsDelegates: AppLocalizations.localizationsDelegates,@@ -973,7 +1040,7 @@ Future<void> _shootPicker(WidgetTester tester, String name, {String query = ''})records: _pickerRecords(),favorites: _favorites(),);- final theme = buildTheme(Brightness.dark, fontFamily: 'SF', fontFamilyFallback: _cjk).copyWith(+ final theme = _theme(Brightness.dark).copyWith(scaffoldBackgroundColor: Colors.transparent,canvasColor: Colors.transparent,);@@ -981,6 +1048,7 @@ Future<void> _shootPicker(WidgetTester tester, String name, {String query = ''})key: _boundary,child: MaterialApp(debugShowCheckedModeBanner: false,+ builder: _textScale,color: Colors.transparent,theme: theme,locale: _locale,@@ -991,7 +1059,7 @@ Future<void> _shootPicker(WidgetTester tester, String name, {String query = ''})width: 560,height: 460,decoration: BoxDecoration(- borderRadius: BorderRadius.circular(Radii.lg),+ borderRadius: BorderRadius.circular(_spec.shape.lg),boxShadow: const [BoxShadow(color: Color(0x73000000), blurRadius: 36, offset: Offset(0, 14)),BoxShadow(color: Color(0x40000000), blurRadius: 3),