39 lines
1.2 KiB
Dart
Raw Permalink Normal View History

2025-08-27 18:20:37 +08:00
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:starwork_flutter/views/main/widget/main_left_drawer_widget.dart';
2025-08-27 18:20:37 +08:00
import 'main_controller.dart';
class MainView extends GetView<MainController> {
const MainView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
key: controller.scaffoldKey, // 添加这一行!
2025-08-27 18:20:37 +08:00
// 使用 Obx 响应 currentIndex 的变化
body: Obx(
() => IndexedStack(
index: controller.currentIndex.value,
children: controller.pages,
),
),
bottomNavigationBar: Obx(
() => BottomNavigationBar(
currentIndex: controller.currentIndex.value,
onTap: (index) => controller.changeIndex(index),
items: controller.bottomNavItems,
type: BottomNavigationBarType.fixed,
// 多于3个时建议 fixed
selectedFontSize: 12.sp,
unselectedFontSize: 12.sp,
),
),
drawer: MainLeftDrawerWidget(
teamList: ['家庭群组', '测试团队1', '测试团队2'],
),
2025-08-27 18:20:37 +08:00
);
}
}