Initial project
This commit is contained in:
0
apps/im_app/lib/features/app_tab/di/.gitkeep
Normal file
0
apps/im_app/lib/features/app_tab/di/.gitkeep
Normal file
0
apps/im_app/lib/features/app_tab/usecases/.gitkeep
Normal file
0
apps/im_app/lib/features/app_tab/usecases/.gitkeep
Normal file
52
apps/im_app/lib/features/app_tab/view/app_tab.dart
Normal file
52
apps/im_app/lib/features/app_tab/view/app_tab.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
/// 主 Tab 容器(Shell 层)
|
||||
///
|
||||
/// 由 [StatefulShellRoute.indexedStack] 驱动,不持有任何状态。
|
||||
/// Tab 切换通过 [navigationShell.goBranch] 完成,go_router 负责保持各 Tab 的导航栈。
|
||||
///
|
||||
/// Tabs(index 顺序):
|
||||
/// - 0:聊天
|
||||
/// - 1:联系人
|
||||
/// - 2:设置
|
||||
class AppTab extends StatelessWidget {
|
||||
const AppTab({
|
||||
super.key,
|
||||
required this.navigationShell,
|
||||
});
|
||||
|
||||
final StatefulNavigationShell navigationShell;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: navigationShell,
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: navigationShell.currentIndex,
|
||||
onTap: (index) => navigationShell.goBranch(
|
||||
index,
|
||||
// 再次点击已激活的 Tab 时回到该 Tab 的初始路由
|
||||
initialLocation: index == navigationShell.currentIndex,
|
||||
),
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.chat_bubble_outline),
|
||||
activeIcon: Icon(Icons.chat_bubble),
|
||||
label: '聊天',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.people_outline),
|
||||
activeIcon: Icon(Icons.people),
|
||||
label: '联系人',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.settings_outlined),
|
||||
activeIcon: Icon(Icons.settings),
|
||||
label: '设置',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user