From 7942113fb28bc80726a025c43c9ea0acb9cc2b75 Mon Sep 17 00:00:00 2001 From: linyudan <1031378945@qq.com> Date: Wed, 20 Dec 2023 14:55:07 -0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=B6=88=E6=81=AF=E5=A5=BD?= =?UTF-8?q?=E5=8F=8B=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yinmeng-ios.xcodeproj/project.pbxproj | 14 ++ .../MewCATransitionAnimation.h | 23 ++++ .../MewCATransitionAnimation.m | 47 +++++++ .../MewMessageFriendViewController.h | 10 +- .../MewMessageFriendViewController.m | 52 ++++++-- .../MewMessageSessionViewController.h | 3 +- .../MewMessageSessionViewController.m | 54 +++----- .../Controller/MewMessageViewController.m | 12 +- .../SubView/MewMineFriendTableViewCell.h | 3 +- .../SubView/MewMineFriendTableViewCell.m | 100 +++++++++++++++ .../View/Session/MewSessionViewController.h | 3 +- .../View/Session/MewSessionViewController.m | 121 +++++++++--------- .../yinmeng-ios/Main/Mine/Api/Api+Mine.h | 2 +- .../yinmeng-ios/Main/Mine/Api/Api+Mine.m | 2 +- 14 files changed, 318 insertions(+), 128 deletions(-) create mode 100644 yinmeng-ios/yinmeng-ios/Base/Tool/CATransitionAnimation/MewCATransitionAnimation.h create mode 100644 yinmeng-ios/yinmeng-ios/Base/Tool/CATransitionAnimation/MewCATransitionAnimation.m diff --git a/yinmeng-ios/yinmeng-ios.xcodeproj/project.pbxproj b/yinmeng-ios/yinmeng-ios.xcodeproj/project.pbxproj index 24c8783..9f4d308 100644 --- a/yinmeng-ios/yinmeng-ios.xcodeproj/project.pbxproj +++ b/yinmeng-ios/yinmeng-ios.xcodeproj/project.pbxproj @@ -212,6 +212,7 @@ 8CD77FFB2B3272CA00F4CFF3 /* MewAlertPopup.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CD77FFA2B3272CA00F4CFF3 /* MewAlertPopup.m */; }; 8CD77FFF2B32832C00F4CFF3 /* MewAlertModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CD77FFE2B32832C00F4CFF3 /* MewAlertModel.m */; }; 8CD780032B32B72300F4CFF3 /* MewMineFriendTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CD780022B32B72300F4CFF3 /* MewMineFriendTableViewCell.m */; }; + 8CD780072B3379C800F4CFF3 /* MewCATransitionAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CD780062B3379C800F4CFF3 /* MewCATransitionAnimation.m */; }; FFDAAB800AD6BB4653B4427F /* Pods_yinmeng_ios.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1797344FB85F47F60D0CC2A0 /* Pods_yinmeng_ios.framework */; }; /* End PBXBuildFile section */ @@ -657,6 +658,8 @@ 8CD77FFE2B32832C00F4CFF3 /* MewAlertModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MewAlertModel.m; sourceTree = ""; }; 8CD780012B32B72300F4CFF3 /* MewMineFriendTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MewMineFriendTableViewCell.h; sourceTree = ""; }; 8CD780022B32B72300F4CFF3 /* MewMineFriendTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MewMineFriendTableViewCell.m; sourceTree = ""; }; + 8CD780052B3379C800F4CFF3 /* MewCATransitionAnimation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MewCATransitionAnimation.h; sourceTree = ""; }; + 8CD780062B3379C800F4CFF3 /* MewCATransitionAnimation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MewCATransitionAnimation.m; sourceTree = ""; }; A22C3BCB2715A2E8FDECEA30 /* Pods-yinmeng-ios.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-yinmeng-ios.release.xcconfig"; path = "Target Support Files/Pods-yinmeng-ios/Pods-yinmeng-ios.release.xcconfig"; sourceTree = ""; }; E9E8A33E3FDD457C53D1E6D7 /* Pods-yinmeng-ios.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-yinmeng-ios.debug.xcconfig"; path = "Target Support Files/Pods-yinmeng-ios/Pods-yinmeng-ios.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -1214,6 +1217,7 @@ 237054422B1F3B3200F5DE14 /* Tool */ = { isa = PBXGroup; children = ( + 8CD780042B33799C00F4CFF3 /* CATransitionAnimation */, 8CD77FF82B32727800F4CFF3 /* MewAlertView */, 237054432B1F3B3200F5DE14 /* YYUtility */, 237054492B1F3B3200F5DE14 /* UIImage */, @@ -2226,6 +2230,15 @@ path = Model; sourceTree = ""; }; + 8CD780042B33799C00F4CFF3 /* CATransitionAnimation */ = { + isa = PBXGroup; + children = ( + 8CD780052B3379C800F4CFF3 /* MewCATransitionAnimation.h */, + 8CD780062B3379C800F4CFF3 /* MewCATransitionAnimation.m */, + ); + path = CATransitionAnimation; + sourceTree = ""; + }; B603F71B608343F0E1A79C4B /* Frameworks */ = { isa = PBXGroup; children = ( @@ -2407,6 +2420,7 @@ 237053F22B1F3B1700F5DE14 /* MewConstant.m in Sources */, 237054DE2B204C4E00F5DE14 /* MewUserVipInfoVo.m in Sources */, 237054AD2B1F3B3200F5DE14 /* YYReachability.m in Sources */, + 8CD780072B3379C800F4CFF3 /* MewCATransitionAnimation.m in Sources */, 237054DB2B204ADE00F5DE14 /* MewUserInfoModel.m in Sources */, 8C9C843A2B0C697A00A601BC /* MewBaseRtcImpl.m in Sources */, 8CD77FE82B3211C800F4CFF3 /* MewSessionFanPartyModel.m in Sources */, diff --git a/yinmeng-ios/yinmeng-ios/Base/Tool/CATransitionAnimation/MewCATransitionAnimation.h b/yinmeng-ios/yinmeng-ios/Base/Tool/CATransitionAnimation/MewCATransitionAnimation.h new file mode 100644 index 0000000..9d6f943 --- /dev/null +++ b/yinmeng-ios/yinmeng-ios/Base/Tool/CATransitionAnimation/MewCATransitionAnimation.h @@ -0,0 +1,23 @@ +// +// MewCATransitionAnimation.h +// yinmeng-ios +// +// Created by 触海 on 2023/12/20. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface MewCATransitionAnimation : NSObject + +@property (nonatomic, strong, readonly) CATransition *transition; + +/// 初始化 ++ (MewCATransitionAnimation *)Mew_TranstionAnimationDuration:(CFTimeInterval)duration + timing:(CAMediaTimingFunctionName)timing + type:(CATransitionType)type subType:(CATransitionSubtype)subType; + +@end + +NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/yinmeng-ios/Base/Tool/CATransitionAnimation/MewCATransitionAnimation.m b/yinmeng-ios/yinmeng-ios/Base/Tool/CATransitionAnimation/MewCATransitionAnimation.m new file mode 100644 index 0000000..248f116 --- /dev/null +++ b/yinmeng-ios/yinmeng-ios/Base/Tool/CATransitionAnimation/MewCATransitionAnimation.m @@ -0,0 +1,47 @@ +// +// MewCATransitionAnimation.m +// yinmeng-ios +// +// Created by 触海 on 2023/12/20. +// + +#import "MewCATransitionAnimation.h" + +@interface MewCATransitionAnimation() +@property (nonatomic, strong) CATransition *_transtion; +@property (nonatomic, assign) CFTimeInterval duration; +@property (nonatomic, assign) CATransitionType type; +@property (nonatomic, assign) CATransitionSubtype subType; +@end + +@implementation MewCATransitionAnimation + +/// 初始化 ++ (MewCATransitionAnimation *)Mew_TranstionAnimationDuration:(CFTimeInterval)duration + timing:(CAMediaTimingFunctionName)timing + type:(CATransitionType)type subType:(CATransitionSubtype)subType { + MewCATransitionAnimation *animation = [[MewCATransitionAnimation alloc] init]; + animation.duration = duration; + animation.type = type; + animation.subType = subType; + animation._transtion = [animation transtionAnimationWithName:timing]; + return animation; +} + + +#pragma mark - Get +- (CATransition *)transition { + return __transtion; +} + +#pragma mark - Private Method +/// 创建CATransition +- (CATransition *)transtionAnimationWithName:(CAMediaTimingFunctionName)timingName { + CATransition *transition = [CATransition animation]; + transition.duration = self.duration; + transition.timingFunction = [CAMediaTimingFunction functionWithName:timingName]; + transition.type = self.type; + transition.subtype = self.subType; + return transition; +} +@end diff --git a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageFriendViewController.h b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageFriendViewController.h index 38ba9b8..da1505d 100644 --- a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageFriendViewController.h +++ b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageFriendViewController.h @@ -8,13 +8,17 @@ #import "MewBaseViewController.h" #import "MewEnum.h" #import +@class MewUserInfoModel; NS_ASSUME_NONNULL_BEGIN - +typedef void(^didSelectFriendClouseEvent)(MewUserInfoModel *userInfo); @interface MewMessageFriendViewController : MewBaseViewController -/// 初始化 -- (instancetype)initWithOpenMessageType:(MewOpenFriendType)type; +/// 分享好友 +@property (nonatomic, weak) didSelectFriendClouseEvent gotoShareFriendComplted; +@property (nonatomic, assign) MewOpenFriendType friendType; +@property (nonatomic, strong) UIViewController *currentViewController; + @end NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageFriendViewController.m b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageFriendViewController.m index 54f225f..dc0e8a6 100644 --- a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageFriendViewController.m +++ b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageFriendViewController.m @@ -9,6 +9,7 @@ /// View #import "MewEmptyTableViewCell.h" #import "MewMineFriendTableViewCell.h" +#import "MewSessionViewController.h" /// Net #import "Api+Mine.h" /// Third @@ -18,6 +19,7 @@ #import "NSArray+MewSafe.h" #import "MewEnum.h" #import "MewMacro.h" +#import "MewCATransitionAnimation.h" @interface MewMessageFriendViewController () @@ -29,25 +31,21 @@ @property (nonatomic, assign) NSInteger page; /** 是否有更多数据 */ @property (nonatomic, assign) BOOL hasMoreData; -@property (nonatomic, assign) MewOpenMessageType friendType; - @end @implementation MewMessageFriendViewController +- (BOOL)mew_isHiddenNavBar { + return self.friendType != Mew_OpenFriendType_Share; +} + + #pragma mark - Life Cycle - (void)viewDidLoad { [super viewDidLoad]; - self.view.backgroundColor = UIColor.redColor; -} - -#pragma mark - Init -- (instancetype)initWithOpenMessageType:(MewOpenFriendType)type { - self = [super init]; - if (self) { - [self setUI]; - } - return self; + [self loadFriendUids]; + [self loadRequestUserInfos]; + [self setUI]; } #pragma mark - Load Data @@ -64,10 +62,10 @@ if (self.friendUids.count == 0) return; NSString *uidStrings = [self.friendUids componentsJoinedByString:@","]; - [Api Mew_GetUserInfos:uidStrings completion:^(MewBaseModel * _Nonnull data, NSInteger code, NSString * _Nonnull msg) { + [Api Mew_GetUserInfos:^(MewBaseModel * _Nonnull data, NSInteger code, NSString * _Nonnull msg) { self.friendModels = [MewUserInfoModel mewModelsWithArray:data.data]; [self.friendTableView reloadData]; - }]; + } uids:uidStrings]; } #pragma mark - UITableViewDelegate, UITableViewDataSource @@ -91,6 +89,32 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (self.friendModels.count == 0) return; + MewUserInfoModel *model = [self.friendModels mewSafeObjectAtIndex:indexPath.row]; + + // 分享好友 + if (self.friendType == Mew_OpenFriendType_Share && self.gotoShareFriendComplted) { + self.gotoShareFriendComplted(model); + } + + + NIMSession *session = [NIMSession session:[NSString stringWithFormat:@"%ld", model.uid] type:NIMSessionTypeP2P]; + MewSessionViewController *controller = [[MewSessionViewController alloc] initWithSession:session]; + // 消息中心选中好友 + if (self.friendType == Mew_OpenFriendType_Normal) { + controller.openType = Mew_OpenMessageType_Normal; + [self.navigationController pushViewController:controller animated:YES]; + + } + + + // 房间内选中好友 + if (self.friendType == Mew_OpenFriendType_In_Room) { + controller.openType = Mew_OpenMessageType_In_Room; + CATransition *transition = [MewCATransitionAnimation Mew_TranstionAnimationDuration:0.3f timing:kCAMediaTimingFunctionEaseInEaseOut type:kCATransitionPush subType:kCATransitionFromRight].transition; + [self.currentViewController.view.layer addAnimation:transition forKey:nil]; + [self.currentViewController addChildViewController:controller]; + [self.currentViewController.view addSubview:controller.view]; + } } diff --git a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageSessionViewController.h b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageSessionViewController.h index dd0416f..aa6a77a 100644 --- a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageSessionViewController.h +++ b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageSessionViewController.h @@ -14,9 +14,8 @@ NS_ASSUME_NONNULL_BEGIN @interface MewMessageSessionViewController : MewBaseViewController -/// 初始化 -- (instancetype)initWithSessionType:(MewOpenMessageType)type; +@property (nonatomic, assign) MewOpenMessageType messageType; /// 当前控制器,因为房间内聊天没有控制器去 push 或者做其他的操作 @property (nonatomic, weak) UIViewController *currentController; diff --git a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageSessionViewController.m b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageSessionViewController.m index 606fe3d..c1c5b4c 100644 --- a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageSessionViewController.m +++ b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageSessionViewController.m @@ -15,6 +15,7 @@ #import "NSArray+MewSafe.h" #import "MewTimeIntervalUtils.h" #import "MewAlertPopup.h" +#import "MewCATransitionAnimation.h" /// View #import "MewMessageSessionHeaderView.h" #import "MewYoungerView.h" @@ -32,7 +33,6 @@ @interface MewMessageSessionViewController () -@property (nonatomic, assign) MewOpenMessageType type; /**会话头部视图**/ @property (nonatomic, strong) MewMessageSessionHeaderView *sessionHeaderView; @@ -66,31 +66,22 @@ - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = UIColor.whiteColor; + [self addNIMNoti]; + [[NIMSDKConfig sharedConfig] setShouldSyncStickTopSessionInfos:YES]; + [self loadRequestSessionDatas]; + [self setUI]; + [self setUIConstraints]; [self loadRequestUserInfoModel]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - if (self.type != Mew_OpenMessageType_Normal) { return; } + if (self.messageType != Mew_OpenMessageType_Normal) { return; } [self loadRequestFansPartyModel]; } -#pragma mark - Init -- (instancetype)initWithSessionType:(MewOpenMessageType)type { - self = [super init]; - if (self) { - self.type = type; - [self addNIMNoti]; - [[NIMSDKConfig sharedConfig] setShouldSyncStickTopSessionInfos:YES]; - [self loadRequestSessionDatas]; - [self setUI]; - [self setUIConstraints]; - - } - return self; -} #pragma mark - Public Method /// 已读全部信息 @@ -115,12 +106,11 @@ } NSArray *allRecentSessions = [NIMSDK sharedSDK].conversationManager.allRecentSessions; -// NSMutableArray *uidArray = [NSMutableArray array]; NSMutableArray *sessionArray = [NSMutableArray array]; __block int unreadCount = 0; [allRecentSessions enumerateObjectsUsingBlock:^(NIMRecentSession * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { BOOL isContainerOffice = [[MewClientConfig shareConfig] mew_isContainerOfficeMsgUid:obj.session.sessionId]; - if (self.type == Mew_OpenMessageType_Normal && isContainerOffice) { + if (self.messageType == Mew_OpenMessageType_Normal && isContainerOffice) { [self.sessionHeaderView mew_updateBadgeViewWithSessionId:obj.session.sessionId unreadCount:obj.unreadCount]; } else { if (obj.session.sessionId.integerValue > 0) { @@ -154,7 +144,7 @@ } - (void)loadRequestFansPartyModel { - if (self.type == Mew_OpenMessageType_In_Room) { return; } + if (self.messageType == Mew_OpenMessageType_In_Room) { return; } [Api Mew_RequestFansParty:^(MewBaseModel * _Nonnull data, NSInteger code, NSString * _Nonnull msg) { if (code == 200) { NSArray *fans = [MewSessionFanPartyModel mewModelsWithArray:data.data]; @@ -190,15 +180,11 @@ NIMRecentSession *selectSession = [self.recentSessions mewSafeObjectAtIndex:indexPath.row]; MewSessionViewController *controller = [[MewSessionViewController alloc] initWithSession:selectSession.session]; - controller.openType = self.type; - if (self.type == Mew_OpenMessageType_Normal) { + controller.openType = self.messageType; + if (self.messageType == Mew_OpenMessageType_Normal) { [self.navigationController pushViewController:controller animated:YES]; } else { - CATransition *transition = [CATransition animation]; - transition.duration = 0.3f; - transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; - transition.type = kCATransitionPush; - transition.subtype = kCATransitionFromRight; + CATransition *transition = [MewCATransitionAnimation Mew_TranstionAnimationDuration:0.3f timing:kCAMediaTimingFunctionEaseInEaseOut type:kCATransitionPush subType:kCATransitionFromRight].transition; [self.currentController.view.layer addAnimation:transition forKey:nil]; [self.currentController.view addSubview:controller.view]; [self.currentController addChildViewController:controller]; @@ -223,7 +209,7 @@ /// 添加最近会话 - (void)didAddRecentSession:(NIMRecentSession *)recentSession totalUnreadCount:(NSInteger)totalUnreadCount { BOOL isContainerOffice = [[MewClientConfig shareConfig] mew_isContainerOfficeMsgUid:recentSession.session.sessionId]; - if (self.type != Mew_OpenMessageType_In_Room && isContainerOffice) { + if (self.messageType != Mew_OpenMessageType_In_Room && isContainerOffice) { [self.sessionHeaderView mew_updateBadgeViewWithSessionId:recentSession.session.sessionId unreadCount:recentSession.unreadCount]; return; } @@ -246,7 +232,7 @@ - (void)didUpdateRecentSession:(NIMRecentSession *)recentSession totalUnreadCount:(NSInteger)totalUnreadCount { NSString *sessionId = recentSession.session.sessionId; BOOL isContainer = [[MewClientConfig shareConfig] mew_isContainerOfficeMsgUid:sessionId]; - if (self.type != Mew_OpenMessageType_In_Room && isContainer) { + if (self.messageType != Mew_OpenMessageType_In_Room && isContainer) { [self.sessionHeaderView mew_updateBadgeViewWithSessionId:sessionId unreadCount:recentSession.unreadCount]; return; } @@ -348,7 +334,9 @@ } NSString *badgeString = badge > 0 ? [NSString stringWithFormat:@"%ld", badge] : nil; - [self.tabBarController.tabBar.items[3] setBadgeValue:badgeString]; + NSInteger itemCount = self.tabBarController.tabBar.items.count; + NSInteger messageIndex = itemCount > 3 ? itemCount - 2 : itemCount - 1; + [self.tabBarController.tabBar.items[messageIndex] setBadgeValue:badgeString]; } /// 找到重新插入最近消息的index @@ -401,7 +389,7 @@ - (void)setUI { [self.view addSubview:self.sessionListTableView]; - if (self.type == Mew_OpenMessageType_In_Room) { return; } + if (self.messageType == Mew_OpenMessageType_In_Room) { return; } self.view.backgroundColor = UIColor.clearColor; [self.view addSubview:self.sessionHeaderView]; } @@ -410,14 +398,14 @@ - (void)setUIConstraints { [self.sessionListTableView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.mas_equalTo(self.view); - if (self.type == Mew_OpenMessageType_Normal) { + if (self.messageType == Mew_OpenMessageType_Normal) { make.top.mas_equalTo(self.sessionHeaderView.mas_bottom); } else { make.top.mas_equalTo(self.view); } }]; - if (self.type == Mew_OpenMessageType_In_Room) { return; } + if (self.messageType == Mew_OpenMessageType_In_Room) { return; } [self.sessionHeaderView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(0); make.top.mas_equalTo(8); @@ -464,6 +452,4 @@ return _sessionHeaderView; } - - @end diff --git a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageViewController.m b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageViewController.m index a40a2be..34a56de 100644 --- a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageViewController.m +++ b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/MewMessageViewController.m @@ -46,12 +46,9 @@ [self setUI]; } - - - #pragma mark - JXCategoryListContainerViewDelegate - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView { - return self.navTitleView.titles.count; + return 2; } - (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index { @@ -60,7 +57,6 @@ } else { return self.friendController; } - } @@ -96,7 +92,8 @@ [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.navTitleView.mas_bottom); - make.left.right.bottom.mas_equalTo(0); + make.left.right.mas_equalTo(0); + make.bottom.mas_equalTo(0); }]; [self.allReadButton mas_makeConstraints:^(MASConstraintMaker *make) { @@ -127,6 +124,7 @@ return _navTitleView; } + - (JXCategoryListContainerView *)listContainerView { if (!_listContainerView) { _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; @@ -139,7 +137,7 @@ - (MewMessageSessionViewController *)sessionController { if (!_sessionController) { - _sessionController = [[MewMessageSessionViewController alloc] initWithSessionType:Mew_OpenMessageType_Normal]; + _sessionController = [[MewMessageSessionViewController alloc] init]; } return _sessionController; } diff --git a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/SubView/MewMineFriendTableViewCell.h b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/SubView/MewMineFriendTableViewCell.h index 0dfdb93..2033a70 100644 --- a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/SubView/MewMineFriendTableViewCell.h +++ b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/SubView/MewMineFriendTableViewCell.h @@ -13,7 +13,8 @@ NS_ASSUME_NONNULL_BEGIN @interface MewMineFriendTableViewCell : UITableViewCell /// 用户信息 @property (nonatomic, strong) MewUserInfoModel *userInfo; - +/// 是否在房间内 +@property (nonatomic, assign, getter=isInRoom) BOOL inRoom; @end diff --git a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/SubView/MewMineFriendTableViewCell.m b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/SubView/MewMineFriendTableViewCell.m index 6ab8459..4ccc8da 100644 --- a/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/SubView/MewMineFriendTableViewCell.m +++ b/yinmeng-ios/yinmeng-ios/Main/Message/View/MewSessionList/Controller/SubView/MewMineFriendTableViewCell.m @@ -6,6 +6,32 @@ // #import "MewMineFriendTableViewCell.h" +/// View +#import "NetImageView.h" +/// Tool +#import "MewThemeColor.h" +#import "MewMacro.h" + + +@interface MewMineFriendTableViewCell() +//头像 +@property (nonatomic, strong) NetImageView *iconImageView; +//水平容器 +@property (nonatomic, strong) UIStackView *horStackView; +//昵称 +@property (nonatomic, strong) UILabel *nickNameLabel; +//性别 +@property (nonatomic, strong) UIImageView *generImageView; +//等级 +@property (nonatomic, strong) NetImageView *levelImageView; +//魅力等级 +@property (nonatomic, strong) NetImageView *charmLevelImageView; +//签名 +@property (nonatomic, strong) UILabel *personSignLabel; +// 分割线 +@property (nonatomic, strong) UIView *lineView; + +@end @implementation MewMineFriendTableViewCell @@ -23,6 +49,80 @@ } +#pragma mark - Get +- (NetImageView *)iconImageView { + if (!_iconImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeUserIcon; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _iconImageView = [[NetImageView alloc] initWithConfig:config]; + _iconImageView.layer.masksToBounds = YES; + _iconImageView.layer.cornerRadius = 55/2; + } + return _iconImageView; +} +- (UIStackView *)horStackView { + if (!_horStackView) { + _horStackView = [[UIStackView alloc] init]; + _horStackView.axis = UILayoutConstraintAxisHorizontal; + _horStackView.distribution = UIStackViewDistributionFill; + _horStackView.alignment = UIStackViewAlignmentCenter; + _horStackView.spacing = 10; + } + return _horStackView; +} + +- (UILabel *)nickNameLabel { + if (!_nickNameLabel) { + _nickNameLabel = [[UILabel alloc] init]; + _nickNameLabel.font = kFontRegular(15); + _nickNameLabel.textColor = MewThemeColor.mewMainTextColor; + } + return _nickNameLabel; +} + +- (UIImageView *)generImageView { + if (!_generImageView) { + _generImageView = [[UIImageView alloc] init]; + _generImageView.userInteractionEnabled = YES; + } + return _generImageView; +} + +- (NetImageView *)levelImageView { + if (!_levelImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _levelImageView = [[NetImageView alloc] initWithConfig:config]; + } + return _levelImageView; +} + +- (NetImageView *)charmLevelImageView { + if (!_charmLevelImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _charmLevelImageView = [[NetImageView alloc] initWithConfig:config]; + } + return _charmLevelImageView; +} + +- (UILabel *)personSignLabel { + if (!_personSignLabel) { + _personSignLabel = [[UILabel alloc] init]; + _personSignLabel.textColor = MewThemeColor.mewSecondTextColor; + _personSignLabel.font = kFontRegular(12); + } + return _personSignLabel; +} + +- (UIView *)lineView { + if (!_lineView) { + _lineView = [[UIView alloc] init]; + _lineView.backgroundColor = MewThemeColor.mewDividerColor; + } + return _lineView; +} @end diff --git a/yinmeng-ios/yinmeng-ios/Main/Message/View/Session/MewSessionViewController.h b/yinmeng-ios/yinmeng-ios/Main/Message/View/Session/MewSessionViewController.h index 9f86e3a..62ee2ce 100644 --- a/yinmeng-ios/yinmeng-ios/Main/Message/View/Session/MewSessionViewController.h +++ b/yinmeng-ios/yinmeng-ios/Main/Message/View/Session/MewSessionViewController.h @@ -6,13 +6,14 @@ // #import "MewMvpViewController.h" +#import "MewEnum.h" @class NIMSession; NS_ASSUME_NONNULL_BEGIN @interface MewSessionViewController : MewMvpViewController -@property (nonatomic, assign) NSInteger openType; +@property (nonatomic, assign) MewOpenMessageType openType; - (instancetype)initWithSession:(NIMSession *)session; @end diff --git a/yinmeng-ios/yinmeng-ios/Main/Message/View/Session/MewSessionViewController.m b/yinmeng-ios/yinmeng-ios/Main/Message/View/Session/MewSessionViewController.m index 60920ff..bd6a133 100644 --- a/yinmeng-ios/yinmeng-ios/Main/Message/View/Session/MewSessionViewController.m +++ b/yinmeng-ios/yinmeng-ios/Main/Message/View/Session/MewSessionViewController.m @@ -37,7 +37,6 @@ @interface MewSessionViewController () ///导航栏 @property (nonatomic,strong) MewSessionNavView *sessionNavView; @@ -65,18 +64,12 @@ - (void)viewDidLoad { [super viewDidLoad]; - [[NIMManager sharedManager] addNIMListener]; - [[MewSessionMessageManager shared] addProtocol:self]; - - + self.view.backgroundColor = UIColor.whiteColor; [self initViews]; - - - self.view.backgroundColor = [UIColor whiteColor]; -// [[NIMSDK sharedSDK].chatManager addDelegate:self]; -// [[NIMSDK sharedSDK].conversationManager addDelegate:self]; -// [self mew_initHeaderAndFooterRefresh]; + [[NIMSDK sharedSDK].chatManager addDelegate:self]; + [[NIMSDK sharedSDK].conversationManager addDelegate:self]; + [self mew_initHeaderAndFooterRefresh]; [IQKeyboardManager sharedManager].enable = NO; } @@ -194,43 +187,43 @@ } #pragma mark - NIMChatManagerDelegate, NIMMediaManagerDelegate (云信通知回调) -- (NIMSession *)getCurrentSession { - return self.session; -} +//- (NIMSession *)getCurrentSession { +// return self.session; +//} -- (void)recvMessages:(NSArray *)messages { -// 8714013 7067608 - - NSLog(@"接收到的消息的数据是:%@",messages); -// [self.messages addObjectsFromArray:messages]; - self.messages = [messages mutableCopy]; - [self.sessionTableView reloadData]; - [self.sessionTableView nim_scrollToBottom:YES]; - [[NIMSDK sharedSDK].conversationManager markAllMessagesReadInSession:self.session]; -} +//- (void)recvMessages:(NSArray *)messages { +//// 8714013 7067608 +// +// NSLog(@"接收到的消息的数据是:%@",messages); +//// [self.messages addObjectsFromArray:messages]; +// self.messages = [messages mutableCopy]; +// [self.sessionTableView reloadData]; +// [self.sessionTableView nim_scrollToBottom:YES]; +// [[NIMSDK sharedSDK].conversationManager markAllMessagesReadInSession:self.session]; +//} // 接收聊天 -//- (void)onRecvMessages:(NSArray *)messages { -// NIMMessage *message = messages.firstObject; -// NIMSession *session = message.session; -// if (![session isEqual:self.session] || !messages.count) { -// return; -// } -// -// -// for (NIMMessage *message in messages) { -// if (message.isDeleted) { -// continue; -// } -// [self.messages addObject:message]; -// } -// [self.sessionTableView reloadData]; -// [self.sessionTableView nim_scrollToBottom:YES]; -// -// [[NIMSDK sharedSDK].conversationManager markAllMessagesReadInSession:self.session]; -//} +- (void)onRecvMessages:(NSArray *)messages { + NIMMessage *message = messages.firstObject; + NIMSession *session = message.session; + if (![session isEqual:self.session] || !messages.count) { + return; + } + + + for (NIMMessage *message in messages) { + if (message.isDeleted) { + continue; + } + [self.messages addObject:message]; + } + [self.sessionTableView reloadData]; + [self.sessionTableView nim_scrollToBottom:YES]; + + [[NIMSDK sharedSDK].conversationManager markAllMessagesReadInSession:self.session]; +} // 发送聊天 - (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error { @@ -326,27 +319,27 @@ /// 刷新头部数据 - (void)mew_headerRefresh { -// if (self.messages.count > 0) { -// [[[NIMSDK sharedSDK] conversationManager] messagesInSession:self.session message:self.messages.firstObject limit:20 completion:^(NSError * _Nullable error, NSArray * _Nullable messages) { -// [self.sessionTableView.mj_header endRefreshing]; -// if (error == nil && messages.count > 0) { -// for (int i = ((int)messages.count - 1); i > 0; i--) { -// NIMMessage *message = [messages mewSafeObjectAtIndex:i]; -// [self.messages insertObject:message atIndex:0]; -// } -// } -// [self.sessionTableView reloadData]; -// }]; -// } else { -// [[[NIMSDK sharedSDK] conversationManager] messagesInSession:self.session message:nil limit:20 completion:^(NSError * _Nullable error, NSArray * _Nullable messages) { -// [self.sessionTableView.mj_header endRefreshing]; -// if (error == nil) { -// [self.messages addObjectsFromArray:messages]; -// } -// [self.sessionTableView reloadData]; -// [self.sessionTableView nim_scrollToBottom:NO]; -// }]; -// } + if (self.messages.count > 0) { + [[[NIMSDK sharedSDK] conversationManager] messagesInSession:self.session message:self.messages.firstObject limit:20 completion:^(NSError * _Nullable error, NSArray * _Nullable messages) { + [self.sessionTableView.mj_header endRefreshing]; + if (error == nil && messages.count > 0) { + for (int i = ((int)messages.count - 1); i > 0; i--) { + NIMMessage *message = [messages mewSafeObjectAtIndex:i]; + [self.messages insertObject:message atIndex:0]; + } + } + [self.sessionTableView reloadData]; + }]; + } else { + [[[NIMSDK sharedSDK] conversationManager] messagesInSession:self.session message:nil limit:20 completion:^(NSError * _Nullable error, NSArray * _Nullable messages) { + [self.sessionTableView.mj_header endRefreshing]; + if (error == nil) { + [self.messages addObjectsFromArray:messages]; + } + [self.sessionTableView reloadData]; + [self.sessionTableView nim_scrollToBottom:NO]; + }]; + } } - (void)initData { diff --git a/yinmeng-ios/yinmeng-ios/Main/Mine/Api/Api+Mine.h b/yinmeng-ios/yinmeng-ios/Main/Mine/Api/Api+Mine.h index db5817b..eee22bd 100644 --- a/yinmeng-ios/yinmeng-ios/Main/Mine/Api/Api+Mine.h +++ b/yinmeng-ios/yinmeng-ios/Main/Mine/Api/Api+Mine.h @@ -119,7 +119,7 @@ NS_ASSUME_NONNULL_BEGIN /// 获取批量的用户数组 /// @param uids 用户ids /// @param completion 完成 -+ (void)Mew_GetUserInfos:(NSString *)uids completion:(MewHttpRequestHelperCompletion)completion; ++ (void)Mew_GetUserInfos:(MewHttpRequestHelperCompletion)completion uids:(NSString *)uids; @end diff --git a/yinmeng-ios/yinmeng-ios/Main/Mine/Api/Api+Mine.m b/yinmeng-ios/yinmeng-ios/Main/Mine/Api/Api+Mine.m index 7f46536..c6c8091 100644 --- a/yinmeng-ios/yinmeng-ios/Main/Mine/Api/Api+Mine.m +++ b/yinmeng-ios/yinmeng-ios/Main/Mine/Api/Api+Mine.m @@ -144,7 +144,7 @@ /// 获取批量的用户数组 /// @param uids 用户ids /// @param completion 完成 -+ (void)Mew_GetUserInfos:(NSString *)uids completion:(MewHttpRequestHelperCompletion)completion { ++ (void)Mew_GetUserInfos:(MewHttpRequestHelperCompletion)completion uids:(NSString *)uids { [self makeRequest:@"user/list" method:MewHttpRequestHelperMethodGET completion:completion, __FUNCTION__, uids, nil]; }