You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.7 KiB
98 lines
2.7 KiB
import 'package:flutter/material.dart'; |
|
import 'package:get/get.dart'; |
|
import 'package:problem_check_system/modules/home/controllers/home_controller.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
class HomePage extends GetView<HomeController> { |
|
const HomePage({super.key}); |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return Obx( |
|
() => Scaffold( |
|
body: controller.pages[controller.selectedIndex.value], |
|
bottomNavigationBar: _buildCustomBottomBar(), |
|
), |
|
); |
|
} |
|
|
|
Widget _buildCustomBottomBar() { |
|
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: '首页', |
|
// ), |
|
_buildBottomBarItem( |
|
index: 0, |
|
icon: Icons.description_outlined, |
|
activeIcon: Icons.description, |
|
label: '问题', |
|
), |
|
_buildBottomBarItem( |
|
index: 1, |
|
icon: Icons.person_outlined, |
|
activeIcon: Icons.person, |
|
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, |
|
), |
|
), |
|
], |
|
), |
|
), |
|
), |
|
); |
|
} |
|
}
|
|
|