main_view.dart 2.3 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. Widget buildBody(BuildContext context) {
  27. return PopScope(
  28. canPop: false,
  29. child: Scaffold(
  30. bottomNavigationBar: buildBottomAppBar(),
  31. drawerEdgeDragWidth: 0,
  32. body: Obx(() {
  33. return pages[controller.currentIndex];
  34. }),
  35. ),
  36. );
  37. }
  38. Widget buildBottomAppBar() {
  39. return StyleProvider(
  40. style: BottomTabBarStyle(),
  41. child: Container(
  42. decoration: BoxDecoration(
  43. borderRadius: BorderRadius.all(Radius.circular(12))
  44. ),
  45. child: ConvexAppBar(
  46. height: 65.h,
  47. backgroundColor: "#0F0F16".color,
  48. activeColor: Colors.transparent,
  49. items: [
  50. TabItem(
  51. icon: Assets.images.iconTabHomeUnselect.image(),
  52. activeIcon: Assets.images.iconTabHomeSelected.image()),
  53. TabItem(
  54. icon: Assets.images.iconTabMoreUnselect.image(),
  55. activeIcon: Assets.images.iconTabMoreSelected.image()),
  56. ],
  57. onTap: (int i) {
  58. if (controller.currentIndex != i) {
  59. controller.changeIndex(i);
  60. }
  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. }