|
|
@ -1,6 +1,7 @@ |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
import 'package:problem_check_system/modules/home/controllers/home_controller.dart'; |
|
|
|
import 'package:problem_check_system/modules/home/controllers/home_controller.dart'; |
|
|
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
|
|
|
|
|
|
|
class HomePage extends GetView<HomeController> { |
|
|
|
class HomePage extends GetView<HomeController> { |
|
|
|
const HomePage({super.key}); |
|
|
|
const HomePage({super.key}); |
|
|
@ -9,28 +10,88 @@ class HomePage extends GetView<HomeController> { |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return Obx( |
|
|
|
return Obx( |
|
|
|
() => Scaffold( |
|
|
|
() => Scaffold( |
|
|
|
body: controller.pages[controller.selectedIndex.value], // 根据状态显示页面 |
|
|
|
body: controller.pages[controller.selectedIndex.value], |
|
|
|
bottomNavigationBar: NavigationBar( |
|
|
|
bottomNavigationBar: _buildCustomBottomBar(), |
|
|
|
selectedIndex: controller.selectedIndex.value, |
|
|
|
), |
|
|
|
onDestinationSelected: controller.changeIndex, // 回调控制状态更新 |
|
|
|
); |
|
|
|
destinations: const [ |
|
|
|
} |
|
|
|
// NavigationDestination( |
|
|
|
|
|
|
|
// icon: Icon(Icons.home_outlined), |
|
|
|
Widget _buildCustomBottomBar() { |
|
|
|
// selectedIcon: Icon(Icons.home), |
|
|
|
return Container( |
|
|
|
|
|
|
|
height: 60.h, // 自定义高度 |
|
|
|
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
|
|
|
color: Colors.white, |
|
|
|
|
|
|
|
boxShadow: [ |
|
|
|
|
|
|
|
BoxShadow( |
|
|
|
|
|
|
|
color: Colors.grey.withAlpha(76), |
|
|
|
|
|
|
|
blurRadius: 8, |
|
|
|
|
|
|
|
offset: const Offset(0, -2), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
child: Row( |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
// 首页项(已注释) |
|
|
|
|
|
|
|
// _buildBottomBarItem( |
|
|
|
|
|
|
|
// index: 0, |
|
|
|
|
|
|
|
// icon: Icons.home_outlined, |
|
|
|
|
|
|
|
// activeIcon: Icons.home, |
|
|
|
// label: '首页', |
|
|
|
// label: '首页', |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
NavigationDestination( |
|
|
|
_buildBottomBarItem( |
|
|
|
icon: Icon(Icons.description_outlined), |
|
|
|
index: 0, |
|
|
|
selectedIcon: Icon(Icons.description), |
|
|
|
icon: Icons.description_outlined, |
|
|
|
|
|
|
|
activeIcon: Icons.description, |
|
|
|
label: '问题', |
|
|
|
label: '问题', |
|
|
|
), |
|
|
|
), |
|
|
|
NavigationDestination( |
|
|
|
_buildBottomBarItem( |
|
|
|
icon: Icon(Icons.person_outline), |
|
|
|
index: 1, |
|
|
|
selectedIcon: Icon(Icons.person), |
|
|
|
icon: Icons.person_outlined, |
|
|
|
|
|
|
|
activeIcon: Icons.person, |
|
|
|
label: '我的', |
|
|
|
label: '我的', |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildBottomBarItem({ |
|
|
|
|
|
|
|
required int index, |
|
|
|
|
|
|
|
required IconData icon, |
|
|
|
|
|
|
|
required IconData activeIcon, |
|
|
|
|
|
|
|
required String label, |
|
|
|
|
|
|
|
}) { |
|
|
|
|
|
|
|
bool isSelected = controller.selectedIndex.value == index; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Expanded( |
|
|
|
|
|
|
|
child: GestureDetector( |
|
|
|
|
|
|
|
onTap: () => controller.changeIndex(index), |
|
|
|
|
|
|
|
child: Container( |
|
|
|
|
|
|
|
color: Colors.transparent, // 透明背景,无点击效果 |
|
|
|
|
|
|
|
child: Row( |
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
Icon( |
|
|
|
|
|
|
|
isSelected ? activeIcon : icon, |
|
|
|
|
|
|
|
color: isSelected |
|
|
|
|
|
|
|
? const Color(0xFF418CFC) |
|
|
|
|
|
|
|
: Colors.grey.shade600, |
|
|
|
|
|
|
|
size: 24.w, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
SizedBox(width: 4.w), // 图标和文字之间的间距 |
|
|
|
|
|
|
|
Text( |
|
|
|
|
|
|
|
label, |
|
|
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
|
|
|
color: isSelected |
|
|
|
|
|
|
|
? const Color(0xFF418CFC) |
|
|
|
|
|
|
|
: Colors.grey.shade600, |
|
|
|
|
|
|
|
fontWeight: isSelected ? FontWeight.w500 : FontWeight.normal, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|