user_admin_view.dart.bk 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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_admin_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 UserAdminView extends GetView<UserAdminController> {
  14. const UserAdminView({super.key});
  15. static Bindings bindings() {
  16. return BindingsBuilder(() {
  17. Get.lazyPut<UserAdminController>(() => UserAdminController());
  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: BoxDecoration(
  31. color: Colors.white,
  32. borderRadius: BorderRadius.circular(1.11.wp),
  33. shape: BoxShape.rectangle,
  34. boxShadow: [
  35. BoxShadow(
  36. color: const Color(0x33000000),
  37. offset: Offset(-0.28.wp, 0.21.wp),
  38. blurRadius: 0.07.wp)
  39. ],
  40. ),
  41. child: Row(
  42. mainAxisAlignment: MainAxisAlignment.start,
  43. children: [
  44. Expanded(
  45. flex: 1,
  46. child: _wLeft(),
  47. ),
  48. Container(
  49. color: const Color(0xffd8d8d8),
  50. width: 1,
  51. ),
  52. Expanded(
  53. flex: 3,
  54. child: _wRight(),
  55. ),
  56. ],
  57. ),
  58. );
  59. }
  60. Widget _wLeft() {
  61. return Container(
  62. margin: EdgeInsets.only(right: 0.8.wp),
  63. child: Column(
  64. children: [
  65. _wLeftTitle(),
  66. SizedBox(height: 1.5.wp),
  67. _wLeftActivitys(),
  68. ],
  69. ),
  70. );
  71. }
  72. Widget _wLeftTitle() {
  73. return Obx(() {
  74. int count = controller.mapActivityList.value.list.length;
  75. return Row(
  76. children: [
  77. SizedBox(width: 0.5.wp),
  78. const Icon(
  79. Icons.circle,
  80. size: 16,
  81. color: Color(0xff1a82c0),
  82. ),
  83. const SizedBox(width: 6),
  84. Text(
  85. "活动列表 (${count})",
  86. style: TextStyle(
  87. color: Colors.black,
  88. fontSize: 1.39.wp,
  89. fontWeight: FontWeight.w700,
  90. ),
  91. textAlign: TextAlign.start,
  92. maxLines: 1,
  93. overflow: TextOverflow.ellipsis,
  94. ),
  95. ],
  96. );
  97. });
  98. }
  99. Widget _wLeftActivitys() {
  100. return Obx(() {
  101. return Expanded(
  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. : Colors.white;
  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: Colors.white,
  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.black,
  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: const Color(0xff333333))),
  160. SizedBox(width: 1.0.wp),
  161. ],
  162. ),
  163. ));
  164. });
  165. }
  166. Widget _wRight() {
  167. return Container(
  168. margin: EdgeInsets.only(left: 0.8.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(0xff1a82c0),
  197. ),
  198. const SizedBox(width: 6),
  199. Text(
  200. "用户列表",
  201. style: TextStyle(
  202. color: Colors.black,
  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(0xff949494),
  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: Color(0xff333333),
  240. fontSize: 1.25.wp,
  241. fontWeight: FontWeight.w500,
  242. );
  243. return Container(
  244. margin: EdgeInsets.symmetric(vertical: 0.wp, horizontal: 3.wp),
  245. child: Row(
  246. mainAxisAlignment: MainAxisAlignment.spaceAround,
  247. children: [
  248. Container(
  249. width: 4.wp,
  250. alignment: Alignment.center,
  251. child: Text("序号", style: style),
  252. ),
  253. Container(
  254. width: 10.wp,
  255. padding: EdgeInsets.symmetric(horizontal: 1.wp),
  256. child: Text("用户名", style: style),
  257. ),
  258. Container(
  259. width: 18.wp,
  260. alignment: Alignment.center,
  261. child: Text("开始时间", style: style),
  262. ),
  263. Container(
  264. width: 9.wp,
  265. alignment: Alignment.center,
  266. child: Text("是否屏蔽", style: style),
  267. ),
  268. Container(
  269. width: 18.wp,
  270. padding: EdgeInsets.only(left: 0.3.wp),
  271. child: Row(
  272. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  273. children: [
  274. Image.asset(
  275. Assets.imagesIcFlagRed,
  276. height: 1.81.wp,
  277. fit: BoxFit.fitHeight,
  278. ),
  279. Image.asset(
  280. Assets.imagesIcFlagYellow,
  281. height: 1.81.wp,
  282. fit: BoxFit.fitHeight,
  283. ),
  284. Image.asset(
  285. Assets.imagesIcFlagBlue,
  286. height: 1.81.wp,
  287. fit: BoxFit.fitHeight,
  288. ),
  289. ],
  290. ),
  291. )
  292. ],
  293. ),
  294. );
  295. }
  296. Widget _wRightTableBody() {
  297. return Obx(() {
  298. var info = controller.mapToController.userInfoList;
  299. return Expanded(
  300. child: Container(
  301. margin: EdgeInsets.symmetric(vertical: 0.6.wp, horizontal: 3.wp),
  302. // decoration: BoxDecoration(
  303. // border: Border.all(width: 1.0, color: const Color(0xffe9e9e9)),
  304. // // borderRadius: BorderRadius.circular(0.35.wp),
  305. // ),
  306. child: ListView.separated(
  307. padding: EdgeInsets.only(top: 0.wp),
  308. itemCount: info.length,
  309. separatorBuilder: (BuildContext context, int index) {
  310. return Container(
  311. height: 0,
  312. width: double.infinity,
  313. color: const Color(0xffe9e9e9),
  314. );
  315. },
  316. itemBuilder: (ctx, i) {
  317. return _wUserElem(ctx, i);
  318. }),
  319. ));
  320. });
  321. }
  322. Widget _wUserElem(BuildContext ctx, int i) {
  323. var style = TextStyle(
  324. color: Color(0xff333333),
  325. fontSize: 1.25.wp,
  326. fontWeight: FontWeight.w500,
  327. );
  328. return Obx(() {
  329. var info = controller.mapToController.userInfoList.value[i];
  330. var dividline = Container(
  331. width: 1,
  332. margin: EdgeInsets.symmetric(vertical: 0.8.wp),
  333. color: Color(0xffdedede));
  334. return Container(
  335. margin:
  336. EdgeInsets.only(left: 0.wp, right: 0.wp, top: 0.1.wp, bottom: 0.wp),
  337. // padding: EdgeInsets.only(left: 0.8.wp, right: 0.8.wp, top: 0.8.wp, bottom: 0.8.wp),
  338. // padding: EdgeInsets.all(0.8.wp),
  339. height: 3.75.wp,
  340. decoration: BoxDecoration(
  341. color: const Color(0xffffffff),
  342. border: Border.all(width: 1.0, color: const Color(0xffe9e9e9)),
  343. // borderRadius: BorderRadius.circular(0.35.wp),
  344. ),
  345. child: Row(
  346. mainAxisAlignment: MainAxisAlignment.spaceAround,
  347. children: [
  348. Container(
  349. width: 4.wp,
  350. alignment: Alignment.center,
  351. child: Text((i + 1).toString(), style: style)),
  352. dividline,
  353. Container(
  354. width: 10.wp,
  355. padding: EdgeInsets.symmetric(horizontal: 1.wp),
  356. child: Text(info.sUserName.toString(), style: style)),
  357. dividline,
  358. Container(
  359. width: 18.wp,
  360. alignment: Alignment.center,
  361. child: Text("2023.06.26 10:05:18", style: style)),
  362. dividline,
  363. Container(
  364. width: 9.wp,
  365. child: _wUserSelectDisplay(info.iUserid!),
  366. ),
  367. dividline,
  368. Container(
  369. width: 18.wp,
  370. child: Row(
  371. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  372. children: [
  373. _wUserSelectGroup(info.iUserid!, 1),
  374. _wUserSelectGroup(info.iUserid!, 2),
  375. _wUserSelectGroup(info.iUserid!, 3),
  376. ],
  377. ),
  378. )
  379. ],
  380. ),
  381. );
  382. });
  383. }
  384. Widget _wUserSelectDisplay(int userid) {
  385. return GestureDetector(
  386. onTap: controller.handleUserDisplay(userid),
  387. child: Image.asset(
  388. userid == 1
  389. ? Assets.imagesIcRadioSelectedOrange
  390. : Assets.imagesIcRadioSelectedGray,
  391. width: 1.67.wp,
  392. height: 1.67.wp,
  393. ));
  394. }
  395. Widget _wUserSelectGroup(int userid, int groupid) {
  396. return GestureDetector(
  397. onTap: () => controller.handleUserGroup(userid),
  398. child: Image.asset(
  399. userid == groupid
  400. ? Assets.imagesIcRadioSelectedOrange
  401. : Assets.imagesIcRadioSelectedGray,
  402. width: 1.67.wp,
  403. height: 1.67.wp,
  404. ));
  405. }
  406. }
  407. void main() {
  408. Mock.initServices();
  409. PageTopController pageTopController = Get.put(PageTopController());
  410. Get.put(MapToController());
  411. // pageTopController.mapName.value = "济南泉城公园";
  412. // pageTopController.mapName.value = "济南森林公园风景区定向运动济南森林公园风景区定向运动";
  413. Get.put(UserAdminController());
  414. runPreview(const UserAdminView());
  415. }