field_control.dart 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. import 'package:application/widget.dart';
  2. import 'package:common_pub/ui/map_view/map_view.dart';
  3. import 'package:common_pub/ui/map_view/view_map_image.dart';
  4. import 'package:common_pub/ui/map_view/view_map_touch.dart';
  5. import 'package:common_pub/ui/map_view/view_map_user_point.dart';
  6. import 'package:common_pub/ui/map_view/view_plug_loading.dart';
  7. import 'package:common_pub/utils.dart';
  8. import 'field_control_controller.dart';
  9. class FieldControlPage extends StatelessWidget {
  10. const FieldControlPage({super.key});
  11. @override
  12. Widget build(BuildContext context) {
  13. return GetBuilder(
  14. init: FieldControlController(),
  15. builder: (c) {
  16. return Container(
  17. height: double.infinity,
  18. width: double.infinity,
  19. color: const Color(0xffc9c0c0),
  20. alignment: Alignment.center,
  21. child: Obx(() {
  22. final mapWatch = c.mapWatch;
  23. return mapWatch != null
  24. ? content(context, mapWatch, c)
  25. : noData();
  26. }));
  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. Widget content(
  43. BuildContext context, MapWatchService map, FieldControlController c) {
  44. return Row(
  45. children: [
  46. Expanded(
  47. child: Column(
  48. children: [
  49. Expanded(
  50. child: ViewMapStack(plug: map.plugMap, children: [
  51. ViewPlugLoading(map.plugMap),
  52. ViewMapImage(map.plugMap),
  53. _ViewTrace(map: map),
  54. ViewMapTouch(map.plugMap)
  55. ])),
  56. _MsgView(),
  57. ],
  58. )),
  59. _ActiveInfoView()
  60. ],
  61. );
  62. }
  63. }
  64. class _ViewTrace extends GetView<FieldControlController> {
  65. const _ViewTrace({required this.map});
  66. final MapWatchService map;
  67. @override
  68. Widget build(BuildContext context) {
  69. return Obx(() {
  70. final children = <Widget>[];
  71. for (final act in map.activeList) {
  72. for (final user in act.userList) {
  73. if (user.isHide.value) {
  74. continue;
  75. }
  76. final trace = user.trace.lastOrNull;
  77. if (trace != null) {
  78. children.add(ViewMapUserPoint(map.plugMap, trace,
  79. info: user.name, color: user.flag.value.color));
  80. }
  81. }
  82. }
  83. return Stack(alignment: Alignment.topLeft, children: children);
  84. });
  85. }
  86. }
  87. class _ActiveInfoView extends GetView<FieldControlController> {
  88. @override
  89. Widget build(BuildContext context) {
  90. return Obx(() => Container(
  91. width: 370,
  92. height: double.infinity,
  93. color: Colors.white,
  94. child: ListView(
  95. children: controller.activeList
  96. .map((element) => activeView(element))
  97. .toList(),
  98. ),
  99. ));
  100. }
  101. Widget activeView(ActiveInfo info) {
  102. final children = <Widget>[
  103. Row(children: [
  104. Text('${info.name} (${info.userList.length}人)'),
  105. const Spacer(),
  106. IconButton(
  107. onPressed: () {
  108. info.isHide.value = !info.isHide.value;
  109. },
  110. icon: info.isHide.value
  111. ? const Icon(Icons.arrow_drop_down)
  112. : const Icon(Icons.arrow_drop_up))
  113. ]),
  114. ];
  115. if (!info.isHide.value) {
  116. children.addAll([
  117. Container(
  118. decoration: BoxDecoration(
  119. color: Colors.white, borderRadius: BorderRadius.circular(5)),
  120. padding: const EdgeInsets.fromLTRB(26, 11, 26, 11),
  121. child: Row(
  122. children: [
  123. Text('广播'),
  124. const Spacer(),
  125. Image.asset(Assets.imagesIcCp, height: 20, width: 20),
  126. Text(' ${info.cpAllCount}'),
  127. const Spacer(),
  128. Text('全部隐藏'),
  129. ],
  130. ),
  131. )
  132. ]);
  133. children
  134. .addAll(info.userList.map((e) => _UserInfoView(data: e)).toList());
  135. }
  136. return Container(
  137. decoration: BoxDecoration(
  138. color: const Color(0xffe0e0e0),
  139. borderRadius: BorderRadius.circular(5)),
  140. margin: const EdgeInsets.fromLTRB(9, 12, 9, 12),
  141. padding: const EdgeInsets.all(9),
  142. child: Column(
  143. children: children,
  144. ),
  145. );
  146. }
  147. }
  148. class _UserInfoView extends GetView<FieldControlController> {
  149. const _UserInfoView({required this.data});
  150. final UserInfo data;
  151. @override
  152. Widget build(BuildContext context) {
  153. return Container(
  154. decoration: BoxDecoration(
  155. color: Colors.white, borderRadius: BorderRadius.circular(5)),
  156. padding: const EdgeInsets.fromLTRB(7, 11, 7, 11),
  157. margin: const EdgeInsets.only(top: 5),
  158. child: Row(
  159. crossAxisAlignment: CrossAxisAlignment.start,
  160. children: [
  161. Obx(() => Container(
  162. margin: const EdgeInsets.only(top: 2),
  163. decoration: BoxDecoration(
  164. color: data.flag.value.color,
  165. borderRadius: BorderRadius.circular(4)),
  166. width: 7,
  167. height: 16)),
  168. const SizedBox(
  169. width: 8,
  170. ),
  171. Expanded(
  172. child: Column(
  173. crossAxisAlignment: CrossAxisAlignment.start,
  174. children: [
  175. Text.rich(TextSpan(
  176. text: data.name,
  177. children: [TextSpan(text: ' [${data.routeName}]')])),
  178. const SizedBox(height: 5),
  179. Row(
  180. children: [
  181. container(null, cpInfo, Colors.blue),
  182. container(
  183. const Icon(
  184. Icons.favorite,
  185. size: 13,
  186. color: Colors.white,
  187. ),
  188. ' ${hr == 0 ? '--' : hr}',
  189. (data.gameInfo.hrInfo.hrInfo.lastOrNull?.hrPer ?? 0)
  190. .toHRPColor()),
  191. container(null, paceInfo, data.pace.color)
  192. ],
  193. ),
  194. const SizedBox(height: 5),
  195. Row(
  196. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  197. children: [
  198. Text('距离 ${data.nextDistance.toString()}'),
  199. Text('时间 ${data.duration.toAppString()}'),
  200. Text('里程 ${data.distance.toString()}'),
  201. ],
  202. )
  203. ],
  204. )),
  205. GestureDetector(
  206. onTap: () {
  207. data.isHide.value = !data.isHide.value;
  208. },
  209. child: Obx(() => Icon(
  210. data.isHide.value ? Icons.visibility_off : Icons.visibility,
  211. color:
  212. data.isHide.value ? Colors.grey : const Color(0xffffbb77),
  213. )),
  214. )
  215. ],
  216. ),
  217. );
  218. }
  219. int get hr {
  220. return data.gameInfo.hrInfo.hrInfo.lastOrNull?.hr ?? 0;
  221. }
  222. String get cpInfo {
  223. final next = data.nextWant;
  224. return '${data.gameInfo.gameSaveInfo.nextControlPoint.orderNo}号点(${next?.sn})';
  225. }
  226. String get paceInfo {
  227. Duration;
  228. return data.pace.toString();
  229. }
  230. Widget container(Widget? icon, String text, Color color) {
  231. final children = <Widget>[];
  232. if (icon != null) {
  233. children.add(icon);
  234. }
  235. children.add(
  236. Text(text, style: const TextStyle(color: Colors.white, fontSize: 14)));
  237. return Container(
  238. height: 18,
  239. padding: const EdgeInsets.fromLTRB(10, 0, 12, 0),
  240. margin: const EdgeInsets.only(right: 6),
  241. alignment: Alignment.center,
  242. decoration:
  243. BoxDecoration(color: color, borderRadius: BorderRadius.circular(9)),
  244. child: Row(
  245. children: children,
  246. ),
  247. );
  248. }
  249. }
  250. class _MsgView extends GetView<FieldControlController> {
  251. @override
  252. Widget build(BuildContext context) {
  253. return Container();
  254. }
  255. }