个人用户资料中心 私聊 跟随进房 关注

This commit is contained in:
fengshuo
2021-12-02 20:34:48 +08:00
parent f8fbbccc31
commit bdd744da32
25 changed files with 482 additions and 107 deletions

View File

@@ -168,7 +168,6 @@
E84B0E3F2727EDF6008818C6 /* XPRoomMessageTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E3E2727EDF6008818C6 /* XPRoomMessageTableViewCell.m */; };
E84B0E422727EE0A008818C6 /* XPRoomMessageHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E412727EE0A008818C6 /* XPRoomMessageHeaderView.m */; };
E84B0E462727EF9D008818C6 /* XPRoomMessageParser.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E452727EF9D008818C6 /* XPRoomMessageParser.m */; };
E865963F27015A9C00846EBD /* XPMineUserTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = E865963E27015A9C00846EBD /* XPMineUserTableView.m */; };
E86596432701611A00846EBD /* UIImage+ImageEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596412701611A00846EBD /* UIImage+ImageEffects.m */; };
E86596512701A1C000846EBD /* StatisticsService.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596502701A1C000846EBD /* StatisticsService.m */; };
E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596532701A55500846EBD /* StatisticsServiceHelper.m */; };
@@ -625,8 +624,6 @@
E84B0E442727EF9D008818C6 /* XPRoomMessageParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageParser.h; sourceTree = "<group>"; };
E84B0E452727EF9D008818C6 /* XPRoomMessageParser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMessageParser.m; sourceTree = "<group>"; };
E84B0E4927280289008818C6 /* XPRoomMessageConstant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageConstant.h; sourceTree = "<group>"; };
E865963D27015A9C00846EBD /* XPMineUserTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineUserTableView.h; sourceTree = "<group>"; };
E865963E27015A9C00846EBD /* XPMineUserTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineUserTableView.m; sourceTree = "<group>"; };
E86596412701611A00846EBD /* UIImage+ImageEffects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+ImageEffects.m"; sourceTree = "<group>"; };
E86596422701611A00846EBD /* UIImage+ImageEffects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+ImageEffects.h"; sourceTree = "<group>"; };
E865964F2701A1C000846EBD /* StatisticsService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatisticsService.h; sourceTree = "<group>"; };
@@ -1981,8 +1978,6 @@
E88B5CC426FB42B000DA9178 /* XPMineUserInfoHeaderView.m */,
E8EEB91B26FC9D58007C6EBA /* XPMineUserInfoDateView.h */,
E8EEB91C26FC9D58007C6EBA /* XPMineUserInfoDateView.m */,
E865963D27015A9C00846EBD /* XPMineUserTableView.h */,
E865963E27015A9C00846EBD /* XPMineUserTableView.m */,
);
path = MineInfo;
sourceTree = "<group>";
@@ -2662,7 +2657,6 @@
E8C6FFD42754AA87004DC9F0 /* XPNoteView.m in Sources */,
E82325F9274E2E42003A3332 /* Api+UserCard.m in Sources */,
E82109B026F1D83500FC3319 /* LoginBindPhonePresent.m in Sources */,
E865963F27015A9C00846EBD /* XPMineUserTableView.m in Sources */,
E8B825C726EA0D9A009E8E9F /* LoginVerifCodeProtocol.h in Sources */,
E824544E26F5BC1A00BE8163 /* XPMineModifPayPwdView.m in Sources */,
E8B825CA26EA1231009E8E9F /* LoginVerifCodeViewController.m in Sources */,

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "mine_user_info_bottom_attention_normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "mine_user_info_bottom_attention_normal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "mine_user_info_bottom_attention_select@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "mine_user_info_bottom_attention_select@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 B

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "mine_user_info_bottom_chat@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "mine_user_info_bottom_chat@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

View File

@@ -56,6 +56,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) NSString *nameplatePic;
///铭牌名称
@property (nonatomic, copy) NSString *nameplateWord;
///如果在房间有直播中字段
@property(nonatomic, copy) NSString * roomUid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic,assign) BOOL valid;
///性别
@property (nonatomic,assign) GenderType gender;
///搜索用户的时候 如果用户在房间中的话 就有roomUid
@property (nonatomic,copy) NSString *roomUid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -20,7 +20,7 @@
[Api searchComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
NSArray * array = [HomeSearchResultModel modelsWithArray:data.data];
[[self getView] searchRoomSuccess:array];
}] key:key type:type page:@"1" pageSize:@"50"];
} showLoading:YES] key:key type:type page:@"1" pageSize:@"50"];
}
@end

View File

@@ -53,15 +53,16 @@
self.nickLabel.text = type == SearchType_Room ? resultModel.title : resultModel.nick;
self.idLabel.text = [NSString stringWithFormat:@"%@号:%@",AppName, resultModel.erbanNo];
self.sexImageView.image = resultModel.gender == GenderType_Female ? [UIImage imageNamed:@"common_female"] : [UIImage imageNamed:@"common_male"];
self.numberView.hidden = !resultModel.valid;
if (type == SearchType_Users) {
self.numberLabel.text = @"直播中";
self.numberView.hidden = resultModel.roomUid.length <= 0;
} else {
if (resultModel.onlineNum > 100) {
self.numberLabel.text = [NSString stringWithFormat:@"%ld", resultModel.onlineNum];
} else {
self.numberLabel.text = [NSString stringWithFormat:@" %ld ", resultModel.onlineNum];
}
self.numberView.hidden = !resultModel.valid;
}
}
}

View File

@@ -136,6 +136,33 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)logoutCurrentAccount:(HttpRequestHelperCompletion)complection
access_token:(NSString *)access_token;
/// 查询两个人的关注状态
/// @param complection 完成
/// @param uid 自己的uid
/// @param isLikeUid 要查询的那个人的uid
+ (void)attentionStatusComplection:(HttpRequestHelperCompletion)complection
uid:(NSString *)uid
isLikeUid:(NSString *)isLikeUid;
/// 关注某人
/// @param complection 完成
/// @param uid 发起关注的人
/// @param likedUid 被关注的人
/// @param ticket ticket
/// @param type l类型默认1
+ (void)attentionComplection:(HttpRequestHelperCompletion)complection
uid:(NSString *)uid
likedUid:(NSString *)likedUid
ticket:(NSString *)ticket
type:(NSString *)type;
/// 获取用户详情
/// @param complection 完成
/// @param uid 发起关注的人
/// @param page page
/// @param pageSize pagesize
+ (void)userDetailInfoComplection:(HttpRequestHelperCompletion)complection uid:(NSString *)uid page:(NSString *)page pageSize:(NSString *)pageSize;
@end

View File

@@ -138,5 +138,31 @@
[self makeRequest:@"acc/logout" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, access_token, nil];
}
///
/// @param complection
/// @param uid uid
/// @param isLikeUid uid
+ (void)attentionStatusComplection:(HttpRequestHelperCompletion)complection uid:(NSString *)uid isLikeUid:(NSString *)isLikeUid {
[self makeRequest:@"fans/islike" method:HttpRequestHelperMethodGET completion:complection,__FUNCTION__, uid, isLikeUid, nil];
}
///
/// @param complection
/// @param uid
/// @param likedUid
/// @param ticket ticket
/// @param type 1 2
+ (void)attentionComplection:(HttpRequestHelperCompletion)complection uid:(NSString *)uid likedUid:(NSString *)likedUid ticket:(NSString *)ticket type:(NSString *)type {
[self makeRequest:@"fans/like" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, uid, likedUid, ticket, type, nil];
}
///
/// @param complection
/// @param uid
/// @param page page
/// @param pageSize pagesize
+ (void)userDetailInfoComplection:(HttpRequestHelperCompletion)complection uid:(NSString *)uid page:(NSString *)page pageSize:(NSString *)pageSize {
[self makeRequest:@"user/detail/get" method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, uid, page, pageSize, nil];
}
@end

View File

@@ -12,6 +12,16 @@ NS_ASSUME_NONNULL_BEGIN
@interface XPMineUserInfoPresenter : BaseMvpPresenter
// 获取用户信息
- (void)getUserInfoWithUid:(NSString *)uid;
// 获取用户详细信息
- (void)getUserDetailInfoWithUid:(NSString *)uid;
/// 两个人的关注状态
/// @param targetUid 对方的uid
- (void)getUserAttentionState:(NSString *)targetUid;
/// 关注用户 /取消该关注
/// @param targetUid 目标用户的uid
/// @param state 是否关注 yes 关注 NO 取消关注
- (void)attentionUser:(NSString *)targetUid state:(BOOL)state;
@end
NS_ASSUME_NONNULL_END

View File

@@ -6,8 +6,9 @@
//
#import "XPMineUserInfoPresenter.h"
///Api
///Tool
#import "Api+Mine.h"
#import "AccountInfoStorage.h"
///Model
#import "UserInfoModel.h"
///P
@@ -25,5 +26,35 @@
}] uid:uid];
}
//
- (void)getUserDetailInfoWithUid:(NSString *)uid {
[Api userDetailInfoComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
[[self getView] ongetDetailInfoSuccess:infoModel];
}] uid:uid page:@"1" pageSize:@"20"];
}
///
/// @param targetUid uid
- (void)getUserAttentionState:(NSString *)targetUid; {
NSString * uid = [[AccountInfoStorage instance] getUid];
[Api attentionStatusComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
BOOL isLike = ((NSNumber *)data.data).boolValue;
[[self getView] getAttentionStateSuccess:isLike];
}] uid:uid isLikeUid:targetUid];
}
/// /
/// @param targetUid uid
/// @param state yes NO
- (void)attentionUser:(NSString *)targetUid state:(BOOL)state {
NSString * uid = [[AccountInfoStorage instance] getUid];
NSString * ticket = [[AccountInfoStorage instance] getTicket];
NSString * type = state ? @"1" : @"2";
[Api attentionComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] attentionUserSuccess:state];
}] uid:uid likedUid:targetUid ticket:ticket type:type];
}
@end

View File

@@ -12,6 +12,12 @@ NS_ASSUME_NONNULL_BEGIN
@protocol XPMineUserInfoProtocol <NSObject>
///获取用户信息成功
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo;
///获取用户详细信息成功
- (void)ongetDetailInfoSuccess:(UserInfoModel *)userInfo;
///关注/取消关注
- (void)attentionUserSuccess:(BOOL)status;
///获取关注状态
- (void)getAttentionStateSuccess:(BOOL)status;
@end
NS_ASSUME_NONNULL_END

View File

@@ -24,6 +24,8 @@
@property (nonatomic,strong) UILabel *idLabel;
///
@property (nonatomic,strong) UILabel *signLabel;
///
@property (nonatomic,strong) UIButton *onlineButton;
@end
@implementation XPMineUserInfoTableViewCell
@@ -46,6 +48,7 @@
[self.backView addSubview:self.sexImageView];
[self.backView addSubview:self.idLabel];
[self.backView addSubview:self.signLabel];
[self.backView addSubview:self.onlineButton];
}
- (void)initSubViewConstraints {
@@ -73,6 +76,12 @@
make.left.mas_equalTo(self.nameLabel);
make.top.mas_equalTo(self.idLabel.mas_bottom).offset(18);
}];
[self.onlineButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(55, 18));
make.right.mas_equalTo(self.backView).offset(-15);
make.top.mas_equalTo(self.backView).offset(10);
}];
}
#pragma mark - Getters And Setters
@@ -137,5 +146,22 @@
return _signLabel;
}
- (UIButton *)onlineButton {
if (!_onlineButton) {
_onlineButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_onlineButton setTitle:@"直播中" forState:UIControlStateNormal];
[_onlineButton setImage:[UIImage imageNamed:@"home_search_user_online"] forState:UIControlStateNormal];
[_onlineButton setTitleColor:[ThemeColor appMainColor] forState:UIControlStateNormal];
_onlineButton.backgroundColor = [UIColor clearColor];
_onlineButton.titleLabel.font = [UIFont systemFontOfSize:10];
_onlineButton.layer.masksToBounds = YES;
_onlineButton.layer.cornerRadius = 18/2;
_onlineButton.layer.borderColor = [ThemeColor appMainColor].CGColor;
_onlineButton.layer.borderWidth = 1;
[_onlineButton addTarget:self action:@selector(onlineButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _onlineButton;
}
@end

View File

@@ -16,29 +16,35 @@
#import "AccountInfoStorage.h"
#import "TTPopup.h"
#import "XPHtmlUrl.h"
#import "UIImage+Utils.h"
///View
#import "XPMineUserInfoTableViewCell.h"
#import "XPMineUserInfoHeaderView.h"
#import "XPMineUserInfoCustomNavView.h"
#import "XPMineUserTableView.h"
///P
#import "XPMineUserInfoPresenter.h"
#import "XPMineUserInfoProtocol.h"
///VC
#import "XPMineUserInfoEditViewController.h"
#import "XPWebViewController.h"
#import "SessionViewController.h"
#import "XPRoomViewController.h"
@interface XPMineUserInfoViewController ()<UITableViewDelegate, UITableViewDataSource, XPMineCustomNavViewDelegate, XPMineUserInfoProtocol, UIGestureRecognizerDelegate>
@interface XPMineUserInfoViewController ()<UITableViewDelegate, UITableViewDataSource, XPMineCustomNavViewDelegate, XPMineUserInfoProtocol, UIGestureRecognizerDelegate, XPMineUserInfoHeaderViewDelegate>
///
@property (nonatomic,strong) XPMineUserTableView *tableView;
@property (nonatomic,strong) UITableView *tableView;
///
@property (nonatomic,strong) XPMineUserInfoHeaderView *headView;
///table
@property (nonatomic,strong) UIView * tableViewHeadView;
///
@property (nonatomic,strong) XPMineUserInfoCustomNavView *navView;
///
@property (nonatomic,strong) UserInfoModel *userInfo;
///
@property (nonatomic,strong) UIStackView *bottomStackView;
///
@property (nonatomic,strong) UIButton *chatButton;
///
@property (nonatomic,strong) UIButton *attentionButton;
@end
@implementation XPMineUserInfoViewController
@@ -55,6 +61,7 @@
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
[self initHttpRequest];
}
- (void)viewWillAppear:(BOOL)animated {
@@ -72,19 +79,24 @@
#pragma mark - Private Method
- (void)initSubViews {
[self.view addSubview:self.headView];
[self.view addSubview:self.tableView];
[self.view addSubview:self.navView];
self.tableView.tableHeaderView = self.tableViewHeadView;
self.tableView.userInfoVC = self;
self.tableView.tableHeaderView = self.headView;
if (self.uid != [AccountInfoStorage instance].getUid.integerValue) {
[self.view addSubview:self.bottomStackView];
[self.bottomStackView addArrangedSubview:self.chatButton];
[self.bottomStackView addArrangedSubview:self.attentionButton];
[self.bottomStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.view).inset(25);
make.height.mas_equalTo(36);
make.bottom.mas_equalTo(self.view).offset(-kSafeAreaBottomHeight - 15);
}];
}
}
- (void)initSubViewConstraints {
[self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self.view);
make.height.mas_equalTo(250 + kSafeAreaTopHeight);
}];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
@@ -93,6 +105,16 @@
make.left.right.top.mas_equalTo(self.view);
make.height.mas_equalTo(kNavigationHeight);
}];
}
- (void)initHttpRequest {
NSString *uid = [NSString stringWithFormat:@"%ld", self.uid];
[self.presenter getUserAttentionState:uid];
// 使
[self.presenter getUserDetailInfoWithUid:uid];
}
#pragma mark -
@@ -157,12 +179,9 @@
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
@@ -192,13 +211,42 @@
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - XPMineUserInfoHeaderViewDelegate
- (void)xPMineUserInfoHeaderView:(XPMineUserInfoHeaderView *)view didClickGoToRoom:(NSString *)roomUid {
[XPRoomViewController openRoom:roomUid viewController:self];
}
#pragma mark - XPMineUserInfoProtocol
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo {
self.userInfo = userInfo;
self.headView.userInfo = userInfo;
[self.tableView reloadData];
}
- (void)ongetDetailInfoSuccess:(UserInfoModel *)userInfo {
self.headView.userInfo = userInfo;
}
- (void)getAttentionStateSuccess:(BOOL)status {
self.attentionButton.selected = status;
}
- (void)attentionUserSuccess:(BOOL)status {
self.attentionButton.selected = status;
}
#pragma mark - Event Response
- (void)chatButtonAction:(UIButton *)sender {
NSString * sessionId = [NSString stringWithFormat:@"%ld",self.uid];
NIMSession * session = [NIMSession session:sessionId type:NIMSessionTypeP2P];
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
[self.navigationController pushViewController:sessionVC animated:YES];
}
- (void)attentionButtonAction:(UIButton *)sender {
NSString *uid = [NSString stringWithFormat:@"%ld", self.uid];
[self.presenter attentionUser:uid state:!sender.selected];
}
#pragma mark - Getters And Setters
- (void)setUid:(NSInteger)uid {
_uid = uid;
@@ -216,9 +264,9 @@
}
}
- (XPMineUserTableView *)tableView {
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[XPMineUserTableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.tableFooterView = [UIView new];
@@ -235,19 +283,12 @@
- (XPMineUserInfoHeaderView *)headView {
if (!_headView) {
_headView = [[XPMineUserInfoHeaderView alloc] init];
_headView.frame = CGRectMake(0, 0, KScreenWidth, 270 + kSafeAreaTopHeight);
_headView.delegate = self;
}
return _headView;
}
- (UIView *)tableViewHeadView {
if (!_tableViewHeadView) {
_tableViewHeadView = [[UIView alloc] init];
_tableViewHeadView.frame = CGRectMake(0, 0, KScreenWidth, 179 + kSafeAreaTopHeight);
_tableViewHeadView.backgroundColor = [UIColor clearColor];
}
return _tableViewHeadView;
}
- (XPMineUserInfoCustomNavView *)navView {
if (!_navView) {
_navView = [[XPMineUserInfoCustomNavView alloc] init];
@@ -256,4 +297,50 @@
return _navView;
}
- (UIStackView *)bottomStackView {
if (!_bottomStackView) {
_bottomStackView = [[UIStackView alloc] init];
_bottomStackView.axis = UILayoutConstraintAxisHorizontal;
_bottomStackView.distribution = UIStackViewDistributionFillEqually;
_bottomStackView.alignment = UIStackViewAlignmentFill;
_bottomStackView.spacing = 25;
}
return _bottomStackView;
}
- (UIButton *)chatButton {
if (!_chatButton) {
_chatButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_chatButton setTitle:@"私信" forState:UIControlStateNormal];
[_chatButton setTitleColor:[ThemeColor cancelButtonTextColor] forState:UIControlStateNormal];
[_chatButton setImage:[UIImage imageNamed:@"mine_user_info_bottom_chat"] forState:UIControlStateNormal];
_chatButton.titleLabel.font = [UIFont systemFontOfSize:15];
[_chatButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor cancelButtonGradientStartColor], [ThemeColor cancelButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
_chatButton.layer.masksToBounds = YES;
_chatButton.layer.cornerRadius = 36/2;
[_chatButton addTarget:self action:@selector(chatButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _chatButton;
}
- (UIButton *)attentionButton {
if (!_attentionButton) {
_attentionButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_attentionButton setTitle:@"关注" forState:UIControlStateNormal];
[_attentionButton setTitle:@"已关注" forState:UIControlStateSelected];
[_attentionButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateNormal];
[_attentionButton setTitleColor:[ThemeColor cancelButtonTextColor] forState:UIControlStateSelected];
[_attentionButton setImage:[UIImage imageNamed:@"mine_user_info_bottom_attention_normal"] forState:UIControlStateNormal];
[_attentionButton setImage:[UIImage imageNamed:@"mine_user_info_bottom_attention_select"] forState:UIControlStateSelected];
_attentionButton.titleLabel.font = [UIFont systemFontOfSize:15];
[_attentionButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_attentionButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor cancelButtonGradientStartColor], [ThemeColor cancelButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateSelected];
_attentionButton.layer.masksToBounds = YES;
_attentionButton.layer.cornerRadius = 36/2;
[_attentionButton addTarget:self action:@selector(attentionButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _attentionButton;
}
@end

View File

@@ -8,12 +8,19 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class UserInfoModel, SDCycleScrollView;
@class UserInfoModel, SDCycleScrollView,XPMineUserInfoHeaderView;
@protocol XPMineUserInfoHeaderViewDelegate <NSObject>
- (void)xPMineUserInfoHeaderView:(XPMineUserInfoHeaderView *)view didClickGoToRoom:(NSString *)roomUid;
@end
@interface XPMineUserInfoHeaderView : UIView
///
@property (nonatomic,strong) UserInfoModel *userInfo;
///轮播图
@property (nonatomic,strong, readonly) SDCycleScrollView *cycleScrollView;
///代理
@property (nonatomic,weak) id<XPMineUserInfoHeaderViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -71,6 +71,18 @@
@property (nonatomic,strong) UILabel *pageLabel;
///
@property (nonatomic,strong) NSArray *imageUrls;
///
@property (nonatomic,strong) UIView * backView;
///
@property (nonatomic,strong) UILabel *nameLabel;
///sex
@property (nonatomic,strong) UIImageView *sexImageView;
///id
@property (nonatomic,strong) UILabel *idLabel;
///
@property (nonatomic,strong) UILabel *signLabel;
///
@property (nonatomic,strong) UIButton *onlineButton;
@end
@implementation XPMineUserInfoHeaderView
@@ -84,17 +96,7 @@
return self;
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView * view = [self.cycleScrollView hitTest:point withEvent:event];
return view;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.cycleScrollView];
[self addSubview:self.pageLabel];
}
- (void)initSubViewConstraints {
[self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
@@ -106,7 +108,51 @@
make.height.mas_equalTo(16);
make.top.mas_equalTo(self).offset(148 + kSafeAreaTopHeight);
}];
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self).inset(15);
make.bottom.mas_equalTo(self).offset(20);
make.height.mas_equalTo(100);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.backView).offset(15);
make.top.mas_equalTo(self.backView).offset(15);
}];
[self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nameLabel.mas_right).offset(5);
make.centerY.mas_equalTo(self.nameLabel);
}];
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nameLabel);
make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(10);
}];
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nameLabel);
make.top.mas_equalTo(self.idLabel.mas_bottom).offset(18);
}];
[self.onlineButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(55, 18));
make.right.mas_equalTo(self.backView).offset(-15);
make.top.mas_equalTo(self.backView).offset(10);
}];
}
- (void)initSubViews {
[self addSubview:self.cycleScrollView];
[self addSubview:self.pageLabel];
[self addSubview:self.backView];
[self.backView addSubview:self.nameLabel];
[self.backView addSubview:self.sexImageView];
[self.backView addSubview:self.idLabel];
[self.backView addSubview:self.signLabel];
[self.backView addSubview:self.onlineButton];
}
#pragma mark - SDPhotoBrowserDelegate
- (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index {
NSString * photoUrl = [self.imageUrls objectAtIndex:index];
@@ -130,7 +176,7 @@
}
-(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index {
self.pageLabel.text = [NSString stringWithFormat:@"%d/%lu",(index + 1), (unsigned long)self.imageUrls.count];
self.pageLabel.text = [NSString stringWithFormat:@"%ld/%lu",(index + 1), (unsigned long)self.imageUrls.count];
}
//
@@ -144,30 +190,114 @@
browser.isMe = NO;
[browser show];
}
#pragma mark - Event Response
- (void)onlineButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineUserInfoHeaderView:didClickGoToRoom:)]) {
[self.delegate xPMineUserInfoHeaderView:self didClickGoToRoom:self.userInfo.roomUid];
}
}
#pragma mark - Getters And Setters
- (void)setUserInfo:(UserInfoModel *)userInfo {
_userInfo = userInfo;
//
NSMutableArray * imageUrls;
if (self.userInfo.privatePhoto.count > 0) {
imageUrls = [[[self.userInfo.privatePhoto.rac_sequence map:^id _Nullable(UserPhoto * _Nullable value) {
return value.photoUrl;
}] array] mutableCopy] ;
}
if (self.userInfo.avatar.length > 0) {
if (imageUrls.count >0) {
[imageUrls addObject:self.userInfo.avatar];
if (_userInfo) {
self.nameLabel.text = _userInfo.nick;
self.idLabel.text = [NSString stringWithFormat:@"%@号:%ld",AppName, (long)_userInfo.erbanNo];
self.signLabel.text = _userInfo.userDesc.length > 0 ? _userInfo.userDesc : @"我是个默认签名";
NSString * sexStr;
if (_userInfo.gender == GenderType_Male) {
sexStr = @"common_male";
} else {
imageUrls = [NSMutableArray array];
[imageUrls addObject:self.userInfo.avatar];
sexStr = @"common_female";
}
self.sexImageView.image = [UIImage imageNamed:sexStr];
self.onlineButton.hidden = _userInfo.roomUid.length <=0;
//
NSMutableArray * imageUrls;
if (self.userInfo.privatePhoto.count > 0) {
imageUrls = [[[self.userInfo.privatePhoto.rac_sequence map:^id _Nullable(UserPhoto * _Nullable value) {
return value.photoUrl;
}] array] mutableCopy] ;
}
if (self.userInfo.avatar.length > 0) {
if (imageUrls.count >0) {
[imageUrls addObject:self.userInfo.avatar];
} else {
imageUrls = [NSMutableArray array];
[imageUrls addObject:self.userInfo.avatar];
}
}
if (imageUrls.count > 0) {
self.imageUrls = imageUrls;
self.cycleScrollView.imageURLStringsGroup = imageUrls;
self.pageLabel.text = [NSString stringWithFormat:@"1/%lu",(unsigned long)imageUrls.count];
}
}
if (imageUrls.count > 0) {
self.imageUrls = imageUrls;
self.cycleScrollView.imageURLStringsGroup = imageUrls;
self.pageLabel.text = [NSString stringWithFormat:@"1/%lu",(unsigned long)imageUrls.count];
}
- (UIView *)backView {
if (!_backView) {
_backView = [[UIView alloc] init];
_backView.backgroundColor = [ThemeColor appCellBackgroundColor];
_backView.layer.masksToBounds = YES;
_backView.layer.cornerRadius = 12;
}
return _backView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:15];
_nameLabel.textColor = [ThemeColor mainTextColor];
}
return _nameLabel;
}
- (UIImageView *)sexImageView {
if (!_sexImageView) {
_sexImageView = [[UIImageView alloc] init];
_sexImageView.userInteractionEnabled = YES;
}
return _sexImageView;
}
- (UILabel *)idLabel {
if (!_idLabel) {
_idLabel = [[UILabel alloc] init];
_idLabel.font = [UIFont systemFontOfSize:11];
_idLabel.textColor = [ThemeColor textThirdColor];
}
return _idLabel;
}
- (UILabel *)signLabel {
if (!_signLabel) {
_signLabel = [[UILabel alloc] init];
_signLabel.font = [UIFont systemFontOfSize:11];;
_signLabel.textColor = [ThemeColor secondTextColor];
}
return _signLabel;
}
- (UIButton *)onlineButton {
if (!_onlineButton) {
_onlineButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_onlineButton setTitle:@"直播中" forState:UIControlStateNormal];
[_onlineButton setImage:[UIImage imageNamed:@"home_search_user_online"] forState:UIControlStateNormal];
[_onlineButton setTitleColor:[ThemeColor appMainColor] forState:UIControlStateNormal];
_onlineButton.backgroundColor = [UIColor clearColor];
_onlineButton.titleLabel.font = [UIFont systemFontOfSize:10];
_onlineButton.layer.masksToBounds = YES;
_onlineButton.layer.cornerRadius = 18/2;
_onlineButton.layer.borderColor = [ThemeColor appMainColor].CGColor;
_onlineButton.layer.borderWidth = 1;
_onlineButton.hidden = YES;
[_onlineButton addTarget:self action:@selector(onlineButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _onlineButton;
}
- (SDCycleScrollView *)cycleScrollView {

View File

@@ -1,16 +0,0 @@
//
// XPMineUserTableView.h
// xplan-ios
//
// Created by 冯硕 on 2021/9/27.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPMineUserTableView : UITableView
///
@property (nonatomic,weak) UIViewController *userInfoVC;
@end
NS_ASSUME_NONNULL_END

View File

@@ -1,24 +0,0 @@
//
// XPMineUserTableView.m
// xplan-ios
//
// Created by on 2021/9/27.
//
#import "XPMineUserTableView.h"
#import "XPMacro.h"
#import "XPMineUserInfoViewController.h"
@implementation XPMineUserTableView
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if (point.y > (250 + kSafeAreaTopHeight)) {
return self;
} else {
UIView* topView= [(XPMineUserInfoViewController *)self.userInfoVC getHeadHitView];
UIView * View = [topView hitTest:point withEvent:event];
return View;
}
}
@end