| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import 'package:application/view/home/user_manage/user_manage_page.dart';
- import 'data_detail/data_detail.dart';
- import 'app_bar.dart';
- import 'map/map_page.dart';
- import 'home_controller.dart';
- import 'package:application/widget.dart';
- class HomeView extends GetView<HomeController> {
- const HomeView({super.key});
- static Bindings bindings() {
- return BindingsBuilder(() {
- Get.lazyPut<HomeController>(() => HomeController());
- });
- }
- @override
- Widget build(BuildContext context) {
- return DefaultTabController(
- initialIndex: 1,
- length: _tabElems.length,
- child: Scaffold(
- appBar: HomeAppBar(
- tab:
- TabBar(
- tabs: _tabElems.map((e) => Tab(text: e.title)).toList(),
- labelColor: Colors.white,
- unselectedLabelColor: Colors.white,
- indicatorSize: TabBarIndicatorSize.tab,
- indicatorPadding: const EdgeInsets.only(bottom: 0),
- indicator: CustomTabIndicator(),
- dividerColor: Colors.transparent
- ),
- ),
- body: Container(
- decoration: const BoxDecoration(image: DecorationImage(image: AssetImage(Assets.imagesBkCommonPage), fit: BoxFit.fill)),
- child: TabBarView(
- physics: const NeverScrollableScrollPhysics(),
- children: _tabElems.map((e) => e.child).toList(),
- )
- ) ,
- ));
- }
- }
- final _tabElems = [
- _TabElem(title: '设置', child: const SizedBox()),
- _TabElem(title: '地图', child: const MapPage()),
- _TabElem(title: '用户管理', child: const UserManagePage()),
- _TabElem(title: '个人排名', child: const SizedBox()),
- _TabElem(title: '分组排名', child: const SizedBox()),
- _TabElem(title: '数据详情', child: const DataDetailPage()),
- ];
- class _TabElem {
- _TabElem({required this.title, required this.child});
- final String title;
- final Widget child;
- }
- class CustomTabIndicator extends Decoration {
- @override
- BoxPainter createBoxPainter([VoidCallback? onChanged]) {
- return _CustomPainter(this, onChanged!);
- }
- }
- class _CustomPainter extends BoxPainter {
- final CustomTabIndicator decoration;
- _CustomPainter(this.decoration, VoidCallback onChanged)
- : super(onChanged);
- @override
- void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
- final size = configuration.size;
- assert(size != null);
- final Paint paint = Paint();
- paint.color = const Color(0xff003656);
- paint.style = PaintingStyle.fill;
- final path = Path();
- final rect = offset & size!;
- path.moveTo(rect.center.dx - 12 , rect.bottom);
- path .lineTo(rect.center.dx + 12, rect.bottom);
- path.lineTo(rect.center.dx, rect.height - 12);
- path.close();
- canvas.drawPath(path, paint);
- }
- }
|