220 lines
7.2 KiB
Mathematica
220 lines
7.2 KiB
Mathematica
![]() |
//
|
||
|
// XPMineUserDataViewController.m
|
||
|
// xplan-ios
|
||
|
//
|
||
|
// Created by 冯硕 on 2022/4/14.
|
||
|
//
|
||
|
|
||
|
#import "XPMineUserDataViewController.h"
|
||
|
///Third
|
||
|
#import <Masonry/Masonry.h>
|
||
|
///View
|
||
|
#import "XPMineDataSkillCardTableViewCell.h"
|
||
|
#import "XPMineDataClanTableViewCell.h"
|
||
|
#import "XPMineDataGiftTableViewCell.h"
|
||
|
///Model
|
||
|
#import "ClanDetailInfoModel.h"
|
||
|
#import "UserInfoModel.h"
|
||
|
///P
|
||
|
#import "XPMineUserDataPresenter.h"
|
||
|
#import "XPMineUserDataProtocol.h"
|
||
|
///View
|
||
|
#import "XPSkillCardViewController.h"
|
||
|
@interface XPMineUserDataViewController ()<XPMineUserDataProtocol, UITableViewDelegate, UITableViewDataSource, XPMineDataClanTableViewCellDelegate, XPMineDataGiftTableViewCellDelegate, XPMineDataSkillCardTableViewCellDelegate>
|
||
|
///列表
|
||
|
@property (nonatomic,strong) UITableView *tableView;
|
||
|
///家族信息
|
||
|
@property (nonatomic,strong) ClanDetailInfoModel *clanDetailInfo;
|
||
|
///技能卡
|
||
|
@property (nonatomic,strong) NSArray *skillArray;
|
||
|
///是否折叠
|
||
|
@property (nonatomic,assign) BOOL isFold;
|
||
|
@property (nonatomic, copy) void(^scrollCallback)(UIScrollView *scrollView);
|
||
|
@end
|
||
|
|
||
|
@implementation XPMineUserDataViewController
|
||
|
|
||
|
- (BOOL)isHiddenNavBar {
|
||
|
return YES;
|
||
|
}
|
||
|
|
||
|
- (__kindof id)createPresenter {
|
||
|
return [[XPMineUserDataPresenter alloc] init];
|
||
|
}
|
||
|
|
||
|
- (void)viewDidLoad {
|
||
|
[super viewDidLoad];
|
||
|
[self initHettpRequest];
|
||
|
[self initSubViews];
|
||
|
[self initSubViewConstraints];
|
||
|
}
|
||
|
#pragma mark - Http
|
||
|
- (void)initHettpRequest {
|
||
|
self.isFold = YES;
|
||
|
[self.presenter getUserSkillCardList:self.userUid];
|
||
|
[self.presenter getClanDetailInfo:self.userUid];
|
||
|
}
|
||
|
#pragma mark - Private Method
|
||
|
- (void)initSubViews {
|
||
|
[self.view addSubview:self.tableView];
|
||
|
}
|
||
|
|
||
|
- (void)initSubViewConstraints {
|
||
|
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.edges.mas_equalTo(self.view);
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||
|
return 3;
|
||
|
}
|
||
|
|
||
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
|
if (indexPath.section == 0) {
|
||
|
return 115;
|
||
|
} else if(indexPath.section == 1) {
|
||
|
if (self.clanDetailInfo.clan.elderUid.length > 0) {
|
||
|
if (self.clanDetailInfo.hall.ownerUid.length > 0) {
|
||
|
return self.isFold ? 115 : (115 + 60);
|
||
|
}else {
|
||
|
return 115;
|
||
|
}
|
||
|
}else {
|
||
|
return 75;
|
||
|
}
|
||
|
} else {
|
||
|
if (self.userInfo.userGiftWall.count > 0) {
|
||
|
CGFloat itemHeight = (56 + 20);
|
||
|
NSInteger count = self.userInfo.userGiftWall.count;
|
||
|
if (self.userInfo.userGiftWall.count > 16) {
|
||
|
count = 16;
|
||
|
}
|
||
|
int page = (int)count / 4;
|
||
|
int scale= count % 4;
|
||
|
if (scale == 0) {
|
||
|
return (itemHeight + 10) * page + 15 + 40;
|
||
|
} else {
|
||
|
return (itemHeight + 10) * (page + 1) + 15 + 40;
|
||
|
}
|
||
|
} else {
|
||
|
return 175;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
|
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) {
|
||
|
|
||
|
XPMineDataClanTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineDataClanTableViewCell class])];
|
||
|
if (cell == nil) {
|
||
|
cell = [[XPMineDataClanTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineDataClanTableViewCell class])];
|
||
|
}
|
||
|
cell.delegate = self;
|
||
|
cell.clanInfo = self.clanDetailInfo;
|
||
|
return cell;
|
||
|
} else {
|
||
|
XPMineDataGiftTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineDataGiftTableViewCell class])];
|
||
|
if (cell == nil) {
|
||
|
cell = [[XPMineDataGiftTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineDataGiftTableViewCell class])];
|
||
|
}
|
||
|
cell.delegate = self;
|
||
|
cell.datasource = self.userInfo.userGiftWall;
|
||
|
return cell;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#pragma mark - XPMineDataClanTableViewCellDelegate
|
||
|
- (void)xPMineDataClanTableViewCell:(XPMineDataClanTableViewCell *)view didClickFold:(UIButton *)sender {
|
||
|
self.isFold = sender.selected;
|
||
|
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
|
||
|
}
|
||
|
|
||
|
- (void)xPMineDataClanTableViewCell:(XPMineDataClanTableViewCell *)view didClickEnter:(ClanDetailInfoModel *)clanInfo {
|
||
|
//TODO: 加入工会
|
||
|
}
|
||
|
|
||
|
#pragma mark - XPMineDataGiftTableViewCellDelegate
|
||
|
- (void)xPMineDataGiftTableViewCell:(XPMineDataGiftTableViewCell *)view didClickMore:(UIButton *)sender {
|
||
|
//TODO: 查看更多礼物墙
|
||
|
}
|
||
|
|
||
|
#pragma mark - XPMineDataSkillCardTableViewCell
|
||
|
- (void)xPMineDataSkillCardTableViewCell:(XPMineDataSkillCardTableViewCell *)view didSelectItem:(MineSkillCardListInfoModel *)skillInfo {
|
||
|
XPSkillCardViewController *skillCardVC = [[XPSkillCardViewController alloc] init];
|
||
|
skillCardVC.uid = self.userUid.integerValue;
|
||
|
[self.navigationController pushViewController:skillCardVC animated:YES];
|
||
|
}
|
||
|
|
||
|
#pragma mark - JXPagingViewListViewDelegate
|
||
|
- (UIView *)listView {
|
||
|
return self.view;
|
||
|
}
|
||
|
|
||
|
- (UIScrollView *)listScrollView {
|
||
|
return self.tableView;
|
||
|
}
|
||
|
|
||
|
- (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
|
||
|
self.scrollCallback = callback;
|
||
|
}
|
||
|
|
||
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
||
|
self.scrollCallback(scrollView);
|
||
|
}
|
||
|
|
||
|
#pragma mark - XPMineUserDataProtocol
|
||
|
- (void)getUserSkillCardListSuccess:(NSArray *)list {
|
||
|
self.skillArray = list;
|
||
|
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
|
||
|
}
|
||
|
|
||
|
- (void)getClanDetailInfoSuccess:(ClanDetailInfoModel *)clanInfo {
|
||
|
self.clanDetailInfo = clanInfo;
|
||
|
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
|
||
|
}
|
||
|
|
||
|
#pragma mark - Getters And Setters
|
||
|
- (void)setUserInfo:(UserInfoModel *)userInfo {
|
||
|
_userInfo = userInfo;
|
||
|
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:2] withRowAnimation:UITableViewRowAnimationNone];
|
||
|
}
|
||
|
|
||
|
- (UITableView *)tableView {
|
||
|
if (!_tableView) {
|
||
|
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||
|
_tableView.delegate = self;
|
||
|
_tableView.dataSource = self;
|
||
|
_tableView.tableFooterView = [UIView new];
|
||
|
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||
|
_tableView.backgroundColor = [UIColor clearColor];
|
||
|
if (@available(iOS 11.0, *)) {
|
||
|
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||
|
}
|
||
|
[_tableView registerClass:[XPMineDataSkillCardTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineDataSkillCardTableViewCell class])];
|
||
|
[_tableView registerClass:[XPMineDataClanTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineDataClanTableViewCell class])];
|
||
|
}
|
||
|
return _tableView;
|
||
|
}
|
||
|
|
||
|
|
||
|
@end
|