IVTUserInfoCenterViewController.m
31.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
//
// IVTUserInfoCenterViewController.m
// IVTMeLiveTwo
//
// Created by XRG on 16/8/25.
// Copyright © 2016年 QLQ. All rights reserved.
//
#import "IVTUserInfoCenterViewController.h"
#import "IVTMyLiveCollectionViewCell.h"
#import "NameSexLevelView.h"
#import "IVTMyContributionListViewController.h"
#import "IVTMyChatContentListViewController.h"
#import "IVTKSYDianBoViewController.h"
static NSString *cellIdentifier = @"UICollectionViewCell";
@interface IVTUserInfoCenterViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
{
BOOL isMyself;
UIScrollView *myScrollView;
UIView *headerView;
UIImageView *userIcon;
NameSexLevelView *nameSexLevelView;
UILabel *meNumberLabel;
UILabel *signLabel;
UILabel *followLabel;
UILabel *fansLabel;
UILabel *likeLabel;
UILabel *liveLabel;
UIImageView *imgFirst;
UIImageView *imgSecond;
UIImageView *imgThird;
UICollectionView *userLiveCollectionView;
UIView *bottomView;
UIButton *guanZhuButton;
UIButton *laHei;
NSInteger laHeiId;
NSDictionary *userInfoDict;
BOOL isFollowed;
NSArray *myLiveListArray;
}
@end
@implementation IVTUserInfoCenterViewController
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
myScrollView.contentInset = UIEdgeInsetsZero;
myScrollView.scrollIndicatorInsets = UIEdgeInsetsZero;
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.navigationController.navigationBarHidden = NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setNavigationBar];
isMyself = ([[IVTAccountTool getUserId] integerValue] == [self.userId integerValue]);
[self initUI];
[self requestUserInfo];
if (isMyself) {
myLiveListArray = [IVTAccountTool getMyLiveListArray];
if (myLiveListArray.count == 0) {
[IVTAccountTool getMyLiveListRequestSuccess:^(NSArray *myLiveList) {
myLiveListArray = myLiveList;
[userLiveCollectionView reloadData];
} error:^(NSDictionary *successData) {
} failure:^(NSError *failureError) {
}];
}
}
else{
[self requestIsLaHei];
[self requestUserLiveList];
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doChangeFollowStatus) name:@"followedChanged" object:nil];
}
- (void)doChangeFollowStatus{
isFollowed = [IVTAccountTool isFollowedToUserId:self.userId];
if (!isFollowed) {
[guanZhuButton setTitle:@"添加关注" forState:UIControlStateNormal];
}
else{
[guanZhuButton setTitle:@"已关注" forState:UIControlStateNormal];
}
}
- (void)setNavigationBar{
self.navigationItem.title = @"个人中心";
}
- (void)initUI{
__unsafe_unretained typeof (self) wself = self;
myScrollView = [[UIScrollView alloc]init];
[self.view addSubview:myScrollView];
[myScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(wself.view.mas_top);
make.right.equalTo(wself.view.mas_right);
if (isMyself) {
make.bottom.equalTo(wself.view.mas_bottom);
}
else{
make.bottom.equalTo(wself.view.mas_bottom).offset(-50);
}
make.left.equalTo(wself.view.mas_left);
}];
[self layoutSubViewsForScrollView];
if (!isMyself) {
//底部View
bottomView = [[UIView alloc]init];
[self.view addSubview:bottomView];
bottomView.backgroundColor = [UIColor whiteColor];
[bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(wself.view.mas_bottom);
make.left.equalTo(wself.view.mas_left);
make.right.equalTo(wself.view.mas_right);
make.height.mas_equalTo(50);
}];
[self layoutSubViewsForBottomView];
}
}
- (void)layoutSubViewsForScrollView{
headerView = [[UIView alloc]init];
headerView.backgroundColor = UIColorFromRGBAlphaHex(0xf6f6f6, 1.0);
[myScrollView addSubview:headerView];
[headerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(myScrollView.mas_top);
make.left.equalTo(myScrollView.mas_left);
make.right.equalTo(myScrollView.mas_right);
make.width.equalTo(myScrollView.mas_width);
make.height.mas_equalTo(365);
}];
[self layoutSubViewForHeaderView];
UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
flowLayout.minimumLineSpacing = 3;
flowLayout.minimumInteritemSpacing = 1;
userLiveCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, 0, 0) collectionViewLayout:flowLayout];
userLiveCollectionView.dataSource=self;
userLiveCollectionView.delegate=self;
userLiveCollectionView.collectionViewLayout = flowLayout;
[userLiveCollectionView setBackgroundColor:[UIColor clearColor]];
//注册Cell,必须要有
[userLiveCollectionView registerClass:[IVTMyLiveCollectionViewCell class] forCellWithReuseIdentifier:cellIdentifier];
[myScrollView addSubview:userLiveCollectionView];
[userLiveCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(myScrollView.mas_left);
make.right.equalTo(myScrollView.mas_right);
make.width.equalTo(myScrollView.mas_width);
make.top.equalTo(headerView.mas_bottom);
if (isMyself) {
make.height.mas_equalTo(kScreenHeight - 365);
}
else{
make.height.mas_equalTo(kScreenHeight - 365 - 50);
}
}];
}
- (void)layoutSubViewForHeaderView{
//用户信息
UIImageView *headerBackView = [[UIImageView alloc] init];
headerBackView.userInteractionEnabled = YES;
headerBackView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"头像背景图片"]];
[headerView addSubview:headerBackView];
[headerBackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(headerView.mas_left);
make.top.equalTo(headerView.mas_top);
make.right.equalTo(headerView.mas_right);
make.height.mas_equalTo(215);
}];
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[backBtn setImage:[UIImage imageNamed:@"返回键"] forState:UIControlStateNormal];
[backBtn setImageEdgeInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
[backBtn addTarget:self action:@selector(tapBack) forControlEvents:UIControlEventTouchUpInside];
[headerBackView addSubview:backBtn];
[backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(headerBackView).offset(18);
make.left.equalTo(headerBackView);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
// 用户头像
userIcon = [[UIImageView alloc]init];
userIcon.image = [UIImage imageNamed:@"占位头像"];
userIcon.clipsToBounds = YES;
userIcon.layer.cornerRadius = 70/2;
[headerBackView addSubview:userIcon];
[userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(headerBackView).offset(63);
make.centerX.equalTo(headerBackView.mas_centerX);
make.size.mas_equalTo(CGSizeMake(70, 70));
}];
nameSexLevelView = [[NameSexLevelView alloc]init];
nameSexLevelView.userNickNameColor = [UIColor whiteColor];
[headerBackView addSubview:nameSexLevelView];
[nameSexLevelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(userIcon.mas_bottom).offset(10);
make.centerX.equalTo(headerBackView.mas_centerX);
make.width.mas_equalTo(50);
make.height.mas_equalTo(18);
}];
meNumberLabel = [[UILabel alloc] init];
meNumberLabel.backgroundColor = [UIColor clearColor];
meNumberLabel.alpha = 0.7f;
meNumberLabel.font = [UIFont IVTH5Font];
meNumberLabel.textAlignment = NSTextAlignmentCenter;
meNumberLabel.textColor = [UIColor YXColorWithHexCode:@"#B4B4B4"];
[headerBackView addSubview:meNumberLabel];
[meNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(nameSexLevelView.mas_bottom).offset(5);
make.centerX.equalTo(headerBackView.mas_centerX);
make.size.mas_equalTo(CGSizeMake(180, 15));
}];
signLabel = [[UILabel alloc] init];
signLabel.backgroundColor = [UIColor clearColor];
signLabel.font = [UIFont YXFontOfSize:12];
signLabel.textAlignment = NSTextAlignmentCenter;
signLabel.textColor = [UIColor YXColorWithHexCode:@"#B4B4B4"];
[headerBackView addSubview:signLabel];
[signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(meNumberLabel.mas_bottom).offset(5);
make.centerX.equalTo(headerBackView.mas_centerX);
make.size.mas_equalTo(CGSizeMake(180, 15));
}];
//关注、粉丝、送出、收到
UIView *numberBackView = [[UIView alloc] init];
// numberBackView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"关注数量等--背景条"]];
numberBackView.backgroundColor = [UIColor blackColor];
numberBackView.alpha = 0.7;
[headerView addSubview:numberBackView];
[numberBackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(headerBackView.mas_bottom).offset(0);
make.left.equalTo(headerView.mas_left).offset(0);
make.size.mas_equalTo(CGSizeMake(kScreenWidth, 50));
}];
UIButton *follow = [UIButton buttonWithType: UIButtonTypeCustom];
follow.backgroundColor = [UIColor clearColor];
[follow setTitle:@"关注" forState:UIControlStateNormal];
[follow setTitleColor:[UIColor IVTAssistColor] forState:UIControlStateNormal];
[follow setTitleEdgeInsets:UIEdgeInsetsMake(20, 0, 0, 0)];
follow.titleLabel.font =[UIFont IVTH5Font];
[numberBackView addSubview:follow];
[follow mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kScreenWidth/4, 50));
make.left.equalTo(numberBackView.mas_left);
make.top.equalTo(numberBackView.mas_top);
}];
followLabel = [[UILabel alloc]init];
followLabel.textAlignment = NSTextAlignmentCenter;
followLabel.textColor = [UIColor whiteColor];
followLabel.font = [UIFont YXFontOfSize:14];
[follow addSubview:followLabel];
[followLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kScreenWidth/4, 30));
make.left.equalTo(follow.mas_left);
make.top.equalTo(follow.mas_top);
}];
UIImageView *lineV1 = [[UIImageView alloc] init];
lineV1.backgroundColor = [UIColor YXColorWithHexCode:@"#dcdcdc"];
[numberBackView addSubview:lineV1];
[lineV1 mas_makeConstraints:^(MASConstraintMaker* make) {
make.top.equalTo(numberBackView.mas_top).with.offset(14);
make.left.equalTo(follow.mas_right);
make.height.equalTo(@(25));
make.width.equalTo(@(0.5));
}];
UIButton *fans = [UIButton buttonWithType: UIButtonTypeCustom];
[fans setTitle:@"粉丝" forState:UIControlStateNormal];
[fans setTitleColor:[UIColor IVTAssistColor] forState:UIControlStateNormal];
[fans setTitleEdgeInsets:UIEdgeInsetsMake(20, 0, 0, 0)];
fans.titleLabel.font =[UIFont IVTH5Font];
[numberBackView addSubview:fans];
[fans mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kScreenWidth/4, 50));
make.leading.equalTo(follow.mas_trailing);
make.top.equalTo(numberBackView.mas_top);
}];
fansLabel = [[UILabel alloc]init];
fansLabel.textAlignment = NSTextAlignmentCenter;
fansLabel.textColor = [UIColor whiteColor];
fansLabel.font = [UIFont YXFontOfSize:14];
[fans addSubview:fansLabel];
[fansLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kScreenWidth/4, 30));
make.leading.equalTo(fans.mas_leading);
make.top.equalTo(fans.mas_top);
}];
UIImageView *lineV2 = [[UIImageView alloc] init];
lineV2.backgroundColor = [UIColor YXColorWithHexCode:@"#dcdcdc"];
[numberBackView addSubview:lineV2];
[lineV2 mas_makeConstraints:^(MASConstraintMaker* make) {
make.top.equalTo(numberBackView.mas_top).with.offset(14);
make.left.equalTo(fans.mas_right);
make.height.equalTo(@(25));
make.width.equalTo(@(0.5));
}];
UIButton *like = [UIButton buttonWithType: UIButtonTypeCustom];
[like setTitle: @"送出" forState:UIControlStateNormal];
[like setTitleColor:[UIColor IVTAssistColor] forState:UIControlStateNormal];
[like setTitleEdgeInsets:UIEdgeInsetsMake(20, 0, 0, 0)];
like.titleLabel.font =[UIFont IVTH5Font];
[numberBackView addSubview:like];
[like mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kScreenWidth/4, 50));
make.leading.equalTo(fans.mas_trailing);
make.top.equalTo(numberBackView.mas_top);
}];
likeLabel = [[UILabel alloc]init];
likeLabel.textColor = [UIColor whiteColor];
likeLabel.font = [UIFont YXFontOfSize:14];
likeLabel.textAlignment = NSTextAlignmentCenter;
[like addSubview:likeLabel];
[likeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kScreenWidth/4, 30));
make.leading.equalTo(like.mas_leading);
make.top.equalTo(like.mas_top);
}];
UIImageView *lineV3 = [[UIImageView alloc] init];
lineV3.backgroundColor = [UIColor YXColorWithHexCode:@"#dcdcdc"];
[numberBackView addSubview:lineV3];
[lineV3 mas_makeConstraints:^(MASConstraintMaker* make) {
make.top.equalTo(numberBackView.mas_top).with.offset(14);
make.left.equalTo(like.mas_right);
make.height.equalTo(@(25));
make.width.equalTo(@(0.5));
}];
UIButton *live = [UIButton buttonWithType: UIButtonTypeCustom];
[live setTitle: @"收到" forState:UIControlStateNormal];
[live setTitleColor:[UIColor IVTAssistColor] forState:UIControlStateNormal];
[live setTitleEdgeInsets:UIEdgeInsetsMake(20, 0, 0, 0)];
live.titleLabel.font =[UIFont IVTH5Font];
[numberBackView addSubview:live];
[live mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kScreenWidth/4, 50));
make.leading.equalTo(like.mas_trailing);
make.top.equalTo(numberBackView.mas_top);
}];
liveLabel = [[UILabel alloc]init];
liveLabel.textAlignment = NSTextAlignmentCenter;
liveLabel.textColor = [UIColor whiteColor];
liveLabel.font = [UIFont YXFontOfSize:14];
[live addSubview:liveLabel];
[liveLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kScreenWidth/4, 30));
make.leading.equalTo(live.mas_leading);
make.top.equalTo(live.mas_top);
}];
//贡献榜
UIImageView *gongxianBackgroundImg = [[UIImageView alloc] init];
gongxianBackgroundImg.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"用户主页---贡献榜背景条"]];
gongxianBackgroundImg.userInteractionEnabled = YES;
UITapGestureRecognizer *singleTap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClickImage)];
[gongxianBackgroundImg addGestureRecognizer:singleTap];
[headerView addSubview:gongxianBackgroundImg];
[gongxianBackgroundImg mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(numberBackView.mas_bottom).offset(8);
make.left.equalTo(headerView.mas_left).offset(0);
make.size.mas_equalTo(CGSizeMake(kScreenWidth, 42));
}];
UILabel *gongxianLabel = [[UILabel alloc] init];
gongxianLabel.text = @"贡献榜";
gongxianLabel.font = [UIFont IVTH3Font];
gongxianLabel.textAlignment = NSTextAlignmentCenter;
gongxianLabel.textColor = [UIColor IVTMainTextColor];
[gongxianBackgroundImg addSubview:gongxianLabel];
[gongxianLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(gongxianBackgroundImg.mas_top).offset(6);
make.left.equalTo(gongxianBackgroundImg).offset(0);
make.size.mas_equalTo(CGSizeMake(70, 30));
}];
UIImageView *rightImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"我的更多键"]];
[gongxianBackgroundImg addSubview:rightImg];
[rightImg mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(gongxianBackgroundImg).offset(13);
make.right.equalTo(gongxianBackgroundImg).offset(-15);
make.size.mas_equalTo(CGSizeMake(8, 15));
}];
imgThird = [[UIImageView alloc] init];
imgThird.image = [UIImage imageNamed:@"占位头像"];
imgThird.clipsToBounds = YES;
imgThird.layer.cornerRadius = 36/2;
[gongxianBackgroundImg addSubview:imgThird];
[imgThird mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(gongxianBackgroundImg).offset(3);
make.right.equalTo(gongxianBackgroundImg).offset(-40);
make.size.mas_equalTo(CGSizeMake(36, 36));
}];
imgSecond = [[UIImageView alloc] init];
imgSecond.image = [UIImage imageNamed:@"占位头像"];
imgSecond.clipsToBounds = YES;
imgSecond.layer.cornerRadius = 36/2;
[gongxianBackgroundImg addSubview:imgSecond];
[imgSecond mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(gongxianBackgroundImg).offset(3);
make.right.equalTo(imgThird.mas_left).offset(-5);
make.size.mas_equalTo(CGSizeMake(36, 36));
}];
imgFirst = [[UIImageView alloc] init];
imgFirst.image = [UIImage imageNamed:@"占位头像"];
imgFirst.clipsToBounds = YES;
imgFirst.layer.cornerRadius = 36/2;
[gongxianBackgroundImg addSubview:imgFirst];
[imgFirst mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(gongxianBackgroundImg).offset(3);
make.right.equalTo(imgSecond.mas_left).offset(-5);
make.size.mas_equalTo(CGSizeMake(36, 36));
}];
// UIImageView *imageViewLine1 = [[UIImageView alloc]init];
// imageViewLine1.backgroundColor = [UIColor darkGrayColor];
// imageViewLine1.alpha = 0.3;
// [gongxianBackgroundImg addSubview:imageViewLine1];
// [imageViewLine1 mas_makeConstraints:^(MASConstraintMaker *make) {
// make.bottom.equalTo(gongxianBackgroundImg.mas_bottom);
// make.left.equalTo(gongxianBackgroundImg.mas_left);
// make.right.equalTo(gongxianBackgroundImg.mas_right);
// make.height.mas_equalTo(0.5);
// }];
//我的直播
UIImageView *myLiveImg = [[UIImageView alloc] init];
myLiveImg.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"我的直播--背景条"]];
[headerView addSubview:myLiveImg];
[myLiveImg mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(gongxianBackgroundImg.mas_bottom).offset(8);
make.left.equalTo(headerView.mas_left).offset(0);
make.size.mas_equalTo(CGSizeMake(kScreenWidth, 42));
}];
UILabel *myLiveLabel = [[UILabel alloc] init];
myLiveLabel.text = @"我的直播";
myLiveLabel.font = [UIFont IVTH3Font];
myLiveLabel.textAlignment = NSTextAlignmentCenter;
myLiveLabel.textColor = [UIColor IVTMainTextColor];
[myLiveImg addSubview:myLiveLabel];
[myLiveLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(myLiveImg).offset(6);
make.left.equalTo(myLiveImg).offset(0);
make.size.mas_equalTo(CGSizeMake(85, 30));
}];
}
- (void)tapBack{
[self.navigationController popViewControllerAnimated:YES];
}
- (void)onClickImage{
IVTMyContributionListViewController *meSupportVC = [[IVTMyContributionListViewController alloc] init];
meSupportVC.userId = self.userId;
[self.navigationController pushViewController:meSupportVC animated:YES];
}
#pragma --mark UICollectionViewDelegate
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return myLiveListArray.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
IVTMyLiveCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
NSString *urlString = [[myLiveListArray objectAtIndex:indexPath.row] valueForKey:@"thumbnail"];
cell.userHeaderImageUrl = urlString;
return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section<[myLiveListArray count]) {
IVTKSYDianBoViewController *dianbo = [[IVTKSYDianBoViewController alloc]init];
dianbo.userId = [IVTAccountTool getUserId];
dianbo.roomInfo = myLiveListArray[indexPath.section];
[self.navigationController pushViewController:dianbo animated:YES];
}
}
//返回这个UICollectionView是否可以被选择
-(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
#pragma mark --UICollectionViewDelegateFlowLayout
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
CGFloat itemWidth = (kScreenWidth - 24)/3;
return CGSizeMake(itemWidth, itemWidth);
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
return UIEdgeInsetsMake(0, 6, 0, 6);
}
- (void)layoutSubViewsForBottomView{
guanZhuButton = [UIButton buttonWithType:UIButtonTypeCustom];
isFollowed = [IVTAccountTool isFollowedToUserId:self.userId];
if (!isFollowed) {
// [guanZhuButton setImage:[UIImage imageNamed:@"用户主页---关注图标"] forState:UIControlStateNormal];
[guanZhuButton setTitle:@"添加关注" forState:UIControlStateNormal];
}
else{
[guanZhuButton setTitle:@"已关注" forState:UIControlStateNormal];
}
[guanZhuButton setTitleColor:[UIColor IVTLightRedColor] forState:UIControlStateNormal];
guanZhuButton.titleLabel.font =[UIFont IVTH3Font];
[guanZhuButton addTarget:self action:@selector(doGuanZhuButton) forControlEvents:UIControlEventTouchUpInside];
[bottomView addSubview:guanZhuButton];
[guanZhuButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kScreenWidth/3, 50));
make.top.equalTo(bottomView.mas_top);
make.left.equalTo(bottomView.mas_left);
}];
//私信
UIButton *message = [UIButton buttonWithType: UIButtonTypeCustom];
[message setTitle:@"私信" forState:UIControlStateNormal];
message.titleLabel.textAlignment = NSTextAlignmentCenter;
[message setTitleColor:[UIColor IVTLightRedColor] forState:UIControlStateNormal];
message.titleLabel.font =[UIFont IVTH3Font];
[message addTarget:self action:@selector(doMessage:) forControlEvents:UIControlEventTouchUpInside];
[bottomView addSubview:message];
[message mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kScreenWidth/3, 50));
make.centerX.equalTo(bottomView);
make.top.equalTo(bottomView.mas_top);
}];
//拉黑
laHei = [UIButton buttonWithType: UIButtonTypeCustom];
laHei.titleLabel.textAlignment = NSTextAlignmentCenter;
[laHei setTitleColor:[UIColor IVTLightRedColor] forState:UIControlStateNormal];
laHei.titleLabel.font =[UIFont IVTH3Font];
[laHei addTarget:self action:@selector(doLaHei) forControlEvents:UIControlEventTouchUpInside];
[bottomView addSubview:laHei];
[laHei mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kScreenWidth/3, 50));
make.top.equalTo(bottomView.mas_top);
make.right.equalTo(bottomView.mas_right);
}];
}
- (void)doGuanZhuButton{
if (isFollowed == NO) {
[[IVTNetworkAPIClient sharedClient] doFollowUser:self.userId success:^(NSDictionary *successData) {
isFollowed = YES;
[[NSNotificationCenter defaultCenter] postNotificationName:@"followedChangedByUserView" object:nil userInfo:userInfoDict];
//添加到已关注列表
[IVTAccountTool insertToMyFollowListArrayWithUserDict:userInfoDict];
[guanZhuButton setTitle:@"已关注" forState:UIControlStateNormal];
[SVProgressHUD setMinimumDismissTimeInterval:2];
[SVProgressHUD showSuccessWithStatus:@"关注成功"];
} error:^(NSDictionary *successData) {
} failure:^(NSError *failureError) {
}];
}
else{
[[IVTNetworkAPIClient sharedClient] doCancelFollowUser:self.userId success:^(NSDictionary *successData) {
isFollowed = NO;
//取消关注,从列表删除
[[NSNotificationCenter defaultCenter] postNotificationName:@"followedChangedByUserView" object:nil userInfo:userInfoDict];
[IVTAccountTool deleteMyFollowToUserId:self.userId];
[guanZhuButton setTitle:@"添加关注" forState:UIControlStateNormal];
[SVProgressHUD setMinimumDismissTimeInterval:2];
[SVProgressHUD showSuccessWithStatus:@"已取消关注"];
} error:^(NSDictionary *successData) {
} failure:^(NSError *failureError) {
}];
}
}
- (void)doMessage:(UIButton *)senderButton{
IVTMyChatContentListViewController *myChatContentListVC = [[IVTMyChatContentListViewController alloc]init];
myChatContentListVC.chatToUserId = self.userId;
myChatContentListVC.chatToUserNickName = [userInfoDict objectForKey:@"name"];
myChatContentListVC.chatToUserAvatarUrl = userInfoDict[@"avatar"];
myChatContentListVC.chatToUserSex = userInfoDict[@"sex"];
myChatContentListVC.chatToUserLevel = userInfoDict[@"level"];
myChatContentListVC.chatToUserSignature = userInfoDict[@"signature"];
[self.navigationController pushViewController:myChatContentListVC animated:YES];
}
- (void)doLaHei{
if ([laHei.titleLabel.text isEqualToString:@"拉黑"]) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"拉黑后你们将解除关注关系,ta将不能再关注你或私信你" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[IVTNetworkAPIClient sharedClient] laHeiForUserId:self.userId success:^(NSDictionary *successData) {
laHeiId = [[successData valueForKey:@"blacklistId"] integerValue];
[laHei setTitle:@"解除拉黑" forState:UIControlStateNormal];
[SVProgressHUD setMinimumDismissTimeInterval:2];
[SVProgressHUD showSuccessWithStatus:@"拉黑成功"];
} error:^(NSDictionary *successData) {
} failure:^(NSError *failureError) {
}];
}]];
[self presentViewController:alert animated:YES completion:nil];
}else{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"确定解除拉黑?" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[IVTNetworkAPIClient sharedClient] cancelLaHeiForUserId:[NSString stringWithFormat:@"%ld",(long)laHeiId] success:^(NSDictionary *successData) {
[laHei setTitle:@"拉黑" forState:UIControlStateNormal];
[SVProgressHUD setMinimumDismissTimeInterval:2];
[SVProgressHUD showSuccessWithStatus:@"已解除拉黑"];
} error:^(NSDictionary *successData) {
} failure:^(NSError *failureError) {
}];
}]];
[self presentViewController:alert animated:YES completion:nil];
}
}
- (void)requestUserInfo{
[[IVTNetworkAPIClient sharedClient] getUserInfoForUserId:self.userId success:^(NSDictionary *successData) {
userInfoDict = successData[@"data"];
[userIcon sd_setImageWithURL:[NSURL URLWithString:userInfoDict[@"avatar"]] placeholderImage:[UIImage imageNamed:@"占位头像"]];
nameSexLevelView.userNickName = [userInfoDict objectForKey:@"name"];
nameSexLevelView.userSex = [userInfoDict objectForKey:@"sex"];
nameSexLevelView.userLevel = [userInfoDict objectForKey:@"level"];
NSString *mejia =[NSString stringWithFormat:@"%@%@",@"蜜家号:",[userInfoDict objectForKey:@"id"]];
meNumberLabel.text = mejia;
if ([userInfoDict objectForKey:@"signature"]!=nil) {
NSString *signature = [NSString stringWithFormat:@"%@",[userInfoDict objectForKey:@"signature"]];
signLabel.text = [signature base64DecodedToString];
}else{
signLabel.text = @"我很懒,所以我什么都没有写";
}
NSInteger followercount = [[userInfoDict objectForKey:@"followercount"] integerValue];
NSString *followCount = [IVTAccountTool numberFormat:followercount];
NSInteger fanscount = [[userInfoDict objectForKey:@"fanscount"] integerValue];
NSString *fanCount = [IVTAccountTool numberFormat:fanscount];
followLabel.text = followCount;
fansLabel.text = fanCount;
NSInteger sentgiftcount = [[userInfoDict objectForKey:@"sentgiftcount"] integerValue];
NSString *likeCount = [IVTAccountTool numberFormat:sentgiftcount];
likeLabel.text = likeCount;
NSInteger sentgiftmoneycount = [[userInfoDict objectForKey:@"sentgiftmoneycount"] integerValue];
NSString *liveCount = [IVTAccountTool numberFormat:sentgiftmoneycount];
liveLabel.text = liveCount;
} error:^(NSDictionary *successData) {
} failure:^(NSError *failureError) {
}];
}
- (void)requestIsLaHei{
[[IVTNetworkAPIClient sharedClient] isLaHeiForUserId:self.userId success:^(NSDictionary *successData) {
NSInteger code = [[successData valueForKey:@"code"] integerValue];
if (code == 1) {
[laHei setTitle:@"拉黑" forState:UIControlStateNormal];
}
else{
laHeiId = [[successData valueForKey:@"id"] integerValue];
[laHei setTitle:@"解除拉黑" forState:UIControlStateNormal];
}
} error:^(NSDictionary *successData) {
} failure:^(NSError *failureError) {
}];
}
- (void)requestUserLiveList{
[[IVTNetworkAPIClient sharedClient] getLiveListForUserId:self.userId success:^(NSDictionary *successData) {
myLiveListArray = [successData valueForKey:@"data"];
[userLiveCollectionView reloadData];
} error:^(NSDictionary *successData) {
} failure:^(NSError *failureError) {
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end