333 lines
12 KiB
Objective-C
333 lines
12 KiB
Objective-C
//
|
|
// CHSessionInfoViewController.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2022/4/25.
|
|
//
|
|
|
|
#import "CHSessionInfoViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <NIMSDK/NIMSDK.h>
|
|
///Tool
|
|
#import "MEWThemeColor.h"
|
|
#import "NetImageView.h"
|
|
#import "TTPopup.h"
|
|
|
|
///View
|
|
#import "YMWebViewController.h"
|
|
|
|
|
|
@interface CHSessionInfoViewController ()
|
|
///最外面的容器
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
|
///用户信息的view
|
|
@property (nonatomic,strong) UIView * infoView;
|
|
///头像
|
|
@property (nonatomic,strong) NetImageView *avatarImageView;
|
|
///昵称
|
|
@property (nonatomic,strong) UILabel *nickLabel;
|
|
///个人主页
|
|
@property (nonatomic,strong) UILabel *titleLabel;
|
|
///箭头
|
|
@property (nonatomic,strong) UIImageView *arrowImageView;
|
|
///显示举报 加入黑名单
|
|
@property (nonatomic,strong) UIStackView *contentStackView;
|
|
///举报
|
|
@property (nonatomic,strong) UIButton *reportButton;
|
|
///分割线
|
|
@property (nonatomic,strong) UIView * lineView;
|
|
///加入黑名单
|
|
@property (nonatomic,strong) UIButton *blackButton;
|
|
|
|
@end
|
|
|
|
@implementation CHSessionInfoViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initData];
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initData {
|
|
[[NIMSDK sharedSDK].userManager fetchUserInfos:@[self.userId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
|
|
if (!error) {
|
|
NIMUser * user = users.firstObject;
|
|
self.avatarImageView.imageUrl = user.userInfo.avatarUrl;
|
|
self.nickLabel.text = user.userInfo.nickName;
|
|
} else {
|
|
[self showErrorToast:@"用户信息请求失败,请重试"];
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
}
|
|
}];
|
|
|
|
self.blackButton.selected = [[NIMSDK sharedSDK].userManager isUserInBlackList:self.userId];
|
|
}
|
|
|
|
- (void)initSubViews {
|
|
self.title = @"举报";
|
|
[self.view addSubview:self.stackView];
|
|
|
|
[self.stackView addArrangedSubview:self.infoView];
|
|
[self.stackView addArrangedSubview:self.contentStackView];
|
|
|
|
[self.infoView addSubview:self.avatarImageView];
|
|
[self.infoView addSubview:self.nickLabel];
|
|
[self.infoView addSubview:self.titleLabel];
|
|
[self.infoView addSubview:self.arrowImageView];
|
|
|
|
[self.contentStackView addArrangedSubview:self.reportButton];
|
|
[self.contentStackView addArrangedSubview:self.lineView];
|
|
[self.contentStackView addArrangedSubview:self.blackButton];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.mas_equalTo(self.view);
|
|
make.top.mas_equalTo(self.view).offset(10);
|
|
}];
|
|
|
|
[self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(60);
|
|
}];
|
|
|
|
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(40, 40));
|
|
make.left.mas_equalTo(self.infoView).offset(15);
|
|
make.centerY.mas_equalTo(self.infoView);
|
|
}];
|
|
|
|
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.mas_equalTo(self.infoView);
|
|
make.left.mas_equalTo(self.avatarImageView.mas_right).offset(5);
|
|
make.right.mas_lessThanOrEqualTo(self.titleLabel.mas_left).offset(-5);
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(self.arrowImageView.mas_left).offset(-5);
|
|
make.centerY.mas_equalTo(self.infoView);
|
|
}];
|
|
|
|
[self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(6.5, 11));
|
|
make.centerY.mas_equalTo(self.infoView);
|
|
make.right.mas_equalTo(self.infoView).offset(-10);
|
|
}];
|
|
|
|
[self.reportButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(44);
|
|
}];
|
|
|
|
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(0.5);
|
|
}];
|
|
|
|
[self.blackButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(44);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Event Response
|
|
- (void)blackButtonAction:(UIButton *)sender {
|
|
NSString *title = nil;
|
|
NSString *message = nil;
|
|
BOOL isInBlack = [[NIMSDK sharedSDK].userManager isUserInBlackList:self.userId];
|
|
if (!isInBlack) {
|
|
title = @"加入黑名单";
|
|
message = @"加入黑名单,你将不再收到对方的消息";
|
|
} else {
|
|
title = @"移除黑名单";
|
|
message = @"移除黑名单,你将正常收到对方的消息";
|
|
}
|
|
|
|
TTAlertConfig *config = [[TTAlertConfig alloc] init];
|
|
config.title = title;
|
|
config.message = message;
|
|
[TTPopup alertWithConfig:config confirmHandler:^{
|
|
if (isInBlack) {
|
|
[[NIMSDK sharedSDK].userManager removeFromBlackBlackList:self.userId completion:^(NSError * _Nullable error) {
|
|
if (error == nil) {
|
|
[self showErrorToast:@"已经成功将对方移除黑名单"];
|
|
self.blackButton.selected = NO;
|
|
} else {
|
|
[self showErrorToast:error.description];
|
|
}
|
|
|
|
}];
|
|
} else {
|
|
[[NIMSDK sharedSDK].userManager addToBlackList:self.userId completion:^(NSError * _Nullable error) {
|
|
if (error == nil) {
|
|
[self showErrorToast:@"已经成功将对方加入黑名单"];
|
|
self.blackButton.selected = YES;
|
|
} else {
|
|
[self showErrorToast:error.description];
|
|
}
|
|
}];
|
|
}
|
|
} cancelHandler:^{
|
|
|
|
}];
|
|
}
|
|
|
|
- (void)reportButtonAction:(UIButton *)sender {
|
|
|
|
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"举报内容" message:@""
|
|
preferredStyle:UIAlertControllerStyleActionSheet];
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"色情低俗,以任何形式传播淫秽、色情、低俗擦边的内" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
|
|
[self showSuccessToast:@"举报成功"];
|
|
}]];
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"政治敏感,进行反党反政府或带有侮辱诋毁党和国家的内容" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
|
|
[self showSuccessToast:@"举报成功"];
|
|
}]];
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"垃圾广告,传播垃圾广告或违法违规广告信息" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
|
|
[self showSuccessToast:@"举报成功"];
|
|
}]];
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"言语攻击,恶意抹黑、诋毁或辱骂他人" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
|
|
[self showSuccessToast:@"举报成功"];
|
|
}]];
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"违规交易,发布线下交易或可能涉及诈骗的内容" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
|
|
[self showSuccessToast:@"举报成功"];
|
|
}]];
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"泄露隐私,以任何形式泄露他人隐私" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
|
|
[self showSuccessToast:@"举报成功"];
|
|
}]];
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"暴力恐怖,传播暴力、血腥、威胁生命健康的内容或展示枪支、刀具" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
|
|
[self showSuccessToast:@"举报成功"];
|
|
}]];
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"侵权盗版,侵犯他人合法版权" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
|
|
[self showSuccessToast:@"举报成功"];
|
|
}]];
|
|
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"其它" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
|
|
[self showSuccessToast:@"举报成功"];
|
|
}]];
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){
|
|
// [self showSuccessToast:@"举报成功"];
|
|
}]];
|
|
[self presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
|
}
|
|
|
|
- (void)didTapUserRecognizer {
|
|
// XPMineUserInfoViewController * mineVC = [[XPMineUserInfoViewController alloc] init];
|
|
// mineVC.uid = self.userId.integerValue;
|
|
// [self.navigationController pushViewController:mineVC animated:YES];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (UIStackView *)stackView {
|
|
if (!_stackView) {
|
|
_stackView = [[UIStackView alloc] init];
|
|
_stackView.axis = UILayoutConstraintAxisVertical;
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
_stackView.alignment = UIStackViewAlignmentFill;
|
|
_stackView.spacing = 20;
|
|
}
|
|
return _stackView;
|
|
}
|
|
|
|
- (UIView *)infoView {
|
|
if (!_infoView) {
|
|
_infoView = [[UIView alloc] init];
|
|
_infoView.backgroundColor = [MEWThemeColor mewAppCellBackgroundColor];
|
|
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapUserRecognizer)];
|
|
[_infoView addGestureRecognizer:tap];
|
|
_infoView.hidden = YES;
|
|
}
|
|
return _infoView;
|
|
}
|
|
|
|
- (NetImageView *)avatarImageView {
|
|
if (!_avatarImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.imageType = ImageTypeUserIcon;
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_avatarImageView.layer.masksToBounds = YES;
|
|
_avatarImageView.layer.cornerRadius = 20;
|
|
}
|
|
return _avatarImageView;
|
|
}
|
|
|
|
- (UILabel *)nickLabel {
|
|
if (!_nickLabel) {
|
|
_nickLabel = [[UILabel alloc] init];
|
|
_nickLabel.font = [UIFont systemFontOfSize:15];
|
|
_nickLabel.textColor = [MEWThemeColor mewMainTextColor];
|
|
}
|
|
return _nickLabel;
|
|
}
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.font = [UIFont systemFontOfSize:14];
|
|
_titleLabel.text = @"个人主页";
|
|
_titleLabel.textColor = [MEWThemeColor mewSecondTextColor];
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
- (UIImageView *)arrowImageView {
|
|
if (!_arrowImageView) {
|
|
_arrowImageView = [[UIImageView alloc] init];
|
|
_arrowImageView.userInteractionEnabled = YES;
|
|
_arrowImageView.image = [UIImage imageNamed:@"room_setting_arrow"];
|
|
}
|
|
return _arrowImageView;
|
|
}
|
|
|
|
|
|
- (UIStackView *)contentStackView {
|
|
if (!_contentStackView) {
|
|
_contentStackView = [[UIStackView alloc] init];
|
|
_contentStackView.axis = UILayoutConstraintAxisVertical;
|
|
_contentStackView.distribution = UIStackViewDistributionFill;
|
|
_contentStackView.alignment = UIStackViewAlignmentFill;
|
|
_contentStackView.spacing = 0;
|
|
}
|
|
return _contentStackView;
|
|
}
|
|
|
|
- (UIButton *)reportButton {
|
|
if (!_reportButton) {
|
|
_reportButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_reportButton setTitle:@"举报" forState:UIControlStateNormal];
|
|
[_reportButton setTitleColor:[MEWThemeColor mewMainTextColor] forState:UIControlStateNormal];
|
|
_reportButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
|
|
[_reportButton setBackgroundColor:[MEWThemeColor mewAppCellBackgroundColor]];
|
|
[_reportButton addTarget:self action:@selector(reportButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _reportButton;
|
|
}
|
|
|
|
- (UIView *)lineView {
|
|
if (!_lineView) {
|
|
_lineView = [[UIView alloc] init];
|
|
_lineView.backgroundColor = [MEWThemeColor mewDividerColor];
|
|
}
|
|
return _lineView;
|
|
}
|
|
|
|
- (UIButton *)blackButton {
|
|
if (!_blackButton) {
|
|
_blackButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_blackButton setTitle:@"加入黑名单" forState:UIControlStateNormal];
|
|
[_blackButton setTitle:@"移除黑名单" forState:UIControlStateSelected];
|
|
[_blackButton setTitleColor:[MEWThemeColor mewMainTextColor] forState:UIControlStateNormal];
|
|
[_blackButton setTitleColor:[MEWThemeColor mewMainTextColor] forState:UIControlStateSelected];
|
|
_blackButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
|
|
[_blackButton setBackgroundColor:[MEWThemeColor mewAppCellBackgroundColor]];
|
|
[_blackButton addTarget:self action:@selector(blackButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
_blackButton.hidden = YES;
|
|
}
|
|
return _blackButton;
|
|
}
|
|
|
|
|
|
@end
|