diff --git a/YuMi.xcodeproj/project.pbxproj b/YuMi.xcodeproj/project.pbxproj index 856e7bab..769ebe1d 100644 --- a/YuMi.xcodeproj/project.pbxproj +++ b/YuMi.xcodeproj/project.pbxproj @@ -291,6 +291,7 @@ 237852A12C072D8D00E360AC /* MSRoomGameModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 237852A02C072D8D00E360AC /* MSRoomGameModel.m */; }; 237852A42C082A9800E360AC /* MSRoomGameSendTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 237852A32C082A9800E360AC /* MSRoomGameSendTextView.m */; }; 237852A72C08764B00E360AC /* MSRoomGameResultsModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 237852A62C08764B00E360AC /* MSRoomGameResultsModel.m */; }; + 237852AA2C0D98BF00E360AC /* MsRoomMessagChatHallHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 237852A92C0D98BF00E360AC /* MsRoomMessagChatHallHeadView.m */; }; 237B94BC2A984DA7007853E3 /* XPTrumpetPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94AE2A984DA7007853E3 /* XPTrumpetPresenter.m */; }; 237B94BD2A984DA7007853E3 /* XPNobleTrumpetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94B32A984DA7007853E3 /* XPNobleTrumpetModel.m */; }; 237B94BE2A984DA7007853E3 /* XPRoomTrumpetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94B72A984DA7007853E3 /* XPRoomTrumpetViewController.m */; }; @@ -2116,6 +2117,8 @@ 237852A32C082A9800E360AC /* MSRoomGameSendTextView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRoomGameSendTextView.m; sourceTree = ""; }; 237852A52C08764B00E360AC /* MSRoomGameResultsModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSRoomGameResultsModel.h; sourceTree = ""; }; 237852A62C08764B00E360AC /* MSRoomGameResultsModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRoomGameResultsModel.m; sourceTree = ""; }; + 237852A82C0D98BF00E360AC /* MsRoomMessagChatHallHeadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MsRoomMessagChatHallHeadView.h; sourceTree = ""; }; + 237852A92C0D98BF00E360AC /* MsRoomMessagChatHallHeadView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MsRoomMessagChatHallHeadView.m; sourceTree = ""; }; 237B94AD2A984DA7007853E3 /* XPTrumpetPresenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPTrumpetPresenter.h; sourceTree = ""; }; 237B94AE2A984DA7007853E3 /* XPTrumpetPresenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPTrumpetPresenter.m; sourceTree = ""; }; 237B94B02A984DA7007853E3 /* XPRoomTrumpetProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPRoomTrumpetProtocol.h; sourceTree = ""; }; @@ -10185,6 +10188,8 @@ E8AEAEF227141C7C0017FCE0 /* XPRoomMessageContainerView.m */, 235714932BEDF517004C81D6 /* MsRoomMessagChatHallView.h */, 235714942BEDF517004C81D6 /* MsRoomMessagChatHallView.m */, + 237852A82C0D98BF00E360AC /* MsRoomMessagChatHallHeadView.h */, + 237852A92C0D98BF00E360AC /* MsRoomMessagChatHallHeadView.m */, ); path = MessageContainerView; sourceTree = ""; @@ -11828,6 +11833,7 @@ 237700FA2BCCD25500D661F1 /* YYLabel+MSRTL.m in Sources */, E84BF7DD277C765400EF8877 /* XPRoomRoleEmptyTableViewCell.m in Sources */, E8F6135C291E26BD00E12650 /* NSMutableDictionary+Saft.m in Sources */, + 237852AA2C0D98BF00E360AC /* MsRoomMessagChatHallHeadView.m in Sources */, 239D0F992BFB43BC002977CE /* MSRoomOnLineAvatarView.m in Sources */, 1427213429A75A2600C7C423 /* XPMonentsLatestPresenter.m in Sources */, E83ABEFD280EB5E200322EE4 /* ContentOpenLiveInfoModel.m in Sources */, diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallHeadView.h b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallHeadView.h new file mode 100644 index 00000000..d62a5320 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallHeadView.h @@ -0,0 +1,16 @@ +// +// MsRoomMessagChatHallHeadView.h +// YuMi +// +// Created by duoban on 2024/6/3. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface MsRoomMessagChatHallHeadView : UIView +@property(nonatomic,copy) NSString *content; +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallHeadView.m b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallHeadView.m new file mode 100644 index 00000000..c13d57b4 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallHeadView.m @@ -0,0 +1,51 @@ +// +// MsRoomMessagChatHallHeadView.m +// YuMi +// +// Created by duoban on 2024/6/3. +// + +#import "MsRoomMessagChatHallHeadView.h" +@interface MsRoomMessagChatHallHeadView() +@property(nonatomic,strong) UILabel *titleView; +@end +@implementation MsRoomMessagChatHallHeadView + +-(instancetype)initWithFrame:(CGRect)frame{ + self = [super initWithFrame:frame]; + if(self){ + [self installUI]; + [self installConstraints]; + } + return self; +} +-(void)installUI{ + self.layer.cornerRadius = 7; + self.layer.masksToBounds = YES; + self.layer.borderWidth = 1; + [self addSubview:self.titleView]; +} +-(void)installConstraints{ + [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.equalTo(self).offset(10); + }]; +} +-(void)setContent:(NSString *)content{ + _content = content; + _titleView.text = _content; + [_titleView.superview layoutIfNeeded]; +// UIImage *bgImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xE3B462),UIColorFromRGB(0x723505)] gradientType:GradientTypeLeftToRight imgSize:self.frame.size]; +// self.backgroundColor = [UIColor colorWithPatternImage:bgImage]; +// UIImage *borderImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xF7D364),UIColorFromRGB(0xFFFAE4),UIColorFromRGB(0xF7D364)] gradientType:GradientTypeLeftToRight imgSize:self.frame.size]; +// self.layer.borderColor = [UIColor colorWithPatternImage:borderImage].CGColor; +} +#pragma mark - 懒加载 +- (UILabel *)titleView{ + if(!_titleView){ + _titleView = [UILabel labelInitWithText:@"" font:[UIFont systemFontOfSize:13 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0xFFF6E1)]; + _titleView.textAlignment = NSTextAlignmentCenter; + } + return _titleView; +} + +@end diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallView.m b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallView.m index adff7802..ed45a30a 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallView.m +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallView.m @@ -47,6 +47,7 @@ #import "XPSkillCardPlayerManager.h" #import "MsRoomMessagChatHallCell.h" #import "MSSessionPublicChatHallTopModel.h" +#import "MsRoomMessagChatHallHeadView.h" @interface MsRoomMessagChatHallView () ///房间的代理 @property (nonatomic,weak) id hostDelegate; @@ -54,8 +55,8 @@ ///列表 @property (nonatomic,strong) UITableView *messageTableView; ///头部 -@property (nonatomic,strong) UIView *headerView; -@property(nonatomic,strong) UILabel *titleView; +@property (nonatomic,strong) MsRoomMessagChatHallHeadView *headerView; + ///messageView 持有这个工具类 进行数据的分发操作 TODO: 有需要在改 @property (nonatomic,strong) XPRoomMessageParser *messageParser; @@ -104,14 +105,13 @@ - (void)initSubViews { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addCustomMessage:) name:@"message" object:nil]; [self addSubview:self.headerView]; - [self.headerView addSubview:self.titleView]; [self addSubview:self.messageTableView]; [Api getPublicChatHallTopText:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if(code == 200){ MSSessionPublicChatHallTopModel *model = [MSSessionPublicChatHallTopModel modelWithDictionary:data.data]; if(model != nil){ - self.titleView.text = model.content; + self.headerView.content = model.content; [self.headerView mas_remakeConstraints:^(MASConstraintMaker *make) { make.leading.mas_equalTo(self).offset(15); make.top.trailing.mas_equalTo(self); @@ -138,9 +138,6 @@ make.height.mas_greaterThanOrEqualTo(0); }]; - [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { - make.leading.trailing.top.bottom.equalTo(self.headerView).inset(10); - }]; [self.messageTableView mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.mas_equalTo(self).offset(15); make.bottom.trailing.mas_equalTo(self); @@ -178,7 +175,7 @@ if(attachment.first == CustomMessageType_Chat_Hall_Headlinesn && attachment.second == Custom_Message_Sub_Chat_Hall_Headlinesn){ MSSessionPublicChatHallTopModel *topModel = [MSSessionPublicChatHallTopModel modelWithDictionary:attachment.data]; if(topModel.recordStatus == 1){ - self.titleView.text = topModel.content; + self.headerView.content = topModel.content; [self.headerView mas_remakeConstraints:^(MASConstraintMaker *make) { make.leading.mas_equalTo(self).offset(15); make.top.trailing.mas_equalTo(self); @@ -186,7 +183,7 @@ }]; }else{ - self.titleView.text = topModel.content; + self.headerView.content = topModel.content; [self.headerView mas_remakeConstraints:^(MASConstraintMaker *make) { make.leading.mas_equalTo(self).offset(15); make.top.trailing.mas_equalTo(self); @@ -233,7 +230,6 @@ - (void)handleNIMCustomMessage:(NIMMessage *)message { self.isMiniEnter = NO; if ([self isCanDisplayMessage:message]) { - NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; [self addRoomMessage:message]; } } @@ -261,7 +257,7 @@ self.isMiniEnter = NO; NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; - RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; + if (content.eventType == NIMChatroomEventTypeEnter) { @@ -435,18 +431,18 @@ } }]; - self.headerView.backgroundColor = UIColorRGBAlpha(0xADF4FF, 0.2); + } - (void)onRoomEntered { - self.headerView.backgroundColor = UIColorRGBAlpha(0xADF4FF, 0.2); + } - (void)onRoomUpdate { ///改变公屏的背景样式 if (self.hostDelegate.getRoomInfo.hadChangeRoomType) { - self.headerView.backgroundColor = UIColorRGBAlpha(0xADF4FF, 0.2); + [self.messageTableView reloadData]; } } @@ -621,11 +617,9 @@ return _messageTableView; } -- (UIView *)headerView { +- (MsRoomMessagChatHallHeadView *)headerView { if (!_headerView) { - _headerView = [[UIView alloc] init]; - _headerView.layer.cornerRadius = 7; - _headerView.layer.masksToBounds = YES; + _headerView = [[MsRoomMessagChatHallHeadView alloc] initWithFrame:CGRectZero]; } return _headerView; } @@ -649,13 +643,6 @@ } return _messageParser; } -- (UILabel *)titleView{ - if(!_titleView){ - _titleView = [UILabel labelInitWithText:@"" font:[UIFont systemFontOfSize:13 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0x05FFE3)]; - _titleView.textAlignment = NSTextAlignmentCenter; - _titleView.numberOfLines = 0; - } - return _titleView; -} + @end