home_view.dart 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import 'package:track_common/widget/prelude.dart';
  2. import 'app_bar.dart';
  3. import 'home_controller.dart';
  4. class HomeView extends GetView<HomeController> {
  5. const HomeView({super.key});
  6. static const name = '/HomeView';
  7. @override
  8. Widget build(BuildContext context) {
  9. return Scaffold(
  10. appBar: HomeAppBar(
  11. tab: TabBar(
  12. controller: controller.tabController,
  13. tabs: controller.tabs.map((e) => Tab(text: e.title)).toList(),
  14. labelColor: Colors.white,
  15. unselectedLabelColor: Colors.white,
  16. indicatorSize: TabBarIndicatorSize.tab,
  17. indicatorPadding: const EdgeInsets.only(bottom: 0),
  18. indicator: CustomTabIndicator(),
  19. dividerColor: Colors.transparent),
  20. ),
  21. body: Container(
  22. decoration: const BoxDecoration(
  23. image: DecorationImage(
  24. image:
  25. AssetImage(Assets.imagesBkCommonPage, package: package),
  26. fit: BoxFit.fill)),
  27. child: TabBarView(
  28. controller: controller.tabController,
  29. physics: const NeverScrollableScrollPhysics(),
  30. children: controller.tabs.map((e) => e.builder()).toList(),
  31. )),
  32. );
  33. }
  34. }
  35. // final _tabElems = [
  36. // _TabElem(title: '设置', child: const SizedBox()),
  37. // _TabElem(title: '地图', child: const MapPage()),
  38. // _TabElem(title: '场控', child: const FieldControlPage()),
  39. // _TabElem(title: '用户管理', child: const UserManagePage()),
  40. // _TabElem(title: '个人排名', child: PersonalRankPage()),
  41. // _TabElem(title: '分组排名', child: const SizedBox()),
  42. // _TabElem(title: '数据详情', child: const DataDetailPage()),
  43. // ];
  44. class CustomTabIndicator extends Decoration {
  45. @override
  46. BoxPainter createBoxPainter([VoidCallback? onChanged]) {
  47. return _CustomPainter(this, onChanged!);
  48. }
  49. }
  50. class _CustomPainter extends BoxPainter {
  51. final CustomTabIndicator decoration;
  52. _CustomPainter(this.decoration, VoidCallback onChanged) : super(onChanged);
  53. @override
  54. void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
  55. final size = configuration.size;
  56. assert(size != null);
  57. final Paint paint = Paint();
  58. paint.color = const Color(0xff003656);
  59. paint.style = PaintingStyle.fill;
  60. final path = Path();
  61. final rect = offset & size!;
  62. path.moveTo(rect.center.dx - 12, rect.bottom);
  63. path.lineTo(rect.center.dx + 12, rect.bottom);
  64. path.lineTo(rect.center.dx, rect.height - 12);
  65. path.close();
  66. canvas.drawPath(path, paint);
  67. }
  68. }