Files
featherVoice/QXLive/Mine(音域)/Controller/家族/QXFamilySubViewController.m
2025-12-01 18:42:49 +08:00

159 lines
4.9 KiB
Objective-C

//
// QXFamilySubViewController.m
// QXLive
//
// Created by 启星 on 2025/11/26.
//
#import "QXFamilySubViewController.h"
#import "QXFamilyMemberCell.h"
#import "QXFamilyTopCell.h"
#import "QXMineNetwork.h"
#import "QXUserHomePageViewController.h"
@interface QXFamilySubViewController ()<UITableViewDelegate,UITableViewDataSource,QXFamilyMemberCellDelegate>
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)QXFamilyModel *model;
@end
@implementation QXFamilySubViewController
-(UIView *)listView{
return self.view;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)initSubViews{
self.bgImageHidden = YES;
self.view.backgroundColor = RGB16(0x102477);
[self.view addSubview:self.tableView];
}
-(void)viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
_tableView.frame = self.view.bounds;
}
-(void)setIndex:(NSInteger)index{
_index = index;
[self getList];
}
-(void)getList{
BOOL isJoin = YES;
if (self.index == 0) {
isJoin = YES;
}else{
isJoin = NO;
}
MJWeakSelf
[QXMineNetwork getMyFamilyIsJoin:isJoin successBlock:^(QXFamilyModel * _Nonnull model) {
weakSelf.model = model;
[weakSelf.tableView reloadData];
[weakSelf.tableView.mj_header endRefreshing];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
-(void)needRefresh{
self.page = 1;
[self getList];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
if (self.model) {
return 2;
}
return 0;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section == 0) {
return 1;
}else{
return self.model.group_members_lists.count;
}
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
QXFamilyTopCell *cell = [QXFamilyTopCell cellWithTableView:tableView];
cell.model = self.model;
return cell;
}else{
QXFamilyMemberCell *cell = [QXFamilyMemberCell cellWithTableView:tableView];
cell.model = self.model.group_members_lists[indexPath.row];
cell.delegate = self;
return cell;
}
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
return 180;
}else{
return 176;
}
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if (section == 0) {
return [UIView new];
}else{
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 50)];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"family_list_section_bg"]];
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.font = [UIFont boldSystemFontOfSize:16];
titleLabel.textColor = RGB16(0xffffff);
[header addSubview:imageView];
[header addSubview:titleLabel];
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(132);
make.height.mas_equalTo(36);
make.centerX.centerY.equalTo(header);
}];
titleLabel.text = @"家族成员";
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(header);
make.centerY.equalTo(header).offset(2);
}];
return header;
}
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 0) {
return 0;
}
return 50;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
return [UIView new];
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
QXFamilyMemberModel*md = self.model.group_members_lists[indexPath.row];
QXUserHomePageViewController *vc = [[QXUserHomePageViewController alloc] init];
vc.user_id = md.user_id;
[self.navigationController pushViewController:vc animated:YES];
}
-(UITableView *)tableView{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.view.height) style:(UITableViewStyleGrouped)];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.backgroundColor = [UIColor clearColor];
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
if (@available(iOS 15.0, *)) {
_tableView.sectionHeaderTopPadding = 0;
} else {
// Fallback on earlier versions
}
MJWeakSelf
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
[weakSelf getList];
}];
}
return _tableView;
}
@end