main_view.dart 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. Widget buildBody(BuildContext context) {
  23. return PopScope(
  24. canPop: false,
  25. child: Scaffold(
  26. bottomNavigationBar: buildBottomAppBar(),
  27. drawerEdgeDragWidth: 0,
  28. body: Obx(() {
  29. return pages[controller.currentIndex];
  30. }),
  31. ),
  32. );
  33. }
  34. Widget buildBottomAppBar() {
  35. return Container(
  36. // height: 100.h,
  37. // decoration: BoxDecoration(
  38. // color: "#0F0F16".color,
  39. // boxShadow: [
  40. // BoxShadow(
  41. // color: Colors.black.withOpacity(0.1),
  42. // spreadRadius: 1,
  43. // blurRadius: 10,
  44. // offset: const Offset(0, 0),
  45. // ),
  46. // ],
  47. // borderRadius: BorderRadius.only(
  48. // topLeft: Radius.circular(20.r),
  49. // topRight: Radius.circular(20.r),
  50. // ),
  51. // ),
  52. child: ConvexAppBar(
  53. height: 80.h,
  54. items: [
  55. TabItem(icon: Assets.images.iconTabHomeUnselect.image(width: 24.w, height: 24.w), activeIcon: Assets.images.iconTabHomeSelected.image(width: 66.w, height: 66.w)),
  56. TabItem(icon: Assets.images.iconTabMoreUnselect.image(width: 24.w, height: 24.w), activeIcon: Assets.images.iconTabMoreSelected.image(width: 66.w, height: 66.w)),
  57. ],
  58. onTap: (int i) {
  59. if (controller.currentIndex != i) {
  60. controller.changeIndex(i);
  61. }
  62. },
  63. )
  64. // BottomAppBar(
  65. // color: Colors.transparent,
  66. // height: 100.h,
  67. // padding: EdgeInsets.zero,
  68. // shape: CircularNotchedRectangle(),
  69. // child: Flex(
  70. // direction: Axis.horizontal,
  71. // mainAxisAlignment: MainAxisAlignment.spaceAround,
  72. // children: [
  73. // Expanded(flex: 1, child: bottomAppBarItem(0)),
  74. // const Expanded(flex: 1, child: SizedBox()),
  75. // Expanded(flex: 1, child: bottomAppBarItem(1))
  76. // ],
  77. // ),
  78. // ),
  79. );
  80. }
  81. Widget bottomAppBarItem(int index) {
  82. return Obx(() {
  83. TabBean tabBean = controller.tabBeans[index];
  84. String imagePath = controller.currentIndex == index
  85. ? tabBean.selectedIcon
  86. : tabBean.normalIcon;
  87. return GestureDetector(
  88. behavior: HitTestBehavior.opaque,
  89. onTap: () {
  90. if (controller.currentIndex != index) {
  91. controller.changeIndex(index);
  92. }
  93. },
  94. child: Container(
  95. child: SizedBox(
  96. height: 100.h,
  97. child: Column(
  98. mainAxisAlignment: MainAxisAlignment.center,
  99. children: [
  100. controller.currentIndex == index
  101. ? Image.asset(
  102. imagePath,
  103. width: 66.w,
  104. height: 66.w,
  105. )
  106. : Image.asset(
  107. imagePath,
  108. width: 24.w,
  109. height: 24.w,
  110. ),
  111. ],
  112. ),
  113. ),
  114. ),
  115. );
  116. });
  117. }
  118. }