90 lines
2.5 KiB
Dart
90 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:tdesign_flutter/tdesign_flutter.dart';
|
|
import '../../utils/utils.dart';
|
|
import '../layout/home/index.dart';
|
|
import '../layout/user/index.dart';
|
|
import 'tab_logic.dart';
|
|
|
|
class TabPage extends StatelessWidget {
|
|
const TabPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final logic = Get.find<TabLogic>();
|
|
final state = Get.find<TabLogic>().state;
|
|
|
|
/// 内容页
|
|
Widget buildPageView() {
|
|
return GetBuilder<TabLogic>(builder: (_) {
|
|
return PageView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
controller: state.pageController,
|
|
onPageChanged: logic.handlePageChanged,
|
|
children: const <Widget>[
|
|
HomePage(),
|
|
UserPage(),
|
|
],
|
|
);
|
|
});
|
|
}
|
|
|
|
List<BottomNavigationBarItem> createBottomItems() {
|
|
return <BottomNavigationBarItem>[
|
|
const BottomNavigationBarItem(
|
|
icon: Icon(
|
|
TDIcons.dashboard,
|
|
color: Colors.grey,
|
|
),
|
|
activeIcon: Icon(
|
|
TDIcons.dashboard,
|
|
color: Color.fromRGBO(0, 82, 217, 1),
|
|
),
|
|
label: "工作台",
|
|
),
|
|
const BottomNavigationBarItem(
|
|
icon: Icon(
|
|
TDIcons.desktop,
|
|
color: Colors.grey,
|
|
),
|
|
activeIcon: Icon(
|
|
TDIcons.desktop,
|
|
color: Color.fromRGBO(0, 82, 217, 1),
|
|
),
|
|
label: "商家中心",
|
|
),
|
|
];
|
|
}
|
|
|
|
/// 底部导航
|
|
Widget buildBottomNavigationBar() {
|
|
List<BottomNavigationBarItem> bottomItems = createBottomItems();
|
|
return GetBuilder<TabLogic>(builder: (_) {
|
|
return BottomNavigationBar(
|
|
items: bottomItems,
|
|
currentIndex: state.currentPage,
|
|
backgroundColor: Colors.white,
|
|
unselectedItemColor: Colors.grey,
|
|
selectedItemColor: const Color.fromRGBO(0, 82, 217, 1),
|
|
type: BottomNavigationBarType.fixed,
|
|
onTap: logic.handleNavBarTap,
|
|
selectedFontSize: 10.sp,
|
|
unselectedFontSize: 10.sp,
|
|
iconSize: 32.w,
|
|
);
|
|
});
|
|
}
|
|
|
|
return PopScope(
|
|
canPop: false,
|
|
onPopInvoked: (_) {
|
|
ToolFn().isExit();
|
|
},
|
|
child: Scaffold(
|
|
body: buildPageView(),
|
|
bottomNavigationBar: buildBottomNavigationBar(),
|
|
));
|
|
}
|
|
}
|