main_view.dart 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import 'package:clean/module/calendar/calendar_view.dart';
  2. import 'package:clean/module/more/more_view.dart';
  3. import 'package:clean/utils/expand.dart';
  4. import 'package:convex_bottom_bar/convex_bottom_bar.dart';
  5. import 'package:flutter_screenutil/flutter_screenutil.dart';
  6. import '../../base/base_page.dart';
  7. import '../../resource/assets.gen.dart';
  8. import '../../router/app_pages.dart';
  9. import '../home/home_view.dart';
  10. import 'main_controller.dart';
  11. import 'package:flutter/Material.dart';
  12. import 'package:get/get.dart';
  13. class MainTabPage extends BasePage<MainController> {
  14. MainTabPage({super.key});
  15. final pages = [
  16. const CalendarPage(),
  17. const HomePage(),
  18. const MorePage(),
  19. ];
  20. static void start() {
  21. Get.offNamed(RoutePath.mainTab, arguments: {});
  22. }
  23. @override
  24. bool immersive() {
  25. return true;
  26. }
  27. @override
  28. bool statusBarDarkFont() {
  29. // TODO: implement statusBarDarkFont
  30. return false;
  31. }
  32. @override
  33. Widget buildBody(BuildContext context) {
  34. return PopScope(
  35. canPop: false,
  36. child: Scaffold(
  37. bottomNavigationBar: buildBottomAppBar(),
  38. drawerEdgeDragWidth: 0,
  39. body: Obx(() {
  40. return pages[controller.currentIndex];
  41. }),
  42. ),
  43. );
  44. }
  45. Widget buildBottomAppBar() {
  46. return StyleProvider(
  47. style: BottomTabBarStyle(),
  48. child: ConvexAppBar(
  49. height: 65.h,
  50. backgroundColor: "#0F0F16".color,
  51. activeColor: Colors.transparent,
  52. items: [
  53. TabItem(
  54. icon: Assets.images.iconTabCalendarUnselect.image(),
  55. activeIcon: Assets.images.iconTabCalendarSelected.image()),
  56. TabItem(
  57. icon: Assets.images.iconTabHomeUnselect.image(),
  58. activeIcon: Assets.images.iconTabHomeSelected.image()),
  59. TabItem(
  60. icon: Assets.images.iconTabMoreUnselect.image(),
  61. activeIcon: Assets.images.iconTabMoreSelected.image()),
  62. ],
  63. initialActiveIndex: controller.currentIndex,
  64. onTap: (int i) {
  65. if (controller.currentIndex != i) {
  66. controller.changeIndex(i);
  67. }
  68. },
  69. ),
  70. );
  71. }
  72. }
  73. // tabbar样式
  74. class BottomTabBarStyle extends StyleHook {
  75. @override
  76. double get activeIconSize => 52.w;
  77. @override
  78. double get activeIconMargin => 12.w;
  79. @override
  80. double get iconSize => 24.w;
  81. @override
  82. TextStyle textStyle(Color color, String? fontFamily) {
  83. // TODO: implement textStyle
  84. return TextStyle(fontSize: 20, color: color);
  85. }
  86. }