Commit 9b98c3f1eb7aa0201c3e7d70302b305b43508cdb

Authored by zhangxiaowen
1 parent e92c4edb

no message

CNLiveSettingModule/Classes/Privacy/CNLiveNotSeeCollectionViewCell.m
@@ -79,13 +79,13 @@ @@ -79,13 +79,13 @@
79 [self.avatarImage mas_makeConstraints:^(MASConstraintMaker *make) { 79 [self.avatarImage mas_makeConstraints:^(MASConstraintMaker *make) {
80 make.top.mas_equalTo(self.contentView).offset(15); 80 make.top.mas_equalTo(self.contentView).offset(15);
81 make.centerX.mas_equalTo(self.contentView); 81 make.centerX.mas_equalTo(self.contentView);
82 - make.size.mas_equalTo(CGSizeMake(50, 50)); 82 + make.size.mas_equalTo(CGSizeMake(45, 45));
83 }]; 83 }];
84 84
85 [self.delButton mas_makeConstraints:^(MASConstraintMaker *make) { 85 [self.delButton mas_makeConstraints:^(MASConstraintMaker *make) {
86 make.top.mas_equalTo(self.contentView).offset(2.5);; 86 make.top.mas_equalTo(self.contentView).offset(2.5);;
87 make.right.mas_equalTo(self.avatarImage.mas_left).offset(12.5); 87 make.right.mas_equalTo(self.avatarImage.mas_left).offset(12.5);
88 - make.size.mas_equalTo(CGSizeMake(25, 25)); 88 + make.size.mas_equalTo(CGSizeMake(30, 30));
89 }]; 89 }];
90 90
91 [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) { 91 [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -99,8 +99,9 @@ @@ -99,8 +99,9 @@
99 - (UIButton *)delButton{ 99 - (UIButton *)delButton{
100 if (!_delButton) { 100 if (!_delButton) {
101 _delButton = [UIButton buttonWithType:UIButtonTypeCustom]; 101 _delButton = [UIButton buttonWithType:UIButtonTypeCustom];
102 - [_delButton setImage:[UIImage imageNamed:@"privacy_edit_minus"] forState:UIControlStateNormal];  
103 - [_delButton addTarget:self action:@selector(clickedDelButton:) forControlEvents:UIControlEventTouchUpInside]; 102 + UIImage *image = [self getImageWithImageName:@"privacy_edit_minus" bundleName:@"CNLiveSettingModule" targetClass:[self class]];
  103 + [_delButton setImage:image forState:UIControlStateNormal];
  104 + [_delButton addTarget:self action:@selector(delButtonDidClicked:) forControlEvents:UIControlEventTouchUpInside];
104 [_delButton setHidden:YES]; 105 [_delButton setHidden:YES];
105 106
106 } 107 }
@@ -126,7 +127,7 @@ @@ -126,7 +127,7 @@
126 } 127 }
127 128
128 #pragma mark - Action Methods 129 #pragma mark - Action Methods
129 -- (void)clickedDelButton:(UIButton *)btn{ 130 +- (void)delButtonDidClicked:(UIButton *)btn{
130 if (self.delegate && [self.delegate respondsToSelector:@selector(clickedDelButton:)]) { 131 if (self.delegate && [self.delegate respondsToSelector:@selector(clickedDelButton:)]) {
131 [self.delegate clickedDelButton:self]; 132 [self.delegate clickedDelButton:self];
132 } 133 }
CNLiveSettingModule/Classes/Privacy/CNLiveNotSeeController.m
@@ -15,16 +15,20 @@ @@ -15,16 +15,20 @@
15 #import "CNLiveNetworking.h" 15 #import "CNLiveNetworking.h"
16 #import "CNLiveEnvironment.h" 16 #import "CNLiveEnvironment.h"
17 #import "CNUserInfoManager.h" 17 #import "CNUserInfoManager.h"
  18 +#import "CNLiveBaseKit.h"
18 19
  20 +#import "CNLiveNavigationBar.h"
19 #import "CNLiveNotSeeCollectionViewCell.h" 21 #import "CNLiveNotSeeCollectionViewCell.h"
20 #import "CNLiveNotSeeModel.h" 22 #import "CNLiveNotSeeModel.h"
21 23
  24 +
22 @interface CNLiveNotSeeController ()<UICollectionViewDelegate, UICollectionViewDataSource, CNLiveNotSeeCollectionViewCellDelegate>{ 25 @interface CNLiveNotSeeController ()<UICollectionViewDelegate, UICollectionViewDataSource, CNLiveNotSeeCollectionViewCellDelegate>{
23 BOOL _isEdit; 26 BOOL _isEdit;
24 } 27 }
25 -@property (nonatomic, strong) UIButton *rightBtn;  
26 -@property (nonatomic, strong) UIButton *leftBtn;  
27 -@property (weak, nonatomic) UICollectionView *collectionView; 28 +
  29 +@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
  30 +@property (nonatomic, strong) UICollectionView *collectionView;
  31 +
28 @property (nonatomic, strong) NSMutableArray *beforeData;//判断完成按钮是否可以点击 一直不改变 32 @property (nonatomic, strong) NSMutableArray *beforeData;//判断完成按钮是否可以点击 一直不改变
29 @property (nonatomic, strong) NSMutableArray *afterData;//随时改变的 33 @property (nonatomic, strong) NSMutableArray *afterData;//随时改变的
30 34
@@ -40,8 +44,8 @@ static const NSInteger margin = 10; @@ -40,8 +44,8 @@ static const NSInteger margin = 10;
40 44
41 static const NSInteger SectionHeight = 50; 45 static const NSInteger SectionHeight = 50;
42 46
43 -#pragma mark - Data  
44 -- (void)getData{ 47 +#pragma mark - 数据
  48 +- (void)loadData{
45 NSDictionary *params = @{@"sid":CNUserShareModel.uid}; 49 NSDictionary *params = @{@"sid":CNUserShareModel.uid};
46 [CNLiveNetworking setAllowRequestDefaultArgument:YES]; 50 [CNLiveNetworking setAllowRequestDefaultArgument:YES];
47 [QMUITips showLoadingInView:self.view]; 51 [QMUITips showLoadingInView:self.view];
@@ -73,7 +77,6 @@ static const NSInteger SectionHeight = 50; @@ -73,7 +77,6 @@ static const NSInteger SectionHeight = 50;
73 //减号 77 //减号
74 [self.beforeData addObject:self.minusModel]; 78 [self.beforeData addObject:self.minusModel];
75 [self.afterData addObject:self.minusModel]; 79 [self.afterData addObject:self.minusModel];
76 -  
77 } 80 }
78 81
79 } 82 }
@@ -82,60 +85,39 @@ static const NSInteger SectionHeight = 50; @@ -82,60 +85,39 @@ static const NSInteger SectionHeight = 50;
82 [self.beforeData addObject:self.addModel]; 85 [self.beforeData addObject:self.addModel];
83 [self.afterData addObject:self.addModel]; 86 [self.afterData addObject:self.addModel];
84 } 87 }
85 - self.title = self.afterData.count > 2?[NSString stringWithFormat:@"%@(%ld)",self.name,self.afterData.count-2]:self.name; 88 + self.navigationBar.title.text = self.afterData.count > 2?[NSString stringWithFormat:@"%@(%ld)",self.name,self.afterData.count-2]:self.name;
86 [self.collectionView reloadData]; 89 [self.collectionView reloadData];
87 90
88 }]; 91 }];
89 92
90 } 93 }
  94 +
  95 +#pragma mark - 生命周期
  96 +- (void)viewWillAppear:(BOOL)animated{
  97 + [super viewWillAppear:animated];
  98 + self.navigationController.navigationBarHidden = YES;
  99 +}
  100 +
91 - (void)viewDidLoad { 101 - (void)viewDidLoad {
92 [super viewDidLoad]; 102 [super viewDidLoad];
93 // Do any additional setup after loading the view. 103 // Do any additional setup after loading the view.
94 self.view.backgroundColor = [UIColor colorWithRed:244.0f/255.0f green:244.0f/255.0f blue:244.0f/255.0f alpha:1.0f]; 104 self.view.backgroundColor = [UIColor colorWithRed:244.0f/255.0f green:244.0f/255.0f blue:244.0f/255.0f alpha:1.0f];
95 _isEdit = NO; 105 _isEdit = NO;
96 - [self getData];  
97 - [self setupUI];  
98 -}  
99 -- (void)dealloc{  
100 - 106 + [self loadData];
  107 + [self createSubviews];
101 } 108 }
  109 +
102 #pragma mark - UI 110 #pragma mark - UI
103 -- (void)setupUI{  
104 - UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:self.leftBtn];  
105 - self.navigationItem.leftBarButtonItem = leftItem;  
106 -  
107 - UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:self.rightBtn];  
108 - self.navigationItem.rightBarButtonItem = rightItem;  
109 -  
110 - UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];  
111 - [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];  
112 -  
113 - //设置CollectionView的属性  
114 - UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];  
115 - collectionView.delegate = self;  
116 - collectionView.dataSource = self;  
117 - collectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);  
118 - collectionView.backgroundColor = [UIColor whiteColor];  
119 -  
120 - collectionView.showsVerticalScrollIndicator = NO;  
121 - collectionView.showsHorizontalScrollIndicator = NO;  
122 - [collectionView registerClass:[CNLiveNotSeeCollectionViewCell class] forCellWithReuseIdentifier:kCNLiveNotSeeCollectionViewCell];  
123 - [collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"UICollectionElementKindSectionHeader"];  
124 - flowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, 0.0000001);  
125 -  
126 - [collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"UICollectionElementKindSectionFooter"];  
127 - flowLayout.footerReferenceSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT);  
128 -  
129 - [self.view addSubview:collectionView];  
130 - _collectionView = collectionView;  
131 - 111 +- (void)createSubviews{
  112 + [self.view addSubview:self.navigationBar];
  113 + [self.view addSubview:self.collectionView];
132 } 114 }
133 115
134 - (void)viewDidLayoutSubviews { 116 - (void)viewDidLayoutSubviews {
135 [super viewDidLayoutSubviews]; 117 [super viewDidLayoutSubviews];
136 [_collectionView mas_remakeConstraints:^(MASConstraintMaker *make) { 118 [_collectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
137 make.left.right.equalTo(self.view); 119 make.left.right.equalTo(self.view);
138 - make.top.equalTo(self.view).offset(NavigationBarHeight); 120 + make.top.equalTo(self.view).offset(NavigationContentTop);
139 make.height.mas_equalTo([self calculateHeight]); 121 make.height.mas_equalTo([self calculateHeight]);
140 122
141 }]; 123 }];
@@ -188,15 +170,13 @@ static const NSInteger SectionHeight = 50; @@ -188,15 +170,13 @@ static const NSInteger SectionHeight = 50;
188 text.text = _type == CNTypeNoLetHimSee?@"把通讯录的某个朋友放到这里,生活圈可见范围发照片他(她)将无法看到。":@"把通讯录的某个朋友放到这里,该朋友更新的照片将不会在你的生活圈中出现。"; 170 text.text = _type == CNTypeNoLetHimSee?@"把通讯录的某个朋友放到这里,生活圈可见范围发照片他(她)将无法看到。":@"把通讯录的某个朋友放到这里,该朋友更新的照片将不会在你的生活圈中出现。";
189 171
190 text.font = UIFontMake(12.0); 172 text.font = UIFontMake(12.0);
191 -// text.textColor = CNLiveColorWithHexString(@"999999"); 173 + text.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
192 text.lineBreakMode = NSLineBreakByCharWrapping; 174 text.lineBreakMode = NSLineBreakByCharWrapping;
193 text.numberOfLines = 0; 175 text.numberOfLines = 0;
194 - text.textAlignment = NSTextAlignmentCenter;  
195 [footerView addSubview:text]; 176 [footerView addSubview:text];
196 return footerView; 177 return footerView;
197 } 178 }
198 179
199 -  
200 } 180 }
201 181
202 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ 182 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
@@ -244,10 +224,10 @@ static const NSInteger SectionHeight = 50; @@ -244,10 +224,10 @@ static const NSInteger SectionHeight = 50;
244 224
245 self.title = self.afterData.count > 2?[NSString stringWithFormat:@"%@(%ld)",self.name,self.afterData.count-2]:self.name; 225 self.title = self.afterData.count > 2?[NSString stringWithFormat:@"%@(%ld)",self.name,self.afterData.count-2]:self.name;
246 //判断完成按钮是否可以点击 226 //判断完成按钮是否可以点击
247 - _rightBtn.userInteractionEnabled = ![self array:self.beforeData isEqualTo:self.afterData];  
248 - _rightBtn.selected = _rightBtn.userInteractionEnabled; 227 + _navigationBar.right.userInteractionEnabled = ![self array:self.beforeData isEqualTo:self.afterData];
  228 + _navigationBar.right.selected = _navigationBar.right.userInteractionEnabled;
249 229
250 -// _collectionView.height = [self calculateHeight]; 230 + _collectionView.height = [self calculateHeight];
251 [self.collectionView reloadData]; 231 [self.collectionView reloadData];
252 232
253 } 233 }
@@ -308,7 +288,7 @@ static const NSInteger SectionHeight = 50; @@ -308,7 +288,7 @@ static const NSInteger SectionHeight = 50;
308 // 288 //
309 //} 289 //}
310 290
311 -#pragma mark - Private Methods 291 +#pragma mark - 私有方法
312 //数组相等 292 //数组相等
313 - (BOOL)array:(NSArray *)array1 isEqualTo:(NSArray *)array2 { 293 - (BOOL)array:(NSArray *)array1 isEqualTo:(NSArray *)array2 {
314 if (array1 == array2) { 294 if (array1 == array2) {
@@ -350,19 +330,20 @@ static const NSInteger SectionHeight = 50; @@ -350,19 +330,20 @@ static const NSInteger SectionHeight = 50;
350 return isEqual; 330 return isEqual;
351 331
352 } 332 }
  333 +
353 - (CGFloat)calculateHeight{ 334 - (CGFloat)calculateHeight{
354 NSInteger count = (SCREEN_WIDTH-2*margin)/CellWidth; 335 NSInteger count = (SCREEN_WIDTH-2*margin)/CellWidth;
355 NSInteger row = ceilf(self.afterData.count*1.0/count); 336 NSInteger row = ceilf(self.afterData.count*1.0/count);
356 CGFloat height = (row*(CellHeight)+SectionHeight) > (SCREEN_HEIGHT-NavigationBarHeight) ? (SCREEN_HEIGHT-NavigationBarHeight):(row*(CellHeight)+SectionHeight); 337 CGFloat height = (row*(CellHeight)+SectionHeight) > (SCREEN_HEIGHT-NavigationBarHeight) ? (SCREEN_HEIGHT-NavigationBarHeight):(row*(CellHeight)+SectionHeight);
357 return height; 338 return height;
358 } 339 }
  340 +
359 //改变编辑状态 341 //改变编辑状态
360 - (void)changeEditState{ 342 - (void)changeEditState{
361 _isEdit = !_isEdit; 343 _isEdit = !_isEdit;
362 for (int i = 0; i < self.afterData.count; i++){ 344 for (int i = 0; i < self.afterData.count; i++){
363 CNLiveNotSeeModel *model = self.afterData[i]; 345 CNLiveNotSeeModel *model = self.afterData[i];
364 model.isEdit = model.type == CNLiveNotSeeModelTypeDefault&&_isEdit? @"1":@"0"; 346 model.isEdit = model.type == CNLiveNotSeeModelTypeDefault&&_isEdit? @"1":@"0";
365 -  
366 } 347 }
367 [self.collectionView reloadData]; 348 [self.collectionView reloadData];
368 } 349 }
@@ -395,41 +376,6 @@ static const NSInteger SectionHeight = 50; @@ -395,41 +376,6 @@ static const NSInteger SectionHeight = 50;
395 376
396 } 377 }
397 378
398 -#pragma mark - Action Methods  
399 -// 点击完成按钮事件-发送请求  
400 -- (void)clickedCompleteButton:(UIButton *)btn{  
401 - btn.userInteractionEnabled = NO;  
402 - [self sendAddDataBlock:^(NSString *isSuccess) {  
403 - if([isSuccess isEqualToString:@"1"]){  
404 - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{  
405 - [self.navigationController popViewControllerAnimated:YES];  
406 - });  
407 - }  
408 - btn.userInteractionEnabled = YES;  
409 -  
410 - }];  
411 -  
412 -}  
413 -  
414 -// 点击取消按钮事件  
415 -- (void)clickedCloseButton:(UIButton *)btn {  
416 - if([self array:self.beforeData isEqualTo:self.afterData]){  
417 - [self.navigationController popViewControllerAnimated:YES];  
418 - return;  
419 -  
420 - }  
421 - UIAlertController *actionAlert1 = [UIAlertController alertControllerWithTitle:@"确认放弃修改吗?" message:nil preferredStyle:UIAlertControllerStyleAlert];  
422 - UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:NULL];  
423 - UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {  
424 - [self.navigationController popViewControllerAnimated:YES];  
425 - }];  
426 -// [action1 setValue:CNLiveColorWithHexString(@"23D41E") forKey:@"_titleTextColor"];  
427 -// [action2 setValue:CNLiveColorWithHexString(@"23D41E") forKey:@"_titleTextColor"];  
428 - [actionAlert1 addAction:action1];  
429 - [actionAlert1 addAction:action2];  
430 - [self presentViewController:actionAlert1 animated:YES completion:nil];  
431 -  
432 -}  
433 /* 379 /*
434 #pragma mark - Navigation 380 #pragma mark - Navigation
435 381
@@ -439,7 +385,8 @@ static const NSInteger SectionHeight = 50; @@ -439,7 +385,8 @@ static const NSInteger SectionHeight = 50;
439 // Pass the selected object to the new view controller. 385 // Pass the selected object to the new view controller.
440 } 386 }
441 */ 387 */
442 -#pragma mark - Lazy Laoding 388 +
  389 +#pragma mark - 懒加载
443 - (NSMutableArray *)beforeData{ 390 - (NSMutableArray *)beforeData{
444 if (!_beforeData) { 391 if (!_beforeData) {
445 _beforeData = [[NSMutableArray alloc] init]; 392 _beforeData = [[NSMutableArray alloc] init];
@@ -454,37 +401,6 @@ static const NSInteger SectionHeight = 50; @@ -454,37 +401,6 @@ static const NSInteger SectionHeight = 50;
454 return _afterData; 401 return _afterData;
455 } 402 }
456 403
457 -- (UIButton *)rightBtn {  
458 - if (!_rightBtn) {  
459 - _rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];  
460 - _rightBtn.frame = CGRectMake(0, 0, 60, 30);  
461 - [_rightBtn setTitle:@"完成" forState:UIControlStateNormal];  
462 - _rightBtn.titleLabel.font = UIFontMake(14.0);  
463 - [_rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];  
464 -// [_rightBtn setBackgroundImage:[UIImage imageWithColor:CNLiveColorWithHexString(@"23D41E")] forState:UIControlStateSelected];  
465 -// [_rightBtn setBackgroundImage:[UIImage imageWithColor:CNLiveColorWithHexString(@"9BF4A4")] forState:UIControlStateNormal];  
466 - [_rightBtn addTarget:self action:@selector(clickedCompleteButton:) forControlEvents:UIControlEventTouchUpInside];  
467 - _rightBtn.layer.masksToBounds = YES;  
468 - _rightBtn.layer.cornerRadius = 15;  
469 - _rightBtn.userInteractionEnabled = NO;  
470 - _rightBtn.selected = NO;  
471 -  
472 - }  
473 - return _rightBtn;  
474 -}  
475 -  
476 -- (UIButton *)leftBtn {  
477 - if (!_leftBtn) {  
478 - _leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];  
479 - [_leftBtn setTitle:@"取消" forState:UIControlStateNormal];  
480 - _leftBtn.frame = CGRectMake(0, 0, 60, 30);  
481 - _leftBtn.titleLabel.font = UIFontMake(15.0);  
482 - [_leftBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];  
483 - [_leftBtn addTarget:self action:@selector(clickedCloseButton:) forControlEvents:UIControlEventTouchUpInside];  
484 - _leftBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;  
485 - }  
486 - return _leftBtn;  
487 -}  
488 - (CNLiveNotSeeModel *)addModel{ 404 - (CNLiveNotSeeModel *)addModel{
489 if (!_addModel) { 405 if (!_addModel) {
490 //加号 406 //加号
@@ -505,9 +421,93 @@ static const NSInteger SectionHeight = 50; @@ -505,9 +421,93 @@ static const NSInteger SectionHeight = 50;
505 } 421 }
506 return _minusModel; 422 return _minusModel;
507 } 423 }
508 -- (UIImage *)navigationBarBackgroundImage {  
509 -// return [UIImage imageWithColor:CNLiveColorWithHexString(@"F4F4F4")];  
510 - return nil; 424 +
  425 +- (CNLiveNavigationBar *)navigationBar {
  426 + if (!_navigationBar) {
  427 + _navigationBar = [CNLiveNavigationBar navigationBar];
  428 + _navigationBar.backgroundColor = [UIColor colorWithRed:244.0f/255.0f green:244.0f/255.0f blue:244.0f/255.0f alpha:1.0f];
  429 +
  430 + // 左按钮
  431 + _navigationBar.leftTitle = @"取消";
  432 + [_navigationBar.left setImage:nil forState:UIControlStateNormal];
  433 + _navigationBar.left.titleLabel.font = [UIFont systemFontOfSize:15.0];
  434 +
  435 + // 右按钮
  436 + CGFloat width = 50;
  437 + CGFloat height = 24;
  438 +
  439 + _navigationBar.right.frame = CGRectMake(SCREEN_WIDTH-width-margin, StatusBarHeight+(NavigationBarHeight-height)/2.0, width, height);
  440 + _navigationBar.right.layer.masksToBounds = YES;
  441 + _navigationBar.right.layer.cornerRadius = 5;
  442 + _navigationBar.right.titleLabel.font = [UIFont systemFontOfSize:15.0];
  443 + _navigationBar.rightTitle = @"完成";
  444 + _navigationBar.right.backgroundColor = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  445 +
  446 + [_navigationBar.right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  447 + [_navigationBar.right setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
  448 +
  449 + __weak typeof(self) weakSelf = self;
  450 + _navigationBar.onClickLeftButton = ^{
  451 + __strong typeof(weakSelf) strongSelf = weakSelf;
  452 + if(!strongSelf) return ;
  453 + if([strongSelf array:strongSelf.beforeData isEqualTo:strongSelf.afterData]){
  454 + [strongSelf.navigationController popViewControllerAnimated:YES];
  455 + return;
  456 +
  457 + }
  458 + UIAlertController *actionAlert1 = [UIAlertController alertControllerWithTitle:@"确认放弃修改吗?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  459 + UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:NULL];
  460 + UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  461 + [strongSelf.navigationController popViewControllerAnimated:YES];
  462 + }];
  463 + [actionAlert1 addAction:action1];
  464 + [actionAlert1 addAction:action2];
  465 + [strongSelf presentViewController:actionAlert1 animated:YES completion:nil];
  466 +
  467 +
  468 + };
  469 + _navigationBar.onClickRightButton = ^{
  470 + __strong typeof(weakSelf) strongSelf = weakSelf;
  471 + if(!strongSelf) return ;
  472 + strongSelf.navigationBar.right.userInteractionEnabled = NO;
  473 + [strongSelf sendAddDataBlock:^(NSString *isSuccess) {
  474 + if([isSuccess isEqualToString:@"1"]){
  475 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  476 + [strongSelf.navigationController popViewControllerAnimated:YES];
  477 + });
  478 + }
  479 + strongSelf.navigationBar.right.userInteractionEnabled = YES;
  480 +
  481 + }];
  482 +
  483 + };
  484 + }
  485 + return _navigationBar;
  486 +}
  487 +
  488 +- (UICollectionView *)collectionView{
  489 + if(!_collectionView){
  490 + UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  491 + [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
  492 +
  493 + //设置CollectionView的属性
  494 + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
  495 + _collectionView.scrollEnabled = NO;
  496 + _collectionView.delegate = self;
  497 + _collectionView.dataSource = self;
  498 + _collectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
  499 + _collectionView.backgroundColor = [UIColor whiteColor];
  500 +
  501 + _collectionView.showsVerticalScrollIndicator = NO;
  502 + _collectionView.showsHorizontalScrollIndicator = NO;
  503 + [_collectionView registerClass:[CNLiveNotSeeCollectionViewCell class] forCellWithReuseIdentifier:kCNLiveNotSeeCollectionViewCell];
  504 + [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"UICollectionElementKindSectionHeader"];
  505 + flowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, 0.0000001);
  506 +
  507 + [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"UICollectionElementKindSectionFooter"];
  508 + flowLayout.footerReferenceSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT);
  509 + }
  510 + return _collectionView;
511 } 511 }
512 512
513 @end 513 @end
CNLiveSettingModule/Classes/Privacy/CNLivePrivacyContactCell.h deleted 100644 → 0
1 -//  
2 -// CNLivePrivacyContactCell.h  
3 -// CNLiveSettingModule  
4 -//  
5 -// Created by CNLive-zxw on 2019/4/24.  
6 -// Copyright © 2019 cnlive. All rights reserved.  
7 -//  
8 -  
9 -#import <UIKit/UIKit.h>  
10 -  
11 -NS_ASSUME_NONNULL_BEGIN  
12 -@class IMAUser;  
13 -  
14 -@protocol CNLivePrivacyContactCellDelegate <NSObject>  
15 -- (void)onPickAction:(IMAUser *)user;  
16 -  
17 -@end  
18 -  
19 -@interface CNLivePrivacyContactCell : UITableViewCell  
20 -@property (nonatomic, strong) UIButton *selectBtn;  
21 -@property (nonatomic, strong) IMAUser *user;  
22 -@property (nonatomic, assign) id<CNLivePrivacyContactCellDelegate> delegate;  
23 -  
24 -+ (instancetype)cellWithTableView:(UITableView *)tableView;  
25 -- (void)onPick;  
26 -  
27 -@end  
28 -  
29 -  
30 -  
31 -@interface CNLivePrivacyGroupCell : UITableViewCell  
32 -+ (instancetype)cellWithTableView:(UITableView *)tableView;  
33 -  
34 -@end  
35 -  
36 -NS_ASSUME_NONNULL_END  
CNLiveSettingModule/Classes/Privacy/CNLivePrivacyContactCell.m deleted 100644 → 0
1 -//  
2 -// CNLivePrivacyContactCell.m  
3 -// CNLiveSettingModule  
4 -//  
5 -// Created by CNLive-zxw on 2019/4/24.  
6 -// Copyright © 2019 cnlive. All rights reserved.  
7 -//  
8 -  
9 -#import "CNLivePrivacyContactCell.h"  
10 -#import <Masonry/Masonry.h>  
11 -#import "QMUIKit.h"  
12 -#import "CNLiveCategory.h"  
13 -  
14 -@interface CNLivePrivacyContactCell ()  
15 -@property (nonatomic, strong) UIImageView *iconImage;  
16 -@property (nonatomic, strong) UILabel *nickLabel;  
17 -  
18 -@end  
19 -  
20 -@implementation CNLivePrivacyContactCell  
21 -#pragma mark - Init  
22 -+ (instancetype)cellWithTableView:(UITableView *)tableView {  
23 - static NSString *indentify = @"CNLivePrivacyContactCell";  
24 - CNLivePrivacyContactCell *cell = [tableView dequeueReusableCellWithIdentifier:indentify];  
25 - if (!cell) {  
26 - cell = [[CNLivePrivacyContactCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentify];  
27 - }  
28 - return cell;  
29 -  
30 -}  
31 -  
32 -- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {  
33 - self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];  
34 - if (self) {  
35 - self.backgroundColor = [UIColor whiteColor];  
36 - [self.contentView addSubview:self.selectBtn];  
37 - [self.contentView addSubview:self.iconImage];  
38 - [self.contentView addSubview:self.nickLabel];  
39 - [self xw_layoutSubviews];  
40 -  
41 - }  
42 - return self;  
43 -}  
44 -  
45 -#pragma mark - Data  
46 -//- (void)setUser:(IMAUser *)user {  
47 -// _user = user;  
48 -// _selectBtn.selected = user.isSelected;  
49 -//  
50 -// [_iconImage sd_setImageWithURL:[NSURL URLWithString:user.icon] placeholderImage:kDefaultUserIcon];  
51 -// _nickLabel.text = [user showTitle];  
52 -//  
53 -// if (!_selectBtn.enabled) {  
54 -// [_selectBtn setBackgroundImage:[UIImage imageNamed:@"privacy_edit_no"] forState:UIControlStateNormal];  
55 -// }  
56 -// else{  
57 -// [_selectBtn setBackgroundImage:[UIImage imageNamed:@"privacy_sel_no"] forState:UIControlStateNormal];  
58 -//  
59 -// }  
60 -//  
61 -//}  
62 -  
63 -#pragma mark - Action  
64 -- (void)onPick {  
65 - [self onPicked:_selectBtn];  
66 -}  
67 -  
68 -- (void)onPicked:(UIButton *)btn {  
69 -// btn.selected = !btn.selected;  
70 -// _user.isSelected = btn.selected;  
71 -//  
72 -// if (self.delegate && [self.delegate respondsToSelector:@selector(onPickAction:)]) {  
73 -// [self.delegate onPickAction:_user];  
74 -// }  
75 -  
76 -}  
77 -  
78 -#pragma mark - Layout  
79 -- (void)xw_layoutSubviews {  
80 - [self.selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {  
81 - make.left.mas_equalTo(self.contentView).mas_offset(20);  
82 - make.centerY.mas_equalTo(self.contentView);  
83 - make.size.mas_equalTo(CGSizeMake(20, 20));  
84 - }];  
85 -  
86 - [self.iconImage mas_makeConstraints:^(MASConstraintMaker *make) {  
87 - make.left.mas_equalTo(self.selectBtn.mas_right).mas_offset(20);  
88 - make.centerY.mas_equalTo(self.contentView);  
89 - make.size.mas_equalTo(CGSizeMake(40, 40));  
90 - }];  
91 -  
92 - [self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {  
93 - make.left.mas_equalTo(self.iconImage.mas_right).mas_offset(10);  
94 - make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10);  
95 - make.centerY.mas_equalTo(self.selectBtn.mas_centerY);  
96 - }];  
97 -  
98 -}  
99 -  
100 -#pragma mark - Getter  
101 -- (UIButton *)selectBtn {  
102 - if (!_selectBtn) {  
103 - _selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];  
104 - [_selectBtn setBackgroundImage:[UIImage imageNamed:@"privacy_sel_no"] forState:UIControlStateNormal];  
105 - [_selectBtn setBackgroundImage:[UIImage imageNamed:@"privacy_sel_yes"] forState:UIControlStateSelected];  
106 - [_selectBtn addTarget:self action:@selector(onPicked:) forControlEvents:UIControlEventTouchUpInside];  
107 - }  
108 - return _selectBtn;  
109 -}  
110 -  
111 -- (UIImageView *)iconImage {  
112 - if (!_iconImage) {  
113 - _iconImage = [[UIImageView alloc] init];  
114 - }  
115 - return _iconImage;  
116 -}  
117 -  
118 -- (UILabel *)nickLabel {  
119 - if (!_nickLabel) {  
120 - _nickLabel = [[UILabel alloc] init];  
121 - _nickLabel.textColor = [UIColor blackColor];  
122 - _nickLabel.font = UIFontMake(17.0);  
123 - }  
124 - return _nickLabel;  
125 -}  
126 -  
127 -- (void)awakeFromNib {  
128 - [super awakeFromNib];  
129 - // Initialization code  
130 -}  
131 -  
132 -- (void)setSelected:(BOOL)selected animated:(BOOL)animated {  
133 - [super setSelected:selected animated:animated];  
134 - // Configure the view for the selected state  
135 -}  
136 -  
137 -@end  
138 -  
139 -@interface CNLivePrivacyGroupCell ()  
140 -@property (nonatomic, strong) UILabel *titleLabel;  
141 -@property (nonatomic, strong) UIImageView *moreImage;  
142 -  
143 -@end  
144 -  
145 -@implementation CNLivePrivacyGroupCell  
146 -+ (instancetype)cellWithTableView:(UITableView *)tableView {  
147 -  
148 - static NSString *indentify = @"CNLivePrivacyGroupCell";  
149 -  
150 - CNLivePrivacyGroupCell *cell = [tableView dequeueReusableCellWithIdentifier:indentify];  
151 - if (!cell) {  
152 - cell = [[CNLivePrivacyGroupCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentify];  
153 - }  
154 - return cell;  
155 -  
156 -}  
157 -  
158 -- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {  
159 - self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];  
160 - if (self) {  
161 - self.backgroundColor = [UIColor whiteColor];  
162 - [self.contentView addSubview:self.titleLabel];  
163 - [self.contentView addSubview:self.moreImage];  
164 - [self xw_layoutSubviews];  
165 - }  
166 - return self;  
167 -}  
168 -  
169 -- (void)xw_layoutSubviews {  
170 - [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {  
171 - make.left.mas_equalTo(self.contentView).mas_offset(20);  
172 - make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-30);  
173 - make.top.mas_equalTo(self.contentView).mas_offset(20);  
174 - }];  
175 -  
176 - [self.moreImage mas_makeConstraints:^(MASConstraintMaker *make) {  
177 - make.size.mas_equalTo(CGSizeMake(7, 14));  
178 - make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10);  
179 - make.centerY.mas_equalTo(self.titleLabel.mas_centerY);  
180 - }];  
181 -  
182 -}  
183 -  
184 -#pragma mark - Getter  
185 -- (UILabel *)titleLabel {  
186 - if (!_titleLabel) {  
187 - _titleLabel = [[UILabel alloc] init];  
188 - _titleLabel.text = @"选择一个群";  
189 - _titleLabel.textColor = [UIColor blackColor];  
190 - _titleLabel.font = UIFontMake(17.0);  
191 - }  
192 - return _titleLabel;  
193 -}  
194 -  
195 -- (UIImageView *)moreImage {  
196 - if (!_moreImage) {  
197 - UIImage *xw_image = [self getImageWithImageName:@"mine_info_front" bundleName:@"CNLiveSettingModule" targetClass:[CNLivePrivacyContactCell class]];  
198 - _moreImage = [[UIImageView alloc] initWithImage:xw_image];  
199 - }  
200 - return _moreImage;  
201 -}  
202 -  
203 -@end