结构调整
This commit is contained in:
196
QXLive/Room(房间)/View/用户信息/QXUserRelationListView.m
Normal file
196
QXLive/Room(房间)/View/用户信息/QXUserRelationListView.m
Normal file
@@ -0,0 +1,196 @@
|
||||
//
|
||||
// QXUserRelationListView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/7/21.
|
||||
//
|
||||
|
||||
#import "QXUserRelationListView.h"
|
||||
#import "QXUserInfoRelationCell.h"
|
||||
#import "QXMineNetwork.h"
|
||||
#import "QXUserInfoRelationCardCell.h"
|
||||
#import "QXUserInfoRelationTableCell.h"
|
||||
|
||||
@interface QXUserRelationListView()<UIGestureRecognizerDelegate,UITableViewDelegate,UITableViewDataSource>
|
||||
@property (nonatomic,strong)UIView *bgView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
@property (nonatomic,strong)UITableView *tableView;
|
||||
@property (nonatomic,strong)NSMutableArray *dataArray;
|
||||
@property (nonatomic,assign)NSInteger page;
|
||||
@end
|
||||
|
||||
@implementation QXUserRelationListView
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)initSubviews{
|
||||
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
|
||||
tap.delegate = self;
|
||||
[self addGestureRecognizer:tap];
|
||||
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, kSafeAreaBottom+ScaleWidth(429+33))];
|
||||
// self.bgView.backgroundColor = [UIColor whiteColor];
|
||||
[self addSubview:self.bgView];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithFrame:self.bgView.bounds];
|
||||
self.bgImageView.image = [UIImage imageNamed:@"room_user_bg"];
|
||||
[self.bgView addSubview:self.bgImageView];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.right.bottom.equalTo(self.bgView);
|
||||
}];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.text = @"关系列表";
|
||||
self.titleLabel.textColor = RGB16(0xffffff);
|
||||
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
[self.bgView addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(20);
|
||||
make.centerX.equalTo(self.bgView);
|
||||
make.height.mas_equalTo(24);
|
||||
}];
|
||||
|
||||
// UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
// layout.itemSize = CGSizeMake(self.width-32, ScaleWidth(100));
|
||||
// layout.minimumLineSpacing = 10;
|
||||
// layout.minimumInteritemSpacing = 10;
|
||||
// layout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16);
|
||||
// layout.scrollDirection = UICollectionViewScrollDirectionVertical;
|
||||
// self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
// [self.collectionView registerNib:[UINib nibWithNibName:@"QXUserInfoRelationCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXUserInfoRelationCell"];
|
||||
//
|
||||
// self.collectionView.delegate = self;
|
||||
// self.collectionView.dataSource = self;
|
||||
// self.collectionView.showsHorizontalScrollIndicator = NO;
|
||||
// self.collectionView.bounces = NO;
|
||||
// self.collectionView.pagingEnabled = YES;
|
||||
// self.collectionView.backgroundColor = [UIColor clearColor];
|
||||
// [self.bgView addSubview:self.collectionView];
|
||||
// [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.mas_equalTo(12);
|
||||
// make.top.equalTo(self.titleLabel.mas_bottom).offset(22);
|
||||
// make.bottom.equalTo(self.bgView);
|
||||
// make.right.mas_equalTo(-12);
|
||||
// }];
|
||||
|
||||
self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:(UITableViewStylePlain)];
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
// self.tableView.scrollEnabled = NO;
|
||||
self.tableView.backgroundColor = [UIColor clearColor];
|
||||
self.tableView.rowHeight = ScaleWidth(141);
|
||||
[self.bgView addSubview:self.tableView];
|
||||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(12);
|
||||
make.top.equalTo(self.titleLabel.mas_bottom).offset(22);
|
||||
make.bottom.equalTo(self.bgView);
|
||||
make.right.mas_equalTo(-12);
|
||||
}];
|
||||
MJWeakSelf
|
||||
self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.page++;
|
||||
[weakSelf getRelationList];
|
||||
}];
|
||||
self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getRelationList];
|
||||
}];
|
||||
}
|
||||
-(void)getRelationList{
|
||||
MJWeakSelf
|
||||
[QXMineNetwork roomUserRelationWithUserId:self.userId page:self.page successBlock:^(QXRelationshipList * _Nonnull list) {
|
||||
weakSelf.list = list;
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
[weakSelf.tableView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}];
|
||||
}
|
||||
-(void)setUserId:(NSString *)userId{
|
||||
self.page = 1;
|
||||
_userId = userId;
|
||||
[self getRelationList];
|
||||
}
|
||||
|
||||
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == self;
|
||||
}
|
||||
//-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
// if (self.isRealLove) {
|
||||
// return self.list.zhenai.count;
|
||||
// }else{
|
||||
// return self.list.qinmi.count;
|
||||
// }
|
||||
//}
|
||||
//- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
// QXUserInfoRelationCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXUserInfoRelationCell" forIndexPath:indexPath];
|
||||
// QXRelationshipListModel *model;
|
||||
// if (self.isRealLove) {
|
||||
// model = self.list.zhenai[indexPath.row];
|
||||
// }else{
|
||||
// model = self.list.qinmi[indexPath.row];
|
||||
// }
|
||||
// cell.model = model;
|
||||
// return cell;
|
||||
//}
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
if (self.isRealLove) {
|
||||
return self.list.zhenai.count;
|
||||
}else{
|
||||
return self.list.qinmi.count;
|
||||
}
|
||||
}
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
MJWeakSelf
|
||||
if (!self.isRealLove) {
|
||||
QXUserInfoRelationCardCell *cell = [QXUserInfoRelationCardCell cellWithTableView:tableView];
|
||||
cell.isList = [self.userId isEqualToString:QXGlobal.shareGlobal.loginModel.user_id];
|
||||
cell.model = self.list.qinmi[indexPath.row];;
|
||||
cell.topSuccessBlock = ^(QXRelationshipListModel * _Nonnull model) {
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getRelationList];
|
||||
};
|
||||
return cell;
|
||||
}else{
|
||||
QXUserInfoRelationTableCell *cell = [QXUserInfoRelationTableCell cellWithTableView:tableView];
|
||||
cell.isList = [self.userId isEqualToString:QXGlobal.shareGlobal.loginModel.user_id];
|
||||
cell.model = self.list.zhenai[indexPath.row];;
|
||||
cell.topSuccessBlock = ^(QXRelationshipListModel * _Nonnull model) {
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getRelationList];
|
||||
};
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void)showInView:(UIView *)view{
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT- ScaleWidth(429+33)-kSafeAreaBottom;
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
-(NSMutableArray *)dataArray{
|
||||
if (!_dataArray) {
|
||||
_dataArray = [NSMutableArray array];
|
||||
}
|
||||
return _dataArray;
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user