diff --git a/lib/features/shell/main_shell.dart b/lib/features/shell/main_shell.dart index de3c83b..520a84a 100644 --- a/lib/features/shell/main_shell.dart +++ b/lib/features/shell/main_shell.dart @@ -2,14 +2,13 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../core/utils/rcon_client.dart'; import '../../providers/rcon_provider.dart'; - import '../console/console_page.dart'; import '../dashboard/dashboard_page.dart'; +import '../dashboard/server_picker_bar.dart'; import '../mod_manager/mod_list_page.dart'; import '../player_management/player_list_page.dart'; import '../settings/settings_page.dart'; import '../terminal/terminal_page.dart'; -import '../dashboard/server_picker_bar.dart'; /// 主导航壳:底部导航「服务器 · 控制台 · 玩家 · 模组 · 终端 · 我的」(M4)。 class MainShell extends StatefulWidget { @@ -50,6 +49,39 @@ class _MainShellState extends State { } } +/// 页签通用骨架:带标题 AppBar(无服务器选中时副标题为空)。 +class _TabScaffold extends StatelessWidget { + final String title; + final String? subtitle; + final Widget child; + + const _TabScaffold({required this.title, required this.child, this.subtitle}); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.transparent, + appBar: AppBar( + title: subtitle == null || subtitle!.isEmpty + ? Text(title) + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text(title), + Text(subtitle!, + style: Theme.of(context) + .textTheme + .bodySmall + ?.copyWith(color: Theme.of(context).hintColor)), + ], + ), + ), + body: child, + ); + } +} + /// 控制台页签:选中服务器后通过 RconProvider 拿连接。 class _ConsoleTab extends StatelessWidget { const _ConsoleTab(); @@ -60,18 +92,26 @@ class _ConsoleTab extends StatelessWidget { final rcon = context.read(); final server = holder.server; if (server == null) { - return const _NeedServerHint(); + return const _TabScaffold(title: '控制台', child: _NeedServerHint()); } return FutureBuilder( future: rcon.getClient(server), builder: (context, snap) { if (snap.connectionState != ConnectionState.done) { - return const Center(child: CircularProgressIndicator()); + return _TabScaffold( + title: '控制台', + subtitle: server.name, + child: const Center(child: CircularProgressIndicator()), + ); } if (snap.hasError) { - return Center(child: Text('RCON 连接失败:${snap.error}')); + return _TabScaffold( + title: '控制台', + subtitle: server.name, + child: Center(child: Text('RCON 连接失败:${snap.error}')), + ); } - return ConsolePage(rconClient: snap.data!); + return ConsolePage(rconClient: snap.data!); // 自带 AppBar }, ); } @@ -87,18 +127,26 @@ class _PlayerTab extends StatelessWidget { final rcon = context.read(); final server = holder.server; if (server == null) { - return const _NeedServerHint(); + return const _TabScaffold(title: '玩家', child: _NeedServerHint()); } return FutureBuilder( future: rcon.getClient(server), builder: (context, snap) { if (snap.connectionState != ConnectionState.done) { - return const Center(child: CircularProgressIndicator()); + return _TabScaffold( + title: '玩家', + subtitle: server.name, + child: const Center(child: CircularProgressIndicator()), + ); } if (snap.hasError) { - return Center(child: Text('RCON 连接失败:${snap.error}')); + return _TabScaffold( + title: '玩家', + subtitle: server.name, + child: Center(child: Text('RCON 连接失败:${snap.error}')), + ); } - return PlayerListPage(rconClient: snap.data!); + return PlayerListPage(rconClient: snap.data!); // 自带 AppBar }, ); }