76 lines
2.1 KiB
Dart
76 lines
2.1 KiB
Dart
import 'dart:io';
|
|
import 'dart:ui';
|
|
|
|
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 PageView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
controller: state.pageController,
|
|
onPageChanged: logic.handlePageChanged,
|
|
children: const <Widget>[
|
|
HomePage(),
|
|
UserPage(),
|
|
],
|
|
);
|
|
}
|
|
|
|
List<NavigationDestination> createBottomItems() {
|
|
return <NavigationDestination>[
|
|
const NavigationDestination(
|
|
selectedIcon: Icon(TDIcons.dashboard, color: Colors.white),
|
|
icon: Icon(TDIcons.dashboard),
|
|
label: '工作台',
|
|
),
|
|
const NavigationDestination(
|
|
selectedIcon: Icon(TDIcons.desktop, color: Colors.white),
|
|
icon: Icon(TDIcons.desktop),
|
|
label: '商家中心',
|
|
),
|
|
];
|
|
}
|
|
|
|
/// 底部导航
|
|
Widget buildBottomNavigationBar() {
|
|
List<NavigationDestination> bottomItems = createBottomItems();
|
|
return NavigationBar(
|
|
backgroundColor: Colors.white,
|
|
shadowColor: Colors.black,
|
|
surfaceTintColor: Colors.white,
|
|
indicatorColor: Colors.blueAccent,
|
|
onDestinationSelected: logic.handleNavBarTap,
|
|
selectedIndex: state.currentPage,
|
|
destinations: bottomItems,
|
|
);
|
|
}
|
|
|
|
return GetBuilder<TabLogic>(builder: (_) {
|
|
return PopScope(
|
|
canPop: false,
|
|
onPopInvoked: (_) {
|
|
ToolFn().isExit();
|
|
},
|
|
child: Scaffold(
|
|
body: buildPageView(),
|
|
bottomNavigationBar: buildBottomNavigationBar(),
|
|
));
|
|
});
|
|
}
|
|
}
|