user_manage_page.dart 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import 'user_manage_controller.dart';
  2. import 'package:application/widget.dart';
  3. class UserManagePage extends StatelessWidget {
  4. const UserManagePage({super.key});
  5. @override
  6. Widget build(BuildContext context) {
  7. return GetBuilder(
  8. init: UserManageController(),
  9. builder: (c) {
  10. return Container(
  11. width: double.infinity,
  12. height: double.infinity,
  13. margin: const EdgeInsets.all(20),
  14. padding: const EdgeInsets.fromLTRB(12, 17, 12, 17),
  15. decoration: BoxDecoration(
  16. color: Colors.white, borderRadius: BorderRadius.circular(16)),
  17. child: Row(
  18. children: [
  19. SizedBox(
  20. width: 260,
  21. height: double.infinity,
  22. child: Obx(() => eActiveList(context, c))),
  23. const VerticalDivider(
  24. width: 15, color: Color(0xffd8d8d8), thickness: 1),
  25. Expanded(child: Obx(() => eUserList(context, c)))
  26. ],
  27. ),
  28. );
  29. });
  30. }
  31. Widget eActiveList(BuildContext context, UserManageController c) {
  32. return Column(
  33. children: [
  34. Row(
  35. children: [
  36. const Padding(padding: EdgeInsets.all(8), child: TitlePoint()),
  37. const Text('活动列表'),
  38. const Spacer(),
  39. Container(
  40. decoration: BoxDecoration(
  41. border: Border.all(color: const Color(0xffe3e3e3))),
  42. child: const Text('2023-06-26'),
  43. )
  44. ],
  45. ),
  46. const SizedBox(height: 20),
  47. Expanded(
  48. child: ListView(
  49. children: c.activeList
  50. .map((e) => wActiveCard(
  51. context, e, c.selectActive.value?.id == e.id, () {
  52. c.selectActive.value = e;
  53. }))
  54. .toList(),
  55. )),
  56. ],
  57. );
  58. }
  59. Widget wActiveCard(BuildContext context, ActiveInfo active, bool selected,
  60. VoidCallback onTap) {
  61. return GestureDetector(
  62. onTap: onTap,
  63. child: Container(
  64. decoration: const BoxDecoration(color: Colors.white, boxShadow: [
  65. BoxShadow(color: Color(0x4d000000), blurRadius: 3.5)
  66. ]),
  67. height: _cardHeight,
  68. width: double.infinity,
  69. margin: const EdgeInsets.only(top: 7),
  70. padding: const EdgeInsets.only(right: 11),
  71. child: Row(
  72. children: [
  73. Container(
  74. margin: const EdgeInsets.only(right: 10),
  75. height: double.infinity,
  76. width: 6.4,
  77. color: selected ? const Color(0xffff870d) : Colors.transparent,
  78. ),
  79. Text(active.name),
  80. const Spacer(),
  81. Text(active.userList.length.toString())
  82. ],
  83. ),
  84. ));
  85. }
  86. Widget eUserList(BuildContext context, UserManageController c) {
  87. final active = c.selectActive.value;
  88. if (active == null) {
  89. return const SizedBox();
  90. }
  91. final userList = c.selectActive.value?.userList??<UserInfo>[];
  92. return Column(
  93. children: [
  94. Row(
  95. children: [
  96. const Padding(padding: EdgeInsets.all(8), child: TitlePoint()),
  97. const Text('用户列表'),
  98. Text(' (${active.name})',
  99. style: const TextStyle(color: Color(0xff949494))),
  100. ],
  101. ),
  102. Expanded(child: Padding(
  103. padding: const EdgeInsets.all(18),
  104. child: Column(
  105. children: [
  106. eUserListTitle(context),
  107. Expanded(child: ListView(
  108. children:userList.indexed.map<Widget>((t){
  109. return eUserCard(context, c, t.$1+1, t.$2);
  110. }).toList(),
  111. ))
  112. ],
  113. )
  114. ))
  115. ],
  116. );
  117. }
  118. Widget eUserListTitle(BuildContext context){
  119. return Row(
  120. children: [
  121. const SizedBox(width: _userIndexWidth, child: Text('序号', textAlign: TextAlign.center)),
  122. const VerticalDivider(color: Colors.transparent),
  123. const SizedBox(width: _userNameWidth, child: Text('用户名', textAlign: TextAlign.center)),
  124. const VerticalDivider(color: Colors.transparent),
  125. const Expanded(child: Text('开始时间')),
  126. const VerticalDivider(color: Colors.transparent),
  127. const SizedBox(width: _userIsNotShowWidth, child: Text('是否屏蔽', textAlign: TextAlign.center)),
  128. const VerticalDivider(color: Colors.transparent),
  129. SizedBox(width: _userFlagWidth, child: Row(
  130. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  131. children: Flag.values.map((e) => Icon(Icons.flag, color: e.color)).toList()
  132. )),
  133. ],
  134. );
  135. }
  136. Widget eUserCard(
  137. BuildContext context, UserManageController c, int index, UserInfo data) {
  138. var startAt = '--';
  139. if(data.startAt!= null){
  140. startAt = data.startAt!.toIso8601String();
  141. }
  142. return Container(
  143. height: _cardHeight,
  144. width: double.infinity,
  145. margin: const EdgeInsets.only(top: 3),
  146. padding: const EdgeInsets.only(top: 10, bottom: 10),
  147. decoration: const BoxDecoration(
  148. color: Colors.white,
  149. boxShadow: [BoxShadow(color: Color(0x4d000000), blurRadius: 0.7)]),
  150. child: Row(children: [
  151. SizedBox(width: _userIndexWidth, child: Text(index.toString(), textAlign: TextAlign.center,)),
  152. const VerticalDivider(),
  153. SizedBox(width: _userNameWidth, child: Text(data.name, textAlign: TextAlign.center,)),
  154. const VerticalDivider(),
  155. Expanded(child: Text(startAt)),
  156. const VerticalDivider(),
  157. Container(
  158. width: _userIsNotShowWidth,
  159. alignment: Alignment.center,
  160. child: Checkbox(
  161. value: data.isHide.value,
  162. onChanged: (v){
  163. if(v != null){
  164. data.isHide.value=v;
  165. }
  166. },
  167. ),
  168. ),
  169. const VerticalDivider(),
  170. SizedBox(width: _userFlagWidth, child: Row(
  171. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  172. children: Flag.values.map((e) => Radio<Flag>(
  173. value: e,
  174. groupValue: data.flag.value,
  175. onChanged: (Flag? value) {
  176. if(value!= null){
  177. data.flag.value=value;
  178. }
  179. },
  180. )).toList()
  181. )),
  182. ]),
  183. );
  184. }
  185. static const _userIndexWidth = 34.0;
  186. static const _userNameWidth = 100.0;
  187. static const _userIsNotShowWidth = 70.0;
  188. static const _userFlagWidth = 170.0;
  189. static const _cardHeight = 42.0;
  190. }