完善个人资料页-相册/勋章
This commit is contained in:
@@ -31,6 +31,95 @@
|
||||
#import "XPMineClanViewController.h"
|
||||
#import "XPMineGuildViewController.h"
|
||||
#import "XPMonentsDetailViewController.h"
|
||||
|
||||
#import "XPMineDataGiftTableViewCell.h"
|
||||
#import "XPMineAlbumTableViewCell.h"
|
||||
#import "XPMineMedalsTableViewCell.h"
|
||||
|
||||
#import "MedalModel.h"
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
Album = 0,
|
||||
Medal = 1,
|
||||
Gifts = 2,
|
||||
LuckyGifts = 3,
|
||||
SectionTypeCount = 4
|
||||
} MineUserInfoPageSectionType;
|
||||
|
||||
@interface XPMineUserSectionHeader : UIView
|
||||
|
||||
@property (nonatomic, copy) NSString *title;
|
||||
@property (nonatomic, copy) NSString *num;
|
||||
@property (nonatomic, assign) BOOL hasMore;
|
||||
@property (nonatomic, copy) void(^didTapMore)(void);
|
||||
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
@property (nonatomic, strong) UILabel *numLabel;
|
||||
@property (nonatomic, strong) UIButton *arrowButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPMineUserSectionHeader
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
self.frame = CGRectMake(0, 0, KScreenWidth, 20);
|
||||
|
||||
_titleLabel = [UILabel labelInitWithText:@""
|
||||
font:[UIFont systemFontOfSize:16 weight:UIFontWeightBold]
|
||||
textColor:UIColorFromRGB(0x191919)];
|
||||
[self addSubview:_titleLabel];
|
||||
[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self);
|
||||
make.left.mas_equalTo(self).offset(16);
|
||||
}];
|
||||
|
||||
_numLabel = [UILabel labelInitWithText:@""
|
||||
font:[UIFont systemFontOfSize:16 weight:UIFontWeightBold]
|
||||
textColor:UIColorFromRGB(0x666666)];
|
||||
[self addSubview:_numLabel];
|
||||
[_numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self);
|
||||
make.left.mas_equalTo(self.titleLabel.mas_right).offset(4);
|
||||
}];
|
||||
|
||||
_arrowButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_arrowButton setBackgroundColor:[UIColor greenColor]];
|
||||
[_arrowButton addTarget:self
|
||||
action:@selector(didTapArrowButton)
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:_arrowButton];
|
||||
[_arrowButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self);
|
||||
make.right.mas_equalTo(self).offset(-16);
|
||||
make.size.mas_equalTo(CGSizeMake(10, 10));
|
||||
}];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setTitle:(NSString *)title {
|
||||
_titleLabel.text = title;
|
||||
}
|
||||
|
||||
- (void)setNum:(NSString *)num {
|
||||
_numLabel.text = num;
|
||||
}
|
||||
|
||||
- (void)setHasMore:(BOOL)hasMore {
|
||||
_arrowButton.hidden = !hasMore;
|
||||
}
|
||||
|
||||
- (void)didTapArrowButton {
|
||||
if (self.didTapMore) {
|
||||
self.didTapMore();
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface XPMineUserDataViewController ()<XPMineUserDataProtocol, UITableViewDelegate, UITableViewDataSource, XPMineDataClanTableViewCellDelegate, XPMineDataGiftTableViewCellDelegate, XPMonentsTableViewCellDelegate, XPMonentsMineProtocol, XPMonentsDetailViewControllerDelegate>
|
||||
///列表
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
@@ -39,15 +128,24 @@
|
||||
|
||||
///是否折叠
|
||||
@property (nonatomic,assign) BOOL isFold;
|
||||
@property (nonatomic,assign) BOOL isGiftsSectionFold;
|
||||
@property (nonatomic,assign) BOOL isLuckyGiftsSectionFold;
|
||||
@property (nonatomic, copy) void(^scrollCallback)(UIScrollView *scrollView);
|
||||
///是否展示加入家族房间
|
||||
@property (nonatomic,assign) BOOL isShowEnterClan;
|
||||
///数据源
|
||||
@property (nonatomic,strong) NSMutableArray<MonentsInfoModel *> *datasource;
|
||||
@property (nonatomic,strong) UIView *headView;
|
||||
///
|
||||
//@property (nonatomic,strong) UIView *headView;
|
||||
@property (nonatomic, strong) UIButton *giftsExpandButton;
|
||||
@property (nonatomic, strong) UIButton *luckyGiftsExpandButton;
|
||||
///
|
||||
@property (nonatomic,assign) BOOL isOpen;
|
||||
|
||||
@property (nonatomic, strong) XPMineUserSectionHeader *albumHeader;
|
||||
@property (nonatomic, strong) XPMineUserSectionHeader *medalHeader;
|
||||
@property (nonatomic, strong) XPMineUserSectionHeader *giftsHeader;
|
||||
@property (nonatomic, strong) XPMineUserSectionHeader *luckyGiftsHeader;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPMineUserDataViewController
|
||||
@@ -62,6 +160,10 @@
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.isGiftsSectionFold = YES;
|
||||
self.isLuckyGiftsSectionFold = YES;
|
||||
|
||||
[self initHttpRequest];
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
@@ -86,99 +188,146 @@
|
||||
|
||||
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
return 2;
|
||||
return SectionTypeCount;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
if(section == 0)return 1;
|
||||
return self.datasource.count > 0 ? self.datasource.count : 1;;
|
||||
// if(section == 0) {
|
||||
// return 1;
|
||||
// }else if (section == 1) {
|
||||
// return (self.clanDetailInfo.clan.elderUid.length > 0 || self.clanDetailInfo.hall.ownerUid.length > 0) ? 1 : 0;
|
||||
// } else {
|
||||
// return 1;
|
||||
// }
|
||||
switch (section) {
|
||||
case Album:
|
||||
return 1;
|
||||
break;
|
||||
case Medal:
|
||||
return 1;
|
||||
break;
|
||||
case Gifts:
|
||||
return 1;
|
||||
break;
|
||||
case LuckyGifts:
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if(indexPath.section == 0){
|
||||
if(self.isOpen == YES){
|
||||
if (self.clanDetailInfo.clan.elderUid.length > 0) {
|
||||
return kGetScaleWidth(150);
|
||||
}
|
||||
return kGetScaleWidth(130);
|
||||
}
|
||||
return kGetScaleWidth(106);
|
||||
}
|
||||
if (self.datasource.count > 0) {
|
||||
MonentsInfoModel * monentInfo= [self.datasource xpSafeObjectAtIndex:indexPath.row];
|
||||
[XPMonentsLayoutConfig getNewlayoutMonentsModelWithDynamic:monentInfo];
|
||||
if(monentInfo.content.length == 0){
|
||||
return monentInfo.rowHeight + 20;
|
||||
}
|
||||
return monentInfo.rowHeight;
|
||||
switch (indexPath.section) {
|
||||
case Album:
|
||||
return 90;
|
||||
break;
|
||||
case Medal:
|
||||
return 70;
|
||||
break;
|
||||
case Gifts:
|
||||
return self.isGiftsSectionFold ? 100 : 300;
|
||||
break;
|
||||
case LuckyGifts:
|
||||
return self.isLuckyGiftsSectionFold ? 100 : 300;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight;
|
||||
}
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
|
||||
return nil;
|
||||
switch (section) {
|
||||
case Album:
|
||||
return nil;
|
||||
break;
|
||||
case Medal:
|
||||
return nil;
|
||||
break;
|
||||
case Gifts:
|
||||
return self.giftsExpandButton;
|
||||
break;
|
||||
case LuckyGifts:
|
||||
return self.luckyGiftsExpandButton;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
||||
return 0.01;
|
||||
switch (section) {
|
||||
case Album:
|
||||
return 0;
|
||||
break;
|
||||
case Medal:
|
||||
return 0;
|
||||
break;
|
||||
case Gifts:
|
||||
return 20;
|
||||
break;
|
||||
case LuckyGifts:
|
||||
return 20;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||||
if(section == 0)return 0.01;
|
||||
return self.datasource.count > 0 ? 30 : 0.01;
|
||||
return 30;
|
||||
}
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
||||
if(section == 0)return nil;
|
||||
return self.datasource.count > 0 ? self.headView : nil;
|
||||
switch (section) {
|
||||
case Album:
|
||||
return self.albumHeader;
|
||||
break;
|
||||
case Medal:
|
||||
return self.medalHeader;
|
||||
break;
|
||||
case Gifts:
|
||||
return self.giftsHeader;
|
||||
break;
|
||||
case LuckyGifts:
|
||||
return self.luckyGiftsHeader;
|
||||
break;
|
||||
default:
|
||||
return [UIView new];
|
||||
break;
|
||||
}
|
||||
}
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if(indexPath.section == 0){
|
||||
XPMineDataClanTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineDataClanTableViewCell class])];
|
||||
if (cell == nil) {
|
||||
cell = [[XPMineDataClanTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineDataClanTableViewCell class])];
|
||||
switch (indexPath.section) {
|
||||
case Album:
|
||||
{
|
||||
XPMineAlbumTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineAlbumTableViewCell class])
|
||||
forIndexPath:indexPath];
|
||||
cell.albumDataSource = self.userInfo.privatePhoto;
|
||||
return cell;
|
||||
}
|
||||
cell.isOpne = self.isOpen;
|
||||
cell.isShowEnterHall = self.isShowEnterClan;
|
||||
cell.delegate = self;
|
||||
cell.userInfo = self.userInfo;
|
||||
cell.clanInfo = self.clanDetailInfo;
|
||||
return cell;
|
||||
break;
|
||||
case Medal:
|
||||
{
|
||||
XPMineMedalsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineMedalsTableViewCell class])
|
||||
forIndexPath:indexPath];
|
||||
cell.medalsDataSource = self.medalInfo.userMedals;
|
||||
return cell;
|
||||
}
|
||||
break;
|
||||
case Gifts:{
|
||||
XPMineDataGiftTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineDataGiftTableViewCell class])];
|
||||
if (cell == nil) {
|
||||
cell = [[XPMineDataGiftTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineDataGiftTableViewCell class])];
|
||||
}
|
||||
// cell.delegate = self;
|
||||
cell.userGiftWall = self.userInfo.userGiftWall;
|
||||
cell.userLuckyBagGiftWall = self.userInfo.userLuckyBagGiftWall;
|
||||
return cell;
|
||||
}
|
||||
break;
|
||||
case LuckyGifts:
|
||||
return [UITableViewCell new];
|
||||
break;
|
||||
default:
|
||||
return [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
||||
break;
|
||||
}
|
||||
|
||||
if (self.datasource.count > 0) {
|
||||
XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"XPMonentsDynamicTableViewCell" forIndexPath:indexPath];
|
||||
MonentsInfoModel * monentsInfo = [self.datasource xpSafeObjectAtIndex:indexPath.row];
|
||||
cell.delegate = self;
|
||||
cell.mineMonentsInfo = monentsInfo;
|
||||
cell.isFillet = indexPath.row == self.datasource.count - 1;
|
||||
return cell;
|
||||
}
|
||||
XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
||||
return cell;
|
||||
// if (indexPath.section == 0) {
|
||||
// XPMineDataSkillCardTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineDataSkillCardTableViewCell class])];
|
||||
// if (cell == nil) {
|
||||
// cell = [[XPMineDataSkillCardTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineDataSkillCardTableViewCell class])];
|
||||
// }
|
||||
// cell.delegate = self;
|
||||
// cell.datasourece = self.skillArray;
|
||||
// return cell;
|
||||
// } else if(indexPath.section == 1) {
|
||||
//
|
||||
// } else {
|
||||
// XPMineDataGiftTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineDataGiftTableViewCell class])];
|
||||
// if (cell == nil) {
|
||||
// cell = [[XPMineDataGiftTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineDataGiftTableViewCell class])];
|
||||
// }
|
||||
// cell.delegate = self;
|
||||
// cell.userGiftWall = self.userInfo.userGiftWall;
|
||||
// cell.userLuckyBagGiftWall = self.userInfo.userLuckyBagGiftWall;
|
||||
// return cell;
|
||||
// }
|
||||
}
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if(indexPath.section == 0)return;
|
||||
@@ -384,44 +533,105 @@
|
||||
[self.datasource removeAllObjects];
|
||||
[self.datasource addObjectsFromArray:dynamicInfo];
|
||||
[self.tableView reloadData];
|
||||
|
||||
self.medalHeader.num = [NSString stringWithFormat:@"(%ld)", (long)self.userInfo.medals.medalCount];
|
||||
}
|
||||
|
||||
- (void)setMedalInfo:(MedalModel *)medalInfo {
|
||||
_medalInfo = medalInfo;
|
||||
self.medalHeader.num = [NSString stringWithFormat:@"(%ld)", (long)medalInfo.medalCount];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
- (UITableView *)tableView {
|
||||
if (!_tableView) {
|
||||
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
|
||||
_tableView.delegate = self;
|
||||
_tableView.dataSource = self;
|
||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
_tableView.backgroundColor = [UIColor clearColor];
|
||||
_tableView.backgroundColor = [UIColor whiteColor];
|
||||
if (@available(iOS 11.0, *)) {
|
||||
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
[_tableView registerClass:[XPMineAlbumTableViewCell class]
|
||||
forCellReuseIdentifier:NSStringFromClass([XPMineAlbumTableViewCell class])];
|
||||
[_tableView registerClass:[XPMineMedalsTableViewCell class]
|
||||
forCellReuseIdentifier:NSStringFromClass([XPMineMedalsTableViewCell class])];
|
||||
[_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
||||
[_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:@"XPMonentsDynamicTableViewCell"];
|
||||
[_tableView registerClass:[XPMineDataClanTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineDataClanTableViewCell class])];
|
||||
[_tableView registerClass:[XPMineDataGiftTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineDataGiftTableViewCell class])];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
|
||||
- (NSMutableArray<MonentsInfoModel *> *)datasource {
|
||||
if (!_datasource) {
|
||||
_datasource = [NSMutableArray array];
|
||||
}
|
||||
return _datasource;
|
||||
}
|
||||
-(UIView *)headView{
|
||||
if (!_headView){
|
||||
_headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 30)];
|
||||
_headView.backgroundColor = [UIColor clearColor];
|
||||
UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(15, 0, KScreenWidth-30, 30)];
|
||||
[_headView addSubview:bgView];
|
||||
bgView.backgroundColor = [UIColor whiteColor];
|
||||
[bgView setCornerWithLeftTopCorner:8 rightTopCorner:8 bottomLeftCorner:0 bottomRightCorner:0 size:CGSizeMake(KScreenWidth-30, 30)];
|
||||
UILabel *titleView = [UILabel labelInitWithText:YMLocalizedString(@"XPMineUserDataViewController1") font:kFontMedium(15) textColor:[DJDKMIMOMColor inputTextColor]];
|
||||
[bgView addSubview:titleView];
|
||||
[titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(12);
|
||||
make.leading.mas_equalTo(12);
|
||||
}];
|
||||
|
||||
- (XPMineUserSectionHeader *)albumHeader {
|
||||
if (!_albumHeader) {
|
||||
_albumHeader = [[XPMineUserSectionHeader alloc] init];
|
||||
_albumHeader.title = @"相册";
|
||||
_albumHeader.hasMore = YES;
|
||||
@kWeakify(self);
|
||||
_albumHeader.didTapMore = ^{
|
||||
@kStrongify(self);
|
||||
};
|
||||
}
|
||||
return _headView;
|
||||
return _albumHeader;
|
||||
}
|
||||
|
||||
- (XPMineUserSectionHeader *)medalHeader {
|
||||
if (!_medalHeader) {
|
||||
_medalHeader = [[XPMineUserSectionHeader alloc] init];
|
||||
_medalHeader.title = @"勋章";
|
||||
_medalHeader.num = @"(0)";
|
||||
_medalHeader.hasMore = NO;
|
||||
}
|
||||
return _medalHeader;
|
||||
}
|
||||
|
||||
- (XPMineUserSectionHeader *)giftsHeader {
|
||||
if (!_giftsHeader) {
|
||||
_giftsHeader = [[XPMineUserSectionHeader alloc] init];
|
||||
_giftsHeader.title = @"普通礼物";
|
||||
_giftsHeader.hasMore = NO;
|
||||
}
|
||||
return _giftsHeader;
|
||||
}
|
||||
|
||||
- (XPMineUserSectionHeader *)luckyGiftsHeader {
|
||||
if (!_luckyGiftsHeader) {
|
||||
_luckyGiftsHeader = [[XPMineUserSectionHeader alloc] init];
|
||||
_luckyGiftsHeader.title = @"幸运礼物";
|
||||
_luckyGiftsHeader.hasMore = NO;
|
||||
}
|
||||
return _luckyGiftsHeader;
|
||||
}
|
||||
|
||||
- (UIButton *)giftsExpandButton {
|
||||
if (!_giftsExpandButton) {
|
||||
_giftsExpandButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_giftsExpandButton setImage:[UIImage imageNamed:@"room_across_pk_panel_fold"] forState:UIControlStateNormal];
|
||||
// [_giftsExpandButton addTarget:self action:@selector(foldButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
_giftsExpandButton.selected = YES;
|
||||
[_giftsExpandButton setEnlargeEdgeWithTop:5 right:10 bottom:10 left:10];
|
||||
}
|
||||
return _giftsExpandButton;
|
||||
}
|
||||
|
||||
- (UIButton *)luckyGiftsExpandButton {
|
||||
if (!_luckyGiftsExpandButton) {
|
||||
_luckyGiftsExpandButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_luckyGiftsExpandButton setImage:[UIImage imageNamed:@"room_across_pk_panel_fold"] forState:UIControlStateNormal];
|
||||
// [_giftsExpandButton addTarget:self action:@selector(foldButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
_luckyGiftsExpandButton.selected = YES;
|
||||
[_luckyGiftsExpandButton setEnlargeEdgeWithTop:5 right:10 bottom:10 left:10];
|
||||
}
|
||||
return _luckyGiftsExpandButton;
|
||||
}
|
||||
@end
|
||||
|
Reference in New Issue
Block a user