|
|
@@ -1,9 +1,13 @@
|
|
|
+import 'package:common_pub/common_pub.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
-import 'package:track_offical/view/home/app_bar.dart';
|
|
|
+import '../../generated/assets.dart';
|
|
|
+import '../../logger.dart';
|
|
|
+import 'app_bar.dart';
|
|
|
+import 'map/map_page.dart';
|
|
|
import 'home_controller.dart';
|
|
|
|
|
|
-class HomeView extends GetView<HomeController>{
|
|
|
+class HomeView extends GetView<HomeController> {
|
|
|
const HomeView({super.key});
|
|
|
|
|
|
static Bindings bindings() {
|
|
|
@@ -12,18 +16,79 @@ class HomeView extends GetView<HomeController>{
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return const Scaffold(
|
|
|
- appBar: HomeAppBar(),
|
|
|
- );
|
|
|
+ return DefaultTabController(
|
|
|
+ initialIndex: 0,
|
|
|
+ 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 SizedBox()),
|
|
|
+ _TabElem(title: '个人排名', child: const SizedBox()),
|
|
|
+ _TabElem(title: '分组排名', child: const SizedBox()),
|
|
|
+ _TabElem(title: '数据详情', child: const SizedBox()),
|
|
|
+];
|
|
|
|
|
|
+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);
|
|
|
+ }
|
|
|
|
|
|
+}
|