| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- 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<MainController> {
- const MainTabPage({super.key});
- @override
- Widget? buildBody(BuildContext context) {
- 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,
- // ),
- // ];
- // }
- }
|