39 lines
1.2 KiB
Dart

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';
import 'main_controller.dart';
class MainView extends GetView<MainController> {
const MainView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
key: controller.scaffoldKey, // 添加这一行!
// 使用 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'],
),
);
}
}