feat(client): toast 限定主显示区/自适应宽/上限80%/超长多行居中(1.0.26)

按真相源新规:toast 改为自定义 Overlay 实现(widgets/pangolin_toast.dart),完全控制布局——
不覆盖左侧栏(left=侧栏宽 desktop204/tablet232/mobile0)、宽度自适应内容上限主区80%、超长文本
多行、主区内水平居中贴底、淡入轻起;仍走语义 token 明暗适配。自动连接改用 showPangolinToast。
同步 design/CONTRACT.md §2 toast 规格(canonical=showPangolinToast)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-29 19:50:33 +08:00
parent 143104b861
commit 277d1c6e97
5 changed files with 90 additions and 18 deletions
+3 -10
View File
@@ -22,9 +22,7 @@ import 'system_tray.dart';
import 'widgets/auth_screen.dart';
import 'widgets/onboarding_screen.dart';
import 'widgets/pangolin_logo.dart';
/// 全局 ScaffoldMessenger key:供无 BuildContext 处(如自动连接)弹 SnackBar/toast。
final rootMessengerKey = GlobalKey<ScaffoldMessengerState>();
import 'widgets/pangolin_toast.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
@@ -101,7 +99,6 @@ class _PangolinAppState extends ConsumerState<PangolinApp> {
final mode = ref.watch(themeModeProvider);
return MaterialApp(
title: '穿山甲',
scaffoldMessengerKey: rootMessengerKey,
debugShowCheckedModeBanner: false,
theme: PangolinTheme.light,
darkTheme: PangolinTheme.dark,
@@ -155,13 +152,9 @@ class _RootFlowState extends ConsumerState<RootFlow> {
if (settings.autoConnect && phase == VpnPhase.off) {
logLine('AutoConnect', 'triggering connect → ${node.code}');
ref.read(connectionProvider.notifier).toggle();
// 自动连接 toast:告知用户「正在自动连接到 X」。
// 自动连接 toast:「正在自动连接到 X」(主显示区内居中,见 pangolin_toast)
final t = ref.read(appTextProvider);
rootMessengerKey.currentState?.showSnackBar(SnackBar(
content: Text(t.autoConnectingTo(node.localizedName(t.lang))),
behavior: SnackBarBehavior.floating,
duration: const Duration(seconds: 3),
));
if (mounted) showPangolinToast(context, t.autoConnectingTo(node.localizedName(t.lang)));
} else {
logLine('AutoConnect', 'NOT connecting (autoConnect=${settings.autoConnect} phase=$phase)');
}