123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/widgets/bbs_content.dart';
- const brands = [
- '奥的斯',
- '富士达',
- '日立',
- '三菱',
- '东芝',
- '蒂森克虏伯',
- '西奥',
- '康力',
- '其他品牌',
- ];
- const systems = [
- '默纳克',
- '新时达',
- '蓝光',
- '西子',
- '海普蒙特',
- '其他系统',
- ];
- const skills = [
- '维保',
- '安装',
- '大修',
- '调试',
- 'CAD',
- ];
- const familiarities = [
- '电气',
- '机械',
- '调试',
- '其他方向',
- ];
- const specialties = [
- '电气自动化',
- '机械工程',
- '其他专业',
- ];
- const experiencedPositions = [
- '学徒',
- '技工',
- '组长',
- '区域主管',
- '中工',
- '大工',
- '项目经理',
- '其他岗位',
- ];
- const traits = [
- '吃苦耐劳',
- '忠诚',
- '稳重',
- '坚守诚信',
- '乐于沟通',
- '善于学习',
- '勤奋务实',
- '适应能力强',
- ];
- class LabelModel {
- String title;
- bool selected;
- LabelModel({this.title, this.selected});
- }
- class LabelCollection extends StatefulWidget {
- final List<String> selectedLabels;
- LabelCollection({this.selectedLabels});
- @override
- State<StatefulWidget> createState() => LabelCollectionState();
- }
- class LabelCollectionState extends State<LabelCollection> {
- List<LabelModel> brandModelList = [];
- List<LabelModel> systemModelList = [];
- List<LabelModel> skillModelList = [];
- List<LabelModel> familiarityModelList = [];
- List<LabelModel> specialtyModelList = [];
- List<LabelModel> positionModelList = [];
- List<LabelModel> traitModelList = [];
- @override
- initState() {
- super.initState();
- dealWithModels(brandModelList, brands);
- dealWithModels(systemModelList, systems);
- dealWithModels(skillModelList, skills);
- dealWithModels(familiarityModelList, familiarities);
- dealWithModels(specialtyModelList, specialties);
- dealWithModels(positionModelList, experiencedPositions);
- dealWithModels(traitModelList, traits);
- }
- void dealWithModels(List<LabelModel> modelList, List<String> strList) {
- modelList.addAll(strList.map((e) =>
- LabelModel(title: e, selected: widget.selectedLabels.contains(e))));
- }
- void feedSelectedLabels(List<LabelModel> modelList) {
- for (var model in modelList) {
- if (model.selected) {
- widget.selectedLabels.add(model.title);
- }
- }
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: MyAppBar(
- centerTitle: '标签',
- onBack: () {
- widget.selectedLabels.clear();
- feedSelectedLabels(brandModelList);
- feedSelectedLabels(systemModelList);
- feedSelectedLabels(skillModelList);
- feedSelectedLabels(familiarityModelList);
- feedSelectedLabels(specialtyModelList);
- feedSelectedLabels(positionModelList);
- feedSelectedLabels(traitModelList);
- Navigator.pop(context);
- },
- ),
- body: ListView(
- children: [
- CommonSectionHeader(
- title: '品牌类',
- ),
- Container(
- padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
- child: Wrap(
- spacing: 5,
- runSpacing: 5,
- children: brandModelList.map((e) => labelButton(e)).toList(),
- ),
- ),
- CommonSectionHeader(
- title: '系统类',
- ),
- Container(
- padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
- child: Wrap(
- spacing: 5,
- runSpacing: 5,
- children: systemModelList.map((e) => labelButton(e)).toList(),
- ),
- ),
- CommonSectionHeader(
- title: '技能类',
- ),
- Container(
- padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
- child: Wrap(
- spacing: 5,
- runSpacing: 5,
- children: skillModelList.map((e) => labelButton(e)).toList(),
- ),
- ),
- CommonSectionHeader(
- title: '擅长方向',
- ),
- Container(
- padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
- child: Wrap(
- spacing: 5,
- runSpacing: 5,
- children:
- familiarityModelList.map((e) => labelButton(e)).toList(),
- ),
- ),
- CommonSectionHeader(
- title: '专业方向',
- ),
- Container(
- padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
- child: Wrap(
- spacing: 5,
- runSpacing: 5,
- children: specialtyModelList.map((e) => labelButton(e)).toList(),
- ),
- ),
- CommonSectionHeader(
- title: '曾任岗位',
- ),
- Container(
- padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
- child: Wrap(
- spacing: 5,
- runSpacing: 5,
- children: positionModelList.map((e) => labelButton(e)).toList(),
- ),
- ),
- CommonSectionHeader(
- title: '性格品质',
- ),
- Container(
- padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
- child: Wrap(
- spacing: 5,
- runSpacing: 5,
- children: traitModelList.map((e) => labelButton(e)).toList(),
- ),
- ),
- ],
- ),
- );
- }
- Widget labelButton(LabelModel model) {
- return GestureDetector(
- onTap: () {
- setState(() {
- model.selected = !model.selected;
- });
- },
- child: Container(
- padding: EdgeInsets.all(10),
- decoration: BoxDecoration(
- color: model.selected ? Color(0xffECF2FF) : Color(0xffF4F8FA),
- borderRadius: BorderRadius.circular(20),
- ),
- child: Text(
- model.title,
- style: TextStyle(
- color: model.selected ? Color(0xff5589FF) : Color(0xff666666),
- fontSize: 13,
- ),
- ),
- ));
- }
- }
|