房间消息提示的qipao

This commit is contained in:
fengshuo
2022-06-14 14:51:47 +08:00
parent c6df46e83b
commit 41c0c9c57f
9 changed files with 338 additions and 5 deletions

View File

@@ -745,6 +745,7 @@
E8D48256278D83AE003C1D08 /* XPAcrossRoomPKPanelUserView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8D48255278D83AE003C1D08 /* XPAcrossRoomPKPanelUserView.m */; };
E8D55C9D28113218006935A5 /* MessageMenuModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8D55C9C28113218006935A5 /* MessageMenuModel.m */; };
E8D55CA0281186D6006935A5 /* SessionAudioRecordView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8D55C9F281186D6006935A5 /* SessionAudioRecordView.m */; };
E8DAC5AC2858305A00012CFD /* XPRoomMessageBubbleView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DAC5AB2858305A00012CFD /* XPRoomMessageBubbleView.m */; };
E8DACCFB2766EDC60052092C /* MicroGiftValueView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DACCFA2766EDC60052092C /* MicroGiftValueView.m */; };
E8DACCFE27673F870052092C /* GiftValueInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DACCFD27673F870052092C /* GiftValueInfoModel.m */; };
E8DBB6F927B639A300AA285D /* LittleGameStageView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DBB6F827B639A300AA285D /* LittleGameStageView.m */; };
@@ -2339,6 +2340,8 @@
E8D55C9C28113218006935A5 /* MessageMenuModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageMenuModel.m; sourceTree = "<group>"; };
E8D55C9E281186D6006935A5 /* SessionAudioRecordView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SessionAudioRecordView.h; sourceTree = "<group>"; };
E8D55C9F281186D6006935A5 /* SessionAudioRecordView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SessionAudioRecordView.m; sourceTree = "<group>"; };
E8DAC5AA2858305A00012CFD /* XPRoomMessageBubbleView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageBubbleView.h; sourceTree = "<group>"; };
E8DAC5AB2858305A00012CFD /* XPRoomMessageBubbleView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMessageBubbleView.m; sourceTree = "<group>"; };
E8DACCF92766EDC60052092C /* MicroGiftValueView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MicroGiftValueView.h; sourceTree = "<group>"; };
E8DACCFA2766EDC60052092C /* MicroGiftValueView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MicroGiftValueView.m; sourceTree = "<group>"; };
E8DACCFC27673F870052092C /* GiftValueInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiftValueInfoModel.h; sourceTree = "<group>"; };
@@ -5399,6 +5402,8 @@
E84CBCE028436D3C00D43221 /* XPMineContactViewController.m */,
E84CBCE2284372D800D43221 /* XPRoomHalfMessageView.h */,
E84CBCE3284372D800D43221 /* XPRoomHalfMessageView.m */,
E8DAC5AA2858305A00012CFD /* XPRoomMessageBubbleView.h */,
E8DAC5AB2858305A00012CFD /* XPRoomMessageBubbleView.m */,
);
path = Friend;
sourceTree = "<group>";
@@ -7476,6 +7481,7 @@
E896EF942771AAC100AD2CC1 /* XPMineFansPresenter.m in Sources */,
E8A86E0627BA38DB001C21F9 /* UIColor+RW.m in Sources */,
E8B825CD26EA18C8009E8E9F /* ThemeColor.m in Sources */,
E8DAC5AC2858305A00012CFD /* XPRoomMessageBubbleView.m in Sources */,
E8A6C29F27CF5FE500AC7442 /* HomeLiveRoomModel.m in Sources */,
E84150B827747B8B00A7F548 /* XPFirstRechargeViewController.m in Sources */,
9BBC02872786D75C0007C24B /* XPNobleUpgradeLevelView.m in Sources */,

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

View File

@@ -0,0 +1,26 @@
//
// XPRoomMessageBubbleView.h
// xplan-ios
//
// Created by 冯硕 on 2022/6/14.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class NIMRecentSession, XPRoomMessageBubbleView;
@protocol XPRoomMessageBubbleViewDelegate <NSObject>
- (void)xPRoomMessageBubbleView:(XPRoomMessageBubbleView *)view didSelectSession:(NIMRecentSession *)session;
@end
@interface XPRoomMessageBubbleView : UIView
- (void)addRecentSession:(NIMRecentSession *)session;
///代理
@property (nonatomic,weak) id<XPRoomMessageBubbleViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,218 @@
//
// XPRoomMessageBubbleView.m
// xplan-ios
//
// Created by on 2022/6/14.
//
#import "XPRoomMessageBubbleView.h"
///Third
#import <Masonry/Masonry.h>
#import <NIMSDK/NIMSDK.h>
///Tool
#import "ThemeColor.h"
#import "NetImageView.h"
#import "NIMMessageUtils.h"
@interface XPRoomMessageBubbleCollectionViewCell : UICollectionViewCell
///
@property (nonatomic,strong) NetImageView *avatarImageView;
///
@property (nonatomic,strong) UILabel *nickLabel;
///
@property (nonatomic,strong) UILabel *contentLabel;
///
@property (nonatomic,strong) NIMRecentSession *session;
@end
@implementation XPRoomMessageBubbleCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.avatarImageView];
[self.contentView addSubview:self.nickLabel];
[self.contentView addSubview:self.contentLabel];
}
- (void)initSubViewConstraints {
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(4);
make.left.mas_equalTo(4);
make.width.height.mas_equalTo(25);
}];
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatarImageView.mas_right).mas_offset(4);
make.right.mas_equalTo(-4);
make.centerY.mas_equalTo(self.avatarImageView.mas_centerY);
}];
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-4);
make.left.mas_equalTo(4);
make.top.mas_equalTo(self.avatarImageView.mas_bottom).mas_offset(4);
}];
}
#pragma mark - Getters And Setters
- (void)setSession:(NIMRecentSession *)session {
_session = session;
if (_session) {
NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:session.session.sessionId];
NSString *avatarUrl = user.userInfo.avatarUrl;
self.avatarImageView.imageUrl = avatarUrl;
self.nickLabel.text = user.userInfo.nickName;
[self.nickLabel sizeToFit];
self.contentLabel.text = [NIMMessageUtils messageContent:session.lastMessage];
}
}
- (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 = 25/2;
_avatarImageView.layer.borderColor = [ThemeColor appMainColor].CGColor;
}
return _avatarImageView;
}
- (UILabel *)nickLabel {
if (!_nickLabel) {
_nickLabel = [[UILabel alloc] init];
_nickLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightBold];
_nickLabel.textColor = [ThemeColor appMainColor];
}
return _nickLabel;
}
- (UILabel *)contentLabel {
if (!_contentLabel) {
_contentLabel = [[UILabel alloc] init];
_contentLabel.font = [UIFont systemFontOfSize:10];
_contentLabel.textColor = [ThemeColor mainTextColor];
}
return _contentLabel;
}
@end
@interface XPRoomMessageBubbleView ()<UICollectionViewDelegate, UICollectionViewDataSource>
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UICollectionView *collectionView;
///
@property (nonatomic,strong) NSMutableArray *datasource;
@end
@implementation XPRoomMessageBubbleView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Public Method
- (void)addRecentSession:(NIMRecentSession *)session {
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[self.datasource addObject:session];
[self.collectionView reloadData];
if (self.datasource.count > 0) {
[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
}
[self performSelector:@selector(animationFinish) withObject:nil afterDelay:3];
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
[self addSubview:self.backImageView];
[self addSubview:self.collectionView];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(0);
}];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self);
make.bottom.mas_equalTo(self).offset(-5);
}];
}
- (void)animationFinish {
[self.datasource removeAllObjects];
[self removeFromSuperview];
}
#pragma mark - UICollectionViewDelegate And UICollectionViewDatasource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.datasource.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPRoomMessageBubbleCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPRoomMessageBubbleCollectionViewCell class]) forIndexPath:indexPath];
cell.session = [self.datasource objectAtIndex:indexPath.row];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomMessageBubbleView:didSelectSession:)]) {
NIMRecentSession * session = [self.datasource objectAtIndex:indexPath.row];
[self.delegate xPRoomMessageBubbleView:self didSelectSession:session];
[self animationFinish];
}
}
#pragma mark - Getters And Setters
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_message_tips_bg"];
}
return _backImageView;
}
- (UICollectionView *)collectionView{
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.itemSize = CGSizeMake(87, 48);
layout.minimumLineSpacing = 0.1;
layout.minimumInteritemSpacing = 0.1;
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.backgroundColor = [UIColor clearColor];
[_collectionView registerClass:[XPRoomMessageBubbleCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPRoomMessageBubbleCollectionViewCell class])];
}
return _collectionView;
}
- (NSMutableArray *)datasource {
if (!_datasource) {
_datasource = [NSMutableArray array];
}
return _datasource;
}
@end

View File

@@ -31,8 +31,9 @@
#import "XPNobleCenterViewController.h"
#import "XPRoomFaceViewController.h"
#import "XPRoomHalfMessageView.h"
#import "XPRoomMessageBubbleView.h"
@interface XPRoomMenuContainerView ()
@interface XPRoomMenuContainerView ()<XPRoomMessageBubbleViewDelegate>
///
@property (nonatomic,strong) UIScrollView *scrollView;
///
@@ -55,6 +56,7 @@
@property (nonatomic,strong) UIButton *arrangeMicButton;
///
@property (nonatomic,strong) UIButton *nobleButton;
@property (nonatomic,strong) XPRoomMessageBubbleView *miniMessageView;
///
@property (nonatomic,weak) id<RoomHostDelegate> delegate;
@end
@@ -279,6 +281,8 @@
}
- (void)onRoomEntered {
NSInteger unreadCount = [[NIMSDK sharedSDK].conversationManager allUnreadCount];
self.messageButton.selected = unreadCount > 0;
[self onRoomUpdate];
}
@@ -368,6 +372,36 @@
}
}
- (void)addNIMRecentSession:(NIMRecentSession *)session {
if (!self.miniMessageView.superview) {
[self.superview insertSubview:self.miniMessageView aboveSubview:self];
[self.miniMessageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.messageButton);
make.bottom.mas_equalTo(self.messageButton.mas_top).offset(-2);
make.size.mas_equalTo(CGSizeMake(87, 55));
}];
}
[self.miniMessageView addRecentSession:session];
NSInteger unreadCount = [[NIMSDK sharedSDK].conversationManager allUnreadCount];
self.messageButton.selected = unreadCount > 0;
}
- (void)removeNIMRecentSession:(NIMRecentSession *)session {
NSInteger unreadCount = [[NIMSDK sharedSDK].conversationManager allUnreadCount];
self.messageButton.selected = unreadCount > 0;
}
#pragma mark - XPRoomMessageBubbleViewDelegate
- (void)xPRoomMessageBubbleView:(XPRoomMessageBubbleView *)view didSelectSession:(NIMRecentSession *)session {
XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight)];
halfMessageView.chatUserId = session.session.sessionId;
[self.superview addSubview:halfMessageView];
[UIView animateWithDuration:.35 animations:^{
CGRect rect = halfMessageView.frame;
rect.origin.y = 0;
halfMessageView.frame = rect;
}];
}
#pragma mark - Getters And Setters
- (UIButton *)inputButton {
@@ -496,4 +530,12 @@
return _scrollView;
}
- (XPRoomMessageBubbleView *)miniMessageView {
if (!_miniMessageView) {
_miniMessageView = [[XPRoomMessageBubbleView alloc] init];
_miniMessageView.delegate = self;
}
return _miniMessageView;
}
@end

View File

@@ -9,7 +9,7 @@
#import "MicroQueueProtocol.h"
#import "RoomAnimationProtocol.h"
@class NIMMessage;
@class NIMMessage, NIMRecentSession;
@class AttachmentModel;
NS_ASSUME_NONNULL_BEGIN
@@ -35,7 +35,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)handleNIMNotificationMessage:(NIMMessage *)message;
- (void)handleNIMCustomMessage:(NIMMessage *)message;
- (void)handleNIMTextMessage:(NIMMessage *)message;
- (void)addNIMRecentSession:(NIMRecentSession *)session;
- (void)removeNIMRecentSession:(NIMRecentSession *)session;
@end
NS_ASSUME_NONNULL_END

View File

@@ -58,7 +58,7 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
@interface XPRoomViewController ()<XPRoomProtocol, RoomHostDelegate, NIMChatroomManagerDelegate, NIMChatManagerDelegate, NIMLoginManagerDelegate, XPRoomSettingInputViewDelegate,XPRoomLittleGameContainerViewDelegate>
@interface XPRoomViewController ()<XPRoomProtocol, RoomHostDelegate, NIMChatroomManagerDelegate, NIMChatManagerDelegate, NIMConversationManagerDelegate, NIMLoginManagerDelegate, XPRoomSettingInputViewDelegate,XPRoomLittleGameContainerViewDelegate>
///
@property (nonatomic,strong) XPRoomBackContainerView *backContainerView;
///
@@ -152,6 +152,7 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
[[NIMSDK sharedSDK].chatroomManager removeDelegate:self];
[[NIMSDK sharedSDK].chatManager removeDelegate:self];
[[NIMSDK sharedSDK].loginManager removeDelegate:self];
[[NIMSDK sharedSDK].conversationManager removeDelegate:self];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@@ -177,10 +178,11 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
[self.presenter getNormalGiftList:self.roomUid];
///
[self.presenter getRoomSuperAdmin:self.roomUid];
//
//x
[[NIMSDK sharedSDK].chatroomManager addDelegate:self];
[[NIMSDK sharedSDK].chatManager addDelegate:self];
[[NIMSDK sharedSDK].loginManager addDelegate:self];
[[NIMSDK sharedSDK].conversationManager addDelegate:self];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myGiftEffectUpdate:) name:kRoomGiftEffectUpdateNotificationKey object:nil];
}
@@ -778,6 +780,22 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
[self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - NIMConversationManagerDelegate
- (void)didAddRecentSession:(NIMRecentSession *)recentSession
totalUnreadCount:(NSInteger)totalUnreadCount {
[self.menuContainerView addNIMRecentSession:recentSession];
}
- (void)didUpdateRecentSession:(NIMRecentSession *)recentSession
totalUnreadCount:(NSInteger)totalUnreadCount {
[self.menuContainerView addNIMRecentSession:recentSession];
}
- (void)didRemoveRecentSession:(NIMRecentSession *)recentSession
totalUnreadCount:(NSInteger)totalUnreadCount {
[self.menuContainerView removeNIMRecentSession:recentSession];
}
#pragma mark - RoomDelegate
- (RoomInfoModel *)getRoomInfo {
return self.roomInfo;