是否是查看自己的个人信息VC 展示不同的操作按钮

This commit is contained in:
fengshuo
2021-12-01 14:43:32 +08:00
committed by zu
parent 6726a74d0f
commit 06f594a77e
2 changed files with 84 additions and 4 deletions

View File

@@ -7,11 +7,15 @@
#import "XPMineUserInfoViewController.h"
///Third
#import <NIMSDK/NIMSDK.h>
#import <Masonry/Masonry.h>
#import <SDCycleScrollView/SDCycleScrollView.h>
///Tool
#import "ThemeColor.h"
#import "XPMacro.h"
#import "AccountInfoStorage.h"
#import "TTPopup.h"
#import "XPHtmlUrl.h"
///View
#import "XPMineUserInfoTableViewCell.h"
#import "XPMineUserInfoHeaderView.h"
@@ -22,6 +26,7 @@
#import "XPMineUserInfoProtocol.h"
///VC
#import "XPMineUserInfoEditViewController.h"
#import "XPWebViewController.h"
@interface XPMineUserInfoViewController ()<UITableViewDelegate, UITableViewDataSource, XPMineCustomNavViewDelegate, XPMineUserInfoProtocol, UIGestureRecognizerDelegate>
///
@@ -55,7 +60,7 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (self.uid > 0) {
NSString * uidStr = [NSString stringWithFormat:@"%lld", self.uid];
NSString * uidStr = [NSString stringWithFormat:@"%ld", self.uid];
[self.presenter getUserInfoWithUid:uidStr];
}
}
@@ -90,6 +95,67 @@
}];
}
#pragma mark -
- (void)showRightNavHandle {
NSMutableArray<TTActionSheetConfig *> *array = [NSMutableArray array];
NSString *uid = [NSString stringWithFormat:@"%ld",self.uid];
TTActionSheetConfig *report = [TTActionSheetConfig normalTitle:@"举报" clickAction:^{
XPWebViewController *vc = [[XPWebViewController alloc]init];
NSString *urlstr = [NSString stringWithFormat:@"%@?reportUid=%@&source=PERSONAL",URLWithType(kReportRoomURL),uid];
vc.url = urlstr;
[self.navigationController pushViewController:vc animated:YES];
}];
TTActionSheetConfig *removeBlack = [TTActionSheetConfig normalTitle:@"移除黑名单" clickAction:^{
[self addOrRemoveBlack:YES uid:uid];
}];
TTActionSheetConfig *black = [TTActionSheetConfig normalTitle:@"拉黑" clickAction:^{
[self addOrRemoveBlack:NO uid:uid];
}];
[array addObjectsFromArray:@[report, black]];
BOOL isInBlackList = [[NIMSDK sharedSDK].userManager isUserInBlackList:uid];
if (isInBlackList) {
[array addObject:removeBlack];
}
[TTPopup actionSheetWithItems:array];
}
//
- (void)addOrRemoveBlack:(BOOL)isRemove uid:(NSString *)uid {
NSString *title;
NSString *message;
if (isRemove) {
title = @"移除黑名单";
message = @"移除黑名单,你将正常收到对方的消息";
}else{
title = @"加入黑名单";
message = @"加入黑名单,你将不再收到对方的消息";
}
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = title;
config.message = message;
[TTPopup alertWithConfig:config confirmHandler:^{
if (isRemove) {
[[NIMSDK sharedSDK].userManager removeFromBlackBlackList:uid completion:^(NSError * _Nullable error) {
if (error == nil) {
[self showSuccessToast:@"移出黑名单成功"];
}
}];
} else {
[[NIMSDK sharedSDK].userManager addToBlackList:uid completion:^(NSError * _Nullable error) {
if (error == nil) {
[self showSuccessToast:@"加入黑名单成功"];
}
}];
}
} cancelHandler:^{
}];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
@@ -114,8 +180,12 @@
#pragma mark - XPMineCustomNavViewDelegate
- (void)xPMineCustomNavView:(XPMineUserInfoCustomNavView *)view didClickEditButton:(UIButton *)sender {
XPMineUserInfoEditViewController * editVC = [[XPMineUserInfoEditViewController alloc] init];
[self.navigationController pushViewController:editVC animated:YES];
if (sender.isSelected) {///
XPMineUserInfoEditViewController * editVC = [[XPMineUserInfoEditViewController alloc] init];
[self.navigationController pushViewController:editVC animated:YES];
} else {
[self showRightNavHandle];
}
}
- (void)xPMineCustomNavView:(XPMineUserInfoCustomNavView *)view didClickBackButton:(UIButton *)sender {
@@ -133,7 +203,15 @@
- (void)setUid:(NSInteger)uid {
_uid = uid;
if (_uid > 0) {
NSString * uidStr = [NSString stringWithFormat:@"%d", uid];
if (_uid == [AccountInfoStorage instance].getUid.integerValue) {
[self.navView.editButton setTitle:@"编辑" forState:UIControlStateNormal];
[self.navView.editButton setImage:[UIImage new] forState:UIControlStateNormal];
} else {
[self.navView.editButton setTitle:@"" forState:UIControlStateNormal];
[self.navView.editButton setImage:[UIImage imageNamed:@"mine_user_info_edit"] forState:UIControlStateNormal];
}
self.navView.editButton.selected = _uid == [AccountInfoStorage instance].getUid.integerValue;
NSString * uidStr = [NSString stringWithFormat:@"%ld", uid];
[self.presenter getUserInfoWithUid:uidStr];
}
}

View File

@@ -86,6 +86,8 @@
if (!_editButton) {
_editButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_editButton setImage:[UIImage imageNamed:@"mine_user_info_edit"] forState:UIControlStateNormal];
_editButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_editButton setTitleColor:[ThemeColor alertTitleColor] forState:UIControlStateNormal];
[_editButton addTarget:self action:@selector(editButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[_editButton setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
}