// home_shell.dart — 主框架分发器(按 formFactor 选三端外壳) // // desktop → 侧栏 6 项 + 顶栏(对照 ui_kits/desktop) // tablet → 暂用 MobileShell(TODO: TabletShell 侧栏双栏,对照 ui_kits/tablet) // mobile → 底 Tab + 滑动(对照 ui_kits/mobile) import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../core/responsive/form_factor.dart'; import '../pangolin_theme.dart'; import '../state/app_providers.dart'; import '../state/update_provider.dart'; import '../widgets/update_dialog.dart'; import 'desktop_shell.dart'; import 'mobile_shell.dart'; import 'tablet_shell.dart'; class HomeShell extends ConsumerWidget { const HomeShell({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { final c = context.pangolin; // 启动自动检查更新:watch 惰性拉起 updateProvider(延迟 3s→查→1h 轮询); // 有新版且本次会话未忽略时弹更新对话框。非强制更新弹前即标 dismiss,避免 // rebuild 重复弹(下轮轮询会重置);强制更新走不可关闭弹窗。 ref.listen>(updateProvider, (prev, next) { final info = next.valueOrNull; if (info == null || !info.hasUpdate) return; final notifier = ref.read(updateProvider.notifier); if (notifier.isDismissed) return; if (!info.forceUpdate) notifier.dismiss(); WidgetsBinding.instance.addPostFrameCallback((_) { if (!context.mounted) return; showUpdateDialog(context, ref.read(appTextProvider), info); }); }); ref.watch(updateProvider); // 激活 provider(惰性 build) final Widget body = switch (context.formFactor) { FormFactor.desktop => const DesktopShell(), FormFactor.tablet => const TabletShell(), FormFactor.mobile => const MobileShell(), }; return Scaffold(backgroundColor: c.bg, body: body); } }