房间公屏的UI
This commit is contained in:
@@ -129,6 +129,10 @@
|
||||
E824546126F5F4E400BE8163 /* XPMineResetPayPwdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E824546026F5F4E400BE8163 /* XPMineResetPayPwdViewController.m */; };
|
||||
E824546426F5FF1C00BE8163 /* XPMineResetPayPasswordPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E824546326F5FF1C00BE8163 /* XPMineResetPayPasswordPresenter.m */; };
|
||||
E824546626F5FF6000BE8163 /* XPMineResetPayPasswordProtocol.h in Sources */ = {isa = PBXBuildFile; fileRef = E824546526F5FF5100BE8163 /* XPMineResetPayPasswordProtocol.h */; };
|
||||
E84B0E3F2727EDF6008818C6 /* XPRoomMessageTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E3E2727EDF6008818C6 /* XPRoomMessageTableViewCell.m */; };
|
||||
E84B0E422727EE0A008818C6 /* XPRoomMessageHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E412727EE0A008818C6 /* XPRoomMessageHeaderView.m */; };
|
||||
E84B0E462727EF9D008818C6 /* XPRoomMessageDisplayModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E452727EF9D008818C6 /* XPRoomMessageDisplayModel.m */; };
|
||||
E84B0E4C27281530008818C6 /* XPRoomMessageHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E4B27281530008818C6 /* XPRoomMessageHelper.m */; };
|
||||
E85B02222722A3D900298C52 /* XPRoomPositionDelgate.h in Sources */ = {isa = PBXBuildFile; fileRef = E85B02212722A3C600298C52 /* XPRoomPositionDelgate.h */; };
|
||||
E865963F27015A9C00846EBD /* XPMineUserTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = E865963E27015A9C00846EBD /* XPMineUserTableView.m */; };
|
||||
E86596432701611A00846EBD /* UIImage+ImageEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596412701611A00846EBD /* UIImage+ImageEffects.m */; };
|
||||
@@ -482,6 +486,15 @@
|
||||
E824546226F5FF1C00BE8163 /* XPMineResetPayPasswordPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineResetPayPasswordPresenter.h; sourceTree = "<group>"; };
|
||||
E824546326F5FF1C00BE8163 /* XPMineResetPayPasswordPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineResetPayPasswordPresenter.m; sourceTree = "<group>"; };
|
||||
E824546526F5FF5100BE8163 /* XPMineResetPayPasswordProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineResetPayPasswordProtocol.h; sourceTree = "<group>"; };
|
||||
E84B0E3D2727EDF6008818C6 /* XPRoomMessageTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageTableViewCell.h; sourceTree = "<group>"; };
|
||||
E84B0E3E2727EDF6008818C6 /* XPRoomMessageTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMessageTableViewCell.m; sourceTree = "<group>"; };
|
||||
E84B0E402727EE0A008818C6 /* XPRoomMessageHeaderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageHeaderView.h; sourceTree = "<group>"; };
|
||||
E84B0E412727EE0A008818C6 /* XPRoomMessageHeaderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMessageHeaderView.m; sourceTree = "<group>"; };
|
||||
E84B0E442727EF9D008818C6 /* XPRoomMessageDisplayModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageDisplayModel.h; sourceTree = "<group>"; };
|
||||
E84B0E452727EF9D008818C6 /* XPRoomMessageDisplayModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMessageDisplayModel.m; sourceTree = "<group>"; };
|
||||
E84B0E4927280289008818C6 /* XPRoomMessageConstant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageConstant.h; sourceTree = "<group>"; };
|
||||
E84B0E4A27281530008818C6 /* XPRoomMessageHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageHelper.h; sourceTree = "<group>"; };
|
||||
E84B0E4B27281530008818C6 /* XPRoomMessageHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMessageHelper.m; sourceTree = "<group>"; };
|
||||
E85B02212722A3C600298C52 /* XPRoomPositionDelgate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomPositionDelgate.h; sourceTree = "<group>"; };
|
||||
E865963D27015A9C00846EBD /* XPMineUserTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineUserTableView.h; sourceTree = "<group>"; };
|
||||
E865963E27015A9C00846EBD /* XPMineUserTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineUserTableView.m; sourceTree = "<group>"; };
|
||||
@@ -1377,6 +1390,36 @@
|
||||
path = UIImage;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E84B0E3C2727EDD4008818C6 /* View */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E84B0E3D2727EDF6008818C6 /* XPRoomMessageTableViewCell.h */,
|
||||
E84B0E3E2727EDF6008818C6 /* XPRoomMessageTableViewCell.m */,
|
||||
E84B0E402727EE0A008818C6 /* XPRoomMessageHeaderView.h */,
|
||||
E84B0E412727EE0A008818C6 /* XPRoomMessageHeaderView.m */,
|
||||
);
|
||||
path = View;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E84B0E432727EF2C008818C6 /* Model */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E84B0E442727EF9D008818C6 /* XPRoomMessageDisplayModel.h */,
|
||||
E84B0E452727EF9D008818C6 /* XPRoomMessageDisplayModel.m */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E84B0E47272801F6008818C6 /* Tool */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E84B0E4927280289008818C6 /* XPRoomMessageConstant.h */,
|
||||
E84B0E4A27281530008818C6 /* XPRoomMessageHelper.h */,
|
||||
E84B0E4B27281530008818C6 /* XPRoomMessageHelper.m */,
|
||||
);
|
||||
path = Tool;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E8659640270160F200846EBD /* VagueImageView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -1664,6 +1707,9 @@
|
||||
E8AEAEE627141ACC0017FCE0 /* MessageContainerView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E84B0E47272801F6008818C6 /* Tool */,
|
||||
E84B0E432727EF2C008818C6 /* Model */,
|
||||
E84B0E3C2727EDD4008818C6 /* View */,
|
||||
E8AEAEF127141C7C0017FCE0 /* XPRoomMessageContainerView.h */,
|
||||
E8AEAEF227141C7C0017FCE0 /* XPRoomMessageContainerView.m */,
|
||||
);
|
||||
@@ -2127,6 +2173,7 @@
|
||||
E81C279826EB3AC40031E639 /* LoginForgetPasswordProtocol.h in Sources */,
|
||||
E82109B026F1D83500FC3319 /* LoginBindPhonePresent.m in Sources */,
|
||||
E865963F27015A9C00846EBD /* XPMineUserTableView.m in Sources */,
|
||||
E84B0E4C27281530008818C6 /* XPRoomMessageHelper.m in Sources */,
|
||||
E8B825C726EA0D9A009E8E9F /* LoginVerifCodeProtocol.h in Sources */,
|
||||
E824544E26F5BC1A00BE8163 /* XPMineModifPayPwdView.m in Sources */,
|
||||
E8B825CA26EA1231009E8E9F /* LoginVerifCodeViewController.m in Sources */,
|
||||
@@ -2148,6 +2195,7 @@
|
||||
E8EEB91D26FC9D58007C6EBA /* XPMineUserInfoDateView.m in Sources */,
|
||||
E8AC722F26F49610007D6E91 /* XPMineNotificationItemModel.m in Sources */,
|
||||
E8E70D7A26F2F16600F03460 /* XPMinePresent.m in Sources */,
|
||||
E84B0E3F2727EDF6008818C6 /* XPRoomMessageTableViewCell.m in Sources */,
|
||||
E8EEB8F226FC2050007C6EBA /* SDPhotoBrowser.m in Sources */,
|
||||
E89DA67827009F16008483C1 /* NSObject+JSONString.m in Sources */,
|
||||
E874B89527217DA6003954B9 /* XPIMChatRoomMessageImpl.m in Sources */,
|
||||
@@ -2281,6 +2329,7 @@
|
||||
E8AC721626F46B06007D6E91 /* XPMineSettingTableViewCell.m in Sources */,
|
||||
E80487652717DDD9008595F2 /* XPRoomMenuItem.m in Sources */,
|
||||
189DD75026E21D9000AB55B1 /* GCDHelper.m in Sources */,
|
||||
E84B0E422727EE0A008818C6 /* XPRoomMessageHeaderView.m in Sources */,
|
||||
186A534826FC6ED900D67B2C /* TTAlertButtonConfig.m in Sources */,
|
||||
E89D60BA271D643A001F8895 /* Api+Room.m in Sources */,
|
||||
E8AEAEF627141C910017FCE0 /* XPRoomPositionContainView.m in Sources */,
|
||||
@@ -2291,6 +2340,7 @@
|
||||
E88B5CB826FB325200DA9178 /* XPMineTeenagerPwdPresenter.m in Sources */,
|
||||
E874B88827215D39003954B9 /* MicroModel.m in Sources */,
|
||||
E868071B271969A50024F48F /* XCRoomPostionNickView.m in Sources */,
|
||||
E84B0E462727EF9D008818C6 /* XPRoomMessageDisplayModel.m in Sources */,
|
||||
E89D60C1271D64B9001F8895 /* RoomInfoModel.m in Sources */,
|
||||
E89DA66727006443008483C1 /* RechargeStorage.m in Sources */,
|
||||
189DD53F26DE255600AB55B1 /* main.m in Sources */,
|
||||
|
@@ -72,6 +72,16 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
+ (UIColor *)positionFemaleNickBackColor;
|
||||
/// 没有用户的 坑位的背景色
|
||||
+ (UIColor *)positionNormalNickBackColor;
|
||||
// ------公屏相关颜色 Start------ /
|
||||
///公屏默认背景的颜色
|
||||
+ (UIColor *)messageBubbleColor;
|
||||
///公屏文字的颜色
|
||||
+ (UIColor *)messageTextColor;
|
||||
///公屏名字的颜色
|
||||
+ (UIColor *)messageNickColor;
|
||||
///默认的文字的颜色
|
||||
+ (UIColor *)messageDefaultTextColor;
|
||||
// ------公屏相关颜色 END------ /
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -130,6 +130,26 @@
|
||||
return [UIColor colorWithWhite:1 alpha:0.5];
|
||||
}
|
||||
|
||||
// ------公屏相关颜色 Start------ /
|
||||
|
||||
///公屏默认背景的颜色
|
||||
+ (UIColor *)messageBubbleColor {
|
||||
return [UIColor colorWithRed:0 green:0 blue:0 alpha:0.35];
|
||||
}
|
||||
///公屏文字的颜色
|
||||
+ (UIColor *)messageTextColor {
|
||||
return [UIColor whiteColor];
|
||||
}
|
||||
///公屏名字的颜色
|
||||
+ (UIColor *)messageNickColor {
|
||||
return UIColorFromRGB(0xFFD98C);
|
||||
}
|
||||
///默认的文字的颜色
|
||||
+ (UIColor *)messageDefaultTextColor {
|
||||
return [UIColor colorWithWhite:1 alpha:0.5];
|
||||
}
|
||||
|
||||
// ------公屏相关颜色 END------ /
|
||||
|
||||
|
||||
|
||||
|
@@ -105,7 +105,7 @@
|
||||
- (void)initEvents {
|
||||
@weakify(self);
|
||||
RAC(self.nextButton, enabled) = [[RACSignal combineLatest:@[self.phoneView.textField.rac_textSignal, self.codeView.textField.rac_textSignal] reduce:^id _Nonnull(NSString *phone, NSString* password){
|
||||
return @(phone.length ==11 && password.length >= 6);
|
||||
return @((phone.length ==11) && password.length >= 6);
|
||||
}] takeUntil:self.rac_willDeallocSignal];
|
||||
|
||||
[[self.forgetPasswordButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
|
||||
|
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// XPRoomMessageDisplayModel.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/10/26.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPRoomMessageDisplayModel : NSObject
|
||||
///消息实体
|
||||
@property (nonatomic,strong, readonly) NIMMessage *message;
|
||||
///索要展示的cell的高度
|
||||
@property (nonatomic,assign, readonly) CGFloat cellHeight;
|
||||
///所要展示的富文本
|
||||
@property (nonatomic,strong, readonly) NSMutableAttributedString *contentAttributed;
|
||||
|
||||
- (instancetype)initDisplayModel:(NIMMessage *)message;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// XPRoomMessageDisplayModel.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/10/26.
|
||||
//
|
||||
|
||||
#import "XPRoomMessageDisplayModel.h"
|
||||
#import <YYText/YYText.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "XPRoomMessageConstant.h"
|
||||
#import "AccountInfoStorage.h"
|
||||
|
||||
@interface XPRoomMessageDisplayModel ()
|
||||
///
|
||||
@property (nonatomic,strong) NIMMessage *message;
|
||||
///索要展示的cell的高度
|
||||
@property (nonatomic,assign) CGFloat cellHeight;
|
||||
///
|
||||
@property (nonatomic,strong) NSMutableAttributedString *contentAttributed;
|
||||
@end
|
||||
|
||||
@implementation XPRoomMessageDisplayModel
|
||||
|
||||
- (instancetype)initDisplayModel:(NIMMessage *)message {
|
||||
if (self = [super init]) {
|
||||
self.message = message;
|
||||
[self makeMessageAttribute:message];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)makeMessageAttribute:(NIMMessage *)message {
|
||||
NIMMessageType messageType = message.messageType;
|
||||
switch (messageType) {
|
||||
case NIMMessageTypeText:
|
||||
[self makeTextAttribute:message];
|
||||
break;
|
||||
case NIMMessageTypeTip:
|
||||
[self makeTipsAttribute:message.text];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)makeTextAttribute:(NIMMessage *)message {
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
if ([message.from isEqualToString:uid]) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// 房间tips消息
|
||||
/// @param text 消息的内容
|
||||
- (void)makeTipsAttribute:(NSString *)text {
|
||||
self.contentAttributed = [self createAttribute:text titleColor:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont isTap:NO];
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark - Tool
|
||||
/// 生成一个富文本
|
||||
/// @param text 富文本的文字
|
||||
/// @param titleColor 文字的颜色
|
||||
/// @param font 文字的大小
|
||||
/// @param isTap 文字是否可以点击
|
||||
- (NSMutableAttributedString *)createAttribute:(NSString *)text titleColor:(UIColor *)titleColor font:(CGFloat)font isTap:(BOOL)isTap {
|
||||
NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:text attributes:nil];
|
||||
attribute.yy_font = [UIFont systemFontOfSize:font];
|
||||
attribute.yy_color = titleColor;
|
||||
attribute.yy_paragraphStyle = [self paragraphStyle];
|
||||
if (isTap) {
|
||||
[attribute yy_setTextHighlightRange:attribute.yy_rangeOfAll color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||||
///TODO : 回调
|
||||
}];
|
||||
}
|
||||
return attribute;
|
||||
}
|
||||
|
||||
/// 设置文本的样式 间隙 缩进 ...
|
||||
- (NSMutableParagraphStyle *)paragraphStyle {
|
||||
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paraStyle.lineSpacing = 4.0f;//行间距
|
||||
// 强制排版(从左到右)
|
||||
paraStyle.alignment = NSTextAlignmentLeft;
|
||||
paraStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
|
||||
|
||||
return paraStyle;
|
||||
}
|
||||
|
||||
|
||||
@end
|
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// XPRoomMessageConstant.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/10/26.
|
||||
//
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "XPMacro.h"
|
||||
|
||||
#ifndef XPRoomMessageConstant_h
|
||||
#define XPRoomMessageConstant_h
|
||||
|
||||
#define kRoomMessageMaxWidth (KScreenWidth - 15 - 90)
|
||||
|
||||
///公屏文本字体的大小
|
||||
static CGFloat kRoomMessageDefalutFont = 12;
|
||||
///文字上下的间隙
|
||||
static CGFloat kRoomMessageTextSpaceHeight = 3;
|
||||
|
||||
static CGFloat kRoomMessageBubbleCornerRadius = 7;
|
||||
|
||||
|
||||
#endif /* XPRoomMessageConstant_h */
|
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// XPRoomMessageHelper.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/10/26.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPRoomMessageHelper : NSObject
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// XPRoomMessageHelper.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/10/26.
|
||||
//
|
||||
|
||||
#import "XPRoomMessageHelper.h"
|
||||
///Third
|
||||
#import "YYText/YYText.h"
|
||||
///Tool
|
||||
#import "UIImageView+LoadImage.h"
|
||||
|
||||
@implementation XPRoomMessageHelper
|
||||
|
||||
|
||||
|
||||
#pragma mark - 富文本的工具类
|
||||
|
||||
/// 生成一个图片的富文本
|
||||
/// @param imageUrl 网络图片的地址
|
||||
/// @param size 网络图片的大小
|
||||
+ (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl size:(CGSize)size {
|
||||
return [self createUrlImageAttribute:imageUrl size:size success:nil];
|
||||
}
|
||||
|
||||
|
||||
/// 生成一个图片的富文本
|
||||
/// @param imageUrl 网络图片的地址
|
||||
/// @param size 网络图片的大小
|
||||
/// @param success 成功 可以拿到图片的大小刷新富文本的大小
|
||||
+ (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl size:(CGSize)size success:(void(^)(UIImage *))success {
|
||||
UIImageView *genderImageView = [[UIImageView alloc]init];
|
||||
[genderImageView load_imageWithUrl:imageUrl placeholderImage:[UIImageConstant defaultAvatarPlaceholder] type:ImageTypeUserIcon success:^(UIImage * _Nonnull image) {
|
||||
if (image && success) {
|
||||
success(image);
|
||||
}
|
||||
}];
|
||||
genderImageView.bounds = CGRectMake(0, 0, size.width, size.height);
|
||||
NSMutableAttributedString * genderString = [NSMutableAttributedString yy_attachmentStringWithContent:genderImageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(genderImageView.frame.size.width, genderImageView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
return genderString;
|
||||
}
|
||||
|
||||
/// 生成本地一个图片的富文本
|
||||
/// @param imageName 网络图片的地址
|
||||
/// @param size 网络图片的大小
|
||||
+ (NSMutableAttributedString *)createLocalImageAttribute:(NSString *)imageName size:(CGSize)size {
|
||||
UIImageView *genderImageView = [[UIImageView alloc]init];
|
||||
genderImageView.image = [UIImage imageNamed:imageName];
|
||||
genderImageView.bounds = CGRectMake(0, 0, size.width, size.height);
|
||||
NSMutableAttributedString * genderString = [NSMutableAttributedString yy_attachmentStringWithContent:genderImageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(genderImageView.frame.size.width, genderImageView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
return genderString;
|
||||
}
|
||||
|
||||
@end
|
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// XPRoomMessageHeaderView.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/10/26.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPRoomMessageHeaderView : UIView
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// XPRoomMessageHeaderView.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/10/26.
|
||||
//
|
||||
|
||||
#import "XPRoomMessageHeaderView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "XPRoomMessageConstant.h"
|
||||
#import "XPMacro.h"
|
||||
|
||||
@interface XPRoomMessageHeaderView ()
|
||||
///背景
|
||||
@property (nonatomic,strong) UIView *bubbleView;
|
||||
///显示
|
||||
@property (nonatomic,strong) UILabel *titleLabel;
|
||||
@end
|
||||
|
||||
@implementation XPRoomMessageHeaderView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self addSubview:self.bubbleView];
|
||||
[self addSubview:self.titleLabel];
|
||||
/// 设置绿色消息
|
||||
NSString *title = @"封面、背景及内容含低俗、引导、暴露等都会被屏蔽处理,泄露用户隐私、导流第三方平台、欺诈用户等将被封号处理。请珍惜自己的直播间哦!";
|
||||
self.titleLabel.text = title;
|
||||
CGFloat height = [self getHeaderViewHeight:title] + kRoomMessageTextSpaceHeight *2;
|
||||
self.frame = CGRectMake(0, 0, kRoomMessageMaxWidth, height);
|
||||
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.bubbleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.top.right.mas_equalTo(self);
|
||||
make.bottom.mas_equalTo(self).offset(-10);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self).inset(10);
|
||||
make.top.mas_equalTo(self.bubbleView).offset(5);
|
||||
}];
|
||||
}
|
||||
|
||||
///获取头部的高度
|
||||
- (CGFloat)getHeaderViewHeight:(NSString *)title {
|
||||
return [title boundingRectWithSize:CGSizeMake(kRoomMessageMaxWidth, CGFLOAT_MAX) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont]} context:nil].size.height;
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UIView *)bubbleView {
|
||||
if (!_bubbleView) {
|
||||
_bubbleView = [[UIView alloc] init];
|
||||
_bubbleView.backgroundColor = [ThemeColor messageBubbleColor];
|
||||
_bubbleView.layer.masksToBounds = YES;
|
||||
_bubbleView.layer.cornerRadius = kRoomMessageBubbleCornerRadius;
|
||||
}
|
||||
return _bubbleView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:kRoomMessageDefalutFont];
|
||||
_titleLabel.textColor = [ThemeColor mainTextColor];
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
@end
|
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// XPRoomMessageTableViewCell.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/10/26.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPRoomMessageTableViewCell : UITableViewCell
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// XPRoomMessageTableViewCell.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/10/26.
|
||||
//
|
||||
|
||||
#import "XPRoomMessageTableViewCell.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <YYText/YYLabel.h>
|
||||
///Tool
|
||||
#import "XPMacro.h"
|
||||
|
||||
@interface XPRoomMessageTableViewCell ()
|
||||
///气泡
|
||||
@property (nonatomic,strong) UIImageView *bubbleImaegeView;
|
||||
///展示的内容
|
||||
@property (nonatomic,strong) YYLabel *contentLabel;
|
||||
@end
|
||||
|
||||
@implementation XPRoomMessageTableViewCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self.contentView addSubview:self.bubbleImaegeView];
|
||||
[self.contentView addSubview:self.contentLabel];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.bubbleImaegeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.top.bottom.mas_equalTo(self.contentView);
|
||||
make.right.mas_equalTo(self.contentLabel);
|
||||
}];
|
||||
|
||||
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView).offset(3);
|
||||
make.centerY.mas_equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UIImageView *)bubbleImaegeView {
|
||||
if (!_bubbleImaegeView) {
|
||||
_bubbleImaegeView = [[UIImageView alloc] init];
|
||||
_bubbleImaegeView.userInteractionEnabled = YES;
|
||||
_bubbleImaegeView.layer.masksToBounds = YES;
|
||||
_bubbleImaegeView.layer.cornerRadius = 7;
|
||||
}
|
||||
return _bubbleImaegeView;
|
||||
}
|
||||
|
||||
- (YYLabel *)contentLabel {
|
||||
if (!_contentLabel) {
|
||||
_contentLabel = [[YYLabel alloc] init];
|
||||
_contentLabel.preferredMaxLayoutWidth = (KScreenWidth - 15 - 90);
|
||||
}
|
||||
return _contentLabel;
|
||||
}
|
||||
|
||||
|
||||
@end
|
@@ -6,11 +6,31 @@
|
||||
//
|
||||
|
||||
#import "XPRoomMessageContainerView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
///Model
|
||||
#import "XPRoomMessageDisplayModel.h"
|
||||
///View
|
||||
#import "XPRoomMessageTableViewCell.h"
|
||||
#import "XPRoomMessageHeaderView.h"
|
||||
#import "View/XPRoomMessageHeaderView.h"
|
||||
|
||||
@interface XPRoomMessageContainerView ()<UITableViewDelegate, UITableViewDataSource>
|
||||
///列表
|
||||
@property (nonatomic,strong) UITableView *messageTableView;
|
||||
///数据源
|
||||
@property (nonatomic,strong) NSMutableArray<XPRoomMessageDisplayModel *> *datasource;
|
||||
///临时存放消息的数组
|
||||
@property (nonatomic,strong) NSMutableArray<XPRoomMessageDisplayModel *> *tempArray;
|
||||
///头部
|
||||
@property (nonatomic,strong) XPRoomMessageHeaderView *headerView;
|
||||
@end
|
||||
|
||||
|
||||
@implementation XPRoomMessageContainerView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
@@ -19,13 +39,67 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
///添加信息
|
||||
- (void)addRoomMessage:(NIMMessage *)message {
|
||||
XPRoomMessageDisplayModel * model = [[XPRoomMessageDisplayModel alloc] initDisplayModel:message];
|
||||
[self.tempArray addObject:message];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.backgroundColor = [UIColor orangeColor];
|
||||
[self addSubview:self.messageTableView];
|
||||
self.messageTableView.tableHeaderView = self.headerView;
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
|
||||
[self.messageTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self).offset(15);
|
||||
make.top.bottom.right.mas_equalTo(self);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.datasource.count;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
XPRoomMessageDisplayModel * model = [self.datasource objectAtIndex:indexPath.row];
|
||||
return model.cellHeight;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
XPRoomMessageTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])];
|
||||
if (cell == nil) {
|
||||
cell = [[XPRoomMessageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])];
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UITableView *)messageTableView {
|
||||
if (!_messageTableView) {
|
||||
_messageTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||
_messageTableView.delegate = self;
|
||||
_messageTableView.dataSource = self;
|
||||
_messageTableView.tableFooterView = [UIView new];
|
||||
_messageTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
_messageTableView.backgroundColor = [UIColor clearColor];
|
||||
if (@available(iOS 11.0, *)) {
|
||||
_messageTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
[_messageTableView registerClass:[XPRoomMessageTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])];
|
||||
}
|
||||
return _messageTableView;
|
||||
}
|
||||
|
||||
- (XPRoomMessageHeaderView *)headerView {
|
||||
if (!_headerView) {
|
||||
_headerView = [[XPRoomMessageHeaderView alloc] init];
|
||||
}
|
||||
return _headerView;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user