修复聊天大厅bug

This commit is contained in:
liyuhua
2024-05-11 19:41:06 +08:00
parent e05876be41
commit f16b7a9bb2
29 changed files with 608 additions and 329 deletions

View File

@@ -214,7 +214,6 @@
234F44E32B3EA4F900E2B532 /* PILineManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 234F44E22B3EA4F900E2B532 /* PILineManager.swift */; };
2357145A2BE8BC6C004C81D6 /* MSSessionPublicChatHallVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 235714592BE8BC6C004C81D6 /* MSSessionPublicChatHallVC.m */; };
235714602BE8BD5C004C81D6 /* MSSessionScrollingModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 2357145F2BE8BD5C004C81D6 /* MSSessionScrollingModel.m */; };
235714642BE8BEA0004C81D6 /* CALayer+Animation.m in Sources */ = {isa = PBXBuildFile; fileRef = 235714632BE8BEA0004C81D6 /* CALayer+Animation.m */; };
235714672BE8C009004C81D6 /* MSSessionScrollingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 235714662BE8C009004C81D6 /* MSSessionScrollingView.m */; };
2357146B2BEA0110004C81D6 /* MSSessionPublicChatHallTopModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 2357146A2BEA0110004C81D6 /* MSSessionPublicChatHallTopModel.m */; };
2357146E2BEB816B004C81D6 /* MSSessionPublicChatHallHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2357146D2BEB816B004C81D6 /* MSSessionPublicChatHallHeadView.m */; };
@@ -231,6 +230,8 @@
235714952BEDF517004C81D6 /* MsRoomMessagChatHallView.m in Sources */ = {isa = PBXBuildFile; fileRef = 235714942BEDF517004C81D6 /* MsRoomMessagChatHallView.m */; };
235714982BEDF54E004C81D6 /* MsRoomMessageMainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 235714972BEDF54E004C81D6 /* MsRoomMessageMainView.m */; };
2357149B2BEE2AD1004C81D6 /* MsRoomMessagChatHallCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2357149A2BEE2AD1004C81D6 /* MsRoomMessagChatHallCell.m */; };
2357149E2BEF0F6D004C81D6 /* MSSessionScrollingItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2357149D2BEF0F6D004C81D6 /* MSSessionScrollingItemCell.m */; };
235714A12BEF510B004C81D6 /* MSSessionScrollingItemFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 235714A02BEF510B004C81D6 /* MSSessionScrollingItemFlowLayout.m */; };
235A451A2B04A352009753F5 /* PIRoomActivityWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 235A45192B04A352009753F5 /* PIRoomActivityWebView.m */; };
235A451D2B04A452009753F5 /* PIRoomActivityWebCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 235A451C2B04A452009753F5 /* PIRoomActivityWebCell.m */; };
235A45232B04BEB6009753F5 /* PIBaseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 235A45222B04BEB6009753F5 /* PIBaseModel.m */; };
@@ -1947,11 +1948,8 @@
235714592BE8BC6C004C81D6 /* MSSessionPublicChatHallVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSSessionPublicChatHallVC.m; sourceTree = "<group>"; };
2357145E2BE8BD5C004C81D6 /* MSSessionScrollingModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSSessionScrollingModel.h; sourceTree = "<group>"; };
2357145F2BE8BD5C004C81D6 /* MSSessionScrollingModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSSessionScrollingModel.m; sourceTree = "<group>"; };
235714622BE8BEA0004C81D6 /* CALayer+Animation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CALayer+Animation.h"; sourceTree = "<group>"; };
235714632BE8BEA0004C81D6 /* CALayer+Animation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "CALayer+Animation.m"; sourceTree = "<group>"; };
235714652BE8C009004C81D6 /* MSSessionScrollingView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSSessionScrollingView.h; sourceTree = "<group>"; };
235714662BE8C009004C81D6 /* MSSessionScrollingView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSSessionScrollingView.m; sourceTree = "<group>"; };
235714682BE8C055004C81D6 /* MSSessionScrollingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSSessionScrollingProtocol.h; sourceTree = "<group>"; };
235714692BEA0110004C81D6 /* MSSessionPublicChatHallTopModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSSessionPublicChatHallTopModel.h; sourceTree = "<group>"; };
2357146A2BEA0110004C81D6 /* MSSessionPublicChatHallTopModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSSessionPublicChatHallTopModel.m; sourceTree = "<group>"; };
2357146C2BEB816B004C81D6 /* MSSessionPublicChatHallHeadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSSessionPublicChatHallHeadView.h; sourceTree = "<group>"; };
@@ -1982,6 +1980,10 @@
235714972BEDF54E004C81D6 /* MsRoomMessageMainView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MsRoomMessageMainView.m; sourceTree = "<group>"; };
235714992BEE2AD1004C81D6 /* MsRoomMessagChatHallCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MsRoomMessagChatHallCell.h; sourceTree = "<group>"; };
2357149A2BEE2AD1004C81D6 /* MsRoomMessagChatHallCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MsRoomMessagChatHallCell.m; sourceTree = "<group>"; };
2357149C2BEF0F6D004C81D6 /* MSSessionScrollingItemCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSSessionScrollingItemCell.h; sourceTree = "<group>"; };
2357149D2BEF0F6D004C81D6 /* MSSessionScrollingItemCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSSessionScrollingItemCell.m; sourceTree = "<group>"; };
2357149F2BEF510B004C81D6 /* MSSessionScrollingItemFlowLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSSessionScrollingItemFlowLayout.h; sourceTree = "<group>"; };
235714A02BEF510B004C81D6 /* MSSessionScrollingItemFlowLayout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSSessionScrollingItemFlowLayout.m; sourceTree = "<group>"; };
235A45182B04A352009753F5 /* PIRoomActivityWebView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIRoomActivityWebView.h; sourceTree = "<group>"; };
235A45192B04A352009753F5 /* PIRoomActivityWebView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIRoomActivityWebView.m; sourceTree = "<group>"; };
235A451B2B04A452009753F5 /* PIRoomActivityWebCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIRoomActivityWebCell.h; sourceTree = "<group>"; };
@@ -4980,7 +4982,6 @@
189DD5A726DFA09700AB55B1 /* Tools */ = {
isa = PBXGroup;
children = (
235714612BE8BE88004C81D6 /* CALayer */,
234F44E12B3EA4DC00E2B532 /* YMLine */,
23CEFC082AFB8FC100576D89 /* sdkContent */,
23FF255C2ABA8EEE0064E904 /* PIIAPTool */,
@@ -5227,7 +5228,6 @@
isa = PBXGroup;
children = (
18F404C6276099DF00A6C548 /* MessageProtocol.h */,
235714682BE8C055004C81D6 /* MSSessionScrollingProtocol.h */,
);
path = Protocol;
sourceTree = "<group>";
@@ -5592,15 +5592,6 @@
path = YMLine;
sourceTree = "<group>";
};
235714612BE8BE88004C81D6 /* CALayer */ = {
isa = PBXGroup;
children = (
235714622BE8BEA0004C81D6 /* CALayer+Animation.h */,
235714632BE8BEA0004C81D6 /* CALayer+Animation.m */,
);
path = CALayer;
sourceTree = "<group>";
};
236B2E1B2AA0786E003967A8 /* Library */ = {
isa = PBXGroup;
children = (
@@ -9579,6 +9570,10 @@
E885D5382977D10E004DC088 /* SessionSettingUserView.m */,
235714652BE8C009004C81D6 /* MSSessionScrollingView.h */,
235714662BE8C009004C81D6 /* MSSessionScrollingView.m */,
2357149C2BEF0F6D004C81D6 /* MSSessionScrollingItemCell.h */,
2357149D2BEF0F6D004C81D6 /* MSSessionScrollingItemCell.m */,
2357149F2BEF510B004C81D6 /* MSSessionScrollingItemFlowLayout.h */,
235714A02BEF510B004C81D6 /* MSSessionScrollingItemFlowLayout.m */,
2357146F2BEB97BD004C81D6 /* MSSessionScrollingItemView.h */,
235714702BEB97BD004C81D6 /* MSSessionScrollingItemView.m */,
2357146C2BEB816B004C81D6 /* MSSessionPublicChatHallHeadView.h */,
@@ -11284,6 +11279,7 @@
E81DCCCD282B63B40039E5C5 /* XPMonentsViewController.m in Sources */,
237700FD2BCD254000D661F1 /* MSBaseTextField.m in Sources */,
237700E62BC7E81F00D661F1 /* UITextField+MSRTL.m in Sources */,
2357149E2BEF0F6D004C81D6 /* MSSessionScrollingItemCell.m in Sources */,
E86507EB281A88A9006951B0 /* MessageContentSkillCardView.m in Sources */,
E8B825CA26EA1231009E8E9F /* LoginVerifCodeViewController.m in Sources */,
189DD76226E60DDC00AB55B1 /* Api+Login.m in Sources */,
@@ -12090,7 +12086,6 @@
238B37C92AC55A2C00BFC9D5 /* XPTreasureFairyStoreResultSmallView.m in Sources */,
E8C1CD7027D894B800376F83 /* RoomFaceTitleItemModel.m in Sources */,
E85E7B4B2A4EB0D300B6D00A /* XPMineGuildManagerSetViewController.m in Sources */,
235714642BE8BEA0004C81D6 /* CALayer+Animation.m in Sources */,
189DD73D26E21C3F00AB55B1 /* YYUtility+Device.m in Sources */,
187EEEDC26E89B32002833B2 /* BaseModel.m in Sources */,
23CEFC682AFCCE7700576D89 /* PIGiftInfoSegmentedView.m in Sources */,
@@ -12346,6 +12341,7 @@
149839C7299E0B9F00F82CBF /* XPMomentListCollectionViewCell.m in Sources */,
236BA4982BB6AFED00C7C73A /* PINoblePrivilegeEmptyCell.m in Sources */,
E88C729C2828F37D0047FB2B /* XPRoomMusicLibraryEmptyTableViewCell.m in Sources */,
235714A12BEF510B004C81D6 /* MSSessionScrollingItemFlowLayout.m in Sources */,
E85E7B0A2A4EB0D200B6D00A /* XPGuildManagerPerPresenter.m in Sources */,
235714922BEDC9B1004C81D6 /* MSSessionPublicChatHalImageModel.m in Sources */,
9B85F3562806DD8A006EDF51 /* XPAnchorPKFinishView.m in Sources */,

View File

@@ -14,10 +14,11 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic,copy) NSString *content;
@property(nonatomic,assign) BOOL isTop;
@property(nonatomic,copy) NSString *partitionId;
@property(nonatomic,assign) NSString *recordStatus;
@property(nonatomic,copy) NSString *nick;
@property(nonatomic,assign) NSInteger endTime;
@property(nonatomic,assign) NSInteger startTime;
//0 有效 1 过期
@property(nonatomic,assign) int recordStatus;
@end
NS_ASSUME_NONNULL_END

View File

@@ -6,10 +6,10 @@
//
#import "PIBaseModel.h"
#import "MSSessionScrollingProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@interface MSSessionScrollingModel : PIBaseModel<MSSessionScrollingProtocol>
@interface MSSessionScrollingModel : PIBaseModel
@property (nonatomic,assign)NSTimeInterval beginTime;
@property (nonatomic,assign)NSTimeInterval endTime;
@property (nonatomic,copy)NSString *content;
@@ -22,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic,copy) NSString *toNick;
@property(nonatomic,copy) NSString *toUid;
@property(nonatomic,assign) CGFloat width;
@property(nonatomic,strong) NSMutableAttributedString * attribute;
@end
NS_ASSUME_NONNULL_END

View File

@@ -1,18 +0,0 @@
//
// MSSessionScrollingProtocol.h
// YuMi
//
// Created by duoban on 2024/5/6.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol MSSessionScrollingProtocol <NSObject>
@required
@property (nonatomic,readonly)NSTimeInterval beginTime;
@property (nonatomic,readonly)NSTimeInterval endTime;
@end
NS_ASSUME_NONNULL_END

View File

@@ -184,7 +184,10 @@
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_Chat_Hall_Headlinesn && attachment.second == Custom_Message_Sub_Chat_Hall_Headlinesn) {
isCanAdd = YES;
MSSessionPublicChatHallTopModel *topModel = [MSSessionPublicChatHallTopModel modelWithDictionary:attachment.data];
if(topModel.recordStatus == 0){
isCanAdd = YES;
}
}
}
break;
@@ -339,9 +342,7 @@
}
- (void)getPublicChatHallTopTextSuccess:(MSSessionPublicChatHallTopModel *)model{
self.headView.topModel = model;
if(model != nil){
[self setTime:model];
}
}
///
@@ -423,7 +424,9 @@
}];
return;
}
dispatch_async(dispatch_get_main_queue(), ^{///线
[self hideHUD];
if (self.messages.count > kRoomMessageMaxLength) {
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
NSArray *needRemoveMsgArray = [self.messages objectsAtIndexes:set];
@@ -557,7 +560,6 @@
if(!messages.count){
return;
}
NIMMessage *message = messages.firstObject;
if (self.messages.count > kRoomMessageMaxLength) {
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
NSArray *needRemoveMsgArray = [self.messages objectsAtIndexes:set];

View File

@@ -30,9 +30,8 @@
}
-(void)setTopModel:(MSSessionPublicChatHallTopModel *)topModel{
_topModel = topModel;
if(_topModel == nil){
if(_topModel.recordStatus == 1 || _topModel == nil){
self.contentView.hidden = YES;
self.addIocnView.hidden = NO;
self.textView.hidden = NO;
_bgImageView.image = kImage(@"ms_public_chat_hall_head_bg");

View File

@@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface MSSessionReleaseHeadlinesPayView : UIView
@property(nonatomic,copy) NSString *releaseCoins;
@property(nonatomic,copy) NSString *coins;
@property(nonatomic,assign) BOOL isRoom;
@property(nonatomic,weak) id<MSSessionReleaseHeadlinesPayViewDelegate>delegate;
@end

View File

@@ -36,6 +36,10 @@
[self.bgView addSubview:self.payBtn];
}
-(void)backAction{
if(self.isRoom){
[self.superview removeFromSuperview];
return;
}
[self removeFromSuperview];
}
-(void)installConstraints{
@@ -72,10 +76,15 @@
}];
}
-(void)payBtnAction{
[self removeFromSuperview];
if(self.delegate && [self.delegate respondsToSelector:@selector(payReleaseHeadlines)]){
[self.delegate payReleaseHeadlines];
}
if(self.isRoom){
[self.superview removeFromSuperview];
return;
}
[self removeFromSuperview];
}
-(void)setReleaseCoins:(NSString *)releaseCoins{
_releaseCoins = releaseCoins;

View File

@@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface MSSessionReleaseHeadlinesView : UIView
@property(nonatomic,copy) NSString *sendText;
@property(nonatomic,copy) NSString *golds;
@property(nonatomic,copy) NSString *myCoins;
@property(nonatomic,weak) id<MSSessionReleaseHeadlinesViewDelegate>delegate;

View File

@@ -66,16 +66,38 @@
-(void)loadDataForRoom{
self.isRoom = YES;
[self getCoinsData];
MSSessionReleaseHeadlinesPayView *payView = [[MSSessionReleaseHeadlinesPayView alloc]initWithFrame:CGRectZero];
payView.tag = 100001;
payView.isRoom = YES;
payView.delegate = self;
[self addSubview:payView];
[payView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
self.bgView.hidden = YES;
}
-(void)setSendText:(NSString *)sendText{
_sendText = sendText;
_textView.text = _sendText;
}
-(void)getCoinsData{
[XNDJTDDLoadingTool showLoadingInView:kWindow];
[Api requestRecordIncome:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
[XNDJTDDLoadingTool hideHUDInView:kWindow];
if(code == 200){
XPIncomeRecordModel *model = [XPIncomeRecordModel modelWithDictionary:data.data];
self.myCoins = @(model.diamonds).stringValue;
MSSessionReleaseHeadlinesPayView *payView = [self viewWithTag:100001];
payView.coins = self.myCoins;
}
}];
[Api getPublicChatHallTopTextPayMoney:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
self.golds = [NSString stringWithFormat:@"%@",data.data];
MSSessionReleaseHeadlinesPayView *payView = [self viewWithTag:100001];
payView.releaseCoins = self.golds;
}];
}
-(void)releaseBtnAction{
@@ -88,6 +110,7 @@
payView.releaseCoins = self.golds;
payView.coins = self.myCoins;
payView.delegate = self;
[self addSubview:payView];
[payView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);

View File

@@ -0,0 +1,16 @@
//
// MSSessionScrollingItemCell.h
// YuMi
//
// Created by duoban on 2024/5/11.
//
#import <UIKit/UIKit.h>
#import "MSSessionScrollingModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface MSSessionScrollingItemCell : UICollectionViewCell
@property(nonatomic,strong) MSSessionScrollingModel *model;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,41 @@
//
// MSSessionScrollingItemCell.m
// YuMi
//
// Created by duoban on 2024/5/11.
//
#import "MSSessionScrollingItemCell.h"
#import "MSSessionScrollingItemView.h"
@interface MSSessionScrollingItemCell()
@property(nonatomic,strong) MSSessionScrollingItemView *itemView;
@end
@implementation MSSessionScrollingItemCell
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self installUI];
[self installConstraints];
}
return self;
}
-(void)installUI{
[self.contentView addSubview:self.itemView];
}
-(void)installConstraints{
[self.itemView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.contentView);
}];
}
- (void)setModel:(MSSessionScrollingModel *)model{
_model = model;
_itemView.model = _model;
}
#pragma mark -
- (MSSessionScrollingItemView *)itemView{
if(!_itemView){
_itemView = [[MSSessionScrollingItemView alloc]initWithFrame:CGRectZero];
}
return _itemView;
}
@end

View File

@@ -0,0 +1,64 @@
//
// MSSessionScrollingItemFlowLayout.h
// YuMi
//
// Created by duoban on 2024/5/11.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
MSDirectionTypeHorizontalType,
MSDirectionTypeVerticalType,
} MSDirectionType;
@interface MSSessionScrollingItemFlowLayout : MSBaseRTLFlowLayout
/**
* 行高(水平瀑布流时),默认为100
*/
@property (nonatomic, assign) CGFloat rowHeight;
/**
* 单元格宽度(垂直瀑布流时)
*/
@property (nonatomic, assign, readonly) CGFloat itemWidth;
/**
* 列数 : 默认为3
*/
@property (nonatomic, assign) NSInteger numberOfColumns;
/**
* 内边距 : 每一列之间的间距 (top, left, bottom, right)默认为{10, 10, 10, 10};
*/
@property (nonatomic, assign) UIEdgeInsets insets;
/**
* 每一行之间的间距 : 默认为10
*/
@property (nonatomic, assign) CGFloat rowGap;
/**
* 每一列之间的间距 : 默认为10
*/
@property (nonatomic, assign) CGFloat columnGap;
/**
* 高度数组 : 存储所有item的高度
*/
@property (nonatomic, strong) NSArray *itemHeights;
/**
* 宽度数组 : 存储所有item的宽度
*/
@property (nonatomic, strong) NSArray *itemWidths;
/**
* 瀑布流类型 : 分为水平瀑布流 和 垂直瀑布流
*/
@property (nonatomic, assign) MSDirectionType type;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,138 @@
//
// MSSessionScrollingItemFlowLayout.m
// YuMi
//
// Created by duoban on 2024/5/11.
//
#import "MSSessionScrollingItemFlowLayout.h"
@interface MSSessionScrollingItemFlowLayout()
@property (nonatomic, strong) NSMutableArray *itemAttributes; // cell
//
@property (nonatomic, strong) NSMutableArray *columnsHeights; // (count=)
@property (nonatomic, assign) CGFloat maxHeight; // ()
@property (nonatomic, assign) CGFloat minHeight; // ()
@property (nonatomic, assign) NSInteger minIndex; //
@property (nonatomic, assign) NSInteger maxIndex; //
//
@property (nonatomic, strong) NSMutableArray *columnsWidths; // (count)
@property (nonatomic, assign) NSInteger tempItemX; // x : cellx
@property (nonatomic, assign) NSInteger maxRowIndex; //
@end
@implementation MSSessionScrollingItemFlowLayout
//
#pragma mark --
/**
*
*/
- (void)prepareLayout {
[super prepareLayout];
// ()
if ((self.type == MSDirectionTypeHorizontalType)) {
self.maxRowIndex = 0;
}
if (self.type == MSDirectionTypeVerticalType) {
// ()
[self.columnsHeights removeAllObjects];
for (NSUInteger i = 0; i < self.numberOfColumns; i++) {
[self.columnsHeights addObject:@(self.insets.top)];
}
}
// cell
[self.itemAttributes removeAllObjects];
NSUInteger itemCount = [self.collectionView numberOfItemsInSection:0];
self.tempItemX = self.insets.left;
for (NSUInteger i = 0; i < itemCount; ++i) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
if (self.type == MSDirectionTypeVerticalType) {
[self setVerticalFrame:indexPath];
}else if ((self.type == MSDirectionTypeHorizontalType)){
[self setHorizontalFrame:indexPath];
}
}
}
/**
* attrsframe
*/
- (void)setHorizontalFrame:(NSIndexPath *)indexPath {
UICollectionViewLayoutAttributes *attrs = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
CGFloat w = [self.itemWidths[indexPath.item] floatValue];
CGFloat width = w + self.columnGap;
CGFloat h = (self.rowHeight == 0) ? 100 : self.rowHeight;
/**
* x+cell
* : +1tempItemX10(self.insets.left)
*/
if (self.tempItemX + w > [UIScreen mainScreen].bounds.size.width) {
self.maxRowIndex++;
self.tempItemX = self.insets.left;
}
CGFloat x = self.tempItemX;
CGFloat y = self.insets.top + self.maxRowIndex * (h + self.rowGap);
attrs.frame = CGRectMake(x, y, w, h);
/**
* 1.cell : rowHeight(100)
* 2.cellx : tempItemX
* 3.celly : minHeightcelly
*/
NSLog(@"%@",NSStringFromCGRect(attrs.frame));
[self.itemAttributes addObject:attrs];
self.tempItemX += width;
}
/**
* attrsframe
*/
- (void)setVerticalFrame:(NSIndexPath *)indexPath {
UICollectionViewLayoutAttributes *attrs = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
// cellframe
CGFloat w = self.itemWidth;
CGFloat h = [self.itemHeights[indexPath.item] floatValue];
CGFloat x = self.insets.left + self.minIndex * (w + self.columnGap);
CGFloat y = self.minHeight + self.rowGap;
attrs.frame = CGRectMake(x, y, w, h);
/**
* 1.cell : (itemWidth)
* 2.cellx : minIndex
* 3.celly : minHeightcelly
*/
//
self.columnsHeights[self.minIndex] = @(CGRectGetMaxY(attrs.frame));
NSLog(@"%@",NSStringFromCGRect(attrs.frame));
[self.itemAttributes addObject:attrs];
}
/**
* collectionView
*/
- (CGSize)collectionViewContentSize {
CGFloat height;
if (self.type == MSDirectionTypeHorizontalType) {
CGFloat rowHeight = (self.rowHeight == 0) ? 100 : self.rowHeight;
height = self.insets.top + (self.maxRowIndex+1) * (rowHeight + self.rowGap);
}else {
height = self.maxHeight;
}
return CGSizeMake(self.collectionView.frame.size.width, height);
}
/**
* cell
*/
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
return self.itemAttributes;
}
@end

View File

@@ -6,9 +6,10 @@
//
#import "MSSessionScrollingItemView.h"
@interface MSSessionScrollingItemView()
@property(nonatomic,strong) NetImageView *avatarVeiw;
@property(nonatomic,strong) UILabel *textView;
@property(nonatomic,strong) YYLabel *textView;
@end
@implementation MSSessionScrollingItemView
@@ -23,7 +24,8 @@
-(void)setModel:(MSSessionScrollingModel *)model{
_model = model;
_avatarVeiw.imageUrl = _model.fromAvatar;
_textView.text = _model.content;
_textView.attributedText = _model.attribute;
}
-(void)installUI{
[self addSubview:self.avatarVeiw];
@@ -37,7 +39,6 @@
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.equalTo(self.avatarVeiw.mas_trailing).mas_offset(kGetScaleWidth(5.5));
make.trailing.mas_equalTo(-kGetScaleWidth(0));
make.height.mas_equalTo(kGetScaleWidth(11.5));
make.centerY.equalTo(self.avatarVeiw);
}];
@@ -53,9 +54,9 @@
}
return _avatarVeiw;
}
- (UILabel *)textView{
- (YYLabel *)textView{
if(!_textView){
_textView = [UILabel labelInitWithText:@"" font:kFontMedium(12) textColor:UIColorFromRGB(0xFFFCED)];
_textView = [YYLabel new];
}
return _textView;
}

View File

@@ -6,22 +6,15 @@
//
#import <UIKit/UIKit.h>
#import "MSSessionScrollingProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@class MSSessionScrollingView;
@protocol MSSessionScrollingViewDelegate <NSObject>
@property (nonatomic,readonly)NSTimeInterval curTime;
- (UIView *)MSSessionScrollingView:(MSSessionScrollingView *)view scrollingWithModel:(id<MSSessionScrollingProtocol>)model;
- (void)MSSessionScrollingView:(MSSessionScrollingView *)view didClickView:(UIView *__nullable)scrollingView atPoint:(CGPoint)point;
@end
@interface MSSessionScrollingView : UIView
@property(nonatomic,weak) id<MSSessionScrollingViewDelegate>delegate;
@property (nonatomic,strong) NSMutableArray <id <MSSessionScrollingProtocol>> *modelList;
@property (nonatomic,strong) NSMutableArray *modelList;
@property (nonatomic, assign)BOOL isPause;
@property (nonatomic, assign)BOOL isChange;

View File

@@ -6,18 +6,20 @@
//
#import "MSSessionScrollingView.h"
#import "CALayer+Animation.h"
#import "MSSessionScrollingItemCell.h"
#import "MSSessionScrollingModel.h"
static const CGFloat ktimerSec = 0.01;
static const CGFloat ktimerSec = 0.1;
static const CGFloat kDandaoCount = 3;
@interface MSSessionScrollingView()
@interface MSSessionScrollingView()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property (nonatomic,weak)NSTimer *timer;
@property (nonatomic,strong)NSMutableArray *waitTimeList;
@property (nonatomic,strong)NSMutableArray *leftTimeList;
@property (nonatomic,strong)NSMutableArray *scrollingList;
@property(nonatomic,strong) UIImageView *bgImageView;
@property(nonatomic,strong) UILabel *textView;
///
@property (nonatomic, strong) UICollectionView *collectionView;
@end
@implementation MSSessionScrollingView
@@ -30,185 +32,144 @@ static const CGFloat kDandaoCount = 3;
return self;
}
-(void)installUI{
[self addSubview:self.bgImageView];
[self.bgImageView addSubview:self.textView];
[self addSubview:self.collectionView];
}
-(void)installConstraints{
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(25.5));
make.centerX.equalTo(self.bgImageView);
}];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.equalTo(self).inset(kGetScaleWidth(3));
make.top.mas_equalTo(kGetScaleWidth(48));
make.bottom.mas_equalTo(-kGetScaleWidth(3));
}];
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.modelList.count+1;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row == 0){
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([UICollectionViewCell class]) forIndexPath:indexPath];
return cell;
}
MSSessionScrollingItemCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([MSSessionScrollingItemCell class]) forIndexPath:indexPath];
cell.model = [self.modelList safeObjectAtIndex1:indexPath.row-1];
return cell;
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
return UIEdgeInsetsMake(0, 0, 0, 0);;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row == 0){
return CGSizeMake(KScreenWidth, kGetScaleWidth(80));
}
MSSessionScrollingModel *model = [self.modelList safeObjectAtIndex1:indexPath.row-1];
return CGSizeMake(model.width + kGetScaleWidth(32.5), kGetScaleWidth(27));
}
- (void)ms_ClickView:(UITapGestureRecognizer *)tap {
if ([self.delegate respondsToSelector:@selector(MSSessionScrollingView:didClickView:atPoint:)]) {
[self.delegate MSSessionScrollingView:self didClickView:nil atPoint:CGPointMake(0, 0)];
}
}
- (void)setModelList:(NSMutableArray *)modelList{
_modelList = modelList;
@kWeakify(self);
_timer = [NSTimer timerWithTimeInterval:ktimerSec repeats:YES block:^(NSTimer * _Nonnull timer) {
@kStrongify(self);
self.collectionView.contentOffset = CGPointMake(self.collectionView.contentOffset.x + 0.5, 0);
CGFloat width = self.collectionView.contentSize.width + 5;
if(self.collectionView.contentOffset.x > width){
self.collectionView.contentOffset = CGPointMake(0, 0);
}
}];
[[NSRunLoop currentRunLoop]addTimer:_timer forMode:NSRunLoopCommonModes];
[self.collectionView reloadData];
}
#pragma mark --
- (void)didMoveToSuperview {
[super didMoveToSuperview];
[self timer];
self.layer.masksToBounds = YES;
}
-(void)dealloc {
[self.timer invalidate];
self.timer = nil;
if(self.timer != nil){
[self.timer invalidate];
self.timer = nil;
}
}
#pragma mark --
///
- (void)pauseAnimation {
_isPause = YES;
[[self.scrollingList valueForKeyPath:@"layer"] makeObjectsPerformSelector:@selector(ms_pauseAnimate)];
[self.timer invalidate];
self.timer = nil;
if(self.timer != nil){
[self.timer invalidate];
self.timer = nil;
}
}
///
- (void)resumeAnimation{
_isPause = NO;
[[self.scrollingList valueForKeyPath:@"layer"] makeObjectsPerformSelector:@selector(ms_resumeAnimate)];
[self timer];
@kWeakify(self);
_timer = [NSTimer timerWithTimeInterval:ktimerSec repeats:YES block:^(NSTimer * _Nonnull timer) {
@kStrongify(self);
self.collectionView.contentOffset = CGPointMake(self.collectionView.contentOffset.x + 0.5, 0);
CGFloat width = self.collectionView.contentSize.width + 5;
if(self.collectionView.contentOffset.x > width){
self.collectionView.contentOffset = CGPointMake(0, 0);
}
}];
[[NSRunLoop currentRunLoop]addTimer:_timer forMode:NSRunLoopCommonModes];
}
#pragma mark --
- (void)checkAndBiu {
if (_isPause) {
return;
}
//
for (int i = 0; i < kDandaoCount; i++) {
double waitValue = [self.waitTimeList[i] doubleValue] - ktimerSec;
if (waitValue <= 0.0) {
waitValue = 0.0;
}
self.waitTimeList[i] = @(waitValue);
double leftValue = [self.leftTimeList[i] doubleValue] - ktimerSec;
if (leftValue <= 0.0) {
leftValue = 0.0;
}
self.leftTimeList[i] = @(leftValue);
}
[self.modelList sortUsingComparator:^NSComparisonResult(id<MSSessionScrollingProtocol> _Nonnull obj1, id<MSSessionScrollingProtocol> _Nonnull obj2) {
if (obj1.beginTime < obj2.beginTime) {
return NSOrderedAscending;
}
return NSOrderedDescending; //
}];
// ,
NSMutableArray *deleteModelArr = [NSMutableArray array];
for (id<MSSessionScrollingProtocol> model in self.modelList) {
//1.
NSTimeInterval beginTime = model.beginTime;
NSTimeInterval curTime = self.delegate.curTime;
if (beginTime > curTime) {
break;
}
//2.
BOOL result = [self checkBoomAndBiuWith:model];
if (result) {
[deleteModelArr addObject:model];
}
}
[self.modelList removeObjectsInArray:deleteModelArr];
}
#pragma mark --
- (BOOL)checkBoomAndBiuWith:(id<MSSessionScrollingProtocol>)model {
CGFloat danmakuH = self.frame.size.height / kDandaoCount + 10;
//
for (int i = 0 ; i < kDandaoCount; i++) {
//1.
NSTimeInterval waitTime = [self.waitTimeList[i] doubleValue];
if (waitTime > 0.0) {
continue;
}
//2.
UIView * danmakuView = [self.delegate MSSessionScrollingView:self scrollingWithModel:model];
NSTimeInterval leftTime = [self.leftTimeList[i] doubleValue];
// = ( + )/endTime
double speed = ( danmakuView.frame.size.width + self.frame.size.width) / model.endTime;
double distance = leftTime * speed;
if (distance > self.frame.size.width) {
continue;
}
if(danmakuH * (i+1) + 5> self.frame.size.height){
continue;
}
[self.scrollingList addObject:danmakuView];
//
// / = v
self.waitTimeList[i] = @(danmakuView.frame.size.width / speed);
self.leftTimeList[i] = @(model.endTime);
//3.
//3.1
CGRect frame = danmakuView.frame;
frame.origin = CGPointMake(self.frame.size.width, danmakuH * i);
danmakuView.frame = frame;
[self addSubview:danmakuView];
[UIView animateWithDuration:model.endTime delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
CGRect frame = danmakuView.frame;
frame.origin.x = - danmakuView.frame.size.width;
danmakuView.frame = frame;
} completion:^(BOOL finished) {
[danmakuView removeFromSuperview];
[self.scrollingList removeObject:danmakuView];
}];
return YES;
}
return NO;
}
#pragma mark --set get
- (NSMutableArray *)modelList {
if (!_modelList) {
_modelList = [NSMutableArray array];
}
return _modelList;
}
-(NSTimer *)timer {
if (!_timer) {
NSTimer *timer = [NSTimer timerWithTimeInterval:ktimerSec repeats:YES block:^(NSTimer * _Nonnull timer) {
[self checkAndBiu];
}];
[[NSRunLoop currentRunLoop]addTimer:timer forMode:NSRunLoopCommonModes];
_timer = timer;
}
return _timer;
}
- (NSMutableArray *)waitTimeList {
if (!_waitTimeList) {
_waitTimeList = [NSMutableArray arrayWithCapacity:kDandaoCount];
for (int i = 0; i < kDandaoCount; i ++) {
_waitTimeList[i] = @0.0;
}
}
return _waitTimeList;
}
- (NSMutableArray *)leftTimeList {
if (!_leftTimeList) {
_leftTimeList = [NSMutableArray arrayWithCapacity:kDandaoCount];
for (int i = 0; i < kDandaoCount; i ++) {
_leftTimeList[i] = @0.0;
}
}
return _leftTimeList;
}
- (NSMutableArray *)scrollingList {
if (!_scrollingList) {
_scrollingList = [NSMutableArray array];
}
return _scrollingList;
}
- (UIImageView *)bgImageView{
if(!_bgImageView){
_bgImageView = [UIImageView new];
_bgImageView.userInteractionEnabled = YES;
_bgImageView.image = kImage(@"ms_public_chat_hall_head_enter_bg");
}
return _bgImageView;
}
- (UILabel *)textView{
if(!_textView){
_textView = [UILabel labelInitWithText:YMLocalizedString(@"MSSessionPublicChatHallVC0") font:kFontBold(17) textColor:UIColorFromRGB(0xFFDDA2)];
}
return _textView;
}
- (UICollectionView *)collectionView {
if (!_collectionView) {
MSBaseRTLFlowLayout *layout = [[MSBaseRTLFlowLayout alloc] init];
layout.minimumLineSpacing = 2;
layout.minimumInteritemSpacing = 10;
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.scrollEnabled = NO;
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.backgroundColor = [UIColor clearColor];
_collectionView.showsVerticalScrollIndicator = NO;
_collectionView.showsHorizontalScrollIndicator = NO;
[_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([UICollectionViewCell class])];
[_collectionView registerClass:[MSSessionScrollingItemCell class] forCellWithReuseIdentifier:NSStringFromClass([MSSessionScrollingItemCell class])];
}
return _collectionView;
}
@end

View File

@@ -10,6 +10,7 @@
#import <JXPagingView/JXPagerView.h>
#import <JXPagingView/JXPagerListRefreshView.h>
#import <JXCategoryView/JXCategoryView.h>
#import "QEmotionHelper.h"
///vc
#import "XPMineAttentionViewController.h"
#import "SessionListViewController.h"
@@ -20,7 +21,7 @@
#import "MessagePresenter.h"
#import "MessageProtocol.h"
#import "MSSessionPublicChatHallVC.h"
@interface XPSessionMainViewController ()<JXCategoryViewDelegate,JXPagerViewDelegate,JXPagerMainTableViewGestureDelegate,MSSessionScrollingViewDelegate>
@interface XPSessionMainViewController ()<JXCategoryViewDelegate,JXPagerViewDelegate,JXPagerMainTableViewGestureDelegate>
@property (nonatomic, strong) JXCategoryTitleView *titleView;
@property (nonatomic, strong) JXCategoryIndicatorImageView *lineView;
@property (nonatomic, strong) JXPagerView *pagingView;
@@ -38,8 +39,8 @@
///
@property (nonatomic,strong) UIButton * allCleanBtn;
@property(nonatomic,strong) MSSessionScrollingView *scrollingView;
@property(nonatomic,strong) UIImageView *bgImageView;
@property(nonatomic,strong) UILabel *textView;
@property(nonatomic,strong) UIButton *clickBnt;
@end
@implementation XPSessionMainViewController
@@ -65,11 +66,18 @@
[self.presenter getPublicChatHallList];
}
-(void)getPublicChatHallListSuccess:(NSArray<MSSessionScrollingModel *> *)list{
NSMutableArray *l = [NSMutableArray new];
for (MSSessionScrollingModel *obj in list) {
obj.beginTime = 3;
obj.endTime = 8;
for (MSSessionScrollingModel *model in list) {
CGSize dstRect = CGSizeMake(model.width, MAXFLOAT);
QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper];
NSMutableAttributedString * attribute = [faceManager attributedStringByText:model.content font:kFontMedium(12)];
[attribute addAttributes:@{NSForegroundColorAttributeName: UIColorFromRGB(0xFFFCED)} range:[attribute.string rangeOfString:attribute.string]];
YYTextContainer *container = [YYTextContainer containerWithSize:dstRect];
container.maximumNumberOfRows = 1;
YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:attribute];
model.width = layout.textBoundingSize.width;
model.attribute = attribute;
}
self.scrollingView.modelList = [[NSMutableArray alloc]initWithArray:list];
}
#pragma mark - Private Method
@@ -81,35 +89,28 @@
[self.view addSubview:self.headBgImageView];
[self.view addSubview:self.pagingView];
[self.view addSubview:self.allCleanBtn];
[self.view addSubview:self.bgImageView];
[self.bgImageView addSubview:self.textView];
[self.bgImageView addSubview:self.scrollingView];
;
[self.view addSubview:self.scrollingView];
[self.scrollingView addSubview:self.clickBnt];
}
- (void)initSubViewConstraints {
[self.headBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.top.trailing.equalTo(self.view);
make.height.mas_equalTo(196);
}];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
[self.scrollingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kStatusBarHeight);
make.height.mas_equalTo(kGetScaleWidth(112));
make.leading.trailing.equalTo(self.view);
}];
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(25.5));
make.centerX.equalTo(self.bgImageView);
}];
[self.scrollingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(0);
make.top.mas_equalTo(kGetScaleWidth(48));
make.trailing.mas_equalTo(-kGetScaleWidth(0));
make.bottom.mas_equalTo(kGetScaleWidth(8));
[self.clickBnt mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.scrollingView);
}];
[self.pagingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.equalTo(self.view);
make.bottom.mas_equalTo(-1);
make.top.equalTo(self.bgImageView.mas_bottom).mas_offset(-50);
make.top.equalTo(self.scrollingView.mas_bottom).mas_offset(-50);
}];
[self.allCleanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(30);
@@ -183,16 +184,7 @@
- (void)allReadButtonClick:(UIButton *)sender {
[[NSNotificationCenter defaultCenter]postNotificationName:@"kAllReadAction" object:nil];
}
#pragma mark- MSSessionScrollingViewDelegate
- (UIView *)MSSessionScrollingView:(MSSessionScrollingView *)view scrollingWithModel:(MSSessionScrollingModel*)model{
MSSessionScrollingItemView *scrollingView = [[MSSessionScrollingItemView alloc]initWithFrame:CGRectMake(0, 0, model.width + kGetScaleWidth(32.5), kGetScaleWidth(27))];
scrollingView.model = model;
return scrollingView;
}
- (void)MSSessionScrollingView:(MSSessionScrollingView *)view didClickView:(UIView *)scrollingView atPoint:(CGPoint)point{
}
-(void)clickPublicChatHallAction{
MSSessionPublicChatHallVC *vc =[MSSessionPublicChatHallVC new];
[self.navigationController pushViewController:vc animated:YES];
@@ -300,25 +292,16 @@
- (MSSessionScrollingView *)scrollingView{
if(!_scrollingView){
_scrollingView = [[MSSessionScrollingView alloc]initWithFrame:CGRectZero];
_scrollingView.delegate = self;
}
return _scrollingView;
}
- (UIImageView *)bgImageView{
if(!_bgImageView){
_bgImageView = [UIImageView new];
_bgImageView.userInteractionEnabled = YES;
_bgImageView.image = kImage(@"ms_public_chat_hall_head_enter_bg");
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickPublicChatHallAction)];
[_bgImageView addGestureRecognizer:tap];
- (UIButton *)clickBnt{
if(!_clickBnt){
_clickBnt = [UIButton new];
[_clickBnt addTarget:self action:@selector(clickPublicChatHallAction) forControlEvents:UIControlEventTouchUpInside];
}
return _bgImageView;
}
- (UILabel *)textView{
if(!_textView){
_textView = [UILabel labelInitWithText:YMLocalizedString(@"MSSessionPublicChatHallVC0") font:kFontBold(17) textColor:UIColorFromRGB(0xFFDDA2)];
}
return _textView;
return _clickBnt;
}
/*
#pragma mark - Navigation

View File

@@ -104,7 +104,6 @@
NSMutableDictionary *ext = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[NSString stringWithFormat:@"%ld", userInfo.uid]];
request.roomExt = [ext toJSONString];
[[NIMSDK sharedSDK].chatroomManager enterChatroom:request completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom, NIMChatroomMember * _Nullable me) {
if (error) {
[[self getView] enterRoomFail:error.code];
@@ -117,7 +116,7 @@
publicChatRoomRequest.roomId = publicChatRoomId;
NSMutableDictionary *publicChatRoomExt = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:publicChatRoomId];
request.roomExt = [publicChatRoomExt toJSONString];
publicChatRoomRequest.roomExt = [publicChatRoomExt toJSONString];
[[NIMSDK sharedSDK].chatroomManager enterChatroom:publicChatRoomRequest completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom, NIMChatroomMember * _Nullable me) {
NSLog(@"111");

View File

@@ -132,8 +132,17 @@
}];
}
-(void)showSendheadlineBtnAction{
if(self.editTextFiled.text.length == 0){
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"MSSessionReleaseHeadlinesView0")];
return;
}
if(self.editTextFiled.text.length > 100){
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"MSSessionReleaseHeadlinesView0")];
return;
}
[self.editTextFiled resignFirstResponder];
[[NSNotificationCenter defaultCenter]postNotificationName:@"kShowSendheadlineView" object:nil];
[[NSNotificationCenter defaultCenter]postNotificationName:@"kShowSendheadlineView" object:self.editTextFiled.text];
self.editTextFiled.text = @"";
}
- (void)keyboardWillShow:(NSNotification *)notification {
[self.superview bringSubviewToFront:self];
@@ -160,6 +169,7 @@
//
- (void)keyboardWillHidden:(NSNotification *)notification {
NSDictionary *info = [notification userInfo];
CGFloat duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
[UIView animateWithDuration:duration animations:^{
@@ -172,6 +182,7 @@
}
-(void)textFieldEditChanged:(NSNotification *)notification{
UITextField *textField = (UITextField *)notification.object;
NSString *toBeString = textField.text;
NSString *lang = [textField.textInputMode primaryLanguage];
@@ -205,7 +216,9 @@
}
}
}
self.inputMessage = textField.text;
if (self.inputMessage.length > 0) {
self.sendButton.enabled = YES;
} else {
@@ -225,6 +238,28 @@
if (textView == nil) {
textView = [[XPRoomSendTextView alloc] initWithDelegate:delegate];
[view addSubview:textView];
}else{
UIButton *headlineBtn = [textView viewWithTag:100];
UIButton *sendButton = [textView viewWithTag:101];
if(delegate.getPublicScreenType == 0){
headlineBtn.hidden = YES;
[sendButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(58);
make.height.mas_equalTo(29);
make.trailing.mas_equalTo(-15);
make.centerY.equalTo(textView);
}];
}else{
[sendButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(58);
make.height.mas_equalTo(29);
make.trailing.mas_equalTo(-53);
make.centerY.equalTo(textView);
}];
headlineBtn.hidden = NO;
}
}
textView.hidden = NO;
@@ -247,7 +282,6 @@
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = UIColorFromRGB(0x260159);
[self addSubview:self.bgEditTextFiled];
[self.bgEditTextFiled addSubview:self.editTextFiled];
[self addSubview:self.sendButton];
@@ -255,19 +289,16 @@
}
- (void)initSubViewConstraints {
[self.headlineBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(50);
make.height.mas_equalTo(45);
make.trailing.mas_equalTo(0);
make.centerY.equalTo(self);
}];
[self.sendButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(58);
make.height.mas_equalTo(29);
make.trailing.mas_equalTo(-53);
make.centerY.equalTo(self);
}];
[self.headlineBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(50);
make.height.mas_equalTo(45);
make.trailing.mas_equalTo(0);
make.centerY.equalTo(self);
}];
[self.bgEditTextFiled mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(6);
make.height.mas_equalTo(36);
@@ -277,11 +308,27 @@
}];
[self.editTextFiled mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(20);
make.trailing.mas_equalTo(-kGetScaleWidth(-20));
make.trailing.mas_equalTo(-kGetScaleWidth(20));
make.top.bottom.mas_equalTo(0);
}];
if(self.delegate.getPublicScreenType == 0){
self.headlineBtn.hidden = YES;
[self.sendButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(58);
make.height.mas_equalTo(29);
make.trailing.mas_equalTo(-15);
make.centerY.equalTo(self);
}];
return;
}
[self.sendButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(58);
make.height.mas_equalTo(29);
make.trailing.mas_equalTo(-53);
make.centerY.equalTo(self);
}];
self.headlineBtn.hidden = NO;
}
- (void)addNotification {
@@ -295,7 +342,7 @@
if(text.length > 0){
self.sendButton.enabled = YES;
}
}
#pragma mark - Getters And Setters
- (MSBaseTextField *)editTextFiled{
@@ -323,6 +370,7 @@
_sendButton.layer.cornerRadius = 7.5;
_sendButton.layer.masksToBounds = YES;
[_sendButton addTarget:self action:@selector(sendButtonDidClick:) forControlEvents:UIControlEventTouchUpInside];
_sendButton.tag = 101;
}
return _sendButton;
}
@@ -347,6 +395,7 @@
_headlineBtn = [UIButton new];
[_headlineBtn setBackgroundImage:[UIImage getLanguageImage:@"ms_room_message_send_headline_icon"] forState:UIControlStateNormal];
[_headlineBtn addTarget:self action:@selector(showSendheadlineBtnAction) forControlEvents:UIControlEventTouchUpInside];
_headlineBtn.tag = 100;
}
return _headlineBtn;
}

View File

@@ -176,6 +176,29 @@
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
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 mas_remakeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self).offset(15);
make.top.trailing.mas_equalTo(self);
make.height.mas_equalTo(0);
}];
}else{
self.titleView.text = topModel.content;
[self.headerView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self).offset(15);
make.top.trailing.mas_equalTo(self);
make.height.mas_greaterThanOrEqualTo(0);
}];
}
if(topModel.recordStatus == 1){
return NO;
}
}
return [[[self supportMessageDic] objectForKey:@(attachment.first)] containsObject:@(attachment.second)];
}
return NO;
@@ -215,29 +238,6 @@
self.isMiniEnter = NO;
if ([self isCanDisplayMessage:message]) {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if(attachment.first == CustomMessageType_Chat_Hall_Headlinesn && attachment.second == Custom_Message_Sub_Chat_Hall_Headlinesn){
MSSessionPublicChatHallTopModel *topModel = [MSSessionPublicChatHallTopModel modelWithDictionary:attachment.data];
if(topModel == nil){
self.titleView.text = topModel.content;
[self.headerView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self).offset(15);
make.top.trailing.mas_equalTo(self);
make.height.mas_equalTo(0);
}];
}else{
self.titleView.text = topModel.content;
[self.headerView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self).offset(15);
make.top.trailing.mas_equalTo(self);
make.height.mas_greaterThanOrEqualTo(0);
}];
}
}
[self addRoomMessage:message];
}
}
@@ -289,7 +289,7 @@
self.isLoadHistoryMessage = NO;
return;
}
[self handleFetchHistoryMessage:message];
[self handleFetchHistoryMessage];
} else {
self.isLoadHistoryMessage = NO;
}
@@ -297,7 +297,7 @@
}
}
- (void)handleFetchHistoryMessage:(NIMMessage *)message {
- (void)handleFetchHistoryMessage{
UserInfoModel *infoModel = self.hostDelegate.getUserInfo;
NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[infoModel.partitionId]];
@@ -411,7 +411,8 @@
- (void)onRoomMiniEntered {
self.isMiniEnter = YES;
self.isLoadHistoryMessage = NO;
[self handleFetchHistoryMessage];
self.headerView.backgroundColor = UIColorRGBAlpha(0x593722, 0.4);
}

View File

@@ -45,7 +45,7 @@
-(void)installConstraints{
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.mas_equalTo(kGetScaleWidth(0));
make.width.mas_equalTo(150);
make.width.mas_equalTo(isMSZH() ? 150 : 200);
make.height.mas_equalTo(kGetScaleWidth(30));
}];

View File

@@ -54,6 +54,7 @@
#import "XPTreasureFairyViewController.h"
#import "PIGeneralPublicScreenModel.h"
#import "MSSessionPublicChatHallTopModel.h"
#import "QEmotionHelper.h"
@implementation XPRoomMessageParser
@@ -201,6 +202,7 @@
if(getNick == nil && model.nick != nil){
getNick = model.nick;
}
NSString * nick = [NSString stringWithFormat:@"%@:", getNick];
if ([message.from isEqualToString:uid]) {
nick = YMLocalizedString(@"XPRoomMessageParser0");
@@ -240,22 +242,28 @@
}
}
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
id nickNameNifo = message.remoteExt[@"atNames"];
NSMutableAttributedString *msgStr;
if (message.text) {
msgStr = [[NSMutableAttributedString alloc] initWithString:message.text];
[msgStr addAttribute:NSForegroundColorAttributeName
value:[DJDKMIMOMColor messageTextColor]
range:NSMakeRange(0, msgStr.length)];
if ([nickNameNifo isKindOfClass:[NSArray class]]) {
for (NSString *nick in nickNameNifo) {
NSRange range = [message.text rangeOfString:nick];
if (range.length) {
[msgStr yy_setTextHighlightRange:range color:UIColorFromRGB(0xFD85C9) backgroundColor:[UIColor clearColor] userInfo:nil];
if(model.nick != nick){
QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper];
msgStr = [faceManager attributedStringByText:message.text font:[UIFont systemFontOfSize:kRoomMessageDefalutFont]];
[msgStr addAttributes:@{NSForegroundColorAttributeName: [DJDKMIMOMColor messageTextColor]} range:[msgStr.string rangeOfString:msgStr.string]];
}else{
msgStr = [[NSMutableAttributedString alloc] initWithString:message.text];
[msgStr addAttribute:NSForegroundColorAttributeName
value:[DJDKMIMOMColor messageTextColor]
range:NSMakeRange(0, msgStr.length)];
if ([nickNameNifo isKindOfClass:[NSArray class]]) {
for (NSString *nick in nickNameNifo) {
NSRange range = [message.text rangeOfString:nick];
if (range.length) {
[msgStr yy_setTextHighlightRange:range color:UIColorFromRGB(0xFD85C9) backgroundColor:[UIColor clearColor] userInfo:nil];
}
}
}
}

View File

@@ -15,6 +15,7 @@ typedef NS_ENUM(NSInteger,RoomPKUserViewType) {
@class RoomPKChooseUserModel;
@interface XPRoomPKUserView : UIView
@property(nonatomic,assign) NSInteger index;
@property (nonatomic,assign) RoomPKUserViewType type;
///用户信息
@property (nonatomic,strong, nullable) RoomPKChooseUserModel *userInfo;

View File

@@ -73,10 +73,13 @@
self.avatarImageView.image = [UIImage imageNamed:@"room_pk_position_blue_bg"];
[self.nickButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x3571FE), UIColorFromRGB(0x7994FC)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
}
[self.nickButton setTitle:YMLocalizedString(@"XPRoomPKUserView0") forState:UIControlStateNormal];
[self.nickButton setTitle:[NSString stringWithFormat:@"%ld",_index] forState:UIControlStateNormal];
}
}
-(void)setIndex:(NSInteger)index{
_index = index;
[self.nickButton setTitle:[NSString stringWithFormat:@"%ld",_index] forState:UIControlStateNormal];
}
- (void)setType:(RoomPKUserViewType)type {
_type = type;
switch (_type) {

View File

@@ -169,6 +169,7 @@
[redArray addObject:redView];
redView.type = RoomPKUserViewType_Red;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(redDidTapRecognizer:)];
redView.index = i + 1;
[redView addGestureRecognizer:tap];
[self.userContainerView addSubview:redView];
[redView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -186,6 +187,7 @@
blueView.type = RoomPKUserViewType_Blue;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(blueDidTapRecognizer:)];
[blueView addGestureRecognizer:tap];
blueView.index = i + 1;
[self.userContainerView addSubview:blueView];
[blueView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth, itemHeight));

View File

@@ -315,15 +315,18 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(showRoomFirstChargeWindowFormNot:) name:kShowFirstRechargeView object:nil];
[XPSkillCardPlayerManager shareInstance].isInRoom = YES;
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(openRedPacketNotification:) name:@"kOpenRedPacketNotification" object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(showSendheadlineView) name:@"kShowSendheadlineView" object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(showSendheadlineView:) name:@"kShowSendheadlineView" object:nil];
}
-(void)showSendheadlineView{
-(void)showSendheadlineView:(NSNotification *)not{
MSSessionReleaseHeadlinesView *releaseView = [[MSSessionReleaseHeadlinesView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
releaseView.sendText = not.object;
[releaseView loadDataForRoom];
releaseView.delegate = self;
[TTPopup popupView:releaseView style:TTPopupStyleAlert];
releaseView.backgroundColor = [UIColor clearColor];
[self.view addSubview:releaseView];
}
#pragma makr- MSSessionReleaseHeadlinesViewDelegate
-(void)releaseHeadlinesWithText:(NSString *)text{

View File

@@ -1523,7 +1523,7 @@ ineHeadView12" = "الحمل";
"XPRoomPKTypeTableViewCell0" = "نمط PK";
"XPRoomPKTypeTableViewCell1" = "PK حسب الفريق";
"XPRoomPKVoteTableViewCell0" = "نوع التصويت في PK";
"XPRoomPKVoteTableViewCell0" = "نوع التصويت ";
"XPRoomPKVoteTableViewCell1" = "حسب قيمة الهدايا";
"XPRoomPKVoteTableViewCell2" = "حسب عدد الأشخاص الذين قدموا الهدايا";

View File

@@ -14,5 +14,6 @@ int main(int argc, char * argv[]) {
// Setup code that might create autoreleased objects goes here.
appDelegateClassName = NSStringFromClass([AppDelegate class]);
}
return UIApplicationMain(argc, argv, nil, appDelegateClassName);
}