更换项目
This commit is contained in:
246
YuMi/Modules/YMMine/View/MineInfo/XPMineUserDataViewController.m
Normal file
246
YuMi/Modules/YMMine/View/MineInfo/XPMineUserDataViewController.m
Normal file
@@ -0,0 +1,246 @@
|
||||
//
|
||||
// YMMineUserDataViewController.m
|
||||
// YUMI
|
||||
//
|
||||
// Created by YUMI on 2022/4/14.
|
||||
//
|
||||
|
||||
#import "XPMineUserDataViewController.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "AccountInfoStorage.h"
|
||||
#import "YUMIMacroUitls.h"
|
||||
#import "TTPopup.h"
|
||||
#import "DJDKMIMOMColor.h"
|
||||
#import "YUMIHtmlUrl.h"
|
||||
///View
|
||||
#import "XPMineDataClanTableViewCell.h"
|
||||
#import "XPMineDataGiftTableViewCell.h"
|
||||
///Model
|
||||
#import "ClanDetailInfoModel.h"
|
||||
#import "UserInfoModel.h"
|
||||
///P
|
||||
#import "XPMineUserDataPresenter.h"
|
||||
#import "XPMineUserDataProtocol.h"
|
||||
///View
|
||||
#import "XPMineUserInfoGiftWallViewController.h"
|
||||
#import "XPMineClanViewController.h"
|
||||
#import "XPMineGuildViewController.h"
|
||||
#import "XPWebViewController.h"
|
||||
@interface XPMineUserDataViewController ()<XPMineUserDataProtocol, UITableViewDelegate, UITableViewDataSource, XPMineDataClanTableViewCellDelegate, XPMineDataGiftTableViewCellDelegate>
|
||||
///列表
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
///家族信息
|
||||
@property (nonatomic,strong) ClanDetailInfoModel *clanDetailInfo;
|
||||
///是否折叠
|
||||
@property (nonatomic,assign) BOOL isFold;
|
||||
@property (nonatomic, copy) void(^scrollCallback)(UIScrollView *scrollView);
|
||||
///是否展示加入家族房间
|
||||
@property (nonatomic,assign) BOOL isShowEnterClan;
|
||||
@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.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);
|
||||
}];
|
||||
}
|
||||
|
||||
///实名认证弹窗
|
||||
- (void)showRealNameAuthenticationTipsAlertView {
|
||||
TTAlertConfig *config = [[TTAlertConfig alloc] init];
|
||||
config.message = YMLocalizedString(@"XPMineUserDataViewController0");
|
||||
config.messageLineSpacing = 4;
|
||||
config.confirmButtonConfig.title = YMLocalizedString(@"XPMineUserDataViewController1");
|
||||
config.confirmButtonConfig.titleColor = UIColor.whiteColor;
|
||||
config.confirmButtonConfig.backgroundColor = [DJDKMIMOMColor appMainColor];
|
||||
|
||||
TTAlertMessageAttributedConfig *nameAttrConf = [[TTAlertMessageAttributedConfig alloc] init];
|
||||
nameAttrConf.text = YMLocalizedString(@"XPMineUserDataViewController2");
|
||||
nameAttrConf.color = [DJDKMIMOMColor appMainColor];
|
||||
config.messageAttributedConfig = @[nameAttrConf];
|
||||
|
||||
[TTPopup alertWithConfig:config confirmHandler:^{
|
||||
|
||||
} cancelHandler:^{
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
return 2;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
if (section == 0) {
|
||||
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) {
|
||||
CGFloat itemHeigh = 40 + 15;
|
||||
if (self.clanDetailInfo.clan.elderUid.length > 0) {
|
||||
if (self.clanDetailInfo.hall.ownerUid.length > 0) {
|
||||
return self.isFold ? (itemHeigh + 68) : (itemHeigh + 68 + 60);
|
||||
}else {
|
||||
return (itemHeigh + 60);
|
||||
}
|
||||
}else {
|
||||
if (self.clanDetailInfo.hall.ownerUid.length > 0) {
|
||||
return (itemHeigh + 60);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CGFloat itemHeight = 65;
|
||||
CGFloat topHeight = 100;
|
||||
return itemHeight * 3 + 10 * 3 + topHeight + 25;
|
||||
}
|
||||
}
|
||||
|
||||
- (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.isShowEnterHall = self.isShowEnterClan;
|
||||
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.userGiftWall = self.userInfo.userGiftWall;
|
||||
cell.userLuckyBagGiftWall = self.userInfo.userLuckyBagGiftWall;
|
||||
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 {
|
||||
[self.presenter getUserInfo:[AccountInfoStorage instance].getUid success:^(UserInfoModel * _Nonnull info) {
|
||||
if (info.isCertified) {
|
||||
[self.presenter memberApplyHall:clanInfo.hall.hallId];
|
||||
} else {
|
||||
[self showRealNameAuthenticationTipsAlertView];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (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)getClanDetailInfoSuccess:(ClanDetailInfoModel *)clanDetailInfo currentUserClanInfo:(ClanDetailInfoModel *)currentUserClanInfo {
|
||||
self.clanDetailInfo = clanDetailInfo;
|
||||
if (currentUserClanInfo.clan.elderUid.length <=0 || currentUserClanInfo.hall.ownerUid.length <=0) {
|
||||
self.isShowEnterClan = YES;
|
||||
} else {
|
||||
self.isShowEnterClan = NO;
|
||||
}
|
||||
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
|
||||
}
|
||||
|
||||
- (void)memberApplyHallSuccess {
|
||||
[self showSuccessToast:YMLocalizedString(@"XPMineUserDataViewController3")];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setUserInfo:(UserInfoModel *)userInfo {
|
||||
_userInfo = userInfo;
|
||||
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] 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:[XPMineDataGiftTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineDataGiftTableViewCell class])];
|
||||
[_tableView registerClass:[XPMineDataClanTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineDataClanTableViewCell class])];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
|
||||
|
||||
@end
|
Reference in New Issue
Block a user