34 lines
935 B
Dart
34 lines
935 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import 'main_controller.dart';
|
|
|
|
class MainView extends GetView<MainController> {
|
|
const MainView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
// 使用 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,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|