完善工作台

This commit is contained in:
2023-12-24 02:10:55 +08:00
parent d444a4c838
commit 55085ee563
11 changed files with 684 additions and 113 deletions

View File

@@ -1,8 +1,10 @@
import 'package:flutter/cupertino.dart';
class TabState {
late int currentPage;
PageController? pageController;
late int currentPage;
TabState() {
///Initialize variables
currentPage = 0;

View File

@@ -17,17 +17,15 @@ class TabPage extends StatelessWidget {
/// 内容页
Widget buildPageView() {
return GetBuilder<TabLogic>(builder: (_) {
return PageView(
physics: const NeverScrollableScrollPhysics(),
controller: state.pageController,
onPageChanged: logic.handlePageChanged,
children: const <Widget>[
HomePage(),
UserPage(),
],
);
});
return PageView(
physics: const NeverScrollableScrollPhysics(),
controller: state.pageController,
onPageChanged: logic.handlePageChanged,
children: const <Widget>[
HomePage(),
UserPage(),
],
);
}
List<BottomNavigationBarItem> createBottomItems() {
@@ -60,30 +58,30 @@ class TabPage extends StatelessWidget {
/// 底部导航
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 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(),
));
return GetBuilder<TabLogic>(builder: (_) {
return PopScope(
canPop: false,
onPopInvoked: (_) {
ToolFn().isExit();
},
child: Scaffold(
body: buildPageView(),
bottomNavigationBar: buildBottomNavigationBar(),
));
});
}
}