main_view.dart 2.2 KB

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