user_rank_view.dart.bk 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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 '../../service/mock.dart';
  6. import '../../widget/page_frame.dart';
  7. import 'user_rank_controller.dart';
  8. import '../../generated/app_api.pb.dart';
  9. import '../../generated/assets.dart';
  10. import '../../screen.dart';
  11. import 'package:trackoffical_app/pb.dart' as pb;
  12. import '../../widget/common.dart';
  13. class UserRankView extends GetView<UserRankController> {
  14. const UserRankView({super.key});
  15. static Bindings bindings() {
  16. return BindingsBuilder(() {
  17. Get.lazyPut<UserRankController>(() => UserRankController());
  18. });
  19. }
  20. @override
  21. Widget build(BuildContext context) {
  22. // final PageTopController c = Get.find();
  23. return PageFrame(child: _wBody(context));
  24. }
  25. Widget _wBody(BuildContext context) {
  26. return Container(
  27. // width: 97.01.wp,
  28. // margin: EdgeInsets.symmetric(vertical: 1.5.wp, horizontal: 1.5.wp),
  29. padding: EdgeInsets.symmetric(vertical: 1.5.wp, horizontal: 1.5.wp),
  30. decoration: const BoxDecoration(
  31. image: DecorationImage(
  32. alignment: Alignment.bottomCenter,
  33. image: AssetImage(Assets.commonPageBgDark),
  34. fit: BoxFit.cover)),
  35. child: Row(
  36. mainAxisAlignment: MainAxisAlignment.start,
  37. children: [
  38. Expanded(
  39. flex: 3,
  40. child: _wLeft(),
  41. ),
  42. // Container(
  43. // color: const Color(0xffd8d8d8),
  44. // width: 1,
  45. // ),
  46. Expanded(
  47. flex: 7,
  48. child: _wRight(),
  49. ),
  50. ],
  51. ),
  52. );
  53. }
  54. Widget _wLeft() {
  55. return Container(
  56. margin: EdgeInsets.only(right: 0.8.wp),
  57. child: Column(
  58. children: [
  59. _wLeftTitle(),
  60. SizedBox(height: 1.5.wp),
  61. _wLeftActivitys(),
  62. ],
  63. ),
  64. );
  65. }
  66. Widget _wLeftTitle() {
  67. return Obx(() {
  68. int count = controller.mapActivityList.value.list.length;
  69. return Row(
  70. children: [
  71. SizedBox(width: 0.5.wp),
  72. const Icon(
  73. Icons.circle,
  74. size: 16,
  75. color: Color(0xff98d8ff),
  76. ),
  77. const SizedBox(width: 6),
  78. Text(
  79. "活动列表 (${count})",
  80. style: TextStyle(
  81. color: Colors.white,
  82. fontSize: 1.39.wp,
  83. fontWeight: FontWeight.w700,
  84. ),
  85. textAlign: TextAlign.start,
  86. maxLines: 1,
  87. overflow: TextOverflow.ellipsis,
  88. ),
  89. ],
  90. );
  91. });
  92. }
  93. Widget _wLeftActivitys() {
  94. return Obx(() {
  95. return Expanded(
  96. child: Container(
  97. padding: EdgeInsets.symmetric(horizontal: 1.wp, vertical: 1.2.wp),
  98. decoration: BoxDecoration(
  99. color: const Color(0xff003656),
  100. borderRadius: BorderRadius.circular(0.63.wp),
  101. ),
  102. child: ListView.builder(
  103. padding: EdgeInsets.only(top: 0.wp),
  104. // itemCount: mapActivitySimpleInfo.length,
  105. itemCount: controller.mapActivityList.value.list.length,
  106. itemBuilder: (ctx, i) {
  107. return _wActivityElem(ctx, i);
  108. })));
  109. });
  110. }
  111. Widget _wActivityElem(BuildContext ctx, int i) {
  112. return Obx(() {
  113. var info = controller.mapActivityList.value.list[i];
  114. var selectActivityId = controller.selectActivityId;
  115. var markColor = selectActivityId.value == info.id
  116. ? const Color(0xffff870d)
  117. : Color(0xff00a0ff);
  118. return GestureDetector(
  119. onTap: () => selectActivityId.value = info.id,
  120. child: Container(
  121. height: 4.1.wp,
  122. margin: EdgeInsets.only(
  123. left: 0.wp, right: 0.wp, top: 0.wp, bottom: 1.wp),
  124. // padding: EdgeInsets.only(left: 0.8.wp, right: 0.8.wp, top: 0.8.wp, bottom: 0.8.wp),
  125. // padding: EdgeInsets.all(0.8.wp),
  126. decoration: BoxDecoration(
  127. color: const Color(0xff00a0ff),
  128. boxShadow: [
  129. BoxShadow(
  130. color: const Color(0x4d000000),
  131. offset: Offset(0.wp, 0.wp),
  132. blurRadius: 0.35.wp)
  133. ],
  134. // borderRadius: BorderRadius.circular(0.35.wp),
  135. ),
  136. child: Row(
  137. children: [
  138. Container(color: markColor, width: 0.63.wp),
  139. SizedBox(width: 0.5.wp),
  140. SizedBox(
  141. width: 18.wp,
  142. child: Text(
  143. info.name,
  144. style: TextStyle(
  145. color: Colors.white,
  146. fontSize: 1.39.wp,
  147. fontWeight: FontWeight.w700,
  148. ),
  149. textAlign: TextAlign.start,
  150. maxLines: 1,
  151. overflow: TextOverflow.ellipsis,
  152. ),
  153. ),
  154. const Spacer(),
  155. Text("${info.totalControlNum}",
  156. style: TextStyle(
  157. fontSize: 1.39.wp,
  158. fontWeight: FontWeight.w500,
  159. color: Colors.white)),
  160. SizedBox(width: 1.0.wp),
  161. ],
  162. ),
  163. ));
  164. });
  165. }
  166. Widget _wRight() {
  167. return Container(
  168. margin: EdgeInsets.only(left: 0.2.wp),
  169. // color: Colors.green,
  170. // height: 80.wp,
  171. child: Column(
  172. children: [
  173. _wRightTitle(),
  174. SizedBox(height: 1.5.wp),
  175. Expanded(
  176. child: _wRightTable(),
  177. ),
  178. ],
  179. ),
  180. );
  181. }
  182. Widget _wRightTitle() {
  183. return Obx(() {
  184. // int count = controller.mapActivityList.value.list.length;
  185. var selectActivityId = controller.selectActivityId.value;
  186. var info;
  187. if (controller.mapActivityList.value.list.isNotEmpty) {
  188. info = controller.mapActivityList.value.list[selectActivityId];
  189. }
  190. return Row(
  191. children: [
  192. SizedBox(width: 0.5.wp),
  193. const Icon(
  194. Icons.circle,
  195. size: 16,
  196. color: Color(0xff98d8ff),
  197. ),
  198. const SizedBox(width: 6),
  199. Text(
  200. "用户列表",
  201. style: TextStyle(
  202. color: Colors.white,
  203. fontSize: 1.39.wp,
  204. fontWeight: FontWeight.w700,
  205. ),
  206. ),
  207. const SizedBox(width: 6),
  208. SizedBox(
  209. width: 58.wp,
  210. child: Text(
  211. info != null ? "(${info.name})" : "",
  212. style: TextStyle(
  213. color: const Color(0xffffcb00),
  214. fontSize: 1.39.wp,
  215. fontWeight: FontWeight.w400,
  216. ),
  217. textAlign: TextAlign.start,
  218. maxLines: 1,
  219. overflow: TextOverflow.ellipsis,
  220. ),
  221. ),
  222. ],
  223. );
  224. });
  225. }
  226. Widget _wRightTable() {
  227. return Container(
  228. // color: Colors.red,
  229. child: Column(
  230. children: [
  231. _wRightTableTitle(),
  232. _wRightTableBody(),
  233. ],
  234. ),
  235. );
  236. }
  237. Widget _wRightTableTitle() {
  238. var style = TextStyle(
  239. color: const Color(0xff98d8ff),
  240. fontSize: 1.39.wp,
  241. fontWeight: FontWeight.w700,
  242. );
  243. return Container(
  244. height: 2.99.wp,
  245. margin: EdgeInsets.symmetric(vertical: 0.wp, horizontal: 0.6.wp),
  246. padding: EdgeInsets.symmetric(horizontal: 1.0.wp),
  247. decoration: BoxDecoration(
  248. color: const Color(0xffffffff).withOpacity(0.1),
  249. // border: Border.all(width: 1.0, color: const Color(0xffe9e9e9)),
  250. borderRadius: BorderRadius.only(
  251. topLeft: Radius.circular(0.63.wp),
  252. topRight: Radius.circular(0.63.wp)),
  253. ),
  254. child: Row(
  255. mainAxisAlignment: MainAxisAlignment.start,
  256. children: [
  257. Container(
  258. width: 5.49.wp,
  259. alignment: Alignment.center,
  260. child: Text("排名", style: style),
  261. ),
  262. Container(
  263. width: 9.2.wp,
  264. padding: EdgeInsets.symmetric(horizontal: 1.wp),
  265. child: Text("用户名", style: style),
  266. ),
  267. Container(
  268. width: 8.2.wp,
  269. alignment: Alignment.center,
  270. child: Text("路线ID", style: style),
  271. ),
  272. Container(
  273. width: 6.wp,
  274. alignment: Alignment.center,
  275. child: Text("成绩", style: style),
  276. ),
  277. Container(
  278. width: 8.8.wp,
  279. alignment: Alignment.center,
  280. child: Text("总时间", style: style),
  281. ),
  282. Container(
  283. width: 9.0.wp,
  284. alignment: Alignment.center,
  285. child: Text("总里程", style: style),
  286. ),
  287. Container(
  288. width: 11.1.wp,
  289. alignment: Alignment.center,
  290. child: Text("配速", style: style),
  291. ),
  292. Container(
  293. width: 6.2.wp,
  294. alignment: Alignment.center,
  295. child: Text("分组", style: style),
  296. ),
  297. ],
  298. ),
  299. );
  300. }
  301. Widget _wRightTableBody() {
  302. return Obx(() {
  303. var info = controller.userRankInfoList;
  304. return Expanded(
  305. child: Container(
  306. margin: EdgeInsets.symmetric(vertical: 0.2.wp, horizontal: 0.6.wp),
  307. decoration: BoxDecoration(
  308. color: const Color(0xffffffff).withOpacity(0.1),
  309. // border: Border.all(width: 1.0, color: const Color(0xffe9e9e9)),
  310. borderRadius: BorderRadius.only(
  311. bottomLeft: Radius.circular(0.63.wp),
  312. bottomRight: Radius.circular(0.63.wp)),
  313. ),
  314. child: ListView.separated(
  315. padding: EdgeInsets.only(top: 0.wp),
  316. itemCount: info.length,
  317. separatorBuilder: (BuildContext context, int index) {
  318. return Container(
  319. height: 0,
  320. width: double.infinity,
  321. color: const Color(0xffe9e9e9),
  322. );
  323. },
  324. itemBuilder: (ctx, i) {
  325. return _wUserElem(ctx, i);
  326. }),
  327. ));
  328. });
  329. }
  330. Widget _wUserElem(BuildContext ctx, int i) {
  331. var style = TextStyle(
  332. color: Color(0xffffffff),
  333. fontSize: 1.25.wp,
  334. fontWeight: FontWeight.w500,
  335. );
  336. var dividline =
  337. Container(width: 0.14.wp, height: 1.74.wp, color: Color(0xffdedede));
  338. return Obx(() {
  339. var info = controller.userRankInfoList[i];
  340. return Container(
  341. margin: EdgeInsets.only(
  342. left: 1.0.wp, right: 1.0.wp, top: 0.6.wp, bottom: 0.wp),
  343. height: 4.08.wp,
  344. child: Row(
  345. mainAxisAlignment: MainAxisAlignment.start,
  346. children: [
  347. Container(
  348. width: 5.49.wp,
  349. alignment: Alignment.center,
  350. decoration: BoxDecoration(
  351. color: const Color(0xffff870d),
  352. // border: Border.all(width: 1.0, color: const Color(0xffe9e9e9)),
  353. borderRadius: BorderRadius.only(
  354. topLeft: Radius.circular(0.63.wp),
  355. bottomLeft: Radius.circular(0.63.wp)),
  356. ),
  357. child: Text(
  358. info.bValid! ? info.iRankNum.toString() : '--',
  359. style: TextStyle(
  360. color: const Color(0xffffffff),
  361. fontSize: 3.03.wp,
  362. fontWeight: FontWeight.w700,
  363. fontStyle: FontStyle.italic))),
  364. Container(width: 0.2.wp),
  365. Expanded(
  366. child: Container(
  367. decoration: BoxDecoration(
  368. color: const Color(0xff003656),
  369. // border: Border.all(width: 1.0, color: const Color(0xffe9e9e9)),
  370. borderRadius: BorderRadius.only(
  371. topRight: Radius.circular(0.63.wp),
  372. bottomRight: Radius.circular(0.63.wp)),
  373. ),
  374. child: Row(
  375. children: [
  376. Container(
  377. width: 9.wp,
  378. padding: EdgeInsets.symmetric(horizontal: 1.wp),
  379. child: Text(info.sUserName!, style: style)),
  380. dividline,
  381. Container(
  382. width: 8.wp,
  383. alignment: Alignment.center,
  384. child: Text(info.sRouteCode!, style: style)),
  385. dividline,
  386. Container(
  387. width: 6.wp,
  388. alignment: Alignment.center,
  389. child: Text(info.bValid! ? '有效' : '无效', style: style)),
  390. dividline,
  391. Container(
  392. width: 8.6.wp,
  393. alignment: Alignment.center,
  394. child: Text(info.bValid! ? info.iTime.toString() : '--', style: style)),
  395. dividline,
  396. Container(
  397. width: 9.wp,
  398. alignment: Alignment.center,
  399. child:
  400. Text(info.bValid! ? info.iMileage!.kmToStr() : '--', style: style)),
  401. dividline,
  402. Container(
  403. width: 11.wp,
  404. alignment: Alignment.center,
  405. child: Text(info.bValid! ? '${info.pacePerKm!.toMinSecondString()}/km' : '--',
  406. style: style)),
  407. dividline,
  408. Container(
  409. width: 6.wp,
  410. alignment: Alignment.center,
  411. child: Image.asset(
  412. userGroupFlag[info.iGroupid! - 1],
  413. height: 1.81.wp,
  414. fit: BoxFit.fitHeight,
  415. ),
  416. )
  417. ],
  418. ),
  419. ),
  420. ),
  421. ],
  422. ),
  423. );
  424. });
  425. }
  426. }
  427. void main() {
  428. Mock.initServices();
  429. PageTopController pageTopController = Get.put(PageTopController());
  430. Get.put(MapToController());
  431. // pageTopController.mapName.value = "济南泉城公园";
  432. // pageTopController.mapName.value = "济南森林公园风景区定向运动济南森林公园风景区定向运动";
  433. Get.put(UserRankController());
  434. runPreview(const UserRankView());
  435. }