From f86647c644b10a03300906aac377505ad1c24c98 Mon Sep 17 00:00:00 2001
From: zjf <zhangjf@probim.com.cn>
Date: Mon, 13 Mar 2023 13:33:04 +0800
Subject: [PATCH] 项目搜索历史标签 及 现场 新增标签更换库  collection view 添加背景颜色 cell修改样式

---
 IphoneBIMe/IphoneBIMe/Classes/Project/Examine/ViewControllers/PBAddExamineViewController.m |   94 ++++++++++++++++++++++-------------------------
 1 files changed, 44 insertions(+), 50 deletions(-)

diff --git a/IphoneBIMe/IphoneBIMe/Classes/Project/Examine/ViewControllers/PBAddExamineViewController.m b/IphoneBIMe/IphoneBIMe/Classes/Project/Examine/ViewControllers/PBAddExamineViewController.m
index 018c28e..c69c229 100644
--- a/IphoneBIMe/IphoneBIMe/Classes/Project/Examine/ViewControllers/PBAddExamineViewController.m
+++ b/IphoneBIMe/IphoneBIMe/Classes/Project/Examine/ViewControllers/PBAddExamineViewController.m
@@ -25,7 +25,6 @@
 #import "PBPersonModel.h"
 #import "PBArtifactsInfoModel.h"
 #import "PBProjectModel.h"
-#import "MSSAutoresizeLabelFlow.h"
 #import "PBTextInputTableViewCell.h"
 #import "PBTopTitleTableViewCell.h"
 #import "PBTimeChooseTableViewCell.h"
@@ -46,6 +45,8 @@
 #import "PBCheckHeaderView.h"
 #import "LXFCameraController.h"
 #import "PBVideoPlayViewController.h"
+#import "LBKeyWordLayout.h"
+#import "KeyWordCell.h"
 static NSString *const inputCellID = @"InputCellID";
 static NSString *const titleCellID = @"titleCellID";
 static NSString *const oneChooseCellID = @"oneChooseCellID";
@@ -57,7 +58,7 @@
 static NSString *const statusCellID = @"statusCellID";
 static NSString *const instructionsCellID = @"instructionsCellID";
 
-@interface PBAddExamineViewController ()<UITableViewDelegate, UITableViewDataSource, UIGestureRecognizerDelegate, LFImagePickerControllerDelegate>
+@interface PBAddExamineViewController ()<UITableViewDelegate, UITableViewDataSource, UIGestureRecognizerDelegate, LFImagePickerControllerDelegate, UICollectionViewDelegate, UICollectionViewDataSource>
 @property (nonatomic, strong) UITableView *tableView;
 @property (nonatomic, strong) NSMutableArray<PBExamineAddModel *> *dataListM;
 @property (nonatomic, strong) NSDictionary *examinDetailDic;
@@ -66,8 +67,6 @@
 @property (nonatomic, strong) PBTimeChooseView *timeChooseView;
 @property (nonatomic, strong) PBEditTimeView *editTimeView;
 @property (nonatomic, strong) UIView *backgroundView;
-@property (nonatomic, strong) UIView *typeBackView;
-@property (nonatomic, strong) MSSAutoresizeLabelFlow *typeListRecordV;
 @property (nonatomic, weak) UIButton *typeListBtn;
 @property (nonatomic, strong) NSDictionary *typeDict;
 @property (nonatomic, strong) PBCheckHeaderView *tableheaderView1;
@@ -77,6 +76,9 @@
 @property (nonatomic, assign) NSInteger personIndex;
 @property (nonatomic, assign) BOOL isSupervisor;//是否为监理人
 @property (nonatomic, assign) BOOL isQualified;//是否状态为已合格
+@property (nonatomic, strong) UICollectionView *collectionView;
+@property (strong, nonatomic) LBKeyWordLayout *layout;
+@property (strong, nonatomic) NSArray *items;
 @end
 
 @implementation PBAddExamineViewController
@@ -847,11 +849,6 @@
     [self hideDropDown];
 }
 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
-//    if ([NSStringFromClass([touch.view class]) isEqualToString:@"MSSAutoresizeLabelFlow"]) {
-//        return NO;
-//    } else {
-//        return YES;
-//    }
     if (touch.view == self.backgroundView) {
         return YES;
     } else {
@@ -864,36 +861,20 @@
         return;
     }
     [self.view addSubview:self.backgroundView];
-    [self.backgroundView addSubview:self.typeBackView];
-    [self.typeBackView circleViewWithRadius:6];
-    [self.typeBackView addSubview:self.typeListRecordV];
-    [UIView animateWithDuration:0.5 animations:^{
-        self.typeBackView.frame = CGRectMake(0, 0, PBScreenWidth, 176);
-        self.backgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
-    }completion:^(BOOL finished) {
-//        self->_isShow = YES;
-        
-    }];
+    [self.view addSubview:self.collectionView];
     self.typeListBtn.enabled = NO;
     self.navigationItem.leftBarButtonItem.enabled = NO;
 }
 - (void)hideDropDown{
-    [UIView animateWithDuration:0.5 animations:^{
-        self.typeBackView.frame = CGRectMake(0, -176, PBScreenWidth, 176);
-        self.backgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
-    }completion:^(BOOL finished) {
-        [self.backgroundView removeFromSuperview];
-        [self.typeBackView removeFromSuperview];
-        [self.typeListRecordV removeFromSuperview];
-//        self->_isShow = NO;
-    }];
+    [self.collectionView removeFromSuperview];
+    [self.backgroundView removeFromSuperview];
     self.typeListBtn.enabled = YES;
     self.navigationItem.leftBarButtonItem.enabled = YES;
 }
 - (UIView *)backgroundView {
     if (_backgroundView == nil) {
         _backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0 , 0, PBScreenWidth, self.view.height)];
-        _backgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
+        _backgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
         [_backgroundView setOpaque:NO];
         UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backTapped:)];
         tap.delegate = self;
@@ -901,30 +882,43 @@
     }
     return _backgroundView;
 }
-- (MSSAutoresizeLabelFlow *)typeListRecordV {
-    NSMutableArray *arrM = [[NSMutableArray alloc] init];
-    for (NSInteger i = 0; i < self.typeArr.count; i++) {
-        NSString *str = [self.typeArr[i] valueForKey:@"aedt_name"];
-        [arrM addObject:str];
+- (UICollectionView *)collectionView {
+    if (_collectionView == nil) {
+        NSMutableArray *arrM = [[NSMutableArray alloc] init];
+        for (NSInteger i = 0; i < self.typeArr.count; i++) {
+            NSString *str = [self.typeArr[i] valueForKey:@"aedt_name"];
+            [arrM addObject:str];
+        }
+        self.items = arrM.copy;
+        self.layout = [[LBKeyWordLayout alloc] init];
+        self.layout.estimatedItemSize = CGSizeMake(80, 30);
+        self.layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
+        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, PBScreenWidth, 200) collectionViewLayout:self.layout];
+        _collectionView.backgroundColor = [UIColor whiteColor];
+        [_collectionView registerClass:[KeyWordCell class] forCellWithReuseIdentifier:@"KeyWordCell"];
+        _collectionView.delegate = self;
+        _collectionView.dataSource = self;
     }
-    NSArray *array = arrM.copy;
-    if (_typeListRecordV == nil) {
-        _typeListRecordV = [[MSSAutoresizeLabelFlow alloc] initWithFrame:CGRectMake(0, 25, PBScreenWidth, 126) titles:array selectedHandler:^(NSUInteger index, NSString *title) {
-            self.typeDict = self.typeArr[index];
-            NSString *btnTitle = [NSString stringWithFormat:@"%@ ⋁",[self.typeDict valueForKey:@"aedt_name"]];
-            [self.typeListBtn setTitle:btnTitle forState:UIControlStateNormal];
-            [self hideDropDown];
-        }];
-    }
-    return _typeListRecordV;
+    return _collectionView;
 }
-- (UIView *)typeBackView {
-    if (_typeBackView == nil) {
-        _typeBackView = [[UIView alloc] initWithFrame:CGRectMake(0, -176, PBScreenWidth, 176)];
-        _typeBackView.backgroundColor = [UIColor whiteColor];
-    }
-    return _typeBackView;
+- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
+    return self.items.count;
 }
+
+- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
+    KeyWordCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"KeyWordCell" forIndexPath:indexPath];
+    cell.maxWidthConstraint.constant = CGRectGetWidth(collectionView.bounds) - self.layout.sectionInset.left - self.layout.sectionInset.right - cell.layoutMargins.left - cell.layoutMargins.right - 10;
+    cell.textLabel.numberOfLines = 1;
+    cell.textLabel.text = self.items[indexPath.row];
+    return cell;
+}
+- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
+    self.typeDict = self.typeArr[indexPath.row];
+    NSString *btnTitle = [NSString stringWithFormat:@"%@ ⋁",[self.typeDict valueForKey:@"aedt_name"]];
+    [self.typeListBtn setTitle:btnTitle forState:UIControlStateNormal];
+    [self hideDropDown];
+}
+
 - (NSMutableArray *)selectedPhotos {
     if (_selectedPhotos == nil) {
         _selectedPhotos = [[NSMutableArray alloc] init];

--
Gitblit v1.9.3