data_detail.dart 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. import 'package:application/view/home/data_detail/data_detail_bar_charts.dart';
  2. import 'package:application/view/home/data_detail/data_detail_cp.dart';
  3. import 'package:application/widget.dart';
  4. import 'package:common_pub/ui/history_detail/trace_bar.dart';
  5. import 'package:common_pub/ui/map_view/map_view.dart';
  6. import 'package:common_pub/ui/map_view/view_map_cp.dart';
  7. import 'package:common_pub/ui/map_view/view_map_image.dart';
  8. import 'package:common_pub/ui/map_view/view_map_touch.dart';
  9. import 'package:common_pub/ui/map_view/view_map_trace.dart';
  10. import 'package:common_pub/ui/map_view/view_plug_loading.dart';
  11. import 'data_detail_controller.dart';
  12. class DataDetailPage extends StatelessWidget {
  13. const DataDetailPage({super.key});
  14. @override
  15. Widget build(BuildContext context) {
  16. return GetBuilder(
  17. init: DataDetailController(),
  18. builder: (c) {
  19. return Container(
  20. height: double.infinity,
  21. width: double.infinity,
  22. color: const Color(0xffc9c0c0),
  23. alignment: Alignment.center,
  24. child: c.mapWatch != null
  25. ? content(context, c.mapWatch!, c)
  26. : noData());
  27. });
  28. }
  29. Widget noData() {
  30. return Center(
  31. child: Column(
  32. mainAxisSize: MainAxisSize.min,
  33. children: [
  34. Image.asset(Assets.imagesIcNoData, height: 64),
  35. const SizedBox(height: 25),
  36. const Text('没有数据, 请选择地图',
  37. style: TextStyle(color: Color(0xff707070), fontSize: 18.5)),
  38. ],
  39. ),
  40. );
  41. }
  42. static const cpColor = Color(0xffcc00ff);
  43. Widget content(
  44. BuildContext context, MapWatchService map, DataDetailController c) {
  45. return Obx(() {
  46. // final children = <Widget>[
  47. // ViewPlugLoading(map.plugMap),
  48. // ViewMapImage(map.plugMap),
  49. // ];
  50. // final data = c.selectedDetail.value;
  51. // if (data != null) {
  52. // children.add(ViewMapCP(
  53. // map.plugMap,
  54. // cpWantAndHistoryList: data.controlPoints,
  55. // isHideRouteBeforeStart: false,
  56. // isShowPath: false,
  57. // cpTheme: ViewMapCPTheme()
  58. // ..cpJumpColor = cpColor
  59. // ..cpPunchedColor = cpColor,
  60. // ));
  61. //
  62. // children.add(ViewMapTrace(map.plugMap, data.traceList,
  63. // controller: c.viewMapTraceController));
  64. // }
  65. //
  66. // children.add(ViewMapTouch(map.plugMap));
  67. return Row(children: [
  68. Expanded(
  69. child: Column(
  70. children: [
  71. Expanded(
  72. child: ViewMapStack(plug: map.plugMap,
  73. children: [ SizedBox.expand(child: _MapContent())])),
  74. _traceBarView(c)
  75. ],
  76. )),
  77. _UserListView()
  78. ]);
  79. });
  80. }
  81. Widget _traceBarView(DataDetailController c) {
  82. final detail = c.selectedDetail.value;
  83. final children = <Widget>[];
  84. if (detail != null) {
  85. final data =
  86. detail.traceList.map((e) => TraceBarData(e.pace)..ts = e.ts).toList();
  87. children.addAll([
  88. const SizedBox(height: 8),
  89. const Text('配速(按时间)'),
  90. TraceBar(
  91. data,
  92. controller: c.traceBarController,
  93. direction: Axis.horizontal,
  94. trackWidth: 10,
  95. paddingStart: 100,
  96. paddingEnd: 100,
  97. mask: true,
  98. isShowCp: true,
  99. cpList: detail.controlPoints,
  100. ),
  101. ]);
  102. }
  103. return Container(
  104. decoration: const BoxDecoration(color: Colors.white),
  105. height: 73,
  106. width: double.infinity,
  107. child: Column(children: children),
  108. );
  109. }
  110. }
  111. class _MapContent extends GetView<DataDetailController>{
  112. static const cpColor = Color(0xffcc00ff);
  113. @override
  114. Widget build(BuildContext context) {
  115. return Obx((){
  116. final map = controller.mapWatch!;
  117. final children = <Widget>[
  118. ViewPlugLoading(map.plugMap),
  119. ViewMapImage(map.plugMap),
  120. ];
  121. final data = controller.selectedDetail.value;
  122. if (data != null) {
  123. children.add(
  124. Container(
  125. color: Colors.white.withAlpha(120),
  126. ),
  127. );
  128. if(controller.selectedLoading.value){
  129. children.add(const Center(child: CircularProgressIndicator()));
  130. }else{
  131. children.add(ViewMapCP(
  132. key: UniqueKey(),
  133. map.plugMap,
  134. cpWantAndHistoryList: data.controlPoints,
  135. isHideRouteBeforeStart: false,
  136. isShowPath: false,
  137. cpTheme: ViewMapCPTheme()
  138. ..cpJumpColor = cpColor
  139. ..cpPunchedColor = cpColor,
  140. ));
  141. children.add(ViewMapTrace(
  142. key: UniqueKey(),
  143. map.plugMap, data.traceList,
  144. controller: controller.viewMapTraceController));
  145. }
  146. }
  147. children.add(ViewMapTouch(map.plugMap));
  148. return Stack(
  149. alignment: Alignment.topLeft,
  150. children: children);
  151. });
  152. }
  153. }
  154. class _UserListView extends GetView<DataDetailController> {
  155. @override
  156. Widget build(BuildContext context) {
  157. return Obx(() {
  158. return Container(
  159. width: 263,
  160. height: double.infinity,
  161. decoration: const BoxDecoration(color: Colors.white, boxShadow: [
  162. BoxShadow(color: Color(0x33000000), blurRadius: 4.3)
  163. ]),
  164. padding: const EdgeInsets.all(20),
  165. child: Column(
  166. children: [
  167. Row(
  168. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  169. children: [
  170. const Text('用户列表'),
  171. IconButton(
  172. onPressed: controller.selectedDetail.value != null
  173. ? () => controller.showDetail.value =
  174. !controller.showDetail.value
  175. : null,
  176. icon: const Icon(Icons.more_horiz)),
  177. ],
  178. ),
  179. Expanded(
  180. child: ListView(
  181. children: controller.showDetail.value
  182. ? _detailView()
  183. : controller.userList
  184. .map((element) => _userElem(element))
  185. .toList(),
  186. ))
  187. ],
  188. ));
  189. });
  190. }
  191. List<Widget> _detailView() {
  192. final detail = controller.selectedDetail.value!;
  193. return [
  194. DataDetailCP(cpList: detail.controlPoints),
  195. const SizedBox(height: 8),
  196. const DataDetailBarCharts(),
  197. ];
  198. }
  199. Widget _userElem(UserInfo data) {
  200. return Obx(() {
  201. final children = <Widget>[
  202. Container(
  203. width: double.infinity,
  204. height: 42,
  205. margin: const EdgeInsets.only(top: 8),
  206. padding: const EdgeInsets.only(left: 4),
  207. decoration: BoxDecoration(
  208. color: Colors.white,
  209. boxShadow: const [
  210. BoxShadow(color: Color(0x29000000), blurRadius: 3)
  211. ],
  212. borderRadius: BorderRadius.circular(3.56)),
  213. child: Row(
  214. children: [
  215. Container(
  216. height: double.infinity,
  217. width: 3.56,
  218. margin: const EdgeInsets.only(top: 8, bottom: 8, right: 3.55),
  219. decoration: BoxDecoration(
  220. color: data.data.oId == controller.selectedUserId.value
  221. ? Colors.orange
  222. : Colors.transparent,
  223. borderRadius: BorderRadius.circular(2.1)),
  224. ),
  225. Text(data.data.oName),
  226. const Spacer(),
  227. IconButton(
  228. onPressed: () {
  229. data.isExpand.value = !data.isExpand.value;
  230. },
  231. icon: Icon(data.isExpand.value
  232. ? Icons.arrow_drop_up
  233. : Icons.arrow_drop_down))
  234. ],
  235. ),
  236. )
  237. ];
  238. if (data.isExpand.value) {
  239. children.add(Column(
  240. children: data.data.list
  241. .map((element) => GestureDetector(
  242. onTap: () => controller.selectDetail(element, data),
  243. child: detailElem(element)))
  244. .toList(),
  245. ));
  246. }
  247. return Column(
  248. children: children,
  249. );
  250. });
  251. }
  252. Widget detailElem(DetailSimple detail) {
  253. return Container(
  254. margin: const EdgeInsets.only(left: 12, top: 2, bottom: 4),
  255. width: double.infinity,
  256. height: 58,
  257. padding: const EdgeInsets.fromLTRB(4, 6, 4, 6),
  258. decoration: BoxDecoration(
  259. color: Colors.white,
  260. borderRadius: BorderRadius.circular(3.5),
  261. boxShadow: const [
  262. BoxShadow(color: Color(0x33000000), blurRadius: 1.3)
  263. ]),
  264. child: Row(
  265. children: [
  266. Container(
  267. height: double.infinity,
  268. width: 3.56,
  269. margin: const EdgeInsets.only(right: 3.55),
  270. decoration: BoxDecoration(
  271. color: detail.gameId ==
  272. controller.selectedDetailSimple.value.gameId
  273. ? Colors.orange
  274. : Colors.transparent,
  275. borderRadius: BorderRadius.circular(2.1)),
  276. ),
  277. Expanded(
  278. child: Column(
  279. crossAxisAlignment: CrossAxisAlignment.start,
  280. children: [
  281. Text(detail.courseName,
  282. maxLines: 1, overflow: TextOverflow.ellipsis),
  283. Text(
  284. detail.actName,
  285. maxLines: 1,
  286. overflow: TextOverflow.ellipsis,
  287. ),
  288. ],
  289. )),
  290. const SizedBox(width: 12),
  291. Text(detail.isComplete ? '完赛' : '未完赛')
  292. ],
  293. ),
  294. );
  295. }
  296. }