|
|
@@ -1,12 +1,104 @@
|
|
|
import 'package:electronic_assistant/base/base_page.dart';
|
|
|
+import 'package:electronic_assistant/module/main/controller.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
+import 'package:get/get.dart';
|
|
|
|
|
|
-class MainTabPage extends BasePage {
|
|
|
+class MainTabPage extends BasePage<MainController> {
|
|
|
const MainTabPage({super.key});
|
|
|
|
|
|
@override
|
|
|
Widget? buildBody(BuildContext context) {
|
|
|
- // TODO: implement buildBody
|
|
|
- throw UnimplementedError();
|
|
|
+ return Scaffold(
|
|
|
+ body: const Center(
|
|
|
+ child: Text('MainTabPage'),
|
|
|
+ ),
|
|
|
+ bottomNavigationBar: BottomAppBar(
|
|
|
+ color: Colors.white,
|
|
|
+ height: 68,
|
|
|
+ shape: const CircularNotchedRectangle(),
|
|
|
+ child: Obx(() {
|
|
|
+ return Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
+ children: <Widget>[
|
|
|
+ SizedBox(child: bottomAppBarItem(0)),
|
|
|
+ const SizedBox(),
|
|
|
+ SizedBox(child: bottomAppBarItem(1)),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ drawer: Drawer(
|
|
|
+ child: Center(
|
|
|
+ child: Column(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: <Widget>[
|
|
|
+ const Text('This is the Drawer'),
|
|
|
+ ElevatedButton(
|
|
|
+ onPressed: () {},
|
|
|
+ child: const Text('Close Drawer'),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
}
|
|
|
+
|
|
|
+ Widget bottomAppBarItem(int index) {
|
|
|
+ //设置默认未选中的状态
|
|
|
+ TextStyle style;
|
|
|
+ TabBean tabBean = controller.tabBeans[index];
|
|
|
+ String imagePath;
|
|
|
+ if (controller.currentIndex == index) {
|
|
|
+ //选中的话
|
|
|
+ style = TextStyle(fontSize: 10, color: tabBean.txtSelectedColor);
|
|
|
+ imagePath = tabBean.selectedIcon;
|
|
|
+ } else {
|
|
|
+ style = TextStyle(fontSize: 10, color: tabBean.txtNormalColor);
|
|
|
+ imagePath = tabBean.normalIcon;
|
|
|
+ }
|
|
|
+ //构造返回的Widget
|
|
|
+ Widget item = GestureDetector(
|
|
|
+ behavior: HitTestBehavior.opaque,
|
|
|
+ child: Center(
|
|
|
+ child: Column(
|
|
|
+ mainAxisSize: MainAxisSize.min,
|
|
|
+ children: <Widget>[
|
|
|
+ Image.asset(imagePath, width: 24, height: 24),
|
|
|
+ Text(
|
|
|
+ tabBean.title,
|
|
|
+ style: style,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ onTap: () {
|
|
|
+ if (controller.currentIndex != index) {
|
|
|
+ controller.updateIndex(index);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ );
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+
|
|
|
+// List<BottomNavigationBarItem> get _buildBottomBarItem {
|
|
|
+// return [
|
|
|
+// BottomNavigationBarItem(
|
|
|
+// icon: Assets.images.mainTabHomeUnSelect.image(width: 24, height: 24),
|
|
|
+// activeIcon:
|
|
|
+// Assets.images.mainTabHomeSelected.image(width: 24, height: 24),
|
|
|
+// label: 'main_tab_home'.tr,
|
|
|
+// ),
|
|
|
+// const BottomNavigationBarItem(
|
|
|
+// icon: SizedBox(width: 24, height: 24),
|
|
|
+// label: '',
|
|
|
+// ),
|
|
|
+// BottomNavigationBarItem(
|
|
|
+// icon: Assets.images.mainTabFileUnSelect.image(width: 24, height: 24),
|
|
|
+// activeIcon:
|
|
|
+// Assets.images.mainTabFileSelected.image(width: 24, height: 24),
|
|
|
+// label: 'main_tab_file'.tr,
|
|
|
+// ),
|
|
|
+// ];
|
|
|
+// }
|
|
|
}
|