- 新增首页平板信息卡片(定位、截图、使用时长、设备操作) - 将消息 Tab 改为管理 Tab,增加横版菜单与消息列表 - 新增相册、闹钟、联系人、应用子页面路由 - 统一主色为桐桐绿并优化调试日志输出
68 lines
2.0 KiB
Dart
68 lines
2.0 KiB
Dart
import 'package:cupertino_ui/cupertino_ui.dart';
|
||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||
import 'package:go_router/go_router.dart';
|
||
|
||
import '../../../l10n/app_localizations.dart';
|
||
|
||
/// 首页 Shell(含底部 Tab:首页 / 管理 / 我的)。
|
||
///
|
||
/// Tab 切换通过 GoRouter 的 StatefulShellRoute 管理,本组件仅渲染当前分支与底部栏。
|
||
/// 实际 Tab 内容由对应特性模块(home / messages / profile)提供。
|
||
class HomePage extends ConsumerWidget {
|
||
const HomePage({required this.child, super.key});
|
||
|
||
/// 当前选中的 Tab 子树(由路由 shell 注入)。
|
||
final Widget child;
|
||
|
||
@override
|
||
Widget build(BuildContext context, WidgetRef ref) {
|
||
final l10n = AppLocalizations.of(context);
|
||
final location = GoRouterState.of(context).uri.path;
|
||
final index = switch (location) {
|
||
final p when p.startsWith('/messages') => 1,
|
||
final p when p.startsWith('/profile') => 2,
|
||
_ => 0,
|
||
};
|
||
|
||
return CupertinoPageScaffold(
|
||
child: Stack(
|
||
children: [
|
||
child,
|
||
Align(
|
||
alignment: Alignment.bottomCenter,
|
||
child: CupertinoTabBar(
|
||
currentIndex: index,
|
||
onTap: (i) => _onTabTap(context, i),
|
||
items: [
|
||
BottomNavigationBarItem(
|
||
icon: const Icon(CupertinoIcons.home),
|
||
label: l10n.tabHome,
|
||
),
|
||
BottomNavigationBarItem(
|
||
icon: const Icon(CupertinoIcons.square_grid_2x2),
|
||
label: l10n.tabManage,
|
||
),
|
||
BottomNavigationBarItem(
|
||
icon: const Icon(CupertinoIcons.person),
|
||
label: l10n.tabProfile,
|
||
),
|
||
],
|
||
),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
void _onTabTap(BuildContext context, int index) {
|
||
switch (index) {
|
||
case 0:
|
||
context.go('/home');
|
||
case 1:
|
||
context.go('/messages');
|
||
case 2:
|
||
context.go('/profile');
|
||
}
|
||
}
|
||
}
|