|
|
|
@ -7,13 +7,6 @@ import '../controllers/usage_controller.dart'; |
|
|
|
class UsageView extends GetView<UsageController> { |
|
|
|
const UsageView({super.key}); |
|
|
|
|
|
|
|
// 1. 将导航栏配置提取为常量,提高可维护性 |
|
|
|
static const _navItems = [ |
|
|
|
_NavItem(Icons.chat_bubble_outline, 'AI chat'), |
|
|
|
_NavItem(Icons.translate, 'interpretation'), |
|
|
|
_NavItem(Icons.people, 'meeting'), |
|
|
|
]; |
|
|
|
|
|
|
|
// 2. 颜色配置集中管理 |
|
|
|
Color _getBgColor(bool isDark) => |
|
|
|
isDark ? Colors.black : const Color(0xFFF9FAFB); |
|
|
|
@ -28,11 +21,11 @@ class UsageView extends GetView<UsageController> { |
|
|
|
|
|
|
|
return Scaffold( |
|
|
|
backgroundColor: isDarkMode ? AppColors.darkBackground : Colors.grey[50], |
|
|
|
body: PageView( |
|
|
|
physics: const NeverScrollableScrollPhysics(), |
|
|
|
controller: controller.pageController, |
|
|
|
children: controller.pageList, |
|
|
|
), |
|
|
|
body: Obx(() => PageView( |
|
|
|
physics: const NeverScrollableScrollPhysics(), |
|
|
|
controller: controller.pageController, |
|
|
|
children: controller.pageList, |
|
|
|
)), |
|
|
|
bottomNavigationBar: Obx( |
|
|
|
() { |
|
|
|
final currentIndex = controller.pageIndex.value; |
|
|
|
@ -48,7 +41,16 @@ class UsageView extends GetView<UsageController> { |
|
|
|
// 3. 添加安全区域适配(针对刘海屏) |
|
|
|
child: BottomNavigationBar( |
|
|
|
// 4. 使用生成的导航项 |
|
|
|
items: _navItems |
|
|
|
items: (controller.showAiChat.value |
|
|
|
? const [ |
|
|
|
_NavItem(Icons.chat_bubble_outline, 'AI chat'), |
|
|
|
_NavItem(Icons.translate, 'interpretation'), |
|
|
|
_NavItem(Icons.people, 'meeting'), |
|
|
|
] |
|
|
|
: const [ |
|
|
|
_NavItem(Icons.translate, 'interpretation'), |
|
|
|
_NavItem(Icons.people, 'meeting'), |
|
|
|
]) |
|
|
|
.map((item) => BottomNavigationBarItem( |
|
|
|
icon: Icon(item.icon), |
|
|
|
activeIcon: Icon(item.icon, |
|
|
|
@ -70,8 +72,8 @@ class UsageView extends GetView<UsageController> { |
|
|
|
type: BottomNavigationBarType.fixed, |
|
|
|
// 7. 增加图标和文字的间距 |
|
|
|
iconSize: 22.w, // 响应式图标尺寸 |
|
|
|
selectedLabelStyle: TextStyle(height: 1.5), // 文字垂直间距 |
|
|
|
unselectedLabelStyle: TextStyle(height: 1.5), |
|
|
|
selectedLabelStyle: TextStyle(height: 1.5.sp), // 文字垂直间距 |
|
|
|
unselectedLabelStyle: TextStyle(height: 1.5.sp), |
|
|
|
), |
|
|
|
); |
|
|
|
}, |
|
|
|
|