首页UI更改

This commit is contained in:
liyuhua
2023-09-05 11:45:21 +08:00
parent bea723fb82
commit 32d974eb12
81 changed files with 1417 additions and 767 deletions

View File

@@ -40,16 +40,14 @@
#import "XPNewHomeRecommendPresenter.h"
#import "XPNewHomeRecommendProtocol.h"
UIKIT_EXTERN NSString * const kShieldingNotification;
@interface XPHomeRecommendViewController ()<UITableViewDelegate, UITableViewDataSource, XPNewHomePlayTableViewCellDelegate, XPHomeBannerTableViewCellDelegate, XPNewHomePlayEmptyTableViewCellDelegate,XPNewHomeRecommendTableViewCellDelegate,XPNewHomeRecommendProtocol>
@interface XPHomeRecommendViewController ()<UITableViewDelegate, UITableViewDataSource, XPNewHomePlayTableViewCellDelegate, XPHomeBannerTableViewCellDelegate,XPNewHomeRecommendTableViewCellDelegate,XPNewHomeRecommendProtocol>
{
NSTimer * timer;
}
///
@property (nonatomic,strong) UITableView *tableView;
///
@property (nonatomic,strong) NSArray<HomeBannerInfoModel *> *bannerList;
///
@property (nonatomic,strong) NSArray<HomeRecommendRoomModel *> *recommendList;
///
@property (nonatomic,strong) NSArray<HomePlayRoomModel *> *playTeamList;
///
@@ -112,12 +110,7 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
//
dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);
dispatch_group_enter(group);
dispatch_group_async(group, queue, ^{
[self.presenter getHomeRecommendRoomListWithGroup:group];
});
dispatch_group_enter(group);
dispatch_group_async(group, queue, ^{
@@ -130,18 +123,8 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
[self.presenter getHomePersonalRoomListWithGroup:group];
});
dispatch_group_enter(group);
dispatch_group_async(group, queue, ^{
[self.presenter getHomeTopBannerListWithGroup:group];
});
dispatch_group_enter(group);
dispatch_group_async(group, queue, ^{
[self getRoomInfoWithGroup:group];
});
dispatch_group_notify(group,dispatch_get_main_queue(), ^{
@@ -156,16 +139,7 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
self.isRequestData = NO;
[self requestData];
}
-(void)getRoomInfoWithGroup:(dispatch_group_t)group{
NSString* roomUid = [AccountInfoStorage instance].getUid;
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data];
self.roomInfo = roomInfo;
}
dispatch_group_leave(group);
} uid:roomUid intoUid:roomUid];
}
- (void)initHeaderAndFooterRrfresh {
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
header.stateLabel.font = [UIFont systemFontOfSize:10.0];
@@ -190,127 +164,73 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
[self requestData];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 4;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
return self.recommendList.count > 0 ? 1 : 0;
} else if(section == 1) {
return self.bannerList.count > 0 ? 1 : 0;
} else if(section == 2) {
return self.recommendList != nil ? 1 : 0;
} else {
return self.personalRoomList.count > 0 ? self.personalRoomList.count : 0;
}
if(section == 0)return self.playTeamList.count > 0 ? 1 : 0;
return self.personalRoomList.count > 0 ? self.personalRoomList.count : 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
return 160 * kScreenScale;
} else if(indexPath.section == 1) {
return 96;
} else if(indexPath.section == 2) {
return 65;
} else {
return 94;
return kGetScaleWidth(102);
}
return self.personalRoomList.count > 0 ? kGetScaleWidth(104) : 300;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
XPNewHomeRecommendTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomeRecommendTableViewCell class])];
if (cell == nil) {
cell = [[XPNewHomeRecommendTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomeRecommendTableViewCell class])];
}
[cell setRecommendsList:self.recommendList];
cell.delegate = self;
return cell;
} else if(indexPath.section == 1) {
XPHomeBannerTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPHomeBannerTableViewCell class])];
if (cell == nil) {
cell = [[XPHomeBannerTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPHomeBannerTableViewCell class])];
}
cell.bannerList = self.bannerList;
cell.delegate = self;
return cell;
} else if(indexPath.section == 2) {
if (self.playTeamList.count > 0) {
if(indexPath.section == 0) {
XPNewHomePlayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePlayTableViewCell class])];
if (cell == nil) {
cell = [[XPNewHomePlayTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePlayTableViewCell class])];
}
// cell.isClan = self.roomInfo.isPermitRoom == PermitRoomType_Licnese;
cell.isClan = YES;
cell.playRoomList = self.playTeamList;
cell.delegate = self;
return cell;
} else {
XPNewHomePlayEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePlayEmptyTableViewCell class])];
if (cell == nil) {
cell = [[XPNewHomePlayEmptyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePlayEmptyTableViewCell class])];
}
// cell.isClan = self.roomInfo.isPermitRoom == PermitRoomType_Licnese;
cell.isClan = YES;
cell.delegate = self;
return cell;
}
if(self.personalRoomList.count == 0){
XPNewHomePlayEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePlayEmptyTableViewCell class])];
if (cell == nil) {
cell = [[XPNewHomePlayEmptyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePlayEmptyTableViewCell class])];
}
} else {
[cell setConstraints];
[cell setTitle:YMLocalizedString(@"XPGuildEmptyCollectionViewCell0")];
return cell;
}
XPNewHomePartyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNewHomePartyTableViewCell class])];
if (cell == nil) {
cell = [[XPNewHomePartyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNewHomePartyTableViewCell class])];
}
cell.roomInfo = [self.personalRoomList safeObjectAtIndex1:indexPath.row];
return cell;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if(section == 0){return 5;}
if (section == 2) {
return 50;
}else if (section == 3){
return 50;
}
return 0.01;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView * view = [[UIView alloc] init];
if(self.recommendList == nil && section == 2)return view;
if(self.personalRoomList == nil && section == 3)return view;
if (section == 2 || section == 3) {
view.frame = CGRectMake(0,0, KScreenWidth, 50);
UILabel * label = [[UILabel alloc] init];
label.textColor = [DJDKMIMOMColor mainTextColor];
label.font = [UIFont systemFontOfSize:16 weight:UIFontWeightBold];
if (section == 2) {
label.text = YMLocalizedString(@"XPHomeRecommendViewController0");
} else {
label.text = YMLocalizedString(@"XPHomeRecommendViewController1");
}
[view addSubview:label];
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(16);
make.left.mas_equalTo(view).offset(15);
make.height.mas_equalTo(22);
}];
}
return view;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.01;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return [UIView new];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
@@ -374,25 +294,19 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
}
}
#pragma mark - XPHomeRecommendProtocol
- (void)getHomeTopBannerListSuccess:(NSArray *)list menuList:(NSArray *)memuList withGroup:(nonnull dispatch_group_t)group{
self.bannerList = list;
dispatch_group_leave(group);
}
///
- (void)getHomeRecommendRoomListSuccess:(NSArray *)list withGroup:(nonnull dispatch_group_t)group{
self.recommendList= list;
dispatch_group_leave(group);
}
///
- (void)getHomePersonalRoomListSuccess:(NSArray *)list withGroup:(nonnull dispatch_group_t)group {
NSMutableArray * array = [NSMutableArray array];
for (HomePlayRoomModel * info in list) {
if(info.isBanner) {
self.bannerList = info.bannerVoList;
} else {
[array addObject:info];
}
[array addObject:info];
}
self.personalRoomList = array;
dispatch_group_leave(group);
@@ -401,11 +315,9 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
- (void)getPlayGameWithTeamSuccess:(NSArray *)list withGroup:(nonnull dispatch_group_t)group{
NSMutableArray * array = [NSMutableArray array];
for (HomePlayRoomModel * info in list) {
if(info.isBanner) {
self.bannerList = info.bannerVoList;
} else {
[array addObject:info];
}
[array addObject:info];
}
self.playTeamList = array;
dispatch_group_leave(group);
@@ -438,20 +350,17 @@ UIKIT_EXTERN NSString * const kShieldingNotification;
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0);
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor clearColor];
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[_tableView registerClass:[XPNewHomeRecommendTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPNewHomeRecommendTableViewCell class])];
[_tableView registerClass:[XPNewHomePlayTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPNewHomePlayTableViewCell class])];
[_tableView registerClass:[XPNewHomePlayEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPNewHomePlayEmptyTableViewCell class])];
[_tableView registerClass:[XPHomeBannerTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPHomeBannerTableViewCell class])];
[_tableView registerClass:[XPNewHomePartyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPNewHomePartyTableViewCell class])];
}
return _tableView;