label_collection.dart 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:liftmanager/widgets/app_bar.dart';
  4. import 'package:liftmanager/widgets/bbs_content.dart';
  5. const brands = [
  6. '奥的斯',
  7. '富士达',
  8. '日立',
  9. '三菱',
  10. '东芝',
  11. '蒂森克虏伯',
  12. '西奥',
  13. '康力',
  14. '其他品牌',
  15. ];
  16. const systems = [
  17. '默纳克',
  18. '新时达',
  19. '蓝光',
  20. '西子',
  21. '海普蒙特',
  22. '其他系统',
  23. ];
  24. const skills = [
  25. '维保',
  26. '安装',
  27. '大修',
  28. '调试',
  29. 'CAD',
  30. ];
  31. const familiarities = [
  32. '电气',
  33. '机械',
  34. '调试',
  35. '其他方向',
  36. ];
  37. const specialties = [
  38. '电气自动化',
  39. '机械工程',
  40. '其他专业',
  41. ];
  42. const experiencedPositions = [
  43. '学徒',
  44. '技工',
  45. '组长',
  46. '区域主管',
  47. '中工',
  48. '大工',
  49. '项目经理',
  50. '其他岗位',
  51. ];
  52. const traits = [
  53. '吃苦耐劳',
  54. '忠诚',
  55. '稳重',
  56. '坚守诚信',
  57. '乐于沟通',
  58. '善于学习',
  59. '勤奋务实',
  60. '适应能力强',
  61. ];
  62. class LabelModel {
  63. String title;
  64. bool selected;
  65. LabelModel({this.title, this.selected});
  66. }
  67. class LabelCollection extends StatefulWidget {
  68. final List<String> selectedLabels;
  69. LabelCollection({this.selectedLabels});
  70. @override
  71. State<StatefulWidget> createState() => LabelCollectionState();
  72. }
  73. class LabelCollectionState extends State<LabelCollection> {
  74. List<LabelModel> brandModelList = [];
  75. List<LabelModel> systemModelList = [];
  76. List<LabelModel> skillModelList = [];
  77. List<LabelModel> familiarityModelList = [];
  78. List<LabelModel> specialtyModelList = [];
  79. List<LabelModel> positionModelList = [];
  80. List<LabelModel> traitModelList = [];
  81. @override
  82. initState() {
  83. super.initState();
  84. dealWithModels(brandModelList, brands);
  85. dealWithModels(systemModelList, systems);
  86. dealWithModels(skillModelList, skills);
  87. dealWithModels(familiarityModelList, familiarities);
  88. dealWithModels(specialtyModelList, specialties);
  89. dealWithModels(positionModelList, experiencedPositions);
  90. dealWithModels(traitModelList, traits);
  91. }
  92. void dealWithModels(List<LabelModel> modelList, List<String> strList) {
  93. modelList.addAll(strList.map((e) =>
  94. LabelModel(title: e, selected: widget.selectedLabels.contains(e))));
  95. }
  96. void feedSelectedLabels(List<LabelModel> modelList) {
  97. for (var model in modelList) {
  98. if (model.selected) {
  99. widget.selectedLabels.add(model.title);
  100. }
  101. }
  102. }
  103. @override
  104. Widget build(BuildContext context) {
  105. return Scaffold(
  106. appBar: MyAppBar(
  107. centerTitle: '标签',
  108. onBack: () {
  109. widget.selectedLabels.clear();
  110. feedSelectedLabels(brandModelList);
  111. feedSelectedLabels(systemModelList);
  112. feedSelectedLabels(skillModelList);
  113. feedSelectedLabels(familiarityModelList);
  114. feedSelectedLabels(specialtyModelList);
  115. feedSelectedLabels(positionModelList);
  116. feedSelectedLabels(traitModelList);
  117. Navigator.pop(context);
  118. },
  119. ),
  120. body: ListView(
  121. children: [
  122. CommonSectionHeader(
  123. title: '品牌类',
  124. ),
  125. Container(
  126. padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
  127. child: Wrap(
  128. spacing: 5,
  129. runSpacing: 5,
  130. children: brandModelList.map((e) => labelButton(e)).toList(),
  131. ),
  132. ),
  133. CommonSectionHeader(
  134. title: '系统类',
  135. ),
  136. Container(
  137. padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
  138. child: Wrap(
  139. spacing: 5,
  140. runSpacing: 5,
  141. children: systemModelList.map((e) => labelButton(e)).toList(),
  142. ),
  143. ),
  144. CommonSectionHeader(
  145. title: '技能类',
  146. ),
  147. Container(
  148. padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
  149. child: Wrap(
  150. spacing: 5,
  151. runSpacing: 5,
  152. children: skillModelList.map((e) => labelButton(e)).toList(),
  153. ),
  154. ),
  155. CommonSectionHeader(
  156. title: '擅长方向',
  157. ),
  158. Container(
  159. padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
  160. child: Wrap(
  161. spacing: 5,
  162. runSpacing: 5,
  163. children:
  164. familiarityModelList.map((e) => labelButton(e)).toList(),
  165. ),
  166. ),
  167. CommonSectionHeader(
  168. title: '专业方向',
  169. ),
  170. Container(
  171. padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
  172. child: Wrap(
  173. spacing: 5,
  174. runSpacing: 5,
  175. children: specialtyModelList.map((e) => labelButton(e)).toList(),
  176. ),
  177. ),
  178. CommonSectionHeader(
  179. title: '曾任岗位',
  180. ),
  181. Container(
  182. padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
  183. child: Wrap(
  184. spacing: 5,
  185. runSpacing: 5,
  186. children: positionModelList.map((e) => labelButton(e)).toList(),
  187. ),
  188. ),
  189. CommonSectionHeader(
  190. title: '性格品质',
  191. ),
  192. Container(
  193. padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
  194. child: Wrap(
  195. spacing: 5,
  196. runSpacing: 5,
  197. children: traitModelList.map((e) => labelButton(e)).toList(),
  198. ),
  199. ),
  200. ],
  201. ),
  202. );
  203. }
  204. Widget labelButton(LabelModel model) {
  205. return GestureDetector(
  206. onTap: () {
  207. setState(() {
  208. model.selected = !model.selected;
  209. });
  210. },
  211. child: Container(
  212. padding: EdgeInsets.all(10),
  213. decoration: BoxDecoration(
  214. color: model.selected ? Color(0xffECF2FF) : Color(0xffF4F8FA),
  215. borderRadius: BorderRadius.circular(20),
  216. ),
  217. child: Text(
  218. model.title,
  219. style: TextStyle(
  220. color: model.selected ? Color(0xff5589FF) : Color(0xff666666),
  221. fontSize: 13,
  222. ),
  223. ),
  224. ));
  225. }
  226. }