activity_view.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:trackoffical_app/utils.dart';
  4. import 'package:trackoffical_app/view/mapto/map_to_controller.dart';
  5. import '../../generated/app_api.pb.dart';
  6. import '../../generated/assets.dart';
  7. import '../../screen.dart';
  8. import 'package:trackoffical_app/pb.dart' as pb;
  9. import '../../widget/common.dart';
  10. class ActivityView extends GetView<MapToController> {
  11. const ActivityView({super.key});
  12. // const ActivityView(this.mapActivitySimpleInfo, this.userInfo, {super.key});
  13. // final MapToController mapToController = Get.find();
  14. // final List<pb.MapActivitySimpleInfo> mapActivitySimpleInfo;
  15. // final List<ModelUserInfo> userInfo;
  16. static Bindings bindings() {
  17. return BindingsBuilder(() {
  18. Get.lazyPut<MapToController>(() => MapToController());
  19. });
  20. }
  21. @override
  22. Widget build(BuildContext context) {
  23. return Container(
  24. width: 25.69.wp,
  25. height: context.height,
  26. padding: EdgeInsets.symmetric(horizontal: 1.wp, vertical: 1.wp),
  27. decoration: BoxDecoration(
  28. color: Colors.white,
  29. // borderRadius: BorderRadius.circular(8),
  30. // shape: BoxShape.rectangle,
  31. boxShadow: [
  32. BoxShadow(
  33. color: const Color(0x33000000),
  34. offset: Offset(-0.28.wp, 0.21.wp),
  35. blurRadius: 0.42.wp)
  36. ],
  37. ),
  38. child: Column(
  39. mainAxisAlignment: MainAxisAlignment.start,
  40. children: [_wActivitys()],
  41. ),
  42. );
  43. }
  44. Widget _wActivitys() {
  45. // var mapActivitySimpleInfo = mapToController.mapActivitySimpleInfo;
  46. return Obx(() {
  47. return Expanded(
  48. child: ListView.builder(
  49. padding: EdgeInsets.only(top: 0.wp),
  50. // itemCount: mapActivitySimpleInfo.length,
  51. itemCount: controller.mapActivityList.value.list.length,
  52. itemBuilder: (ctx, i) {
  53. return _wActivityElem(ctx, i);
  54. }));
  55. });
  56. }
  57. Widget _wActivityElem(BuildContext ctx, int i) {
  58. // var info = mapActivitySimpleInfo[i].obs;
  59. var info = controller.mapActivityList.value.list[i];
  60. var expand = true.obs;
  61. return Obx(() {
  62. return GestureDetector(
  63. // onTap: info.isOpen? ()=>ActivityDetailView.to(info): null,
  64. child: Container(
  65. margin:
  66. EdgeInsets.only(left: 0.wp, right: 0.wp, top: 0.wp, bottom: 1.wp),
  67. // padding: EdgeInsets.only(left: 0.8.wp, right: 0.8.wp, top: 0.8.wp, bottom: 0.8.wp),
  68. padding: EdgeInsets.all(0.8.wp),
  69. decoration: BoxDecoration(
  70. color: const Color(0xffe0e0e0),
  71. borderRadius: BorderRadius.circular(0.35.wp),
  72. ),
  73. child: Column(
  74. children: [
  75. _activityTitle(info, expand),
  76. expand.value ? _activityControl(info) : Container(),
  77. expand.value ? _wUserList() : Container(),
  78. ],
  79. ),
  80. ));
  81. });
  82. }
  83. Widget _activityTitle(MapActivitySimpleInfo info, var expand) {
  84. return Container(
  85. child: GestureDetector(
  86. onTap: () {
  87. // debugPrint("expand.value = ${expand.value}");
  88. expand.value = !(expand.value);
  89. },
  90. child: Row(
  91. mainAxisAlignment: MainAxisAlignment.start,
  92. crossAxisAlignment: CrossAxisAlignment.center,
  93. children: [
  94. SizedBox(
  95. width: 16.8.wp,
  96. child: Text(info.name,
  97. softWrap: false,
  98. maxLines: 1,
  99. overflow: TextOverflow.ellipsis,
  100. style: TextStyle(
  101. fontSize: 1.29.wp,
  102. fontWeight: FontWeight.w700,
  103. color: const Color(0xff333333))),
  104. ),
  105. SizedBox(width: 0.3.wp),
  106. Text("(${info.totalControlNum}人)",
  107. style: TextStyle(
  108. fontSize: 1.11.wp,
  109. fontWeight: FontWeight.w500,
  110. color: const Color(0xff333333))),
  111. SizedBox(width: 0.6.wp),
  112. Image.asset(
  113. expand.value ? Assets.imagesIcArrowUp : Assets.imagesIcArrowDown,
  114. height: 0.86.wp,
  115. fit: BoxFit.fitHeight,
  116. ),
  117. ],
  118. ),
  119. ),
  120. );
  121. }
  122. Widget _activityControl(MapActivitySimpleInfo info) {
  123. return Container(
  124. margin: EdgeInsets.only(top: 0.6.wp),
  125. padding: EdgeInsets.symmetric(vertical: 0.5.wp, horizontal: 1.wp),
  126. decoration: BoxDecoration(
  127. color: Colors.white,
  128. borderRadius: BorderRadius.circular(0.42.wp),
  129. ),
  130. child: Row(
  131. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  132. children: [
  133. Row(
  134. children: [
  135. Text("广播",
  136. style: TextStyle(
  137. fontSize: 1.11.wp,
  138. fontWeight: FontWeight.w500,
  139. color: Colors.black)),
  140. SizedBox(width: 0.5.wp),
  141. Image.asset(
  142. Assets.imagesIcBullhorn,
  143. height: 1.13.wp,
  144. fit: BoxFit.fitHeight,
  145. ),
  146. ],
  147. ),
  148. Row(
  149. children: [
  150. Image.asset(
  151. Assets.imagesIcCp,
  152. height: 1.35.wp,
  153. fit: BoxFit.fitHeight,
  154. ),
  155. SizedBox(width: 0.3.wp),
  156. Text("${info.totalControlNum}"),
  157. ],
  158. ),
  159. Row(
  160. children: [
  161. Text("全部隐藏",
  162. style: TextStyle(
  163. fontSize: 1.11.wp,
  164. fontWeight: FontWeight.w500,
  165. color: Colors.black)),
  166. SizedBox(width: 0.5.wp),
  167. Image.asset(
  168. Assets.imagesIcEye,
  169. height: 1.1.wp,
  170. fit: BoxFit.fitHeight,
  171. ),
  172. ],
  173. ),
  174. ],
  175. ));
  176. }
  177. Widget _wUserList() {
  178. final children = <Widget>[];
  179. return Obx(() {
  180. for (var i = 0; i < controller.userInfoList.length; i++) {
  181. final userInfo = controller.userInfoList[i];
  182. children.add(Container(
  183. height: 6.25.wp,
  184. margin: EdgeInsets.only(top: 0.5.wp),
  185. padding: EdgeInsets.symmetric(vertical: 0.5.wp, horizontal: 0.5.wp),
  186. decoration: BoxDecoration(
  187. color: Colors.white,
  188. borderRadius: BorderRadius.circular(0.42.wp),
  189. ),
  190. child: Column(
  191. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  192. children: [
  193. _wUserInfoRow1(userInfo),
  194. _wUserInfoRow2(userInfo),
  195. _wUserInfoRow3(userInfo),
  196. ],
  197. )));
  198. }
  199. return Column(
  200. children: children,
  201. );
  202. });
  203. }
  204. Widget _wUserInfoRow1(ModelUserInfo userInfo) {
  205. return Row(
  206. mainAxisAlignment: MainAxisAlignment.start,
  207. crossAxisAlignment: CrossAxisAlignment.center,
  208. children: [
  209. wUserMark(userInfo.iUserid!),
  210. SizedBox(width: 0.5.wp),
  211. Text(userInfo.sUserName!,
  212. style: TextStyle(
  213. fontSize: 1.25.wp,
  214. fontWeight: FontWeight.w500,
  215. color: Colors.black)),
  216. SizedBox(width: 0.5.wp),
  217. Text("[${userInfo.sRouteCode}]",
  218. style: TextStyle(
  219. fontSize: 0.97.wp,
  220. fontWeight: FontWeight.w400,
  221. color: Colors.black)),
  222. const Spacer(),
  223. Image.asset(
  224. true ? Assets.imagesIcEye : Assets.imagesIcEyeOff,
  225. height: 1.1.wp,
  226. fit: BoxFit.fitHeight,
  227. ),
  228. SizedBox(width: 0.5.wp),
  229. ],
  230. );
  231. }
  232. Widget _wUserInfoRow2(ModelUserInfo userInfo) {
  233. return Row(
  234. mainAxisAlignment: MainAxisAlignment.spaceAround,
  235. crossAxisAlignment: CrossAxisAlignment.center,
  236. children: [
  237. //待打点位
  238. Container(
  239. width: 7.81.wp,
  240. padding: EdgeInsets.symmetric(vertical: 0.wp, horizontal: 0.6.wp),
  241. decoration: BoxDecoration(
  242. color: const Color(0xff00a0ff),
  243. borderRadius: BorderRadius.circular(0.63.wp)),
  244. child: Text("${userInfo.iNextCPId}号点 (${userInfo.sNextCPCode})",
  245. textAlign: TextAlign.center,
  246. softWrap: false,
  247. maxLines: 1,
  248. overflow: TextOverflow.ellipsis,
  249. style: TextStyle(
  250. fontSize: 0.97.wp,
  251. fontWeight: FontWeight.w400,
  252. color: Colors.white)),
  253. ),
  254. // 心率
  255. Container(
  256. width: 4.67.wp,
  257. padding: EdgeInsets.symmetric(vertical: 0.wp, horizontal: 0.9.wp),
  258. decoration: BoxDecoration(
  259. color: userInfo.iHr!.toHRPColor(),
  260. borderRadius: BorderRadius.circular(0.63.wp)),
  261. child: Row(
  262. mainAxisAlignment: MainAxisAlignment.spaceAround,
  263. children: [
  264. Image.asset(Assets.imagesIcHeart,
  265. height: 0.82.wp, fit: BoxFit.fitHeight),
  266. // SizedBox(width: 0.5.wp),
  267. Text("${userInfo.iHr}",
  268. style: TextStyle(
  269. fontSize: 0.97.wp,
  270. fontWeight: FontWeight.w400,
  271. color: Colors.white)),
  272. ],
  273. )),
  274. //配速
  275. Container(
  276. width: 6.39.wp,
  277. padding: EdgeInsets.symmetric(vertical: 0.wp, horizontal: 0.6.wp),
  278. decoration: BoxDecoration(
  279. color: const Color(0xffff880f),
  280. borderRadius: BorderRadius.circular(0.63.wp)),
  281. child: Text("${userInfo.pacePerKm?.toMinSecondString()}/km",
  282. textAlign: TextAlign.center,
  283. softWrap: false,
  284. maxLines: 1,
  285. overflow: TextOverflow.ellipsis,
  286. style: TextStyle(
  287. fontSize: 0.97.wp,
  288. fontWeight: FontWeight.w400,
  289. color: Colors.white)),
  290. ),
  291. ],
  292. );
  293. }
  294. Widget _wUserInfoRow3(ModelUserInfo userInfo) {
  295. return Row(
  296. mainAxisAlignment: MainAxisAlignment.spaceAround,
  297. crossAxisAlignment: CrossAxisAlignment.center,
  298. children: [
  299. Text("距离 ${userInfo.iDistance!}m",
  300. style: TextStyle(
  301. fontSize: 0.97.wp,
  302. fontWeight: FontWeight.w400,
  303. color: Colors.black)),
  304. SizedBox(width: 0.5.wp),
  305. Text("时间 ${userInfo.iTime}",
  306. style: TextStyle(
  307. fontSize: 0.97.wp,
  308. fontWeight: FontWeight.w400,
  309. color: Colors.black)),
  310. SizedBox(width: 0.5.wp),
  311. Text("里程 ${userInfo.iMileage} km",
  312. style: TextStyle(
  313. fontSize: 0.97.wp,
  314. fontWeight: FontWeight.w400,
  315. color: Colors.black)),
  316. ],
  317. );
  318. }
  319. }