| | |
| | | @IBOutlet weak var btn_next: UIButton! |
| | | @IBOutlet weak var view_content: UIView! |
| | | @IBOutlet weak var collectionVIew: UICollectionView! |
| | | private var setIndex = Set<IndexPath>() |
| | | private var selectModels = Set<TagModel>() |
| | | |
| | | private var items = [["原生家庭","亲子关系","夫妻关系"],["情感纠结","思念亲人","优质睡眠","提升能量"],["高维智慧","清理净化","情绪稳定"]] |
| | | var responseUserAnswerModel:ResponseUserAnswerModel! |
| | | private var items = [[TagModel]?]() |
| | | |
| | | |
| | | override func viewWillAppear(_ animated: Bool) { |
| | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | |
| | | var topIndex = 0 |
| | | Services.getTag().subscribe(onNext: { data in |
| | | self.items = Array<TagModel>.splitArray((data.data ?? []), subArraySize: 3) |
| | | self.collectionVIew.reloadData() |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | } |
| | | |
| | | @IBAction func nextAction(_ sender: UIButton) { |
| | | NotificationCenter.default.post(name: PlantGuideQuit_Noti, object: true) |
| | | responseUserAnswerModel.tagsId = selectModels.map({"\($0.id)"}).joined(separator: ",") |
| | | Services.saveUserAnswers(responseUserAnswerModel).subscribe(onNext: { data in |
| | | NotificationCenter.default.post(name: PlantGuideQuit_Noti, object: true) |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | @IBAction func previousAction(_ sender: UIButton) { |
| | |
| | | extension PlanGuide_3_VC:UICollectionViewDelegate & UICollectionViewDataSource{ |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | if setIndex.contains(indexPath){ |
| | | setIndex.remove(indexPath) |
| | | let m = items[indexPath.section]![indexPath.row] |
| | | |
| | | if selectModels.contains(m){ |
| | | selectModels.remove(m) |
| | | }else{ |
| | | setIndex.insert(indexPath) |
| | | selectModels.insert(m) |
| | | } |
| | | collectionView.reloadData() |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | return items[section].count |
| | | return items[section]?.count ?? 0 |
| | | } |
| | | |
| | | func numberOfSections(in collectionView: UICollectionView) -> Int { |
| | |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! Planguide_3_CCell |
| | | cell.label_title.text = items[indexPath.section][indexPath.row] |
| | | cell.isSelect(setIndex.contains(indexPath)) |
| | | let m = items[indexPath.section]![indexPath.row] |
| | | cell.label_title.text = m.tagName |
| | | cell.isSelect(selectModels.contains(m)) |
| | | return cell |
| | | } |
| | | } |