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.

52 lines
1.8 KiB

// lib/modules/home/views/home_page.dart
import 'package:flutter/material.dart';
import 'package:get/get.dart';
2 months ago
import 'package:problem_check_system/modules/home/controllers/home_controller.dart';
class HomePage extends GetView<HomeController> {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Obx(
() => Scaffold(
body: controller.pages[controller.selectedIndex.value],
// 1. 将 BottomNavigationBar 替换为 NavigationBar
bottomNavigationBar: NavigationBar(
// 2. 将 'currentIndex' 属性重命名为 'selectedIndex'
selectedIndex: controller.selectedIndex.value,
// 3. 将 'onTap' 属性重命名为 'onDestinationSelected'
onDestinationSelected: controller.changeIndex,
// M3 风格调整 (可选, 但推荐)
// 动画时长
animationDuration: const Duration(milliseconds: 800),
// 4. 将 'items' 替换为 'destinations',并使用 NavigationDestination
destinations: const [
NavigationDestination(
// M3 的一个重要特性是区分选中和未选中的图标
icon: Icon(Icons.home_outlined, color: Colors.blue),
selectedIcon: Icon(Icons.home, color: Colors.blue),
label: '企业',
),
NavigationDestination(
icon: Icon(Icons.now_widgets_outlined, color: Colors.orange),
selectedIcon: Icon(Icons.now_widgets, color: Colors.orange),
label: '全部问题',
),
NavigationDestination(
icon: Icon(Icons.person_outline, color: Colors.cyan),
selectedIcon: Icon(Icons.person, color: Colors.cyan),
label: '我的',
),
],
),
),
);
}
}