temp save: 基本完成房间聊天列表的内容高度适配 | 调整房间音乐面板入口 & UI
This commit is contained in:
21
YuMi/Assets.xcassets/1.0.30/menu_music.imageset/Contents.json
vendored
Normal file
21
YuMi/Assets.xcassets/1.0.30/menu_music.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "房间背景@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
YuMi/Assets.xcassets/1.0.30/menu_music.imageset/房间背景@3x.png
vendored
Normal file
BIN
YuMi/Assets.xcassets/1.0.30/menu_music.imageset/房间背景@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
@@ -419,7 +419,7 @@
|
||||
|
||||
[progressBG addSubview:self.progressBar];
|
||||
[self.progressBar mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(progressBG).offset(21);
|
||||
make.leading.mas_equalTo(progressBG).offset(isMSRTL() ? 18 : 21);
|
||||
make.bottom.mas_equalTo(progressBG).offset(kGetScaleWidth(-35));
|
||||
make.width.mas_equalTo(18);
|
||||
make.height.mas_equalTo(kGetScaleWidth(180)).multipliedBy(1);
|
||||
|
@@ -52,6 +52,8 @@ UIKIT_EXTERN NSString * kRoomBackMusicPlayMusicOrderKey;
|
||||
@property (nonatomic,strong) XPRoomMusicLibraryViewController *musicLibraryVC;
|
||||
///数据的请求
|
||||
@property (nonatomic,strong) NSFetchRequest *request;
|
||||
|
||||
@property(nonatomic, strong) UIVisualEffectView *blurEffectView;
|
||||
@end
|
||||
|
||||
@implementation XPRoomBackMusicPlayerView
|
||||
@@ -61,7 +63,7 @@ UIKIT_EXTERN NSString * kRoomBackMusicPlayMusicOrderKey;
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
#pragma mark - Public Method
|
||||
@@ -76,10 +78,25 @@ UIKIT_EXTERN NSString * kRoomBackMusicPlayMusicOrderKey;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)handleTapBackground {
|
||||
[UIView animateWithDuration:0.25
|
||||
animations:^{
|
||||
self.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)initSubViews {
|
||||
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.8];
|
||||
self.layer.masksToBounds = YES;
|
||||
self.layer.cornerRadius = 40.f;
|
||||
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.0];
|
||||
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
b.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight - 250);
|
||||
[b addTarget:self action:@selector(handleTapBackground) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:b];
|
||||
|
||||
[self setCornerRadius:16
|
||||
cornerMask:kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner];
|
||||
[self addSubview:self.blurEffectView];
|
||||
[self addSubview:self.titleLabel];
|
||||
[self addSubview:self.voiceImageView];
|
||||
[self addSubview:self.voiceSliderView];
|
||||
@@ -90,15 +107,20 @@ UIKIT_EXTERN NSString * kRoomBackMusicPlayMusicOrderKey;
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.blurEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.leading.trailing.mas_equalTo(self);
|
||||
make.height.mas_equalTo(kGetScaleWidth(200));
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.mas_equalTo(self).inset(30);
|
||||
make.top.mas_equalTo(self).offset(17);
|
||||
make.bottom.mas_equalTo(self.blurEffectView.mas_centerY).offset(-24);
|
||||
}];
|
||||
|
||||
[self.voiceImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(12, 15));
|
||||
make.leading.mas_equalTo(self.titleLabel);
|
||||
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(18);
|
||||
make.centerY.mas_equalTo(self.blurEffectView);
|
||||
}];
|
||||
|
||||
[self.voiceSliderView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -413,5 +435,21 @@ UIKIT_EXTERN NSString * kRoomBackMusicPlayMusicOrderKey;
|
||||
return _request;
|
||||
}
|
||||
|
||||
- (UIVisualEffectView *)blurEffectView {
|
||||
if (!_blurEffectView) {
|
||||
// 创建模糊效果
|
||||
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; // 选择模糊样式(例如:Light, Dark, ExtraLight 等)
|
||||
|
||||
// 创建包含模糊效果的视图
|
||||
_blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
|
||||
|
||||
// 设置模糊视图的大小与目标视图一致
|
||||
_blurEffectView.frame = CGRectMake(0, 0, KScreenWidth, kGetScaleWidth(200));
|
||||
_blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; // 使模糊视图适应目标视图的尺寸变化
|
||||
|
||||
[_blurEffectView setCornerRadius:16];
|
||||
}
|
||||
return _blurEffectView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -29,6 +29,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)showPKPanelView;
|
||||
|
||||
- (void)showMusicPanel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -119,12 +119,6 @@
|
||||
@property (nonatomic, strong) XPAnchorFansTeamEntranceView *fansTeamEntranceView;
|
||||
///个播小时榜入口按钮
|
||||
@property (nonatomic, strong) XPRoomAnchorRankEnterView *hourRankEntranceView;
|
||||
/////话题的容器
|
||||
//@property (nonatomic,strong) UIStackView *topicStackView;
|
||||
/////话题
|
||||
//@property (nonatomic,strong) UILabel *topicLabel;
|
||||
/////编辑
|
||||
//@property (nonatomic,strong) UIButton *editButton;
|
||||
///跨房pk的面板
|
||||
@property (nonatomic,strong) XPAcrossRoomPKPanelView *acrossPKPanelView;
|
||||
///跨房PK预约倒计时
|
||||
@@ -437,6 +431,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - DJ 抓个Beat
|
||||
- (void)showMusicPanel {
|
||||
[self addSubview:self.musicPlayView];
|
||||
[self bringSubviewToFront:self.musicPlayView];
|
||||
self.musicPlayView.frame = CGRectMake(0, KScreenHeight, KScreenWidth, 200);
|
||||
|
||||
// POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
|
||||
// moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth, self.musicPlayView.center.y)];
|
||||
// moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(KScreenWidth/ 2, self.musicPlayView.center.y)];
|
||||
// moveAnimation.beginTime = CACurrentMediaTime();
|
||||
// moveAnimation.duration = 0.5;
|
||||
// moveAnimation.repeatCount = 1;
|
||||
// moveAnimation.removedOnCompletion = YES;
|
||||
// [self.musicPlayView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
|
||||
//
|
||||
[UIView animateWithDuration:0.25 animations:^{
|
||||
// self.musicEnterButton.hidden = YES;
|
||||
self.musicPlayView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
||||
} completion:nil];
|
||||
// [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_music_click];
|
||||
}
|
||||
|
||||
#pragma mark - 房间PK
|
||||
// MARK: ----- 修改开始
|
||||
- (void)showPKPanelView {
|
||||
@@ -669,10 +685,10 @@
|
||||
|
||||
- (void)onRoomMiniEntered {
|
||||
if ([XPRoomMiniManager shareManager].getCurrentMusic) {
|
||||
if (!self.musicPlayView.superview) {
|
||||
[self addSubview:self.musicPlayView];
|
||||
self.musicPlayView.frame = CGRectMake(-KScreenWidth, kNavigationHeight + 4, KScreenWidth - 85, 80);
|
||||
}
|
||||
// if (!self.musicPlayView.superview) {
|
||||
// [self addSubview:self.musicPlayView];
|
||||
// self.musicPlayView.frame = CGRectMake(-KScreenWidth, kNavigationHeight + 4, KScreenWidth - 85, 80);
|
||||
// }
|
||||
[self.musicPlayView configCurrentPlayingMusic:[XPRoomMiniManager shareManager].getCurrentMusic isPlaying:[XPRoomMiniManager shareManager].musicPlaying];
|
||||
[[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO];
|
||||
}
|
||||
@@ -1263,24 +1279,11 @@
|
||||
}
|
||||
|
||||
- (void)musicEnterButtonAction:(UIButton *)sender {
|
||||
if (!self.musicPlayView.superview) {
|
||||
[self addSubview:self.musicPlayView];
|
||||
self.musicPlayView.frame = CGRectMake(-KScreenWidth, kNavigationHeight + 4, KScreenWidth - 85, 80);
|
||||
}
|
||||
|
||||
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
|
||||
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth, self.musicPlayView.center.y)];
|
||||
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(KScreenWidth/ 2, self.musicPlayView.center.y)];
|
||||
moveAnimation.beginTime = CACurrentMediaTime();
|
||||
moveAnimation.duration = 0.5;
|
||||
moveAnimation.repeatCount = 1;
|
||||
moveAnimation.removedOnCompletion = YES;
|
||||
[self.musicPlayView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
|
||||
|
||||
[UIView animateWithDuration:0.2 animations:^{
|
||||
self.musicEnterButton.hidden = YES;
|
||||
} completion:nil];
|
||||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_music_click];
|
||||
[self showMusicPanel];
|
||||
// if (!self.musicPlayView.superview) {
|
||||
// [self addSubview:self.musicPlayView];
|
||||
// self.musicPlayView.frame = CGRectMake(-KScreenWidth, kNavigationHeight + 4, KScreenWidth - 85, 80);
|
||||
// }
|
||||
}
|
||||
|
||||
#pragma mark - 房间话题
|
||||
|
@@ -15,6 +15,7 @@ static const NSInteger kItemsPerRow = 5;
|
||||
@interface MSRoomMenuGameView()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
|
||||
@property(nonatomic,strong) UIButton *backBtn;
|
||||
@property(nonatomic,strong) UIView *ms_bgView;
|
||||
@property(nonatomic, strong) UIVisualEffectView *blurEffectView;
|
||||
@property(nonatomic,strong) UICollectionView *collectionView;
|
||||
|
||||
@property (nonatomic, assign) CGFloat itemHeight;
|
||||
@@ -26,7 +27,6 @@ static const NSInteger kItemsPerRow = 5;
|
||||
-(instancetype)initWithFrame:(CGRect)frame{
|
||||
self = [super initWithFrame:frame];
|
||||
if(self){
|
||||
|
||||
self.itemHeight = kGetScaleWidth(80);
|
||||
self.emptyHeight = kGetScaleWidth(100);
|
||||
self.dataSource = @[].mutableCopy;
|
||||
@@ -41,6 +41,7 @@ static const NSInteger kItemsPerRow = 5;
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
[self addSubview:self.backBtn];
|
||||
[self addSubview:self.ms_bgView];
|
||||
[self addSubview:self.blurEffectView];
|
||||
[self addSubview:self.collectionView];
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ static const NSInteger kItemsPerRow = 5;
|
||||
[self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self);
|
||||
}];
|
||||
[self.ms_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
[self.blurEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.equalTo(self).inset(0);
|
||||
make.bottom.equalTo(self).offset(12);
|
||||
make.height.mas_equalTo(kGetScaleWidth(246));
|
||||
@@ -180,4 +181,22 @@ static const NSInteger kItemsPerRow = 5;
|
||||
}
|
||||
return _collectionView;
|
||||
}
|
||||
|
||||
- (UIVisualEffectView *)blurEffectView {
|
||||
if (!_blurEffectView) {
|
||||
// 创建模糊效果
|
||||
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
|
||||
|
||||
// 创建包含模糊效果的视图
|
||||
_blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
|
||||
|
||||
// 设置模糊视图的大小与目标视图一致
|
||||
_blurEffectView.frame = CGRectMake(0, 0, KScreenWidth, kGetScaleWidth(246));
|
||||
_blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
|
||||
[_blurEffectView setCornerRadius:12];
|
||||
}
|
||||
return _blurEffectView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -80,6 +80,8 @@ UIKIT_EXTERN NSString * kRoomBackMusicCaptureVolumeKey;
|
||||
|
||||
@property (nonatomic, assign) BOOL isDisplayMicStatusControl;
|
||||
|
||||
@property(nonatomic, assign) BOOL isOnMic;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -166,7 +168,7 @@ UIKIT_EXTERN NSString * kRoomBackMusicCaptureVolumeKey;
|
||||
case XPRoomMenuItemType_More: {
|
||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"XP didTapForNewFunction"];
|
||||
[self.moreButton setImage:[UIImage imageNamed:@"room_menu_more"] forState:UIControlStateNormal];
|
||||
XPRoomMoreMenuViewController * moreMenuVC = [[XPRoomMoreMenuViewController alloc] initWithDelegate:self.delegate];
|
||||
XPRoomMoreMenuViewController * moreMenuVC = [[XPRoomMoreMenuViewController alloc] initWithDelegate:self.delegate isUserOnMic:self.isOnMic];
|
||||
[self.delegate.getCurrentNav presentViewController:moreMenuVC animated:YES completion:nil];
|
||||
}
|
||||
break;
|
||||
@@ -521,6 +523,7 @@ UIKIT_EXTERN NSString * kRoomBackMusicCaptureVolumeKey;
|
||||
- (void)onMicroQueueUpdate:(NSMutableDictionary<NSString *,MicroQueueModel *> *)queue {
|
||||
MicroQueueModel *model = [self findMySelfMicro:queue];
|
||||
if (model) {
|
||||
self.isOnMic = YES;
|
||||
self.micButton.hidden = NO;
|
||||
if ([RtcManager instance].isLocalMuted) {
|
||||
[self micButtonUpdate:2];
|
||||
@@ -541,6 +544,7 @@ UIKIT_EXTERN NSString * kRoomBackMusicCaptureVolumeKey;
|
||||
|
||||
self.faceButton.hidden = NO;
|
||||
} else {
|
||||
self.isOnMic = NO;
|
||||
self.micButton.hidden = YES;
|
||||
self.faceButton.hidden = YES;
|
||||
}
|
||||
|
@@ -28,95 +28,34 @@
|
||||
- (void)setContent:(NSAttributedString *)content {
|
||||
_content = content;
|
||||
|
||||
CGSize size = [content boundingRectWithSize:CGSizeMake(kRoomMessageMaxWidth, 0)
|
||||
CGFloat width = kRoomMessageMaxWidth;
|
||||
if (self.isBoom) {
|
||||
width = kRoomMessageMaxWidth - kGetScaleWidth(60);
|
||||
}
|
||||
|
||||
CGSize size = [content boundingRectWithSize:CGSizeMake(width, 0)
|
||||
options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin
|
||||
context:nil].size;
|
||||
|
||||
YYTextContainer *container = [YYTextContainer containerWithSize:CGSizeMake(size.width, CGFLOAT_MAX)];
|
||||
container.maximumNumberOfRows = 0;
|
||||
container.truncationType = YYTextTruncationTypeEnd;
|
||||
container.insets = UIEdgeInsetsMake(self.contentTopMargin, self.contentLeftMargin, self.contentBottomMargin, self.contentRightMargin);
|
||||
self.textLayout = [YYTextLayout layoutWithContainer:container text:content];
|
||||
|
||||
CGSize textSize = self.textLayout.textBoundingRect.size;
|
||||
// CGFloat anotherHeight = [self heightForAttributedStringUsingTextKit:content maxWidth:kRoomMessageMaxWidth].height;
|
||||
|
||||
if ([NSString isEmpty:self.bubbleImageUrl]) {
|
||||
self.rowHeight = ceil(textSize.height) + self.cellBottomMargin + self.contentTopMargin + 20;
|
||||
self.rowHeight =
|
||||
ceil(textSize.height) +
|
||||
self.cellBottomMargin +
|
||||
(isMSRTL() ? self.contentTopMargin : (self.isBoom ? 20 : 8));
|
||||
} else {
|
||||
self.rowHeight = ceil(textSize.height) + self.contentTopMargin + self.contentBottomMargin + self.cellBottomMargin + 20;
|
||||
self.rowHeight =
|
||||
ceil(textSize.height) +
|
||||
(isMSRTL() ? self.contentTopMargin : (self.isBoom ? 20 : 8)) +
|
||||
self.contentBottomMargin +
|
||||
self.cellBottomMargin;
|
||||
}
|
||||
self.rowHeight += 10;
|
||||
|
||||
// if ([self.cellKey isEqualToString:@"ChatMessage"]) {
|
||||
// NSLog(@" ----- 11 ----- %@ : %@", [NSValue valueWithCGSize:textSize], [NSValue valueWithCGSize:[self heightForAttributedStringUsingTextKit:content maxWidth:kRoomMessageMaxWidth]]);
|
||||
// }
|
||||
|
||||
// self.rowHeight = [self heightForAttributedText:content
|
||||
// maxWidth:kRoomMessageMaxWidth];
|
||||
|
||||
// CGFloat width = isMSRTL() ? 10 : 0;
|
||||
////// width = self.vipIcon.length > 0 ? width + 15 : width;
|
||||
// CGSize maxSize = CGSizeMake(kRoomMessageMaxWidth - self.contentLeftMargin - self.contentRightMargin - 12, MAXFLOAT);
|
||||
// YYTextContainer *container = [YYTextContainer containerWithSize:maxSize];
|
||||
// container.maximumNumberOfRows = 0;
|
||||
// YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:self.content];
|
||||
// CGFloat rowHeight = layout.textBoundingSize.height + self.contentTopMargin + self.contentBottomMargin + self.cellBottomMargin;
|
||||
// self.rowHeight = rowHeight + width ;
|
||||
self.rowHeight += 10 + (self.isBoom ? 20 : 0);
|
||||
}
|
||||
|
||||
- (CGSize)heightForAttributedStringUsingTextKit:(NSAttributedString *)attributedString
|
||||
maxWidth:(CGFloat)maxWidth {
|
||||
NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:attributedString];
|
||||
NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX)];
|
||||
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
|
||||
|
||||
[layoutManager addTextContainer:textContainer];
|
||||
[textStorage addLayoutManager:layoutManager];
|
||||
|
||||
// 让布局管理器计算文本高度
|
||||
[layoutManager glyphRangeForTextContainer:textContainer];
|
||||
return [layoutManager usedRectForTextContainer:textContainer].size;
|
||||
}
|
||||
|
||||
- (CGFloat)heightForAttributedText:(NSAttributedString *)attributedText maxWidth:(CGFloat)maxWidth {
|
||||
// 创建一个 YYTextContainer
|
||||
YYTextContainer *container = [YYTextContainer new];
|
||||
container.size = CGSizeMake(maxWidth, CGFLOAT_MAX); // 设置宽度,支持无限高度
|
||||
container.maximumNumberOfRows = 0; // 允许多行
|
||||
|
||||
// 遍历富文本,设置未加载图片的占位尺寸
|
||||
// 确认是否 “@用户名” 会影响计算结果
|
||||
NSInteger index = 0;
|
||||
NSMutableAttributedString *mutableAttributedText = [attributedText mutableCopy];
|
||||
[mutableAttributedText enumerateAttribute:YYTextAttachmentAttributeName
|
||||
inRange:NSMakeRange(0, mutableAttributedText.length)
|
||||
options:0
|
||||
usingBlock:^(id value, NSRange range, BOOL *stop) {
|
||||
|
||||
if ([value isKindOfClass:[YYTextAttachment class]]) {
|
||||
// TODO: 把图片变为字符串来占位, 观察结果是第二行字符长度少于前缀图片,则会高度减少
|
||||
YYTextAttachment *attachment = (YYTextAttachment *)value;
|
||||
NSLog(@" ---00--- : %@", attachment.content);
|
||||
if (attachment.content == nil) {
|
||||
attachment.content = [[UIView alloc] init]; // 占位内容
|
||||
NSValue *v = [self.extraSizeArray xpSafeObjectAtIndex:index];
|
||||
if (value) {
|
||||
UIView *placeholderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [v CGSizeValue].width, [v CGSizeValue].height)];
|
||||
attachment.content = placeholderView; // 使用占位尺寸
|
||||
} else {
|
||||
*stop = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
// 通过 YYTextLayout 创建布局
|
||||
YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:mutableAttributedText];
|
||||
|
||||
self.textWidth = ceil(layout.textBoundingSize.width);
|
||||
|
||||
// 返回布局的文本高度
|
||||
return ceil(layout.textBoundingSize.height) + self.contentTopMargin + self.contentBottomMargin + self.cellBottomMargin; // 向上取整,避免内容裁切
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -67,8 +67,6 @@
|
||||
Boom632Model *model = [Boom632Model modelWithJSON:attachment.data];
|
||||
|
||||
XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init];
|
||||
|
||||
|
||||
NSString *text = [NSString stringWithFormat:@"%@%@%@", YMLocalizedString(@"RoomMessageBoom_0"), model.nick, YMLocalizedString(@"RoomMessageBoom_1")];
|
||||
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
|
||||
@@ -76,11 +74,11 @@
|
||||
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, text.length)];
|
||||
[attributedString addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xFF3B3B) range:NSMakeRange([YMLocalizedString(@"RoomMessageBoom_0") length], model.nick.length)];
|
||||
|
||||
messageInfo.content = attributedString;
|
||||
messageInfo.isBoom = YES;
|
||||
messageInfo.boomImageUrl = model.pic;
|
||||
messageInfo.rowHeight = 80;
|
||||
messageInfo.first = attachment.first;
|
||||
messageInfo.content = attributedString;
|
||||
return messageInfo;
|
||||
}
|
||||
}
|
||||
@@ -221,8 +219,6 @@
|
||||
return [self createGeneralPublicScreenAttribute:attachment messageInfo:messageInfo];
|
||||
}else if(first == CustomMessageType_Super_Gift){
|
||||
return [self createGeneralPublicScreenAttribute:attachment messageInfo:messageInfo];
|
||||
}else if(first == CustomMessageType_Chat_Hall_Headlines && attachment.second == Custom_Message_Sub_Chat_Hall_Headlines){
|
||||
|
||||
}
|
||||
|
||||
return nil;
|
||||
@@ -363,30 +359,25 @@
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
|
||||
if (extModel.charmUrl.length > 0) {//等级
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.charmUrl]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
if (extModel.charmUrl.length > 0) {//等级
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.charmUrl]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
|
||||
if (extModel.vipIcon.length > 0) {//VIPicon
|
||||
messageInfo.vipIcon = extModel.vipIcon;
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.vipIcon]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
|
||||
if(extModel.isCustomWord == YES){
|
||||
if (extModel.inRoomNameplatePic.length > 0) {
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.inRoomNameplatePic]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
}else{
|
||||
if (extModel.inRoomNameplatePic.length > 0 && extModel.inRoomNameplateWord.length > 0) {
|
||||
[attribute appendAttributedString:[self createNameplateAttibute:extModel.inRoomNameplateWord image:extModel.inRoomNameplatePic textFont:[UIFont systemFontOfSize:9]]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
if (extModel.vipIcon.length > 0) {//VIPicon
|
||||
messageInfo.vipIcon = extModel.vipIcon;
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.vipIcon]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
|
||||
if (extModel.inRoomNameplatePic.length > 0) {
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.inRoomNameplatePic
|
||||
size:CGSizeMake(60, kFontRegular(kRoomMessageDefalutFont).lineHeight)]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
|
||||
[attribute appendAttributedString:[self createNickAtrribute:nick uid:message.from.integerValue]];
|
||||
|
||||
if (extModel.carName.length > 0) {
|
||||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser1") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||||
[attribute appendAttributedString:[self createTextAttribute:extModel.carName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||||
@@ -509,30 +500,42 @@
|
||||
|
||||
PIGeneralPublicScreenModel *screenModel = [PIGeneralPublicScreenModel modelWithDictionary:attachment.data];
|
||||
NSDictionary *textDic = screenModel.template;
|
||||
if(textDic.allKeys.count == 0)return messageInfo;
|
||||
if(textDic.allKeys.count == 0) {
|
||||
return messageInfo;
|
||||
}
|
||||
NSString *key = [NSBundle uploadLanguageText];
|
||||
NSString *title = textDic[key] == nil ? textDic[textDic.allKeys.firstObject] : textDic[key];
|
||||
|
||||
if(title.length == 0)return messageInfo;
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont],NSForegroundColorAttributeName:[DJDKMIMOMColor colorWithHexString:screenModel.textColor]}];
|
||||
if(title.length == 0) {
|
||||
return messageInfo;
|
||||
}
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title
|
||||
attributes:@{
|
||||
NSFontAttributeName:kFontRegular(kRoomMessageDefalutFont),
|
||||
NSForegroundColorAttributeName:[DJDKMIMOMColor colorWithHexString:screenModel.textColor]}];
|
||||
for (PIGeneralPublicScreenItemModel *model in screenModel.contents) {
|
||||
if([model.type isEqualToString:@"TEXT"]){
|
||||
NSDictionary *subTextDic = model.text;
|
||||
if(subTextDic.allKeys.count > 0){
|
||||
NSString *subText = subTextDic[key] == nil ? subTextDic[subTextDic.allKeys.firstObject] : subTextDic[key];
|
||||
NSAttributedString *attText = [[NSAttributedString alloc]initWithString:subText attributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor colorWithHexString:model.textColor]}];
|
||||
NSAttributedString *attText = [[NSAttributedString alloc] initWithString:subText
|
||||
attributes:@{
|
||||
NSForegroundColorAttributeName:[DJDKMIMOMColor colorWithHexString:model.textColor]}];
|
||||
if ([attribute.string containsString:[NSString stringWithFormat:@"{%@}",model.key]]){
|
||||
[attribute replaceCharactersInRange:[attribute.string rangeOfString:[NSString stringWithFormat:@"{%@}",model.key]] withAttributedString:attText];
|
||||
}
|
||||
|
||||
@kWeakify(self)
|
||||
[attribute yy_setTextHighlightRange:[attribute.string rangeOfString:subText] color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||||
@kStrongify(self);
|
||||
if(model.skipType == 6){
|
||||
if(model.skipContent.length == 0)return;
|
||||
[self showUserCard:model.skipContent.integerValue];
|
||||
}
|
||||
}];
|
||||
[attribute yy_setTextHighlightRange:[attribute.string rangeOfString:subText]
|
||||
color:nil
|
||||
backgroundColor:nil
|
||||
tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||||
@kStrongify(self);
|
||||
if(model.skipType == 6){
|
||||
if(model.skipContent.length == 0)return;
|
||||
[self showUserCard:model.skipContent.integerValue];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
}else if ([model.type isEqualToString:@"IMAGE"]){
|
||||
@@ -803,7 +806,7 @@
|
||||
imageView.image = face;
|
||||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
imageView.bounds = CGRectMake(0, 0, 30, 30);
|
||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height) alignToFont:kFontRegular(kRoomMessageDefalutFont) alignment:YYTextVerticalAlignmentCenter];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:1]];
|
||||
[attribute appendAttributedString:attrString];
|
||||
}
|
||||
@@ -1138,7 +1141,7 @@
|
||||
|
||||
//img
|
||||
if (giftInfo.giftUrl) {
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:giftInfo.giftUrl]];
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:giftInfo.giftUrl size:CGSizeMake(40, 40)]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
|
||||
@@ -1248,7 +1251,7 @@
|
||||
[attribute appendAttributedString: [self createNickAtrribute:info.targetNick uid:info.targetUid.integerValue]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
//img
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:giftInfo.giftUrl]];
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:giftInfo.giftUrl size:CGSizeMake(40, 40)]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
//x N
|
||||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@" X%ld",info.giftNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||||
@@ -1363,9 +1366,9 @@
|
||||
imageView.bounds = CGRectMake(0, 0, defaultSize.width, defaultSize.height);
|
||||
|
||||
// 异步加载图片
|
||||
@kWeakify(self);
|
||||
// @kWeakify(self);
|
||||
[imageView loadImageWithUrl:imageName completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
|
||||
@kStrongify(self);
|
||||
// @kStrongify(self);
|
||||
if (image) {
|
||||
CGFloat scale = image.size.width / image.size.height;
|
||||
CGSize newSize = scale > 0 ? CGSizeMake(60 * scale, kFontRegular(kRoomMessageDefalutFont).lineHeight) : defaultSize;
|
||||
@@ -1439,9 +1442,9 @@
|
||||
UIImage* image = imageView.image;
|
||||
if (image) {
|
||||
CGFloat scale = image.size.width / image.size.height;
|
||||
imageView.bounds = CGRectMake(0, 0, 18 * scale, 18);
|
||||
imageView.bounds = CGRectMake(0, 0, kFontRegular(kRoomMessageDefalutFont).lineHeight * scale, kFontRegular(kRoomMessageDefalutFont).lineHeight);
|
||||
} else {
|
||||
imageView.bounds = CGRectMake(0, 0, 18, 18);
|
||||
imageView.bounds = CGRectMake(0, 0, kFontRegular(kRoomMessageDefalutFont).lineHeight, kFontRegular(kRoomMessageDefalutFont).lineHeight);
|
||||
}
|
||||
imageView.layer.masksToBounds = YES;
|
||||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
@@ -1472,7 +1475,7 @@
|
||||
UIImageView *imaveView = [[UIImageView alloc]init];
|
||||
imaveView.image = [UIImage imageNamed:imageName];
|
||||
CGFloat scale = (CGFloat)imaveView.image.size.width / (CGFloat)imaveView.image.size.height;
|
||||
imaveView.bounds = CGRectMake(0, 0, 16 * scale, 16);
|
||||
imaveView.bounds = CGRectMake(0, 0, kFontRegular(kRoomMessageDefalutFont).lineHeight * scale, kFontRegular(kRoomMessageDefalutFont).lineHeight);
|
||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:kFontRegular(kRoomMessageDefalutFont) alignment:YYTextVerticalAlignmentCenter];
|
||||
return attrString;
|
||||
|
||||
@@ -1486,8 +1489,8 @@
|
||||
UIImageView *imaveView = [[UIImageView alloc]init];
|
||||
imaveView.image = [UIImage getLanguageImage:imageName];
|
||||
CGFloat scale = (CGFloat)imaveView.image.size.width / (CGFloat)imaveView.image.size.height;
|
||||
imaveView.bounds = CGRectMake(0, 0, 16 * scale, 16);
|
||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
imaveView.bounds = CGRectMake(0, 0, kFontRegular(kRoomMessageDefalutFont).lineHeight * scale, kFontRegular(kRoomMessageDefalutFont).lineHeight);
|
||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:kFontRegular(kRoomMessageDefalutFont) alignment:YYTextVerticalAlignmentCenter];
|
||||
return attrString;
|
||||
|
||||
}
|
||||
@@ -1497,8 +1500,8 @@
|
||||
UIImageView *imaveView = [[UIImageView alloc]init];
|
||||
imaveView.image = image;
|
||||
CGFloat scale = (CGFloat)imaveView.image.size.width / (CGFloat)imaveView.image.size.height;
|
||||
imaveView.bounds = CGRectMake(0, 0, 20 * scale, 20);
|
||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
imaveView.bounds = CGRectMake(0, 0, kFontRegular(kRoomMessageDefalutFont).lineHeight * scale, kFontRegular(kRoomMessageDefalutFont).lineHeight);
|
||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:kFontRegular(kRoomMessageDefalutFont) alignment:YYTextVerticalAlignmentCenter];
|
||||
return attrString;
|
||||
}
|
||||
|
||||
@@ -1522,8 +1525,8 @@
|
||||
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paraStyle.lineSpacing = 4.0f;//行间距
|
||||
// 强制排版(从左到右)
|
||||
paraStyle.alignment = NSTextAlignmentLeft;
|
||||
paraStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
|
||||
paraStyle.alignment = NSTextAlignmentNatural;
|
||||
paraStyle.baseWritingDirection = isMSRTL() ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight;
|
||||
return paraStyle;
|
||||
}
|
||||
|
||||
@@ -1532,8 +1535,8 @@
|
||||
- (NSMutableAttributedString *)createSapceAttribute:(CGFloat)width {
|
||||
UIView *spaceView = [[UIView alloc]init];
|
||||
spaceView.backgroundColor = [UIColor clearColor];
|
||||
spaceView.bounds = CGRectMake(0, 0, width, 10);
|
||||
NSMutableAttributedString * attribute = [NSMutableAttributedString yy_attachmentStringWithContent:spaceView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(spaceView.frame.size.width, spaceView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
spaceView.bounds = CGRectMake(0, 0, width, kFontRegular(kRoomMessageDefalutFont).lineHeight);
|
||||
NSMutableAttributedString * attribute = [NSMutableAttributedString yy_attachmentStringWithContent:spaceView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(spaceView.frame.size.width, spaceView.frame.size.height) alignToFont:kFontRegular(kRoomMessageDefalutFont) alignment:YYTextVerticalAlignmentCenter];
|
||||
return attribute;
|
||||
}
|
||||
|
||||
|
@@ -16,8 +16,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
@interface XPNetImageYYLabel : YYLabel
|
||||
|
||||
@property (nonatomic, assign) CGFloat textWidth;
|
||||
@property (nonatomic, assign) CGFloat maxWidth;
|
||||
|
||||
@end
|
||||
|
||||
|
@@ -13,10 +13,10 @@
|
||||
@implementation XPNetImageYYLabel
|
||||
|
||||
- (void)setAttributedText:(NSAttributedString *)attributedText {
|
||||
if (!attributedText) return;
|
||||
|
||||
NSMutableAttributedString* attributedTextCopy = [attributedText mutableCopy];
|
||||
|
||||
CGSize maxSize = CGSizeMake(kRoomMessageMaxWidth, MAXFLOAT);
|
||||
self.maxWidth = maxSize.width;
|
||||
CGSize maxSize = CGSizeMake(kRoomMessageMaxWidth - 24, MAXFLOAT);
|
||||
|
||||
CGSize size = [attributedText boundingRectWithSize:maxSize
|
||||
options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin
|
||||
@@ -25,55 +25,85 @@
|
||||
YYTextContainer *container = [YYTextContainer containerWithSize:CGSizeMake(size.width, MAXFLOAT)];
|
||||
container.truncationType = YYTextTruncationTypeEnd;
|
||||
|
||||
// YYTextLayout * layout = [YYTextLayout layoutWithContainerSize:maxSize text:attributedText];
|
||||
YYTextLayout * layout = [YYTextLayout layoutWithContainer:container text:attributedText];
|
||||
YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:maxSize
|
||||
text:attributedTextCopy];
|
||||
|
||||
for (YYTextAttachment *attachment in layout.attachments) {
|
||||
if (!attachment || ![attachment.content isKindOfClass:[NetImageView class]]) continue;
|
||||
NSInteger index = [layout.attachments indexOfObject:attachment];
|
||||
NetImageView* imageView = attachment.content;
|
||||
if (!imageView.imageUrl) continue;
|
||||
|
||||
NSValue * value = [layout.attachmentRanges xpSafeObjectAtIndex:index];
|
||||
NSRange range = value.rangeValue;
|
||||
|
||||
if (imageView.state == NetImageStateLoaded) {
|
||||
attributedTextCopy = [self updateNetImageAttribute:imageView attributes:attributedTextCopy range:range];
|
||||
for (NSUInteger i = 0; i < layout.attachments.count; i++) {
|
||||
YYTextAttachment *attachment = [layout.attachments xpSafeObjectAtIndex:i];
|
||||
if (![attachment.content isKindOfClass:[NetImageView class]]) {
|
||||
continue;
|
||||
}else {
|
||||
}
|
||||
|
||||
NetImageView *imageView = (NetImageView *)attachment.content;
|
||||
if (!imageView.imageUrl){
|
||||
continue;
|
||||
}
|
||||
|
||||
NSValue *value = [layout.attachmentRanges xpSafeObjectAtIndex:i];
|
||||
if (!value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSRange range = value.rangeValue;
|
||||
if (imageView.state == NetImageStateLoaded) {
|
||||
attributedTextCopy = [self updateNetImageAttribute:imageView
|
||||
attributes:attributedTextCopy
|
||||
range:range];
|
||||
} else {
|
||||
@kWeakify(self);
|
||||
[imageView loadImage:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
|
||||
@kStrongify(self);
|
||||
imageView.image = image;
|
||||
[super setAttributedText:[self updateNetImageAttribute:imageView attributes:attributedTextCopy range:range]];
|
||||
@kWeakify(self);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@kStrongify(self);
|
||||
[self updateImageAndRefresh:imageView
|
||||
attributedText:attributedTextCopy
|
||||
range:range];
|
||||
});
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
self.textWidth = layout.textBoundingRect.size.width + 12;
|
||||
|
||||
[super setAttributedText:attributedTextCopy];
|
||||
[super setAttributedText:attributedTextCopy];
|
||||
}
|
||||
|
||||
- (NSMutableAttributedString*)updateNetImageAttribute:(NetImageView*)imageView attributes:(NSMutableAttributedString*)attributes range:(NSRange)range{
|
||||
|
||||
UIImage* image = imageView.image;
|
||||
CGSize size;
|
||||
if (image != nil){
|
||||
CGFloat scale = image.size.width / image.size.height;
|
||||
// 目前是根据原高度(imageView.bounds.size.height)等比例缩放图片。
|
||||
size = CGSizeMake(imageView.bounds.size.height * scale, imageView.bounds.size.height);
|
||||
imageView.bounds = CGRectMake(0, 0, size.width, size.height);
|
||||
}else{
|
||||
size = CGSizeMake(18, 18);
|
||||
imageView.bounds = CGRectMake(0, 0, 18, 18);
|
||||
- (void)updateImageAndRefresh:(NetImageView *)imageView
|
||||
attributedText:(NSMutableAttributedString *)attributedText
|
||||
range:(NSRange)range {
|
||||
if (!imageView || !attributedText) return;
|
||||
imageView.image = imageView.image ?: [UIImage new];
|
||||
NSMutableAttributedString *updatedAttributes = [self updateNetImageAttribute:imageView
|
||||
attributes:attributedText
|
||||
range:range];
|
||||
[super setAttributedText:updatedAttributes];
|
||||
}
|
||||
|
||||
- (NSMutableAttributedString*)updateNetImageAttribute:(NetImageView*)imageView
|
||||
attributes:(NSMutableAttributedString*)attributes
|
||||
range:(NSRange)range{
|
||||
if (!imageView || !attributes) {
|
||||
return attributes;
|
||||
}
|
||||
NSMutableAttributedString * replaceAttr = [NSMutableAttributedString yy_attachmentStringWithContent:imageView
|
||||
contentMode:UIViewContentModeScaleAspectFit
|
||||
attachmentSize:size
|
||||
alignToFont:kFontRegular(kRoomMessageDefalutFont)
|
||||
alignment:YYTextVerticalAlignmentCenter];
|
||||
[attributes replaceCharactersInRange:range withAttributedString:replaceAttr];
|
||||
|
||||
CGSize size = imageView.bounds.size;
|
||||
if (CGSizeEqualToSize(size, CGSizeZero)) {
|
||||
size = CGSizeMake(kFontRegular(kRoomMessageDefalutFont).lineHeight,
|
||||
kFontRegular(kRoomMessageDefalutFont).lineHeight);
|
||||
}
|
||||
UIImage *image = imageView.image;
|
||||
if (image) {
|
||||
CGFloat scale = image.size.width / image.size.height;
|
||||
size = CGSizeMake(imageView.bounds.size.height * scale, imageView.bounds.size.height);
|
||||
}
|
||||
|
||||
imageView.bounds = CGRectMake(0, 0, size.width, size.height);
|
||||
|
||||
NSMutableAttributedString *replaceAttr = [NSMutableAttributedString yy_attachmentStringWithContent:imageView
|
||||
contentMode:UIViewContentModeScaleAspectFit
|
||||
attachmentSize:size
|
||||
alignToFont:kFontRegular(kRoomMessageDefalutFont)
|
||||
alignment:YYTextVerticalAlignmentCenter];
|
||||
[attributes replaceCharactersInRange:range withAttributedString:replaceAttr];
|
||||
return attributes;
|
||||
}
|
||||
|
||||
|
@@ -53,20 +53,20 @@
|
||||
make.width.mas_equalTo(kRoomMessageMaxWidth);
|
||||
make.height.mas_equalTo(height);
|
||||
}];
|
||||
if (isMSRTL()){
|
||||
[self.bubbleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(10);
|
||||
make.top.mas_equalTo(self);
|
||||
make.width.mas_equalTo(kRoomMessageMaxWidth-10);
|
||||
make.bottom.mas_equalTo(self).offset(-10);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.mas_equalTo(self).inset(15);
|
||||
make.centerY.mas_equalTo(self.bubbleView);
|
||||
}];
|
||||
return;
|
||||
}
|
||||
// if (isMSRTL()){
|
||||
// [self.bubbleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.leading.mas_equalTo(10);
|
||||
// make.top.mas_equalTo(self);
|
||||
// make.width.mas_equalTo(kRoomMessageMaxWidth-10);
|
||||
// make.bottom.mas_equalTo(self).offset(-10);
|
||||
// }];
|
||||
//
|
||||
// [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.leading.trailing.mas_equalTo(self).inset(15);
|
||||
// make.centerY.mas_equalTo(self.bubbleView);
|
||||
// }];
|
||||
// return;
|
||||
// }
|
||||
[self.bubbleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.top.mas_equalTo(self);
|
||||
make.width.mas_equalTo(kRoomMessageMaxWidth-10);
|
||||
@@ -81,8 +81,13 @@
|
||||
|
||||
///获取头部的高度
|
||||
- (CGFloat)getHeaderViewHeight:(NSString *)title {
|
||||
CGFloat width = isMSRTL() ? kRoomMessageMaxWidth - 30 : kRoomMessageMaxWidth - 20;
|
||||
return [title boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont]} context:nil].size.height;
|
||||
CGFloat width = kRoomMessageMaxWidth - 20; //isMSRTL() ? kRoomMessageMaxWidth - 30 :
|
||||
return [title boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX)
|
||||
options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin
|
||||
attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont]}
|
||||
context:nil]
|
||||
.size
|
||||
.height;
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
|
@@ -35,8 +35,7 @@
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
[self initSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -60,7 +59,6 @@
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.contentLabel).offset(-16);
|
||||
make.top.mas_equalTo(self.contentLabel).offset(0);
|
||||
@@ -82,27 +80,50 @@
|
||||
- (void)setIsLeftBigImage:(BOOL)isLeftBigImage {
|
||||
_isLeftBigImage = isLeftBigImage;
|
||||
if (isLeftBigImage) {
|
||||
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(0);
|
||||
make.top.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(-10);
|
||||
make.trailing.mas_equalTo(self.contentLabel).offset(10);
|
||||
}];
|
||||
|
||||
[self.leftBigImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(0);
|
||||
make.centerY.mas_equalTo(self.contentView);
|
||||
make.size.mas_equalTo(CGSizeMake(50, 50));
|
||||
make.top.mas_equalTo(6);
|
||||
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(60), kGetScaleWidth(60)));
|
||||
}];
|
||||
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.leftBigImageView.mas_centerX);
|
||||
make.top.mas_equalTo(0);
|
||||
// make.bottom.mas_equalTo(-self.messageInfo.contentBottomMargin);
|
||||
make.bottom.mas_equalTo(self.leftBigImageView).offset(6);
|
||||
make.trailing.mas_equalTo(-8);
|
||||
}];
|
||||
|
||||
// [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
|
||||
// make.trailing.mas_equalTo(self.contentView).offset(-8);
|
||||
//// make.centerY.mas_equalTo(self.contentView);
|
||||
// make.centerY.mas_equalTo(self.leftBigImageView);
|
||||
// }];
|
||||
|
||||
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.bottom.mas_equalTo(self.bubbleImageView);
|
||||
make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
|
||||
make.trailing.mas_equalTo(self.bubbleImageView).offset(-8);
|
||||
}];
|
||||
|
||||
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
|
||||
make.centerY.mas_equalTo(self.contentView);
|
||||
if (isMSRTL()) {
|
||||
make.width.mas_equalTo(20);
|
||||
}
|
||||
[self.blurEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.bubbleImageView);
|
||||
}];
|
||||
self.blurEffectView.hidden = NO;
|
||||
|
||||
// [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
// make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
|
||||
// make.trailing.mas_equalTo(-self.messageInfo.contentRightMargin - 8);
|
||||
// make.top.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentTopMargin);
|
||||
// make.bottom.mas_equalTo(self.bubbleImageView).offset(-self.messageInfo.contentBottomMargin);
|
||||
//// if (isMSRTL()) {
|
||||
//// make.width.mas_equalTo([self RTLLabelWidth] - 65);
|
||||
//// }
|
||||
// }];
|
||||
|
||||
} else {
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +134,8 @@
|
||||
CGFloat left = (image.size.width - 1) / 2;
|
||||
CGFloat right = (image.size.width - 1) / 2;
|
||||
CGFloat bottom = (image.size.height - 1) / 2;
|
||||
return [image resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right) resizingMode:UIImageResizingModeStretch];
|
||||
return [image resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right)
|
||||
resizingMode:UIImageResizingModeStretch];
|
||||
}
|
||||
#pragma mark - UIGestureRecognizerDelegate
|
||||
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
|
||||
@@ -131,6 +153,7 @@
|
||||
[self.delegate xPRoomMessageTableViewCellDidTapEmpty:self];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)clickBtnAction{
|
||||
|
||||
}
|
||||
@@ -141,123 +164,78 @@
|
||||
}
|
||||
_messageInfo = messageInfo;
|
||||
if (messageInfo) {
|
||||
|
||||
// [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
// make.leading.mas_equalTo(self.bubbleImageView).offset(_messageInfo.contentLeftMargin);
|
||||
// make.top.mas_equalTo(self.bubbleImageView).offset(_messageInfo.contentTopMargin);
|
||||
// make.bottom.mas_equalTo(self.bubbleImageView).offset(-_messageInfo.contentBottomMargin);
|
||||
// }];
|
||||
|
||||
self.contentLabel.attributedText = messageInfo.content;
|
||||
// self.contentLabel.textLayout = messageInfo.textLayout;
|
||||
|
||||
if (![NSString isEmpty:messageInfo.bubbleImageUrl]) {
|
||||
self.blurEffectView.hidden = YES;
|
||||
@kWeakify(self);
|
||||
[self.bubbleImageView loadImageWithUrl:messageInfo.bubbleImageUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
|
||||
@kStrongify(self);
|
||||
UIImage *image1 = [UIImage imageWithCGImage:image.CGImage scale:2.0 orientation:UIImageOrientationUp];
|
||||
UIImage *cutImage = [image1 cropRightAndBottomPixels:2];
|
||||
self.bubbleImageView.image = [self resizableImage:cutImage];
|
||||
|
||||
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(messageInfo.contentLeftMargin);
|
||||
make.top.mas_equalTo(messageInfo.contentTopMargin);
|
||||
make.bottom.mas_equalTo(- messageInfo.contentBottomMargin - messageInfo.cellBottomMargin);
|
||||
|
||||
// make.centerY.mas_equalTo(self.contentView);
|
||||
|
||||
// if (isMSRTL()) {
|
||||
make.width.mas_greaterThanOrEqualTo([self RTLLabelWidth] - messageInfo.contentLeftMargin);
|
||||
// make.height.mas_greaterThanOrEqualTo([self RTLLabelHeight]);
|
||||
// }
|
||||
}];
|
||||
|
||||
[self.bubbleImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(0);
|
||||
make.leading.trailing.mas_equalTo(self.contentView).offset(0);
|
||||
// make.trailing.mas_equalTo(self.contentLabel).offset(-messageInfo.contentRightMargin - 10);
|
||||
}];
|
||||
}];
|
||||
|
||||
|
||||
if (self.isLeftBigImage) {
|
||||
self.leftBigImageView.imageUrl = messageInfo.boomImageUrl;
|
||||
} else {
|
||||
self.blurEffectView.hidden = NO;
|
||||
self.bubbleImageView.image = [UIImage imageWithColor:[DJDKMIMOMColor messageBubbleColor]];
|
||||
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(messageInfo.contentLeftMargin);
|
||||
make.bottom.mas_equalTo(-messageInfo.cellBottomMargin);
|
||||
make.top.mas_equalTo(messageInfo.contentTopMargin);
|
||||
make.width.mas_equalTo([self RTLLabelWidth] - messageInfo.contentLeftMargin);
|
||||
}];
|
||||
// [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
//// make.top.equalTo(self.contentView).offset(10); // 距离顶部 10 点
|
||||
//// make.bottom.equalTo(self.contentView).offset(-10); // 距离底部 10 点
|
||||
//// make.trailing.equalTo(self.contentView).offset(-10); // 距离右侧 10 点
|
||||
//// make.centerY.mas_equalTo(self.contentView);
|
||||
//// if (isMSRTL()) {
|
||||
//// make.width.mas_greaterThanOrEqualTo([self RTLLabelWidth]);
|
||||
// make.height.mas_greaterThanOrEqualTo([self RTLLabelHeight]);
|
||||
//// }
|
||||
// make.leading.equalTo(self.contentView).offset(10); // 左侧有足够空间,避免过宽
|
||||
// }];
|
||||
[self.bubbleImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.contentLabel).offset(-8);
|
||||
make.trailing.mas_equalTo(self.contentLabel).offset(8);
|
||||
make.bottom.mas_equalTo(self.contentLabel).offset(0);
|
||||
}];
|
||||
[self updateLayout];
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
|
||||
// if (self.isLeftBigImage) {
|
||||
// self.leftBigImageView.imageUrl = messageInfo.boomImageUrl;
|
||||
// [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
// make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
|
||||
// make.trailing.mas_equalTo(-self.messageInfo.contentRightMargin - 8);
|
||||
//// make.centerY.mas_equalTo(self.contentView);
|
||||
// make.top.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentTopMargin);
|
||||
// make.bottom.mas_equalTo(self.bubbleImageView).offset(-self.messageInfo.contentBottomMargin);
|
||||
//// if (isMSRTL()) {
|
||||
//// make.width.mas_equalTo([self RTLLabelWidth] - 65);
|
||||
//// }
|
||||
// }];
|
||||
// } else {
|
||||
|
||||
// }
|
||||
|
||||
// _bubbleImageView.hidden = _messageInfo.isHiddenBubble;
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)RTLLabelWidth {
|
||||
CGSize size = [self.contentLabel.attributedText boundingRectWithSize:CGSizeMake(kRoomMessageMaxWidth, 0)
|
||||
- (void)updateLayout {
|
||||
if ([NSString isEmpty:self.messageInfo.bubbleImageUrl]) {
|
||||
[self updateLayoutWithoutBubble];
|
||||
}else {
|
||||
[self updateLayoutWithBubble];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateLayoutWithBubble {
|
||||
self.blurEffectView.hidden = !self.messageInfo.isHiddenBubble;
|
||||
@kWeakify(self);
|
||||
[self.bubbleImageView loadImageWithUrl:self.messageInfo.bubbleImageUrl
|
||||
completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
|
||||
@kStrongify(self);
|
||||
UIImage *image1 = [UIImage imageWithCGImage:image.CGImage scale:2.0 orientation:UIImageOrientationUp];
|
||||
UIImage *cutImage = [image1 cropRightAndBottomPixels:2];
|
||||
self.bubbleImageView.image = [self resizableImage:cutImage];
|
||||
|
||||
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.messageInfo.contentLeftMargin);
|
||||
make.top.mas_equalTo(0);//self.messageInfo.contentTopMargin);
|
||||
make.bottom.mas_equalTo(- self.messageInfo.contentBottomMargin - self.messageInfo.cellBottomMargin);
|
||||
make.width.mas_equalTo([self RTLLabelWidth] - self.messageInfo.contentLeftMargin);
|
||||
}];
|
||||
|
||||
[self.bubbleImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(0);
|
||||
make.leading.trailing.mas_equalTo(self.contentView).offset(0);
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)updateLayoutWithoutBubble {
|
||||
self.blurEffectView.hidden = NO;
|
||||
self.bubbleImageView.image = [UIImage imageWithColor:[DJDKMIMOMColor messageBubbleColor]];
|
||||
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.messageInfo.contentLeftMargin);
|
||||
make.bottom.mas_equalTo(-self.messageInfo.cellBottomMargin);
|
||||
make.top.mas_equalTo(0);//self.messageInfo.contentTopMargin);
|
||||
make.width.mas_equalTo([self RTLLabelWidth] - self.messageInfo.contentLeftMargin - self.messageInfo.contentRightMargin);
|
||||
}];
|
||||
|
||||
[self.bubbleImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.contentLabel).offset(-8);
|
||||
make.trailing.mas_equalTo(self.contentLabel).offset(8);
|
||||
make.bottom.mas_equalTo(self.contentLabel).offset(0);
|
||||
}];
|
||||
}
|
||||
|
||||
- (CGSize)RTLLabelSize {
|
||||
return [self.contentLabel.attributedText boundingRectWithSize:CGSizeMake(kRoomMessageMaxWidth, 0)
|
||||
options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin
|
||||
context:nil].size;
|
||||
// NSLog(@" ----- 11 ----- %@", [NSValue valueWithCGSize:size]);
|
||||
// return MIN(ceil(size.width) + self.messageInfo.contentLeftMargin + self.messageInfo.contentRightMargin + 8, self.contentLabel.maxWidth);
|
||||
return ceil(size.width);// + self.messageInfo.contentLeftMargin + self.messageInfo.contentRightMargin + 8;
|
||||
}
|
||||
- (CGFloat)RTLLabelWidth {
|
||||
return MIN(ceil([self RTLLabelSize].width) + self.messageInfo.contentLeftMargin + self.messageInfo.contentRightMargin + 8,
|
||||
kRoomMessageMaxWidth - self.messageInfo.contentLeftMargin);
|
||||
}
|
||||
|
||||
- (CGFloat)RTLLabelHeight {
|
||||
CGSize size = [self.contentLabel.attributedText boundingRectWithSize:CGSizeMake(kRoomMessageMaxWidth, 0)
|
||||
options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin
|
||||
context:nil].size;
|
||||
return ceil(size.height);
|
||||
}
|
||||
|
||||
- (UIImage *)scaleToSize:(UIImage *)img {
|
||||
// 创建一个bitmap的context
|
||||
// 并把它设置成为当前正在使用的context
|
||||
CGFloat width = img.size.width * 0.5;
|
||||
CGFloat height = img.size.height * 0.5;
|
||||
UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), NO, 1);
|
||||
// 绘制改变大小的图片
|
||||
[img drawInRect:CGRectMake(0, 0, width, height)];
|
||||
// 从当前context中创建一个改变大小后的图片
|
||||
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
// 使当前的context出堆栈
|
||||
UIGraphicsEndImageContext();
|
||||
// 返回新的改变大小后的图片
|
||||
return scaledImage;
|
||||
return ceil([self RTLLabelSize].height);
|
||||
}
|
||||
|
||||
- (void)setRoomType:(RoomType)roomType {
|
||||
@@ -278,13 +256,6 @@
|
||||
_bubbleImageView.clipsToBounds = NO;
|
||||
_bubbleImageView.userInteractionEnabled = YES;
|
||||
[_bubbleImageView setCornerRadius:8];
|
||||
// _bubbleImageView.layer.masksToBounds = YES;
|
||||
// _bubbleImageView.layer.cornerRadius = 8;
|
||||
|
||||
// [_contentLabel setCornerRadius:8
|
||||
// corners:kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner | kCALayerMaxXMaxYCorner | kCALayerMinXMaxYCorner
|
||||
// borderWidth:1
|
||||
// borderColor:[UIColor greenColor]];
|
||||
}
|
||||
return _bubbleImageView;
|
||||
}
|
||||
@@ -304,12 +275,6 @@
|
||||
_contentLabel.preferredMaxLayoutWidth = kRoomMessageMaxWidth ;
|
||||
_contentLabel.numberOfLines = 0;
|
||||
_contentLabel.userInteractionEnabled = YES;
|
||||
|
||||
// [_contentLabel setCornerRadius:8
|
||||
// corners:kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner | kCALayerMaxXMaxYCorner | kCALayerMinXMaxYCorner
|
||||
// borderWidth:1
|
||||
// borderColor:[UIColor redColor]];
|
||||
|
||||
}
|
||||
return _contentLabel;
|
||||
}
|
||||
|
@@ -62,6 +62,8 @@ typedef NS_ENUM(NSInteger, RoomMoreMenuType) {
|
||||
RoomMoreMenuType_Room_Type_Setting = 25,
|
||||
|
||||
RoomMoreMenuType_Room_Type_Background = 26,
|
||||
|
||||
RoomMoreMenuType_Room_Music_Panel = 27,
|
||||
};
|
||||
|
||||
@interface XPRoomMoreItemModel : PIBaseModel
|
||||
|
@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface XPMoreMenuPresenter : BaseMvpPresenter
|
||||
|
||||
///获取更多菜单
|
||||
- (void)getMoreMenuDataSource:(RoomInfoModel *)roomInfo isSuperAdmin:(BOOL)isSuperAdmin;
|
||||
- (void)getMoreMenuDataSource:(RoomInfoModel *)roomInfo isSuperAdmin:(BOOL)isSuperAdmin isOnMic:(BOOL)isOnMic;
|
||||
|
||||
/// 开启房间礼物值
|
||||
/// @param roomUid 房间的uid
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
@implementation XPMoreMenuPresenter
|
||||
|
||||
- (void)getMoreMenuDataSource:(RoomInfoModel *)roomInfo isSuperAdmin:(BOOL)isSuperAdmin {
|
||||
- (void)getMoreMenuDataSource:(RoomInfoModel *)roomInfo isSuperAdmin:(BOOL)isSuperAdmin isOnMic:(BOOL)isOnMic {
|
||||
XPRoomMoreItemModel * roomPK = [[XPRoomMoreItemModel alloc] init];
|
||||
roomPK.title = roomInfo.roomModeType == RoomModeType_Open_PK_Mode ?YMLocalizedString(@"XPMoreMenuPresenter26") : YMLocalizedString(@"XPMoreMenuPresenter1");
|
||||
roomPK.imageName= @"room_pk_menu_icon";
|
||||
@@ -135,6 +135,12 @@
|
||||
roomTypeSetting.imageName = @"room_type_selection_icon";
|
||||
roomTypeSetting.type = RoomMoreMenuType_Room_Type_Setting;
|
||||
roomTypeSetting.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor];
|
||||
|
||||
XPRoomMoreItemModel * musicPanel = [[XPRoomMoreItemModel alloc] init];
|
||||
musicPanel.title = YMLocalizedString(@"XPRoomMusicVoiceSettingView1");
|
||||
musicPanel.imageName = @"menu_music";
|
||||
musicPanel.type = RoomMoreMenuType_Room_Music_Panel;
|
||||
musicPanel.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor];
|
||||
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
if (uid.length <= 0) {
|
||||
@@ -159,6 +165,11 @@
|
||||
[array addObject:roomPK];
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
|
||||
if (isOnMic) {
|
||||
[array addObject:musicPanel];
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
|
||||
if (isCreator && roomInfo.type != RoomType_MiniGame) {
|
||||
if(roomInfo.type != RoomType_Anchor){
|
||||
@@ -166,12 +177,12 @@
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isCreator && roomInfo.type == RoomType_Anchor) {
|
||||
[array addObject:anchorRoomPK];
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
|
||||
|
||||
if ((isCreator || isManager || isSuperAdmin) && roomInfo.hasWishGiftPermit) {
|
||||
[array addObject:wishGift];
|
||||
}
|
||||
@@ -189,7 +200,6 @@
|
||||
}
|
||||
[array addObject:roomSetting];
|
||||
[array addObject:clearScreen];
|
||||
|
||||
} else {
|
||||
[array addObject:trumpet];
|
||||
[array addObject:giftEffect];
|
||||
|
@@ -10,7 +10,7 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPRoomMoreMenuViewController : MvpViewController
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate;
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate isUserOnMic:(BOOL)isOnMic;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#import "XPMoreMenuProtocol.h"
|
||||
#import "CustomRoomBGContentViewController.h"
|
||||
|
||||
|
||||
UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
|
||||
|
||||
@interface XPRoomMoreMenuViewController ()<UICollectionViewDelegate, UICollectionViewDataSource,XPMoreMenuProtocol>
|
||||
@@ -62,13 +63,16 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
|
||||
@property (nonatomic,strong) RoomInfoModel *roomInfo;
|
||||
|
||||
@property (nonatomic,assign) id<RoomHostDelegate> hostDelegate;
|
||||
|
||||
@property(nonatomic, assign) BOOL isOnMic;
|
||||
@end
|
||||
|
||||
@implementation XPRoomMoreMenuViewController
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate{
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate isUserOnMic:(BOOL)isOnMic {
|
||||
if (self = [super init]) {
|
||||
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
||||
self.isOnMic = isOnMic;
|
||||
self.roomInfo = delegate.getRoomInfo;
|
||||
self.hostDelegate = delegate;
|
||||
}
|
||||
@@ -91,7 +95,7 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
|
||||
break;
|
||||
}
|
||||
}
|
||||
[self.presenter getMoreMenuDataSource:self.roomInfo isSuperAdmin:meIsSuperAdmin];
|
||||
[self.presenter getMoreMenuDataSource:self.roomInfo isSuperAdmin:meIsSuperAdmin isOnMic:self.isOnMic];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
@@ -221,7 +225,7 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
|
||||
}
|
||||
|
||||
- (void)cancelMatchRandomPKSuccess {
|
||||
self.hostDelegate.getRoomInfo.pkMatchStartTime = nil;
|
||||
self.hostDelegate.getRoomInfo.pkMatchStartTime = 0;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"cancelMatchRandomPK" object:nil];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
|
||||
@@ -248,7 +252,7 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
|
||||
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
|
||||
XPRoomMoreItemModel * item = [self.datasource xpSafeObjectAtIndex:indexPath.row];
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld",self.roomInfo.uid];
|
||||
NSString * roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId];
|
||||
// NSString * roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId];
|
||||
switch (item.type) {
|
||||
case RoomMoreMenuType_Gift_Effect_Open:
|
||||
{
|
||||
@@ -511,6 +515,15 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
|
||||
[self.hostDelegate.getCurrentNav presentViewController:vc
|
||||
animated:YES
|
||||
completion:nil];
|
||||
}
|
||||
break;
|
||||
case RoomMoreMenuType_Room_Music_Panel: {
|
||||
@kWeakify(self);
|
||||
[self dismissViewControllerAnimated:YES
|
||||
completion:^{
|
||||
@kStrongify(self);
|
||||
[self.hostDelegate displayMusicPanel];
|
||||
}];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@@ -51,6 +51,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
-(NSInteger)getPublicScreenType;
|
||||
|
||||
- (void)displayMusicPanel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -460,15 +460,18 @@
|
||||
if (!_sendGiftButton) {
|
||||
_sendGiftButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_sendGiftButton setTitle:YMLocalizedString(@"XPGiftBarView2") forState:UIControlStateNormal];
|
||||
[_sendGiftButton setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateNormal];
|
||||
[_sendGiftButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
[_sendGiftButton setTitle:YMLocalizedString(@"XPGiftBarView3" ) forState:UIControlStateDisabled];
|
||||
[_sendGiftButton setTitleColor:[DJDKMIMOMColor disableButtonTextColor] forState:UIControlStateDisabled];
|
||||
[_sendGiftButton setTitle:YMLocalizedString(@"XPGiftBarView4") forState:UIControlStateSelected];
|
||||
[_sendGiftButton setTitleColor:[DJDKMIMOMColor disableButtonTextColor] forState:UIControlStateSelected];
|
||||
[_sendGiftButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor], [DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
||||
[_sendGiftButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xE29030), UIColorFromRGB(0xFCC074)]
|
||||
gradientType:GradientTypeLeftToRight
|
||||
imgSize:CGSizeMake(10, 10)]
|
||||
forState:UIControlStateNormal];
|
||||
[_sendGiftButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor disableButtonColor], [DJDKMIMOMColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
|
||||
[_sendGiftButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor disableButtonColor], [DJDKMIMOMColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateSelected];
|
||||
_sendGiftButton.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
_sendGiftButton.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
_sendGiftButton.layer.masksToBounds = YES;
|
||||
_sendGiftButton.layer.cornerRadius = 15;
|
||||
[_sendGiftButton addTarget:self action:@selector(sendButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
@@ -1208,10 +1208,10 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
[self.anchorScrollView addSubview:self.quickMessageContainerView];
|
||||
[self.anchorScrollView addSubview:self.activityContainerView];
|
||||
[self.anchorScrollView addSubview:self.roomHeaderView];
|
||||
[self.anchorScrollView addSubview:self.functionView];
|
||||
if (!self.menuContainerView.superview) {
|
||||
[self.view addSubview:self.menuContainerView];
|
||||
}
|
||||
[self.anchorScrollView addSubview:self.functionView];
|
||||
[self.view bringSubviewToFront:self.animationView];
|
||||
|
||||
[self updateViewConstraintsOnAnchorRoom];
|
||||
@@ -1604,9 +1604,8 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
[self.anchorScrollView addSubview:self.quickMessageContainerView];
|
||||
[self.anchorScrollView addSubview:self.activityContainerView];
|
||||
[self.anchorScrollView addSubview:self.roomHeaderView];
|
||||
[self.anchorScrollView addSubview:self.functionView];
|
||||
[self.anchorScrollView addSubview:self.menuContainerView];
|
||||
|
||||
[self.anchorScrollView addSubview:self.functionView];
|
||||
[self.view bringSubviewToFront:self.animationView];
|
||||
|
||||
[self updateViewConstraintsOnAnchorRoom];
|
||||
@@ -1834,8 +1833,8 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
[self.view addSubview:self.menuContainerView];
|
||||
[self.view addSubview:self.activityContainerView];
|
||||
[self.view addSubview:self.roomHeaderView];
|
||||
[self.view addSubview:self.functionView];
|
||||
[self.view bringSubviewToFront:self.menuContainerView];
|
||||
[self.view addSubview:self.functionView];
|
||||
[self.view bringSubviewToFront:self.animationView];
|
||||
|
||||
[self initSubViewConstraints];
|
||||
@@ -2525,10 +2524,11 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
[self.anchorScrollView addSubview:self.quickMessageContainerView];
|
||||
[self.anchorScrollView addSubview:self.activityContainerView];
|
||||
[self.anchorScrollView addSubview:self.roomHeaderView];
|
||||
[self.anchorScrollView addSubview:self.functionView];
|
||||
if (!self.menuContainerView.superview) {
|
||||
[self.view addSubview:self.menuContainerView];
|
||||
}
|
||||
[self.anchorScrollView addSubview:self.functionView];
|
||||
|
||||
[self.view bringSubviewToFront:self.animationView];
|
||||
|
||||
[self updateViewConstraintsOnAnchorRoom];
|
||||
@@ -2587,6 +2587,10 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
return self.messageContainerView.type;
|
||||
}
|
||||
|
||||
- (void)displayMusicPanel {
|
||||
[self.functionView showMusicPanel];
|
||||
}
|
||||
|
||||
#pragma mark - XPFirstRechargeViewDelegate
|
||||
-(void)rechargeHandle{}
|
||||
-(void)contactCustomerService{
|
||||
|
Reference in New Issue
Block a user