449 lines
18 KiB
Objective-C
449 lines
18 KiB
Objective-C
//
|
|
// XPMineUserDataViewController.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2022/4/14.
|
|
//
|
|
|
|
#import "XPMineUserDataViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "AccountInfoStorage.h"
|
|
#import "XPMonentsLayoutConfig.h"
|
|
///View
|
|
|
|
#import "XPMineDataClanTableViewCell.h"
|
|
#import "XPMineDataGiftTableViewCell.h"
|
|
#import "XPMonentsTableViewCell.h"
|
|
#import "XPMonentsEmptyTableViewCell.h"
|
|
///Model
|
|
#import "ClanDetailInfoModel.h"
|
|
#import "UserInfoModel.h"
|
|
#import "MineSkillCardListInfoModel.h"
|
|
///P
|
|
#import "XPMineUserDataPresenter.h"
|
|
#import "XPMineUserDataProtocol.h"
|
|
#import "XPMonentsMineProtocol.h"
|
|
///View
|
|
|
|
#import "XPMineUserInfoGiftWallViewController.h"
|
|
#import "XPMineClanViewController.h"
|
|
#import "XPMineGuildViewController.h"
|
|
#import "XPMonentsDetailViewController.h"
|
|
@interface XPMineUserDataViewController ()<XPMineUserDataProtocol, UITableViewDelegate, UITableViewDataSource, XPMineDataClanTableViewCellDelegate, XPMineDataGiftTableViewCellDelegate, XPMonentsTableViewCellDelegate, XPMonentsMineProtocol, XPMonentsDetailViewControllerDelegate>
|
|
///列表
|
|
@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);
|
|
///是否展示加入家族房间
|
|
@property (nonatomic,assign) BOOL isShowEnterClan;
|
|
///数据源
|
|
@property (nonatomic,strong) NSMutableArray<MonentsInfoModel *> *datasource;
|
|
@property (nonatomic,strong) UIView *headView;
|
|
///
|
|
///
|
|
@property (nonatomic,assign) BOOL isOpne;
|
|
@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.isOpne = self.userUid.integerValue == [[AccountInfoStorage instance]getUid].integerValue;
|
|
self.isFold = YES;
|
|
self.isShowEnterClan = NO;
|
|
[self.presenter getClanDetailInfo:self.userUid currentUserUid:[AccountInfoStorage instance].getUid];
|
|
}
|
|
#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 2;
|
|
}
|
|
|
|
- (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;
|
|
// }
|
|
}
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
if(indexPath.section == 0){
|
|
if(self.isOpne == YES){
|
|
if (self.clanDetailInfo.clan.elderUid.length > 0) {
|
|
return kGetScaleWidth(172);
|
|
}
|
|
return kGetScaleWidth(152);
|
|
}
|
|
return kGetScaleWidth(128);
|
|
}
|
|
if (self.datasource.count > 0) {
|
|
MonentsInfoModel * monentInfo= [self.datasource safeObjectAtIndex1:indexPath.row];
|
|
[XPMonentsLayoutConfig getNewlayoutMonentsModelWithDynamic:monentInfo];
|
|
if(monentInfo.content.length == 0){
|
|
return monentInfo.rowHeight + 20;
|
|
}
|
|
return monentInfo.rowHeight;
|
|
}
|
|
return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight;
|
|
}
|
|
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
|
|
return nil;
|
|
}
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
|
return 0.01;
|
|
}
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
|
if(section == 0)return 0.01;
|
|
return self.datasource.count > 0 ? 30 : 0.01;
|
|
}
|
|
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
|
if(section == 0)return nil;
|
|
return self.datasource.count > 0 ? self.headView : nil;
|
|
}
|
|
- (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])];
|
|
}
|
|
cell.isOpne = self.isOpne;
|
|
cell.isShowEnterHall = self.isShowEnterClan;
|
|
cell.delegate = self;
|
|
cell.userInfo = self.userInfo;
|
|
cell.clanInfo = self.clanDetailInfo;
|
|
return cell;
|
|
}
|
|
|
|
if (self.datasource.count > 0) {
|
|
XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"XPMonentsDynamicTableViewCell" forIndexPath:indexPath];
|
|
MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1: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;
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
if (self.datasource.count > 0) {
|
|
XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init];
|
|
MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row];
|
|
if(monentsInfo.dynamicId == nil){
|
|
return;
|
|
}
|
|
detailVC.monentsInfo = monentsInfo;
|
|
detailVC.delegate = self;
|
|
[self.navigationController pushViewController:detailVC animated:YES];
|
|
}
|
|
}
|
|
#pragma mark - XPMonentsTableViewCellDelegate
|
|
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo {
|
|
if(monentsInfo.dynamicId == nil){
|
|
[self showErrorToast:YMLocalizedString(@"XPMineUserDataViewController2")];
|
|
return;
|
|
}
|
|
[self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]];
|
|
}
|
|
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicCommon:(MonentsInfoModel *)monentsInfo{
|
|
if(monentsInfo.dynamicId == nil){
|
|
[self showErrorToast:YMLocalizedString(@"XPMineUserDataViewController3")];
|
|
return;
|
|
}
|
|
XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init];
|
|
detailVC.monentsInfo = monentsInfo;
|
|
detailVC.delegate = self;
|
|
[self.navigationController pushViewController:detailVC animated:YES];
|
|
}
|
|
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicDelete:(MonentsInfoModel *)monentsInfo {
|
|
[TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsMineViewController0") confirmHandler:^{
|
|
[self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]];
|
|
} cancelHandler:^{
|
|
|
|
}];
|
|
}
|
|
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicShielding:(nonnull MonentsInfoModel *)monentsInfo{
|
|
|
|
|
|
[self showLoading];
|
|
[self.presenter requesstShieldingWtihType:@"0" objId:monentsInfo.dynamicId];
|
|
|
|
|
|
}
|
|
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicFold:(MonentsInfoModel *)monentsInfo {
|
|
__block MonentsInfoModel * monentsInfos;
|
|
[self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
if (obj.dynamicId.integerValue == monentsInfo.dynamicId.integerValue) {
|
|
monentsInfos = obj;
|
|
*stop = YES;
|
|
}
|
|
}];
|
|
if (monentsInfos) {
|
|
NSInteger section = [self.datasource indexOfObject:monentsInfo];
|
|
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:section inSection:1]] withRowAnimation:UITableViewRowAnimationNone];
|
|
}
|
|
}
|
|
|
|
#pragma mark - XPMonentsDetailViewControllerDelegate
|
|
- (void)xPMonentsDetailViewController:(XPMonentsDetailViewController *)view deleteMonents:(NSString *)dynamicId {
|
|
__block MonentsInfoModel * deleteInfo;
|
|
[self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
if (obj.dynamicId.integerValue == dynamicId.integerValue) {
|
|
deleteInfo = obj;
|
|
}
|
|
}];
|
|
|
|
if (deleteInfo) {
|
|
[self.datasource removeObject:deleteInfo];
|
|
[self.tableView reloadData];
|
|
}
|
|
}
|
|
|
|
#pragma mark - XPMonentsMineProtocol
|
|
- (void)requesstShieldingSuccess:(NSString *)monentsInfo{
|
|
[self hideHUD];
|
|
[self showSuccessToast:YMLocalizedString(@"XPMonentsMineViewController2")];
|
|
__block MonentsInfoModel * deleteInfo;
|
|
[self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
if (obj.dynamicId.integerValue == monentsInfo.integerValue) {
|
|
deleteInfo = obj;
|
|
}
|
|
}];
|
|
|
|
if (deleteInfo) {
|
|
[self.datasource removeObject:deleteInfo];
|
|
[self.tableView reloadData];
|
|
}
|
|
}
|
|
- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status {
|
|
[self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
if ([obj.dynamicId isEqualToString:dynamicId]) {
|
|
NSInteger likeCount = obj.likeCount.integerValue;
|
|
if (status) {
|
|
likeCount += 1;
|
|
obj.isLike += 1;
|
|
} else {
|
|
likeCount -= 1;
|
|
obj.isLike -= 1;
|
|
}
|
|
obj.likeCount = @(likeCount).stringValue;
|
|
*stop = YES;
|
|
}
|
|
}];
|
|
[self.tableView reloadData];
|
|
}
|
|
|
|
- (void)deleteMonentsSuccess:(NSString *)monentsInfo {
|
|
[self showSuccessToast:YMLocalizedString(@"XPMonentsMineViewController1")];
|
|
__block MonentsInfoModel * deleteInfo;
|
|
[self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
if (obj.dynamicId.integerValue == monentsInfo.integerValue) {
|
|
deleteInfo = obj;
|
|
}
|
|
}];
|
|
|
|
if (deleteInfo) {
|
|
[self.datasource removeObject:deleteInfo];
|
|
[self.tableView reloadData];
|
|
}
|
|
}
|
|
|
|
#pragma mark - XPMineDataClanTableViewCellDelegate
|
|
- (void)xPMineDataClanTableViewCell:(XPMineDataClanTableViewCell *)view didClickFold:(UIButton *)sender {
|
|
self.isFold = !sender.selected;
|
|
[self.tableView reloadData];
|
|
// [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
|
|
}
|
|
- (void)xPMineDataClanTableViewCell:(XPMineDataClanTableViewCell *)view didClickOpen:(ClanDetailInfoModel *)clanInfo{
|
|
self.isOpne = YES;
|
|
[self.tableView reloadData];
|
|
}
|
|
- (void)xPMineDataClanTableViewCell:(XPMineDataClanTableViewCell *)view didClickEnter:(ClanDetailInfoModel *)clanInfo {
|
|
[self.presenter memberApplyHall:clanInfo.hall.hallId];
|
|
}
|
|
|
|
- (void)xPMineDataClanTableViewCell:(XPMineDataClanTableViewCell *)view didClickClanView:(ClanDetailInfoModel *)clanInfo {
|
|
XPMineClanViewController * clanVC = [[XPMineClanViewController alloc] init];
|
|
clanVC.uid = self.clanDetailInfo.clan.elderUid;
|
|
[self.navigationController pushViewController:clanVC animated:YES];
|
|
}
|
|
|
|
- (void)xPMineDataClanTableViewCell:(XPMineDataClanTableViewCell *)view didClickHallView:(ClanDetailInfoModel *)clanInfo {
|
|
XPMineGuildViewController * hallVC = [[XPMineGuildViewController alloc] init];
|
|
hallVC.ownerUid = clanInfo.hall.ownerUid;
|
|
hallVC.guildId = clanInfo.hall.hallId;
|
|
[self.navigationController pushViewController:hallVC animated:YES];
|
|
}
|
|
|
|
#pragma mark - XPMineDataGiftTableViewCellDelegate
|
|
- (void)xPMineDataGiftTableViewCell:(XPMineDataGiftTableViewCell *)view didClickMore:(UIButton *)sender {
|
|
XPMineUserInfoGiftWallViewController * giftWallVC = [[XPMineUserInfoGiftWallViewController alloc] init];
|
|
giftWallVC.userUid = self.userUid;
|
|
[self.navigationController pushViewController:giftWallVC 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 {
|
|
NSMutableArray<MineSkillCardListInfoModel *> * array = [NSMutableArray arrayWithArray:list];
|
|
__block MineSkillCardListInfoModel * voiceCard;
|
|
[array enumerateObjectsUsingBlock:^(MineSkillCardListInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
if ([obj.cardId isEqualToString:@"8"]) {
|
|
voiceCard = obj;
|
|
*stop = YES;
|
|
}
|
|
}];
|
|
if (voiceCard) {
|
|
[array removeObject:voiceCard];
|
|
}
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineUserDataViewController:didGetVoiceSuccess:)]) {
|
|
[self.delegate xPMineUserDataViewController:self didGetVoiceSuccess:voiceCard];
|
|
}
|
|
self.skillArray = [array copy];
|
|
[self.tableView reloadData];
|
|
// [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
|
|
}
|
|
|
|
- (void)getClanDetailInfoSuccess:(ClanDetailInfoModel *)clanDetailInfo currentUserClanInfo:(ClanDetailInfoModel *)currentUserClanInfo {
|
|
self.clanDetailInfo = clanDetailInfo;
|
|
if (clanDetailInfo.hall.hallName.length > 0 && currentUserClanInfo.hall.hallName.length <= 0 && ![[AccountInfoStorage instance].getUid isEqualToString:self.userUid]) {
|
|
self.isShowEnterClan = YES;
|
|
} else {
|
|
self.isShowEnterClan = NO;
|
|
}
|
|
[self.tableView reloadData];
|
|
// [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
|
|
}
|
|
|
|
- (void)memberApplyHallSuccess {
|
|
[self showSuccessToast:YMLocalizedString(@"XPMineUserDataViewController0")];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setUserInfo:(UserInfoModel *)userInfo {
|
|
_userInfo = userInfo;
|
|
|
|
[self.tableView reloadData];
|
|
}
|
|
- (void)setDynamicInfo:(NSArray<MonentsInfoModel *> *)dynamicInfo {
|
|
[self.datasource removeAllObjects];
|
|
[self.datasource addObjectsFromArray:dynamicInfo];
|
|
[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];
|
|
if (@available(iOS 11.0, *)) {
|
|
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
}
|
|
[_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
|
[_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:@"XPMonentsDynamicTableViewCell"];
|
|
[_tableView registerClass:[XPMineDataClanTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineDataClanTableViewCell 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.left.mas_equalTo(12);
|
|
}];
|
|
}
|
|
return _headView;
|
|
}
|
|
@end
|