Merge branch 'test/fix-chat-bug' into 1.0.30
# Conflicts: # YuMi/Modules/YMRoom/View/MessageContainerView/Model/XPMessageInfoModel.m # YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m # YuMi/Modules/YMRoom/View/MessageContainerView/View/XPNetImageYYLabel.m # YuMi/Modules/YMRoom/View/MessageContainerView/View/XPRoomMessageHeaderView.m # YuMi/Modules/YMRoom/View/MessageContainerView/View/XPRoomMessageTableViewCell.m # YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m # YuMi/Modules/YMRoom/View/ThemeColor+Room.m
@@ -500,6 +500,7 @@
|
||||
4C6E1F752CEAEC3C0073D0A3 /* ShoppingMallTagView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C6E1F742CEAEC3C0073D0A3 /* ShoppingMallTagView.m */; };
|
||||
4C6E1F792CEB12780073D0A3 /* UIView+GradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C6E1F782CEB12780073D0A3 /* UIView+GradientLayer.m */; };
|
||||
4C6E1F7C2CEB25B10073D0A3 /* ShoppingMallItemPreview.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C6E1F7B2CEB25B10073D0A3 /* ShoppingMallItemPreview.m */; };
|
||||
4C815A172CFEB758002A46A6 /* SuperBlockViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C815A162CFEB758002A46A6 /* SuperBlockViewController.m */; };
|
||||
4CC6195A2CEC7770008C1EE8 /* MyDressingDataPresent.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC619592CEC7770008C1EE8 /* MyDressingDataPresent.m */; };
|
||||
4CC6195D2CEC996E008C1EE8 /* MyDressingDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC6195C2CEC996E008C1EE8 /* MyDressingDataModel.m */; };
|
||||
540EC1D02C89925F00F3BF0D /* GiftComboView.m in Sources */ = {isa = PBXBuildFile; fileRef = 540EC1CF2C89925F00F3BF0D /* GiftComboView.m */; };
|
||||
@@ -2587,6 +2588,8 @@
|
||||
4C6E1F782CEB12780073D0A3 /* UIView+GradientLayer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIView+GradientLayer.m"; sourceTree = "<group>"; };
|
||||
4C6E1F7A2CEB25B10073D0A3 /* ShoppingMallItemPreview.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShoppingMallItemPreview.h; sourceTree = "<group>"; };
|
||||
4C6E1F7B2CEB25B10073D0A3 /* ShoppingMallItemPreview.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShoppingMallItemPreview.m; sourceTree = "<group>"; };
|
||||
4C815A152CFEB758002A46A6 /* SuperBlockViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SuperBlockViewController.h; sourceTree = "<group>"; };
|
||||
4C815A162CFEB758002A46A6 /* SuperBlockViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SuperBlockViewController.m; sourceTree = "<group>"; };
|
||||
4CC619582CEC7770008C1EE8 /* MyDressingDataPresent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyDressingDataPresent.h; sourceTree = "<group>"; };
|
||||
4CC619592CEC7770008C1EE8 /* MyDressingDataPresent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MyDressingDataPresent.m; sourceTree = "<group>"; };
|
||||
4CC6195B2CEC996E008C1EE8 /* MyDressingDataModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyDressingDataModel.h; sourceTree = "<group>"; };
|
||||
@@ -11181,6 +11184,8 @@
|
||||
23E9EA992A84C39700B792F2 /* XPMineUserInfoRecordedSoundView.m */,
|
||||
9BE01ACC28925F7D00B50299 /* XPMineNewUserRechargeView.h */,
|
||||
9BE01ACD28925F7D00B50299 /* XPMineNewUserRechargeView.m */,
|
||||
4C815A152CFEB758002A46A6 /* SuperBlockViewController.h */,
|
||||
4C815A162CFEB758002A46A6 /* SuperBlockViewController.m */,
|
||||
);
|
||||
path = SubViews;
|
||||
sourceTree = "<group>";
|
||||
@@ -12896,6 +12901,7 @@
|
||||
9BFB10222897D68400B3985E /* XPTabAnchorCardModel.m in Sources */,
|
||||
E8B846DC26FDE24300A777FE /* RechargeListModel.m in Sources */,
|
||||
9B1B7292280010E8003FACE9 /* Api+FansTeam.m in Sources */,
|
||||
4C815A172CFEB758002A46A6 /* SuperBlockViewController.m in Sources */,
|
||||
E8A3539728FE7C250014A784 /* XPWishGiftPresenter.m in Sources */,
|
||||
E85E7B142A4EB0D200B6D00A /* GuildAuthModel.m in Sources */,
|
||||
9BE01ADE2892A66D00B50299 /* DressUpShopModel.m in Sources */,
|
||||
|
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "common_new_user_en.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
@@ -10,6 +9,7 @@
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "组 7594@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
BIN
YuMi/Assets.xcassets/1.0.30/block_selected.imageset/组 7594@3x.png
vendored
Normal file
After Width: | Height: | Size: 959 B |
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "common_new_user_ar.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
@@ -10,6 +9,7 @@
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "矩形 3035@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
BIN
YuMi/Assets.xcassets/1.0.30/block_unselected.imageset/矩形 3035@3x.png
vendored
Normal file
After Width: | Height: | Size: 1.0 KiB |
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "common_icon_beautiful_ar.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
@@ -10,6 +9,7 @@
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "房间背景@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
BIN
YuMi/Assets.xcassets/1.0.30/menu_music.imageset/房间背景@3x.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.6 KiB |
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "room_new_user_greet_new_ar.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 1.2 KiB |
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "common_icon_beautiful_en.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 3.6 KiB |
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "room_new_user_greet_new_en.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 1.2 KiB |
@@ -5,12 +5,11 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "room_new_user_greet_new@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "room_new_user_greet_new@3x.png",
|
||||
"filename" : "新人.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 938 B |
Before Width: | Height: | Size: 1.7 KiB |
BIN
YuMi/Assets.xcassets/low/Greet/room_new_user_greet_new.imageset/新人.png
vendored
Normal file
After Width: | Height: | Size: 984 B |
@@ -5,12 +5,11 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_effect@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_effect@3x.png",
|
||||
"filename" : "特效.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.3 KiB |
BIN
YuMi/Assets.xcassets/middle/gift_tag_effect.imageset/特效.png
vendored
Normal file
After Width: | Height: | Size: 970 B |
@@ -5,12 +5,11 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_exclude@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_exclude@3x.png",
|
||||
"filename" : "独一无二.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.2 KiB |
BIN
YuMi/Assets.xcassets/middle/gift_tag_exclude.imageset/独一无二.png
vendored
Normal file
After Width: | Height: | Size: 853 B |
@@ -5,12 +5,11 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_latest@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_latest@3x.png",
|
||||
"filename" : "新礼物.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.2 KiB |
BIN
YuMi/Assets.xcassets/middle/gift_tag_latest.imageset/新礼物.png
vendored
Normal file
After Width: | Height: | Size: 1.1 KiB |
@@ -5,12 +5,11 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_time_limit@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_time_limit@3x.png",
|
||||
"filename" : "限定礼物.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.2 KiB |
BIN
YuMi/Assets.xcassets/middle/gift_tag_time_limit.imageset/限定礼物.png
vendored
Normal file
After Width: | Height: | Size: 893 B |
@@ -10,7 +10,7 @@
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_type_newIcon@3x.png",
|
||||
"filename" : "新礼物.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 846 B |
BIN
YuMi/Assets.xcassets/middle/gift_type_newIcon.imageset/新礼物.png
vendored
Normal file
After Width: | Height: | Size: 1.1 KiB |
@@ -5,12 +5,11 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "common_icon_beautiful@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "common_icon_beautiful@3x.png",
|
||||
"filename" : "靓号.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1023 B |
Before Width: | Height: | Size: 2.1 KiB |
BIN
YuMi/Assets.xcassets/utils/common_icon_beautiful.imageset/靓号.png
vendored
Normal file
After Width: | Height: | Size: 1002 B |
@@ -5,12 +5,11 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "common_new_user@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "common_new_user@3x.png",
|
||||
"filename" : "新人.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.0 KiB |
BIN
YuMi/Assets.xcassets/utils/common_new_user.imageset/新人.png
vendored
Normal file
After Width: | Height: | Size: 984 B |
@@ -9,6 +9,24 @@
|
||||
|
||||
@implementation MyDressingDataModel
|
||||
|
||||
// JSON 字段映射
|
||||
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
|
||||
return @{
|
||||
@"dressShopId" : @"id"
|
||||
};
|
||||
}
|
||||
|
||||
//// 自定义转换逻辑
|
||||
//- (id)mj_newValueFromOldValue:(id)oldValue property:(MJProperty *)property {
|
||||
// if ([property.name isEqualToString:@"dressShopId"]) {
|
||||
// if ([oldValue isKindOfClass:[NSNumber class]]) {
|
||||
// // 将 NSNumber 转换为 NSString
|
||||
// return [oldValue stringValue];
|
||||
// }
|
||||
// }
|
||||
// return oldValue;
|
||||
//}
|
||||
|
||||
- (NSString *)expiredContent {
|
||||
if (self.hasExpired) {
|
||||
return YMLocalizedString(@"XPMineCarTableViewCell1");
|
||||
@@ -74,16 +92,37 @@
|
||||
|
||||
// 辅助方法:格式化价格,支持 0-2 位小数
|
||||
- (NSString *)formatPrice:(CGFloat)price {
|
||||
if (fmod(price, 1.0) == 0.0) {
|
||||
// 整数,移除小数部分
|
||||
return [NSString stringWithFormat:@"%.0f", price];
|
||||
} else if (fmod(price * 10, 1.0) == 0.0) {
|
||||
// 保留 1 位小数
|
||||
return [NSString stringWithFormat:@"%.1f", price];
|
||||
} else {
|
||||
// 保留 2 位小数
|
||||
return [NSString stringWithFormat:@"%.2f", price];
|
||||
// if (fmod(price, 1.0) == 0.0) {
|
||||
// // 整数,移除小数部分
|
||||
// return [NSString stringWithFormat:@"%.0f", price];
|
||||
// } else if (fmod(price * 10, 1.0) == 0.0) {
|
||||
// // 保留 1 位小数
|
||||
// return [NSString stringWithFormat:@"%.1f", price];
|
||||
// } else {
|
||||
// // 保留 2 位小数
|
||||
// return [NSString stringWithFormat:@"%.2f", price];
|
||||
// }
|
||||
|
||||
NSString *priceString = [NSString stringWithFormat:@"%.8f", price]; // 确保保留足够的位数
|
||||
NSArray<NSString *> *components = [priceString componentsSeparatedByString:@"."]; // 分割整数和小数部分
|
||||
NSString *integerPart = components[0];
|
||||
NSString *decimalPart = components.count > 1 ? components[1] : @"";
|
||||
|
||||
if (decimalPart.length > 2) {
|
||||
// 保留最多两位有效小数,直接截断
|
||||
decimalPart = [decimalPart substringToIndex:2];
|
||||
}
|
||||
|
||||
if ([decimalPart isEqualToString:@"00"]) {
|
||||
// 如果小数部分为 00,只返回整数部分
|
||||
return integerPart;
|
||||
} else if ([decimalPart hasSuffix:@"0"]) {
|
||||
// 如果小数部分以 0 结尾,保留 1 位小数
|
||||
decimalPart = [decimalPart substringToIndex:1];
|
||||
}
|
||||
|
||||
// 拼接整数和截断后的小数部分
|
||||
return [NSString stringWithFormat:@"%@.%@", integerPart, decimalPart];
|
||||
}
|
||||
|
||||
|
||||
|
@@ -77,7 +77,7 @@
|
||||
ticket:ticket
|
||||
uid:uid
|
||||
page:@(page).stringValue
|
||||
pageSize:@"2"];
|
||||
pageSize:@"20"];
|
||||
}
|
||||
|
||||
- (void)loadBubble:(NSInteger)page
|
||||
@@ -91,7 +91,7 @@
|
||||
}
|
||||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||
|
||||
} showLoading:page != 1 errorToast:YES] page:@(page).stringValue pageSize:@"2"];
|
||||
} showLoading:page != 1 errorToast:YES] page:@(page).stringValue pageSize:@"20"];
|
||||
}
|
||||
|
||||
- (void)loadMyDressingItems:(NSInteger)type
|
||||
@@ -107,7 +107,7 @@
|
||||
|
||||
} showLoading:page != 1 errorToast:YES]
|
||||
page:@(page).stringValue
|
||||
pageSize:@"2"
|
||||
pageSize:@"20"
|
||||
dressType:@(type).stringValue];
|
||||
}
|
||||
|
||||
|
@@ -106,7 +106,7 @@ static NSArray<NSDictionary<NSString *, NSNumber *> *> *MyDressUpOptions(void) {
|
||||
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(100);
|
||||
make.centerX.mas_equalTo(self.view);
|
||||
make.size.mas_equalTo(CGSizeMake(73, 73));
|
||||
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(73), kGetScaleWidth(73)));
|
||||
}];
|
||||
|
||||
[self.view addSubview:self.avatarHeadViewImageView];
|
||||
@@ -130,7 +130,7 @@ static NSArray<NSDictionary<NSString *, NSNumber *> *> *MyDressUpOptions(void) {
|
||||
listView.bottomSpace = bottom;
|
||||
[self.view addSubview:listView];
|
||||
[listView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.avatarView.mas_bottom).offset(14);
|
||||
make.top.mas_equalTo(self.avatarView.mas_bottom).offset(16);
|
||||
make.leading.trailing.bottom.mas_equalTo(self.view);
|
||||
}];
|
||||
@kWeakify(self);
|
||||
@@ -292,7 +292,7 @@ static NSArray<NSDictionary<NSString *, NSNumber *> *> *MyDressUpOptions(void) {
|
||||
// 弹窗购买
|
||||
BOOL isVaild = model.obtainWay<=1;
|
||||
if (isVaild) {
|
||||
isVaild = ![NSString isEmpty:model.dressId];
|
||||
isVaild = ![NSString isEmpty:model.dressShopId] && model.dressShopId.integerValue > 0;
|
||||
}
|
||||
|
||||
ShoppingMallItemPreview *preview = [[ShoppingMallItemPreview alloc] initWithMyDress:model
|
||||
@@ -321,15 +321,13 @@ static NSArray<NSDictionary<NSString *, NSNumber *> *> *MyDressUpOptions(void) {
|
||||
// 直接使用
|
||||
NSInteger dressID = 0;
|
||||
if (model) {
|
||||
if (type == 1) {
|
||||
if (type == 1 || type == 2) {
|
||||
dressID = model.id;
|
||||
} else {
|
||||
dressID = model.dressId.integerValue;
|
||||
}
|
||||
}
|
||||
if (dressID == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@kWeakify(self);
|
||||
[self.presenter useDressBy:type
|
||||
dressID:dressID
|
||||
|
@@ -211,7 +211,7 @@
|
||||
[self.contentView addSubview:self.roomCardView];
|
||||
[self.roomCardView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.centerX.mas_equalTo(self.itemBGView);
|
||||
make.width.height.mas_equalTo(self.itemBGView.mas_width).multipliedBy(0.8f);
|
||||
make.width.height.mas_equalTo(self.itemBGView.mas_width);//.multipliedBy(0.8f);
|
||||
}];
|
||||
|
||||
[self.contentView addSubview:self.playButton];
|
||||
@@ -240,6 +240,21 @@
|
||||
- (void)setModel:(MyDressingDataModel *)model {
|
||||
_model = model;
|
||||
if (model) {
|
||||
switch (model.dressType) {
|
||||
case 4:{
|
||||
[self.itemImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.itemBGView);
|
||||
make.width.mas_equalTo(kGetScaleWidth(90));
|
||||
make.height.mas_equalTo(kGetScaleWidth(46));
|
||||
}];
|
||||
[self.contentView layoutIfNeeded];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
self.titleLabel.text = model.name;
|
||||
|
||||
if (model.dressType == 3) {
|
||||
@@ -265,6 +280,10 @@
|
||||
self.playButton.hidden = YES;
|
||||
self.itemImageView.image = kImage(@"mall_item_not_used");
|
||||
self.titleLabel.text = YMLocalizedString(@"1.0.30_text_12");
|
||||
[self.itemImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.itemBGView);
|
||||
make.width.height.mas_equalTo(self.itemBGView.mas_width).multipliedBy(0.4f);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +435,7 @@
|
||||
[self.contentView addSubview:self.roomCardView];
|
||||
[self.roomCardView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.centerX.mas_equalTo(self.itemBGView);
|
||||
make.width.height.mas_equalTo(self.itemBGView.mas_width).multipliedBy(0.8f);
|
||||
make.width.height.mas_equalTo(self.itemBGView.mas_width);//.multipliedBy(0.8f);
|
||||
}];
|
||||
|
||||
[self.contentView addSubview:self.playButton];
|
||||
@@ -466,6 +485,21 @@
|
||||
- (void)setCellModel:(DressUpShopModel *)cellModel {
|
||||
_cellModel = cellModel;
|
||||
|
||||
switch (cellModel.dressType) {
|
||||
case 4:{
|
||||
[self.itemImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.itemBGView);
|
||||
make.width.mas_equalTo(kGetScaleWidth(90));
|
||||
make.height.mas_equalTo(kGetScaleWidth(46));
|
||||
}];
|
||||
[self.contentView layoutIfNeeded];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (cellModel.dressType == 3) {
|
||||
self.itemImageView.hidden = YES;
|
||||
self.roomCardView.hidden = NO;
|
||||
@@ -838,7 +872,7 @@
|
||||
for (int i = 0; i < items.count; i++) {
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeZero;// CGSizeMake((screenWidth-30) / 2 - 10, kGetScaleWidth(244));
|
||||
layout.minimumInteritemSpacing = 10;
|
||||
layout.minimumInteritemSpacing = 0;
|
||||
layout.minimumLineSpacing = 10;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 15, self.bottomSpace + 10, 15);
|
||||
|
||||
@@ -848,7 +882,7 @@
|
||||
collectionView.dataSource = self;
|
||||
collectionView.backgroundColor = [UIColor clearColor];
|
||||
collectionView.tag = i;
|
||||
collectionView.allowsSelection = YES;
|
||||
collectionView.contentInset = UIEdgeInsetsMake(16, 0, 0, 0);
|
||||
[collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
|
||||
[collectionView registerClass:[ShoppingMallItemCard class] forCellWithReuseIdentifier:@"ShoppingMallItemCard"];
|
||||
[collectionView registerClass:[ShoppingMallEmptyCard class] forCellWithReuseIdentifier:@"ShoppingMallEmptyCard"];
|
||||
@@ -860,7 +894,6 @@
|
||||
|
||||
if (self.isForMyDressingPage) {
|
||||
[self addRefreshControl:collectionView];
|
||||
[self addLoadMoreForCollectionView:collectionView];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -924,6 +957,11 @@
|
||||
}
|
||||
for (UICollectionView *itemView in self.itemCollectionViewArray) {
|
||||
[itemView reloadData];
|
||||
[itemView selectItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UICollectionViewScrollPositionNone];
|
||||
if (self.returnSelectedModel) {
|
||||
NSArray *data = self.dataCache[@(itemView.tag)];
|
||||
self.returnSelectedModel(data.firstObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,28 +971,47 @@
|
||||
if (index < self.itemCollectionViewArray.count) {
|
||||
UICollectionView *itemView = self.itemCollectionViewArray[index];
|
||||
[itemView reloadData];
|
||||
[itemView selectItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UICollectionViewScrollPositionNone];
|
||||
if (self.returnSelectedModel) {
|
||||
self.returnSelectedModel(data.firstObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateItemCollectionViewWithMyDressingData:(NSArray <MyDressingDataModel *>*)data
|
||||
pageNum:(NSInteger)pageNum
|
||||
atIndex:(NSInteger)index {
|
||||
|
||||
NSMutableArray <MyDressingDataModel *>*sortedData = data.mutableCopy;
|
||||
[sortedData sortUsingComparator:^NSComparisonResult(MyDressingDataModel * _Nonnull obj1, MyDressingDataModel * _Nonnull obj2) {
|
||||
if (obj1.used) {
|
||||
return NSOrderedAscending;
|
||||
}
|
||||
if (obj2.used) {
|
||||
return NSOrderedDescending;
|
||||
}
|
||||
return NSOrderedSame;
|
||||
}];
|
||||
|
||||
if (pageNum == 1) {
|
||||
self.myDressingDataCache[@(index)] = data;
|
||||
self.myDressingDataCache[@(index)] = sortedData.copy;
|
||||
} else {
|
||||
NSMutableArray *array = self.myDressingDataCache[@(index)].mutableCopy;
|
||||
[array addObjectsFromArray:data];
|
||||
[array addObjectsFromArray:sortedData];
|
||||
self.myDressingDataCache[@(index)] = array.copy;
|
||||
}
|
||||
|
||||
if (index < self.itemCollectionViewArray.count) {
|
||||
UICollectionView *itemView = self.itemCollectionViewArray[index];
|
||||
if (pageNum == 1 && !itemView.mj_footer) {
|
||||
[self addLoadMoreForCollectionView:itemView];
|
||||
}
|
||||
[itemView.refreshControl endRefreshing];
|
||||
[itemView.mj_header endRefreshing];
|
||||
[itemView.mj_footer endRefreshing];
|
||||
[itemView reloadData];
|
||||
|
||||
if (data.count == 0 || data.count < 2) {
|
||||
if (data.count == 0 || data.count < 20) {
|
||||
[itemView.mj_footer endRefreshingWithNoMoreData];
|
||||
NSNumber *currentPageNum = [self.myDressingDataPagesNumbers xpSafeObjectAtIndex:itemView.tag];
|
||||
|
||||
@@ -1005,14 +1062,15 @@
|
||||
- (CGSize)collectionView:(UICollectionView *)collectionView
|
||||
layout:(UICollectionViewLayout *)collectionViewLayout
|
||||
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
CGFloat width = (KScreenWidth-30) / 2 - 5;
|
||||
if (self.isForMyDressingPage) {
|
||||
return CGSizeMake((KScreenWidth-30) / 2 - 10, kGetScaleWidth(190));
|
||||
return CGSizeMake(width, kGetScaleWidth(190));
|
||||
} else {
|
||||
NSArray *data = self.dataCache[@(collectionView.tag)];
|
||||
if (data.count == 0 ) {
|
||||
return CGSizeMake(KScreenWidth, 200);
|
||||
} else {
|
||||
return CGSizeMake((KScreenWidth-30) / 2 - 10, kGetScaleWidth(244));
|
||||
return CGSizeMake(width, kGetScaleWidth(244));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1140,7 +1198,6 @@
|
||||
[self loadMyDressingItems:collectionView.tag pageNum:1];
|
||||
[collectionView.mj_footer resetNoMoreData];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -20,6 +20,7 @@
|
||||
@property(nonatomic, strong) DressUpShopModel *model;
|
||||
@property(nonatomic, strong) MyDressingDataModel *myDressingModel;
|
||||
@property(nonatomic, strong) NetImageView *itemImageView;
|
||||
@property(nonatomic, strong) UIView *itemImageBGView;
|
||||
@property(nonatomic, strong) VAPView *mp4View;
|
||||
@property(nonatomic, strong) XPRoomGiftAnimationParser *mp4Parser;
|
||||
@property(nonatomic, strong) SVGAImageView *svgaView;
|
||||
@@ -47,8 +48,8 @@
|
||||
if (self = [super init]) {
|
||||
[self setupUI];
|
||||
self.isForGive = isForGive;
|
||||
self.model = model;
|
||||
self.userModel = [[XPSkillCardPlayerManager shareInstance] userInfoModel];
|
||||
self.model = model;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -57,8 +58,8 @@
|
||||
if (self = [super init]) {
|
||||
[self setupUI];
|
||||
self.isVaild = isVaild;
|
||||
self.myDressingModel = model;
|
||||
self.userModel = [[XPSkillCardPlayerManager shareInstance] userInfoModel];
|
||||
self.myDressingModel = model;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -69,6 +70,14 @@
|
||||
self.itemImageView.imageUrl = model.pic;
|
||||
self.nameLabel.text = model.name;
|
||||
|
||||
if (model.dressType == 4) {
|
||||
[self.itemImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.itemImageBGView);
|
||||
make.width.mas_equalTo(kGetScaleWidth(90));
|
||||
make.height.mas_equalTo(kGetScaleWidth(46));
|
||||
}];
|
||||
}
|
||||
|
||||
if (model.vipLimit > self.userModel.userVipInfoVO.vipLevel) {
|
||||
self.buyButton.hidden = YES;
|
||||
self.giveButton.hidden = YES;
|
||||
@@ -114,6 +123,15 @@
|
||||
|
||||
- (void)setMyDressingModel:(MyDressingDataModel *)myDressingModel {
|
||||
_myDressingModel = myDressingModel;
|
||||
|
||||
if (myDressingModel.dressType == 4) {
|
||||
[self.itemImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.itemImageBGView);
|
||||
make.width.mas_equalTo(kGetScaleWidth(90));
|
||||
make.height.mas_equalTo(kGetScaleWidth(46));
|
||||
}];
|
||||
}
|
||||
|
||||
self.itemImageView.imageUrl = myDressingModel.pic;
|
||||
self.nameLabel.text = myDressingModel.name;
|
||||
if (self.isVaild) {
|
||||
@@ -142,6 +160,13 @@
|
||||
make.edges.mas_equalTo(self);
|
||||
}];
|
||||
|
||||
[self addSubview:self.itemImageBGView];
|
||||
[self.itemImageBGView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self);
|
||||
make.top.mas_equalTo(32);
|
||||
make.size.mas_equalTo(CGSizeMake(155, 155));
|
||||
}];
|
||||
|
||||
[self addSubview:self.itemImageView];
|
||||
[self.itemImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self);
|
||||
@@ -152,7 +177,7 @@
|
||||
[self addSubview:self.nameLabel];
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self);
|
||||
make.top.mas_equalTo(self.itemImageView.mas_bottom).offset(4);
|
||||
make.top.mas_equalTo(self.itemImageBGView.mas_bottom).offset(4);
|
||||
make.height.mas_equalTo(22);
|
||||
}];
|
||||
|
||||
@@ -226,6 +251,13 @@
|
||||
return bgImageView;
|
||||
}
|
||||
|
||||
- (UIView *)itemImageBGView {
|
||||
if (!_itemImageBGView) {
|
||||
_itemImageBGView = [[UIView alloc] init];
|
||||
}
|
||||
return _itemImageBGView;
|
||||
}
|
||||
|
||||
- (NetImageView *)itemImageView {
|
||||
if (!_itemImageView) {
|
||||
_itemImageView = [[NetImageView alloc] init];
|
||||
|
@@ -31,8 +31,8 @@
|
||||
self.clipsToBounds = YES;
|
||||
if (colors.count>1) {
|
||||
[self addGradientBackgroundWithColors:colors
|
||||
startPoint:isMSRTL() ? CGPointMake(0.0, 1.0) : CGPointMake(0.0, 0.0)
|
||||
endPoint:isMSRTL() ? CGPointMake(0.0, 0.0) : CGPointMake(0.0, 1.0)
|
||||
startPoint:isMSRTL() ? CGPointMake(0.0, 0.0) : CGPointMake(1.0, 0.0)
|
||||
endPoint:isMSRTL() ? CGPointMake(1.0, 0.0) : CGPointMake(0.0, 0.0)
|
||||
cornerRadius:0];
|
||||
} else if (colors.count == 1){
|
||||
self.backgroundColor = colors.firstObject;
|
||||
@@ -53,8 +53,8 @@
|
||||
textColor:(UIColor *)textColor {
|
||||
if (colors.count>1) {
|
||||
[self addGradientBackgroundWithColors:colors //@[UIColorFromRGB(0xE29030), UIColorFromRGB(0xFCC074)]
|
||||
startPoint:isMSRTL() ? CGPointMake(0.0, 1.0) : CGPointMake(0.0, 0.0)
|
||||
endPoint:isMSRTL() ? CGPointMake(0.0, 0.0) : CGPointMake(0.0, 1.0)
|
||||
startPoint:isMSRTL() ? CGPointMake(0.0, 0.0) : CGPointMake(1.0, 0.0)
|
||||
endPoint:isMSRTL() ? CGPointMake(1.0, 0.0) : CGPointMake(0.0, 0.0)
|
||||
cornerRadius:0];
|
||||
} else if (colors.count == 1){
|
||||
self.backgroundColor = colors.firstObject;
|
||||
|
@@ -69,7 +69,7 @@ static NSArray<NSDictionary<NSString *, NSNumber *> *> *DressUpOptions(void) {
|
||||
[self setupBottomControlBar];
|
||||
[self setupContentList];
|
||||
|
||||
[self hideBottomControlArea];
|
||||
// [self hideBottomControlArea];
|
||||
}
|
||||
|
||||
- (void)setupBackground {
|
||||
@@ -175,7 +175,7 @@ static NSArray<NSDictionary<NSString *, NSNumber *> *> *DressUpOptions(void) {
|
||||
if (self.selectedModel.obtainWay > 1) {
|
||||
self.bottomControlPriceLabel.text = @"";
|
||||
} else {
|
||||
self.bottomControlPriceLabel.attributedText = [self.selectedModel mallItemPricePerDay:YES isFullDisplay:YES];
|
||||
self.bottomControlPriceLabel.attributedText = [self.selectedModel mallItemPricePerDay:NO isFullDisplay:YES];
|
||||
}
|
||||
} else {
|
||||
self.bottomControlPriceLabel.text = @"";
|
||||
@@ -203,14 +203,10 @@ static NSArray<NSDictionary<NSString *, NSNumber *> *> *DressUpOptions(void) {
|
||||
}
|
||||
|
||||
- (void)hideBottomControlArea {
|
||||
[UIView animateWithDuration:0.25 animations:^{
|
||||
[self.bottomControlArea mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(80 + kSafeAreaBottomHeight);
|
||||
}];
|
||||
[self.bottomControlArea layoutIfNeeded];
|
||||
} completion:^(BOOL finished) {
|
||||
// [self.view layoutIfNeeded];
|
||||
[self.bottomControlArea mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(80 + kSafeAreaBottomHeight);
|
||||
}];
|
||||
[self.bottomControlArea layoutIfNeeded];
|
||||
}
|
||||
|
||||
- (void)didTapBuy:(id)sender {
|
||||
@@ -416,6 +412,7 @@ static NSArray<NSDictionary<NSString *, NSNumber *> *> *DressUpOptions(void) {
|
||||
- (UIButton *)bottomControlBuyButton {
|
||||
if (!_bottomControlBuyButton) {
|
||||
_bottomControlBuyButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_bottomControlBuyButton.titleLabel.font = kFontMedium(14);
|
||||
[_bottomControlBuyButton setTitle:YMLocalizedString(@"1.0.30_text_5") forState:UIControlStateNormal];
|
||||
[_bottomControlBuyButton setTitleColor:UIColorFromRGB(0x51281B) forState:UIControlStateNormal];
|
||||
[_bottomControlBuyButton addGradientBackgroundWithColors:@[UIColorFromRGB(0xFFE3B2), UIColorFromRGB(0xE9A71D)]
|
||||
@@ -432,6 +429,7 @@ static NSArray<NSDictionary<NSString *, NSNumber *> *> *DressUpOptions(void) {
|
||||
- (UIButton *)bottomControlGiveButton {
|
||||
if (!_bottomControlGiveButton) {
|
||||
_bottomControlGiveButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_bottomControlGiveButton.titleLabel.font = kFontMedium(14);
|
||||
[_bottomControlGiveButton setTitle:YMLocalizedString(@"1.0.30_text_6") forState:UIControlStateNormal];
|
||||
[_bottomControlGiveButton setTitleColor:UIColorFromRGB(0x172055) forState:UIControlStateNormal];
|
||||
[_bottomControlGiveButton addGradientBackgroundWithColors:@[UIColorFromRGB(0xB2FCFF), UIColorFromRGB(0x4DA2EA)]
|
||||
@@ -485,13 +483,9 @@ static NSArray<NSDictionary<NSString *, NSNumber *> *> *DressUpOptions(void) {
|
||||
atIndex:0];
|
||||
[b setAttributedTitle:title
|
||||
forState:UIControlStateNormal];
|
||||
// [b setImage:kImage(@"mall_my_icon") forState:UIControlStateNormal];
|
||||
|
||||
CGFloat spacing = 8.0; // 图像和标题之间的间距
|
||||
// b.imageEdgeInsets = UIEdgeInsetsMake(0, b.titleLabel.intrinsicContentSize.width + spacing, 0, -b.titleLabel.intrinsicContentSize.width - spacing);
|
||||
// b.titleEdgeInsets = UIEdgeInsetsMake(0, -b.imageView.frame.size.width*2, 0, b.imageView.frame.size.width*2 + spacing);
|
||||
//
|
||||
// // 设置按钮的整体布局和样式
|
||||
CGFloat spacing = 8.0;
|
||||
|
||||
b.contentEdgeInsets = UIEdgeInsetsMake(0, spacing, 4, spacing);
|
||||
|
||||
[b addTarget:self action:@selector(didTapMyDress) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
@@ -54,6 +54,8 @@
|
||||
///下一步
|
||||
@property (nonatomic,strong) UIButton *nextButton;
|
||||
|
||||
@property(nonatomic, strong) UILabel *block18Tips;
|
||||
|
||||
///邀请码的容器
|
||||
@property (nonatomic,strong) UIView *codeContainView;
|
||||
///邀请码输入框
|
||||
@@ -102,28 +104,21 @@
|
||||
[self.bgView addSubview:self.remindLabel];
|
||||
[self.bgView addSubview:self.sexStackView];
|
||||
|
||||
|
||||
|
||||
[self.bgView addSubview:self.backView];
|
||||
|
||||
[self.view addSubview:self.codeContainView];
|
||||
[self.view addSubview:self.nextButton];
|
||||
|
||||
|
||||
|
||||
[self.view addSubview:self.block18Tips];
|
||||
|
||||
[self.backView addSubview:self.textField];
|
||||
[self.backView addSubview:self.refreshButton];
|
||||
[self.backView addSubview:self.nameLabel];
|
||||
|
||||
|
||||
|
||||
[self.sexStackView addArrangedSubview:self.maleView];
|
||||
[self.sexStackView addArrangedSubview:self.femaleView];
|
||||
|
||||
[self.codeContainView addSubview:self.codeTextField];
|
||||
|
||||
|
||||
if ([self.presenter getThirdUserInfo] && [self.presenter getThirdUserInfo].userName.length > 0) {
|
||||
self.textField.text = [self.presenter getThirdUserInfo].userName;
|
||||
} else {
|
||||
@@ -153,15 +148,13 @@
|
||||
make.top.mas_equalTo(kGetScaleWidth(48));
|
||||
|
||||
}];
|
||||
|
||||
|
||||
|
||||
[self.sexStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(kGetScaleWidth(38));
|
||||
make.trailing.mas_equalTo(-kGetScaleWidth(38));
|
||||
make.top.mas_equalTo(kGetScaleWidth(86));
|
||||
}];
|
||||
|
||||
|
||||
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(kGetScaleWidth(303));
|
||||
make.height.mas_equalTo(kGetScaleWidth(52));
|
||||
@@ -193,7 +186,6 @@
|
||||
make.height.mas_equalTo(kGetScaleWidth(108));
|
||||
}];
|
||||
|
||||
|
||||
[self.codeContainView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.height.mas_equalTo(self.backView);
|
||||
make.top.mas_equalTo(self.backView.mas_bottom).offset(kGetScaleWidth(20));
|
||||
@@ -205,8 +197,6 @@
|
||||
make.trailing.mas_equalTo(self.codeContainView).offset(-kGetScaleWidth(18));
|
||||
}];
|
||||
|
||||
|
||||
|
||||
[self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(kGetScaleWidth(303));
|
||||
make.centerX.equalTo(self.bgView);
|
||||
@@ -214,7 +204,10 @@
|
||||
make.top.mas_equalTo(self.codeContainView.mas_bottom).offset(kGetScaleWidth(48));
|
||||
}];
|
||||
|
||||
|
||||
[self.block18Tips mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.nextButton);
|
||||
make.top.mas_equalTo(self.nextButton.mas_bottom).offset(8);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)initEvents {
|
||||
@@ -482,6 +475,14 @@
|
||||
return _nextButton;
|
||||
}
|
||||
|
||||
- (UILabel *)block18Tips {
|
||||
if (!_block18Tips) {
|
||||
_block18Tips = [UILabel labelInitWithText:YMLocalizedString(@"1.0.30_text_25")
|
||||
font:kFontRegular(11)
|
||||
textColor:UIColorFromRGB(0xAFB1B3)];
|
||||
}
|
||||
return _block18Tips;
|
||||
}
|
||||
|
||||
- (UIView *)bgView{
|
||||
if(!_bgView){
|
||||
|
@@ -79,18 +79,8 @@
|
||||
NSArray *redPacketHistory = [[NSUserDefaults standardUserDefaults] objectForKey:kTuWenMessageHistory];
|
||||
if ( [redPacketHistory containsObject: model1.message.messageId]) {
|
||||
self.isNewImageView.hidden = YES;
|
||||
[self.isNewImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.trailing.mas_equalTo(self.backView);
|
||||
make.centerY.equalTo(self.titleLabel);
|
||||
make.size.mas_equalTo(CGSizeMake(0, 10));
|
||||
}];
|
||||
} else {
|
||||
self.isNewImageView.hidden = NO;
|
||||
[self.isNewImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.trailing.mas_equalTo(self.backView);
|
||||
make.centerY.equalTo(self.titleLabel);
|
||||
make.size.mas_equalTo(CGSizeMake(24, 10));
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
///View
|
||||
#import "XPSessionFindNewViewController.h"
|
||||
#import "TTPopUp.h"
|
||||
#import "XPSkillCardPlayerManager.h"
|
||||
|
||||
|
||||
NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey";
|
||||
@@ -90,6 +91,7 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey";
|
||||
if (code == 200) {
|
||||
UserInfoModel * userInfo = [UserInfoModel modelWithDictionary:data.data];
|
||||
self.userInfo = userInfo;
|
||||
[[XPSkillCardPlayerManager shareInstance] setUserInfoModel:userInfo];
|
||||
[self.sessionListView reloadData];
|
||||
}
|
||||
} uid:uid];
|
||||
|
@@ -359,6 +359,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// - isShow: 是否开启
|
||||
+(void)updateCPSetting:(HttpRequestHelperCompletion)completion type:(NSNumber *)type isShow:(NSNumber *)isShow;
|
||||
|
||||
+(void)requestBlockTime:(HttpRequestHelperCompletion)completion;
|
||||
|
||||
+(void)blockUser:(HttpRequestHelperCompletion)completion uid:(NSNumber *)uid hours:(NSNumber *)hours blockReason:(NSString *)blockReason;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -463,4 +463,13 @@
|
||||
+(void)updateCPSetting:(HttpRequestHelperCompletion)completion type:(NSNumber *)type isShow:(NSNumber *)isShow {
|
||||
[self makeRequest:@"user/setting/update" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, type, isShow, nil];
|
||||
}
|
||||
|
||||
+(void)requestBlockTime:(HttpRequestHelperCompletion)completion {
|
||||
[self makeRequest:@"user/blockTime" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
|
||||
}
|
||||
|
||||
+(void)blockUser:(HttpRequestHelperCompletion)completion uid:(NSNumber *)uid hours:(NSNumber *)hours blockReason:(NSString *)blockReason {
|
||||
[self makeRequest:@"user/block" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, uid, hours, blockReason, nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -41,6 +41,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
-(void)getTagList;
|
||||
////保存个人简介标签
|
||||
-(void)saveTagListWithLabels:(NSString *)labels;
|
||||
|
||||
- (void)requestBlockTimesSuccess:(void(^)(NSArray *array))finishHim
|
||||
failure:(void(^)(NSError *error))failure;
|
||||
- (void)superBlock:(NSInteger)uid
|
||||
hours:(NSInteger)hours
|
||||
resaon:(NSString *)reason
|
||||
success:(void(^)(void))finishHim
|
||||
failure:(void(^)(NSError *error))failure;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -123,4 +123,34 @@
|
||||
[[self getView]saveTagListSuccess];
|
||||
}showLoading:YES errorToast:YES] labels:labels];
|
||||
}
|
||||
|
||||
- (void)requestBlockTimesSuccess:(void(^)(NSArray *array))finishHim
|
||||
failure:(void(^)(NSError *error))failure {
|
||||
[Api requestBlockTime:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
if (finishHim) {
|
||||
finishHim(data.data);
|
||||
}
|
||||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||
if (failure) {
|
||||
failure([NSError errorWithDomain:msg code:code userInfo:nil]);
|
||||
}
|
||||
} showLoading:YES errorToast:YES]];
|
||||
}
|
||||
|
||||
- (void)superBlock:(NSInteger)uid
|
||||
hours:(NSInteger)hours
|
||||
resaon:(NSString *)reason
|
||||
success:(void(^)(void))finishHim
|
||||
failure:(void(^)(NSError *error))failure {
|
||||
[Api blockUser:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
if (finishHim) {
|
||||
finishHim();
|
||||
}
|
||||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||
if (failure) {
|
||||
failure([NSError errorWithDomain:msg code:code userInfo:nil]);
|
||||
}
|
||||
} showLoading:YES errorToast:YES] uid:@(uid) hours:@(hours) blockReason:reason];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -149,7 +149,7 @@
|
||||
self.countLabel.text = [NSString stringWithFormat:@"x%ld", (long)giftModel.reciveCount];
|
||||
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.contentView);
|
||||
make.leading.trailing.mas_equalTo(self.contentView).inset(2);
|
||||
make.bottom.mas_equalTo(-24);
|
||||
make.height.mas_equalTo(18);
|
||||
}];
|
||||
@@ -162,7 +162,7 @@
|
||||
self.countLabel.hidden = YES;
|
||||
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.contentView);
|
||||
make.leading.trailing.mas_equalTo(self.contentView).inset(2);
|
||||
make.bottom.mas_equalTo(-8);
|
||||
make.height.mas_equalTo(18);
|
||||
}];
|
||||
@@ -195,6 +195,10 @@
|
||||
- (UILabel *)nameLabel {
|
||||
if (!_nameLabel) {
|
||||
_nameLabel = [UILabel labelInitWithText:@"" font:kFontMedium(12) textColor:[UIColor whiteColor]];
|
||||
_nameLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_nameLabel.numberOfLines = 2;
|
||||
_nameLabel.minimumScaleFactor = 0.7f;
|
||||
_nameLabel.adjustsFontSizeToFitWidth = YES;
|
||||
}
|
||||
return _nameLabel;
|
||||
}
|
||||
|
@@ -142,31 +142,44 @@
|
||||
|
||||
NSString *formattedPriceString = [self formatPrice: self.vipLevel>0 ? self.discountPrice : self.dressPrice];
|
||||
if (isFull == NO) {
|
||||
formattedPriceString = [NSString formatNumberToKOrM:formattedPriceString];
|
||||
formattedPriceString = [NSString formatNumberToKOrM_NoRounding:formattedPriceString];
|
||||
}
|
||||
|
||||
if (isMSRTL()) {
|
||||
// 添加金币图片
|
||||
[attributedString appendAttributedString:[self iconAttributedString]];
|
||||
// 添加 day 文本
|
||||
NSString *formattedDayNumString = [NSString stringWithFormat:@"D%ld/", (long)self.dressDay];
|
||||
NSAttributedString *dayNumString = [[NSAttributedString alloc] initWithString:formattedDayNumString attributes:dayAttributes];
|
||||
[attributedString appendAttributedString:dayNumString];
|
||||
|
||||
// 添加 price 文本
|
||||
NSAttributedString *priceString = [[NSAttributedString alloc] initWithString:formattedPriceString attributes:priceAttributes];
|
||||
[attributedString appendAttributedString:priceString];
|
||||
|
||||
// MARK:DO NOT CHANGE ANYTHING!!!!!!
|
||||
// 添加空格
|
||||
NSAttributedString *spaceString = [[NSAttributedString alloc] initWithString:@" "];
|
||||
[attributedString appendAttributedString:spaceString];
|
||||
|
||||
// 添加金币图片
|
||||
[attributedString appendAttributedString:[self iconAttributedString]];
|
||||
|
||||
// 添加空格
|
||||
NSAttributedString *spaceString_1 = [[NSAttributedString alloc] initWithString:@" "];
|
||||
[attributedString appendAttributedString:spaceString_1];
|
||||
|
||||
// 添加原始价格
|
||||
if (includeOriginalPrice && self.vipLevel > 0) {
|
||||
NSString *originalPriceString = [NSString stringWithFormat:@"%@", [self formatPrice:self.dressPrice]];
|
||||
originalPriceString = [NSString formatNumberToKOrM_NoRounding:originalPriceString];
|
||||
NSAttributedString *originalPriceAttributedString = [[NSAttributedString alloc] initWithString:originalPriceString attributes:originalPriceAttributes];
|
||||
[attributedString appendAttributedString:originalPriceAttributedString];
|
||||
}
|
||||
|
||||
// 添加 day 文本
|
||||
NSString *formattedDayNumString_0 = @"D";//[NSString stringWithFormat:@"%@", YMLocalizedString(@"1.0.30_text_24")];
|
||||
NSAttributedString *dayNumString_0 = [[NSAttributedString alloc] initWithString:formattedDayNumString_0 attributes:dayAttributes];
|
||||
[attributedString appendAttributedString:dayNumString_0];
|
||||
NSString *formattedDayNumString = [NSString stringWithFormat:@"%ld", (long)self.dressDay];
|
||||
NSAttributedString *dayNumString = [[NSAttributedString alloc] initWithString:formattedDayNumString attributes:dayAttributes];
|
||||
[attributedString appendAttributedString:dayNumString];
|
||||
NSString *formattedDayNumString_1 = @"/";
|
||||
NSAttributedString *dayNumString_1 = [[NSAttributedString alloc] initWithString:formattedDayNumString_1 attributes:dayAttributes];
|
||||
[attributedString appendAttributedString:dayNumString_1];
|
||||
|
||||
// 添加 price 文本
|
||||
NSAttributedString *priceString = [[NSAttributedString alloc] initWithString:formattedPriceString attributes:priceAttributes];
|
||||
[attributedString appendAttributedString:priceString];
|
||||
} else {
|
||||
// 1. 添加金币图片
|
||||
[attributedString appendAttributedString:[self iconAttributedString]];
|
||||
@@ -185,6 +198,7 @@
|
||||
// 添加原始价格
|
||||
if (includeOriginalPrice && self.vipLevel > 0) {
|
||||
NSString *originalPriceString = [NSString stringWithFormat:@"%@", [self formatPrice:self.dressPrice]];
|
||||
originalPriceString = [NSString formatNumberToKOrM_NoRounding:originalPriceString];
|
||||
NSAttributedString *originalPriceAttributedString = [[NSAttributedString alloc] initWithString:originalPriceString attributes:originalPriceAttributes];
|
||||
[attributedString appendAttributedString:originalPriceAttributedString];
|
||||
}
|
||||
@@ -213,6 +227,27 @@
|
||||
// 保留 2 位小数
|
||||
return [NSString stringWithFormat:@"%.2f", price];
|
||||
}
|
||||
|
||||
// NSString *priceString = [NSString stringWithFormat:@"%.8f", price]; // 确保保留足够的位数
|
||||
// NSArray<NSString *> *components = [priceString componentsSeparatedByString:@"."]; // 分割整数和小数部分
|
||||
// NSString *integerPart = components[0];
|
||||
// NSString *decimalPart = components.count > 1 ? components[1] : @"";
|
||||
//
|
||||
// if (decimalPart.length > 2) {
|
||||
// // 保留最多两位有效小数,直接截断
|
||||
// decimalPart = [decimalPart substringToIndex:2];
|
||||
// }
|
||||
//
|
||||
// if ([decimalPart isEqualToString:@"00"]) {
|
||||
// // 如果小数部分为 00,只返回整数部分
|
||||
// return integerPart;
|
||||
// } else if ([decimalPart hasSuffix:@"0"]) {
|
||||
// // 如果小数部分以 0 结尾,保留 1 位小数
|
||||
// decimalPart = [decimalPart substringToIndex:1];
|
||||
// }
|
||||
//
|
||||
// // 拼接整数和截断后的小数部分
|
||||
// return [NSString stringWithFormat:@"%@.%@", integerPart, decimalPart];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -82,7 +82,16 @@
|
||||
make.centerY.mas_equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
[self.sendButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.trailing.mas_equalTo(self.contentView).offset(-15);
|
||||
make.centerY.mas_equalTo(self.contentView);
|
||||
make.size.mas_equalTo(CGSizeMake(60, 26));
|
||||
}];
|
||||
|
||||
self.nickLabel.textColor = [UIColor whiteColor];
|
||||
self.sexImageView.hidden = YES;
|
||||
[self.avatarImageView setCornerRadius:25];
|
||||
self.idLabel.textColor = UIColorFromRGB(0xd9e7f7);
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
|
@@ -80,6 +80,9 @@ UISearchBarDelegate>
|
||||
self.defaultFriendsList = tempArray.copy;
|
||||
self.datasource = tempArray.copy;
|
||||
[self.tableView reloadData];
|
||||
if (users.count == 0) {
|
||||
[self showEmptyView];
|
||||
}
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
|
||||
}];
|
||||
@@ -93,7 +96,7 @@ UISearchBarDelegate>
|
||||
|
||||
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.view);
|
||||
make.top.mas_equalTo(self.view).offset(44 + 11);
|
||||
make.top.mas_equalTo(self.view).offset(kStatusBarHeight + kSafeAreaTopHeight);
|
||||
make.height.mas_equalTo(22);
|
||||
}];
|
||||
|
||||
@@ -120,17 +123,11 @@ UISearchBarDelegate>
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
// [self.view addSubview:self.searchView];
|
||||
[self.view addSubview:self.searchBar];
|
||||
[self.view addSubview:self.tableView];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
// [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.top.mas_equalTo(self.view).offset(kNavigationHeight);
|
||||
// make.leading.trailing.mas_equalTo(self.view);
|
||||
// make.height.mas_equalTo(kNavigationHeight);
|
||||
// }];
|
||||
[self.searchBar mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.view).offset(kNavigationHeight + 8);
|
||||
make.leading.trailing.mas_equalTo(self.view).inset(15);
|
||||
|
@@ -43,6 +43,7 @@
|
||||
#import "XPMineUserDataViewController.h"
|
||||
#import "XPMomentsMineViewController.h"
|
||||
#import "XPGiftUserDataViewController.h"
|
||||
#import "SuperBlockViewController.h"
|
||||
|
||||
#import "XPRoomMiniManager.h"
|
||||
|
||||
@@ -194,27 +195,38 @@ HWDMP4PlayDelegate>
|
||||
- (void)showRightNavHandle {
|
||||
NSMutableArray<TTActionSheetConfig *> *array = [NSMutableArray array];
|
||||
NSString *uid = [NSString stringWithFormat:@"%ld",self.uid];
|
||||
@kWeakify(self);
|
||||
TTActionSheetConfig *report = [TTActionSheetConfig normalTitle:YMLocalizedString(@"XPMineUserInfoViewController0") clickAction:^{
|
||||
@kStrongify(self);
|
||||
XPWebViewController *vc = [[XPWebViewController alloc] initWithRoomUID:nil];
|
||||
NSString *urlStr = [NSString stringWithFormat:@"%@?reportUid=%@&source=PERSONAL",URLWithType(kReportRoomURL),uid];
|
||||
vc.url = urlStr;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}];
|
||||
|
||||
TTActionSheetConfig *black = [TTActionSheetConfig normalTitle:YMLocalizedString(@"XPMineUserInfoViewController1") clickAction:^{
|
||||
[self addOrRemoveBlack:NO uid:uid];
|
||||
}];
|
||||
|
||||
[array addObjectsFromArray:@[report, black]];
|
||||
[array addObject:report];
|
||||
|
||||
BOOL isInBlackList = [[NIMSDK sharedSDK].userManager isUserInBlackList:uid] || [self isSystemAccount];
|
||||
if (isInBlackList) {
|
||||
[array removeObject:black];
|
||||
if (!isInBlackList) {
|
||||
TTActionSheetConfig *black = [TTActionSheetConfig normalTitle:YMLocalizedString(@"XPMineUserInfoViewController1") clickAction:^{
|
||||
@kStrongify(self);
|
||||
[self addOrRemoveBlack:NO uid:uid];
|
||||
}];
|
||||
[array addObject:black];
|
||||
}
|
||||
|
||||
if ([XPSkillCardPlayerManager shareInstance].userInfoModel.hasSuperRole) {
|
||||
TTActionSheetConfig *superBlock = [TTActionSheetConfig normalTitle:YMLocalizedString(@"1.0.30_text_26") clickAction:^{
|
||||
@kStrongify(self);
|
||||
SuperBlockViewController *vc = [[SuperBlockViewController alloc] init];
|
||||
vc.targetUser = self.userInfo;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}];
|
||||
[array addObject:superBlock];
|
||||
}
|
||||
|
||||
[TTPopup actionSheetWithItems:array];
|
||||
}
|
||||
|
||||
|
||||
//加入黑名单
|
||||
- (void)addOrRemoveBlack:(BOOL)isRemove uid:(NSString *)uid {
|
||||
NSString *title;
|
||||
@@ -381,7 +393,7 @@ HWDMP4PlayDelegate>
|
||||
|
||||
self.headerHeight = [XPMineUserInfoHeaderView headerHeight:userInfo];
|
||||
[self.pagingView reloadData];
|
||||
// self.pagingView.hidden = NO;
|
||||
|
||||
|
||||
if(isMSRTL()){
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
|
18
YuMi/Modules/YMMine/View/SubViews/SuperBlockViewController.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// SuperBlockViewController.h
|
||||
// YuMi
|
||||
//
|
||||
// Created by P on 2024/12/3.
|
||||
//
|
||||
|
||||
#import "MvpViewController.h"
|
||||
@class UserInfoModel;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SuperBlockViewController : MvpViewController
|
||||
|
||||
@property(nonatomic, strong) UserInfoModel *targetUser;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
352
YuMi/Modules/YMMine/View/SubViews/SuperBlockViewController.m
Normal file
@@ -0,0 +1,352 @@
|
||||
//
|
||||
// SuperBlockViewController.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by P on 2024/12/3.
|
||||
//
|
||||
|
||||
#import "SuperBlockViewController.h"
|
||||
#import "XPMineUserInfoPresenter.h"
|
||||
#import "UserInfoModel.h"
|
||||
|
||||
@interface BlockHourCell : UICollectionViewCell
|
||||
|
||||
@property(nonatomic, assign) NSInteger hours;
|
||||
@property(nonatomic, strong) UIImageView *selectedStatusImageView;
|
||||
@property(nonatomic, strong) UILabel *titleLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation BlockHourCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self.contentView addSubview:self.selectedStatusImageView];
|
||||
[self.selectedStatusImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self.contentView);
|
||||
make.leading.mas_equalTo(0);
|
||||
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(18), kGetScaleWidth(18)));
|
||||
}];
|
||||
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self.contentView);
|
||||
make.leading.mas_equalTo(self.selectedStatusImageView.mas_trailing).offset(6);
|
||||
make.trailing.mas_equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (UIImageView *)selectedStatusImageView {
|
||||
if (!_selectedStatusImageView) {
|
||||
_selectedStatusImageView = [[UIImageView alloc] initWithImage:kImage(@"block_unselected")];
|
||||
}
|
||||
return _selectedStatusImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [UILabel labelInitWithText:@"" font:kFontRegular(14) textColor:UIColorFromRGB(0x313131)];
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
- (void)setHours:(NSInteger)hours {
|
||||
_hours = hours;
|
||||
self.titleLabel.text = [NSString stringWithFormat:YMLocalizedString(@"1.0.30_text_28"), @(hours)];
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected {
|
||||
[super setSelected:selected];
|
||||
if (selected) {
|
||||
self.selectedStatusImageView.image = kImage(@"block_selected");
|
||||
} else {
|
||||
self.selectedStatusImageView.image = kImage(@"block_unselected");
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface SuperBlockViewController () <UICollectionViewDelegateFlowLayout, UICollectionViewDataSource, UITextViewDelegate, UIGestureRecognizerDelegate>
|
||||
|
||||
@property(nonatomic, copy) NSArray <NSNumber *>*blockTimes;
|
||||
@property(nonatomic, strong) NetImageView *avatarImageView;
|
||||
@property(nonatomic, strong) UILabel *nameLabel;
|
||||
@property(nonatomic, strong) UILabel *IDLabel;
|
||||
@property(nonatomic, strong) UICollectionView *blockedTimeCollectionView;
|
||||
@property(nonatomic, strong) UITextView *reasonTextView;
|
||||
@property(nonatomic, strong) UILabel *placeholderLabel;
|
||||
@property(nonatomic, strong) UIButton *blockButton;
|
||||
@property(nonatomic, assign) NSInteger selectedHours;
|
||||
@end
|
||||
|
||||
@implementation SuperBlockViewController
|
||||
|
||||
- (XPMineUserInfoPresenter *)createPresenter {
|
||||
return [[XPMineUserInfoPresenter alloc] init];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.title = YMLocalizedString(@"1.0.30_text_26");
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapSpace:)];
|
||||
tap.cancelsTouchesInView = NO; // 允许触摸事件继续传递
|
||||
tap.delegate = self;
|
||||
[self.view addGestureRecognizer:tap];
|
||||
|
||||
@kWeakify(self);
|
||||
[self.presenter requestBlockTimesSuccess:^(NSArray * _Nonnull array) {
|
||||
@kStrongify(self);
|
||||
self.blockTimes = array;
|
||||
[self setupUI];
|
||||
[self updateUI];
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
@kStrongify(self);
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setupUI {
|
||||
[self.view addSubview:self.avatarImageView];
|
||||
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(16);
|
||||
make.top.mas_equalTo(20);
|
||||
make.size.mas_equalTo(52);
|
||||
}];
|
||||
|
||||
[self.view addSubview:self.nameLabel];
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.avatarImageView.mas_trailing).offset(8);
|
||||
make.top.mas_equalTo(self.avatarImageView).offset(5);
|
||||
make.height.mas_equalTo(22);
|
||||
}];
|
||||
|
||||
[self.view addSubview:self.IDLabel];
|
||||
[self.IDLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.avatarImageView.mas_trailing).offset(8);
|
||||
make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(2);
|
||||
make.height.mas_equalTo(18);
|
||||
}];
|
||||
|
||||
[self.view addSubview:[self line]];
|
||||
|
||||
UILabel *timeTitleLabel = [self titleLabel:YMLocalizedString(@"1.0.30_text_27") withRedStar:NO];
|
||||
[self.view addSubview:timeTitleLabel];
|
||||
[timeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.avatarImageView);
|
||||
make.top.mas_equalTo(self.avatarImageView.mas_bottom).offset(41);
|
||||
}];
|
||||
|
||||
[self.view addSubview:self.blockedTimeCollectionView];
|
||||
[self.blockedTimeCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(timeTitleLabel.mas_bottom).offset(12);
|
||||
make.leading.mas_equalTo(self.view).offset(16);
|
||||
make.trailing.mas_equalTo(self.view).offset(-70);
|
||||
make.height.mas_equalTo(0);
|
||||
}];
|
||||
|
||||
[self.view addSubview:[self line]];
|
||||
|
||||
UILabel *reasonTitleLabel = [self titleLabel:YMLocalizedString(@"1.0.30_text_29") withRedStar:YES];
|
||||
[self.view addSubview:reasonTitleLabel];
|
||||
[reasonTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.avatarImageView);
|
||||
make.top.mas_equalTo(self.blockedTimeCollectionView.mas_bottom).offset(10);
|
||||
}];
|
||||
|
||||
[self.view addSubview:self.reasonTextView];
|
||||
[self.reasonTextView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(reasonTitleLabel.mas_bottom).offset(10);
|
||||
make.leading.trailing.mas_equalTo(self.view).inset(16);
|
||||
make.height.mas_equalTo(140);
|
||||
}];
|
||||
|
||||
[self.view addSubview:self.blockButton];
|
||||
[self.blockButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.view);
|
||||
make.top.mas_equalTo(self.reasonTextView.mas_bottom).offset(20);
|
||||
make.size.mas_equalTo(CGSizeMake(234, 44));
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)updateUI {
|
||||
self.selectedHours = [[self.blockTimes xpSafeObjectAtIndex:0] integerValue];
|
||||
|
||||
self.avatarImageView.imageUrl = self.targetUser.avatar;
|
||||
self.nameLabel.text = self.targetUser.nick;
|
||||
self.IDLabel.text = [NSString stringWithFormat:@"ID: %@", @(self.targetUser.erbanNo)];
|
||||
[self.blockedTimeCollectionView reloadData];
|
||||
NSIndexPath *defaultIndexPath = [NSIndexPath indexPathForItem:0 inSection:0];
|
||||
[self.blockedTimeCollectionView selectItemAtIndexPath:defaultIndexPath
|
||||
animated:NO
|
||||
scrollPosition:UICollectionViewScrollPositionNone];
|
||||
|
||||
NSInteger lines = ceil(self.blockTimes.count/2.0);
|
||||
[self.blockedTimeCollectionView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(lines * 40);
|
||||
}];
|
||||
|
||||
[self.view layoutIfNeeded];
|
||||
}
|
||||
|
||||
- (void)didTapSpace:(UITapGestureRecognizer *)gesture {
|
||||
[self.view endEditing:YES]; // 收起键盘
|
||||
}
|
||||
|
||||
- (void)didTapBlock {
|
||||
if ([NSString isEmpty:self.reasonTextView.text]) {
|
||||
|
||||
} else {
|
||||
@kWeakify(self);
|
||||
[self.presenter superBlock:self.targetUser.uid
|
||||
hours:self.selectedHours
|
||||
resaon:self.reasonTextView.text
|
||||
success:^{
|
||||
@kStrongify(self);
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
|
||||
// 如果触摸点在 UITextView 或 UICollectionView 内,则不触发手势
|
||||
if ([touch.view isKindOfClass:[UICollectionView class]] || [touch.view isKindOfClass:[UITextView class]]) {
|
||||
return NO;
|
||||
}
|
||||
return YES; // 触发手势
|
||||
}
|
||||
|
||||
#pragma mark - UITextViewDelegate
|
||||
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
|
||||
NSString *newText = [textView.text stringByReplacingCharactersInRange:range withString:text];
|
||||
self.placeholderLabel.hidden = ![NSString isEmpty:newText];
|
||||
self.blockButton.alpha = [NSString isEmpty:newText] ? 0.5 : 1;
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||||
return self.blockTimes.count;
|
||||
}
|
||||
|
||||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
BlockHourCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BlockHourCell" forIndexPath:indexPath];
|
||||
NSNumber *hour = [self.blockTimes xpSafeObjectAtIndex:indexPath.row];
|
||||
cell.hours = hour.integerValue;
|
||||
return cell;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
- (NetImageView *)avatarImageView {
|
||||
if (!_avatarImageView) {
|
||||
_avatarImageView = [[NetImageView alloc] init];
|
||||
[_avatarImageView setCornerRadius:52/2];
|
||||
}
|
||||
return _avatarImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)nameLabel {
|
||||
if (!_nameLabel) {
|
||||
_nameLabel = [UILabel labelInitWithText:@"" font:kFontMedium(16) textColor:UIColorFromRGB(0x313131)];
|
||||
}
|
||||
return _nameLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)IDLabel {
|
||||
if (!_IDLabel) {
|
||||
_IDLabel = [UILabel labelInitWithText:@"" font:kFontRegular(13) textColor:UIColorFromRGB(0x7b7b7d)];
|
||||
}
|
||||
return _IDLabel;
|
||||
}
|
||||
|
||||
- (UIView *)line {
|
||||
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(16, 102, KScreenWidth-32, 1)];
|
||||
v.backgroundColor = UIColorFromRGB(0xe4e4e4);
|
||||
return v;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel:(NSString *)title withRedStar:(BOOL)isRed {
|
||||
UILabel *label = [UILabel labelInitWithText:@"" font:kFontMedium(15) textColor:UIColorFromRGB(0x313131)];
|
||||
NSMutableAttributedString *s_title = [[NSMutableAttributedString alloc] initWithString:title
|
||||
attributes:@{
|
||||
NSFontAttributeName: kFontMedium(15),
|
||||
NSForegroundColorAttributeName: UIColorFromRGB(0x313131)
|
||||
}];
|
||||
|
||||
if (isRed) {
|
||||
NSAttributedString *star = [[NSAttributedString alloc] initWithString:@"*" attributes:@{
|
||||
NSFontAttributeName: kFontMedium(15),
|
||||
NSForegroundColorAttributeName: UIColorFromRGB(0xff3332)
|
||||
}];
|
||||
[s_title insertAttributedString:star atIndex:s_title.length];
|
||||
}
|
||||
|
||||
label.attributedText = s_title;
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
- (UICollectionView *)blockedTimeCollectionView {
|
||||
if (!_blockedTimeCollectionView) {
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeMake((KScreenWidth - 32)/3, kGetScaleWidth(20));
|
||||
layout.minimumLineSpacing = 14;
|
||||
layout.minimumInteritemSpacing = 20;
|
||||
_blockedTimeCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
_blockedTimeCollectionView.scrollEnabled = NO;
|
||||
_blockedTimeCollectionView.allowsMultipleSelection = NO;
|
||||
_blockedTimeCollectionView.delegate = self;
|
||||
_blockedTimeCollectionView.dataSource = self;
|
||||
[_blockedTimeCollectionView registerClass:[BlockHourCell class] forCellWithReuseIdentifier:@"BlockHourCell"];
|
||||
}
|
||||
return _blockedTimeCollectionView;
|
||||
}
|
||||
|
||||
- (UITextView *)reasonTextView {
|
||||
if (!_reasonTextView) {
|
||||
_reasonTextView = [[UITextView alloc] init];
|
||||
_reasonTextView.delegate = self;
|
||||
[_reasonTextView setCornerRadius:10];
|
||||
_reasonTextView.backgroundColor = UIColorFromRGB(0xf6f6f6);
|
||||
|
||||
[_reasonTextView addSubview:self.placeholderLabel];
|
||||
[self.placeholderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(10);
|
||||
make.leading.mas_equalTo(12);
|
||||
make.trailing.mas_equalTo(-12);
|
||||
}];
|
||||
}
|
||||
return _reasonTextView;
|
||||
}
|
||||
|
||||
- (UIButton *)blockButton {
|
||||
if (!_blockButton) {
|
||||
_blockButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_blockButton addGradientBackgroundWithColors:@[UIColorFromRGB(0xE29030), UIColorFromRGB(0xfcc074)]
|
||||
startPoint:CGPointMake(0, 0.5)
|
||||
endPoint:CGPointMake(1, 0.5)
|
||||
cornerRadius:22];
|
||||
[_blockButton setTitle:YMLocalizedString(@"1.0.30_text_31") forState:UIControlStateNormal];
|
||||
[_blockButton addTarget:self action:@selector(didTapBlock) forControlEvents:UIControlEventTouchUpInside];
|
||||
_blockButton.alpha = 0.5;
|
||||
}
|
||||
return _blockButton;
|
||||
}
|
||||
|
||||
- (UILabel *)placeholderLabel {
|
||||
if (!_placeholderLabel) {
|
||||
_placeholderLabel = [UILabel labelInitWithText:YMLocalizedString(@"1.0.30_text_30")
|
||||
font:kFontRegular(14)
|
||||
textColor:UIColorFromRGB(0x7b7b7d)];
|
||||
}
|
||||
return _placeholderLabel;
|
||||
}
|
||||
|
||||
@end
|
@@ -104,7 +104,7 @@
|
||||
make.height.mas_equalTo(kMOMENTS_TEXT_TOPIC_HEIGHT);
|
||||
}];
|
||||
[self.photoView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(KScreenWidth-30);
|
||||
make.width.mas_equalTo(KScreenWidth-30);
|
||||
}];
|
||||
[self.toolBarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.mas_equalTo(self.backView);
|
||||
|
@@ -220,7 +220,7 @@
|
||||
_titleView.cellSpacing = 26;
|
||||
_titleView.titles = self.titles;
|
||||
_titleView.listContainer = self.listContainerView;
|
||||
_titleView.defaultSelectedIndex = 0;
|
||||
_titleView.defaultSelectedIndex = 2;
|
||||
_titleView.contentEdgeInsetLeft = 15;
|
||||
}
|
||||
return _titleView;
|
||||
|
@@ -250,11 +250,13 @@
|
||||
self.flagImage.imageUrl = roomInfo.regionFlag;
|
||||
|
||||
_heatView.text = [NSString isEmpty:roomInfo.hotValue.stringValue] ? @"0" : roomInfo.hotValue.stringValue;
|
||||
_rankImageView.image = nil;
|
||||
|
||||
_pkImageView.hidden = !_roomInfo.crossPking;
|
||||
if (roomInfo.hourTop > 0) {
|
||||
NSString *name = [NSString stringWithFormat:@"room_top_%ld", (long)roomInfo.hourTop];
|
||||
_rankImageView.image = [UIImage getLanguageImage:name];
|
||||
} else {
|
||||
_rankImageView.image = nil;
|
||||
}
|
||||
|
||||
for (int i = 0; i < self.membersCount; i++) {
|
||||
|
@@ -368,7 +368,7 @@
|
||||
[_collectionView registerClass:[XPNewHomePartyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPNewHomePartyCollectionViewCell class])];
|
||||
[_collectionView registerClass:[XPGuildEmptyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGuildEmptyCollectionViewCell class])];
|
||||
[_collectionView registerClass:[HomePartyBannerCell class] forCellWithReuseIdentifier:NSStringFromClass([HomePartyBannerCell class])];
|
||||
_collectionView.contentInset = UIEdgeInsetsMake(0, 0, 10, 0);
|
||||
_collectionView.contentInset = UIEdgeInsetsMake(10, 0, 10, 0);
|
||||
}
|
||||
return _collectionView;
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -17,7 +17,7 @@
|
||||
if (hour<24) {
|
||||
return [NSString stringWithFormat:@"<1%@", YMLocalizedString(@"1.0.18_8")];
|
||||
} else {
|
||||
return [NSString stringWithFormat:@"%@%@", @(hour/24), YMLocalizedString(@"1.0.18_8")];
|
||||
return [NSString stringWithFormat:@"%@%@", @(hour/24), YMLocalizedString(@"1.0.18_14")];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -46,7 +46,6 @@
|
||||
uID:(NSString *)UID
|
||||
{
|
||||
LuckyGiftWinningFlagViewModel *model = [LuckyGiftWinningFlagViewModel modelWithDictionary:attachment.data];
|
||||
// LuckyGiftWinningFlagViewModel *model = [LuckyGiftWinningFlagViewModel modelWithJSON:attachment.data];
|
||||
if (model.roomId != roomID || model.uid != UID.integerValue) {
|
||||
return;
|
||||
}
|
||||
@@ -146,6 +145,8 @@
|
||||
self.winPriceLabel.text = model.coins;
|
||||
self.winTimesLabel.text = model.times;
|
||||
self.backgroundImageView.image = model.level == 1 ? kImage(@"luck_gift_gold") : kImage(@"luck_gift_pruple");
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"receiveLuckGiftWinning" object:model.coins];
|
||||
}
|
||||
|
||||
- (void)display {
|
||||
|
@@ -315,8 +315,17 @@ PIUniversalBannerViewDelegate>
|
||||
receiveInfo.nick = [attachment.data objectForKey:@"sendUserNick"];
|
||||
receiveInfo.uid = [[attachment.data objectForKey:@"sendUserUid"] stringValue];
|
||||
} else if (attachment.second == Custom_Message_Sub_Gift_Send) {
|
||||
receiveInfo.targetUsers = @[];
|
||||
NSLog(@"******************* %@", receiveInfo.targetAvatar);
|
||||
if (receiveInfo.targetUsers.count == 0) {
|
||||
GiftReceiveUserInfoModel *model = [[GiftReceiveUserInfoModel alloc] init];
|
||||
model.nick = receiveInfo.targetNick;
|
||||
model.avatar = receiveInfo.targetAvatar;
|
||||
model.uid = receiveInfo.uid.integerValue;
|
||||
receiveInfo.targetUsers = @[model];
|
||||
}
|
||||
|
||||
if (receiveInfo.targetUids.count == 0) {
|
||||
receiveInfo.targetUids = @[@(receiveInfo.uid.integerValue)];
|
||||
}
|
||||
}
|
||||
|
||||
if (!_embeddedTargetDatas) {
|
||||
@@ -358,6 +367,11 @@ PIUniversalBannerViewDelegate>
|
||||
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
|
||||
receiveInfo.isComboBatch = attachment.second == Custom_Message_Sub_AllMicroSend;
|
||||
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
|
||||
|
||||
if (receiveInfo.gift.notifyFull) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self receiveGiftHandleSendGiftAnimation:attachment];
|
||||
if (receiveInfo.isLuckyBagGift) {
|
||||
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
|
||||
@@ -497,7 +511,6 @@ PIUniversalBannerViewDelegate>
|
||||
#pragma mark - 收到送礼者中奖飘屏
|
||||
- (void)receiveLuckGiftWinning:(AttachmentModel *)attachment {
|
||||
RoomInfoModel *roomInfo = self.delegate.getRoomInfo;
|
||||
|
||||
[LuckyGiftWinningFlagView display:self
|
||||
with:attachment
|
||||
roomID:roomInfo.roomId
|
||||
@@ -1129,10 +1142,6 @@ PIUniversalBannerViewDelegate>
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:26], NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
[attribute setYy_alignment:NSTextAlignmentLeft];
|
||||
|
||||
#if DEBUG
|
||||
effectPath = @"";
|
||||
#endif
|
||||
|
||||
if (effectPath.length > 0) {
|
||||
@kWeakify(self);
|
||||
[self.parser parseWithURL:[NSURL URLWithString:effectPath] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -23,7 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
///cell的高度
|
||||
@property (nonatomic,assign) CGFloat rowHeight;
|
||||
@property (nonatomic,assign) CGFloat textWidth;
|
||||
@property(nonatomic, strong) NSMutableArray *extraSizeArray;
|
||||
//@property(nonatomic, strong) YYTextLayout *textLayout;
|
||||
//@property(nonatomic, strong) NSMutableArray *extraSizeArray;
|
||||
///文本内容的
|
||||
@property (nonatomic,assign) CGFloat contentLeftMargin;
|
||||
///文本右边的间隙
|
||||
@@ -43,6 +44,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@property (nonatomic, copy) NSString *boomImageUrl;
|
||||
|
||||
@property(nonatomic, copy) NSString *cellKey;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -26,100 +26,40 @@
|
||||
}
|
||||
|
||||
- (void)setContent:(NSAttributedString *)content {
|
||||
self.rowHeight = [self heightForAttributedText:content
|
||||
maxWidth:kRoomMessageMaxWidth];
|
||||
_content = content;
|
||||
|
||||
// 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 ;
|
||||
}
|
||||
|
||||
- (CGFloat)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 ceil([layoutManager usedRectForTextContainer:textContainer].size.height); // 向上取整
|
||||
}
|
||||
|
||||
- (CGFloat)heightForAttributedText:(NSAttributedString *)attributedText maxWidth:(CGFloat)maxWidth {
|
||||
|
||||
CGSize containerSize = CGSizeMake(maxWidth, CGFLOAT_MAX);
|
||||
YYTextContainer *_container = [YYTextContainer containerWithSize:containerSize];
|
||||
_container.maximumNumberOfRows = 0; // 不限制行数
|
||||
YYTextLayout *_layout = [YYTextLayout layoutWithContainer:_container text:attributedText];
|
||||
CGFloat textHeight = _layout.textBoundingSize.height;
|
||||
return textHeight + self.contentTopMargin + self.contentBottomMargin + self.cellBottomMargin;
|
||||
|
||||
// return [attributedText.string boundingRectWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont]} context:nil].size.height;
|
||||
|
||||
|
||||
// 创建一个 YYTextContainer
|
||||
YYTextContainer *container = [YYTextContainer new];
|
||||
container.size = CGSizeMake(maxWidth, CGFLOAT_MAX); // 设置宽度,支持无限高度
|
||||
container.maximumNumberOfRows = 0; // 允许多行
|
||||
|
||||
// 遍历富文本,设置未加载图片的占位尺寸
|
||||
// 确认是否 “@用户名” 会影响计算结果
|
||||
NSMutableAttributedString *mutableAttributedText = [[NSMutableAttributedString alloc] initWithAttributedString:attributedText.copy];
|
||||
if (isMSRTL()) {
|
||||
NSInteger index = 0;
|
||||
[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 && [attachment.content isKindOfClass:[NetImageView class]]) {
|
||||
NSValue *v = [self.extraSizeArray xpSafeObjectAtIndex:index];
|
||||
NSString *tempString = @"";
|
||||
if (value) {
|
||||
CGSize size = [v CGSizeValue];
|
||||
// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
|
||||
// attachment.content = view;
|
||||
if (size.width <= 20) {
|
||||
tempString = @"ABCD";
|
||||
} else if (size.width <=40) {
|
||||
tempString = @"ABCDEF";
|
||||
} else {
|
||||
tempString = @"ABCDEFGH";
|
||||
}
|
||||
}
|
||||
|
||||
NSAttributedString *replaceString = [[NSAttributedString alloc] initWithString:tempString
|
||||
attributes:@{
|
||||
NSFontAttributeName: kFontRegular(kRoomMessageDefalutFont),
|
||||
NSForegroundColorAttributeName: [UIColor whiteColor]
|
||||
}];
|
||||
[mutableAttributedText replaceCharactersInRange:range withAttributedString:replaceString];
|
||||
}
|
||||
}
|
||||
}];
|
||||
CGFloat width = kRoomMessageMaxWidth;
|
||||
if (self.isBoom) {
|
||||
width = kRoomMessageMaxWidth - kGetScaleWidth(60);
|
||||
}
|
||||
|
||||
// 通过 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; // 向上取整,避免内容裁切
|
||||
}
|
||||
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.contentLeftMargin);
|
||||
YYTextLayout *textLayout = [YYTextLayout layoutWithContainer:container text:content];
|
||||
|
||||
CGSize textSize = textLayout.textBoundingRect.size;
|
||||
self.textWidth = textSize.width;
|
||||
if ([NSString isEmpty:self.bubbleImageUrl]) {
|
||||
self.rowHeight =
|
||||
ceil(textSize.height) +
|
||||
self.cellBottomMargin +
|
||||
(isMSRTL() ? self.contentTopMargin : (self.isBoom ? 20 : 8));
|
||||
} else {
|
||||
self.rowHeight =
|
||||
ceil(textSize.height) +
|
||||
(isMSRTL() ? self.contentTopMargin : (self.isBoom ? 20 : 8)) +
|
||||
// self.contentBottomMargin +
|
||||
self.cellBottomMargin;
|
||||
}
|
||||
// if ([self.cellKey isEqualToString:@"ChatMessage"]) {
|
||||
self.rowHeight += 10;
|
||||
// }
|
||||
self.rowHeight += (self.isBoom ? 20 : 0);
|
||||
}
|
||||
@end
|
||||
|
@@ -10,7 +10,7 @@
|
||||
#ifndef XPRoomMessageConstant_h
|
||||
#define XPRoomMessageConstant_h
|
||||
|
||||
#define kRoomMessageMaxWidth (KScreenWidth - 15 - 90)
|
||||
#define kRoomMessageMaxWidth (KScreenWidth - 15 - 90 - 8)
|
||||
|
||||
///公屏文本字体的大小
|
||||
static CGFloat kRoomMessageDefalutFont = 15;
|
||||
|
@@ -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;
|
||||
@@ -243,7 +239,7 @@
|
||||
getNick = model.nick;
|
||||
}
|
||||
|
||||
NSString *nick = [NSString stringWithFormat:@"%@:", getNick];
|
||||
NSString * nick = [NSString stringWithFormat:@"%@:", getNick];
|
||||
if ([message.from isEqualToString:uid]) {
|
||||
nick = YMLocalizedString(@"XPRoomMessageParser0");
|
||||
}
|
||||
@@ -251,57 +247,44 @@
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||||
|
||||
///官方新用户
|
||||
if (model.defUser == UserLevelType_Offical || model.newUser) {
|
||||
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:model.defUser newUser:model.newUser fromSayHelloChannel:model.fromSayHelloChannel]];
|
||||
}
|
||||
|
||||
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:model.defUser newUser:model.newUser fromSayHelloChannel:model.fromSayHelloChannel]];
|
||||
if ([self isCurrentRoomSuperAdmin:message.from]) {
|
||||
[attribute appendAttributedString:[self createLanguageImageAttribute:@"common_super_admin"]];
|
||||
}
|
||||
|
||||
if (![NSString isEmpty:model.experUrl]) {
|
||||
messageInfo.experUrl = model.experUrl;
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:model.experUrl]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
|
||||
if (![NSString isEmpty:model.charmUrl]) {//等级
|
||||
messageInfo.charmUrl = model.charmUrl;
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:model.charmUrl]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
|
||||
if (![NSString isEmpty:model.vipIcon]) {
|
||||
messageInfo.vipIcon = model.vipIcon;
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:model.vipIcon]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
if(model.isCustomWord == YES){
|
||||
if (model.inRoomNameplatePic.length > 0){
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
}else{
|
||||
// if (model.inRoomNameplatePic.length > 0 && model.inRoomNameplateWord.length > 0) { //铭牌有图片加文字
|
||||
if (model.inRoomNameplatePic.length > 0) {
|
||||
[attribute appendAttributedString:[self createNameplateAttibute:model.inRoomNameplateWord image:model.inRoomNameplatePic textFont:[UIFont systemFontOfSize:9]]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
// } else if (model.inRoomNameplatePic.length > 0) {//铭牌只有图片
|
||||
// [attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic]];
|
||||
// [attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
// }
|
||||
if (model.inRoomNameplatePic.length > 0) {
|
||||
[attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic
|
||||
size:CGSizeMake(60, kFontRegular(kRoomMessageDefalutFont).lineHeight)]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
}
|
||||
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||||
[attribute appendAttributedString:[self createTextAttribute:nick color:[UIColor colorWithWhite:1 alpha:0.7] font:kRoomMessageDefalutFont]];
|
||||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||||
|
||||
id nickNameNifo = message.remoteExt[@"atNames"];
|
||||
NSMutableAttributedString *msgStr;
|
||||
|
||||
if (message.text) {
|
||||
msgStr = [[NSMutableAttributedString alloc] initWithString:message.text
|
||||
attributes:@{
|
||||
NSFontAttributeName: kFontRegular(kRoomMessageDefalutFont)
|
||||
}];
|
||||
NSMutableAttributedString *msgStr;
|
||||
msgStr = [[NSMutableAttributedString alloc] initWithString:message.text];
|
||||
[msgStr addAttribute:NSForegroundColorAttributeName
|
||||
value:[DJDKMIMOMColor messageTextColor]
|
||||
range:NSMakeRange(0, msgStr.length)];
|
||||
[msgStr addAttribute:NSFontAttributeName
|
||||
value:kFontRegular(kRoomMessageDefalutFont)
|
||||
range:NSMakeRange(0, msgStr.length)];
|
||||
if ([nickNameNifo isKindOfClass:[NSArray class]]) {
|
||||
for (NSString *nick in nickNameNifo) {
|
||||
NSRange range = [message.text rangeOfString:nick];
|
||||
@@ -312,12 +295,12 @@
|
||||
}
|
||||
[attribute appendAttributedString:msgStr];
|
||||
}
|
||||
[self attributeAddLongPressHihtLight:attribute
|
||||
uid:message.from
|
||||
nick:((NIMMessageChatroomExtension *)message.messageExt).roomNickname];
|
||||
|
||||
[self attributeAddLongPressHihtLight:attribute uid:message.from nick:((NIMMessageChatroomExtension *)message.messageExt).roomNickname];
|
||||
|
||||
messageInfo.cellKey = @"ChatMessage";
|
||||
messageInfo.content = attribute;
|
||||
messageInfo.vipIcon = model.vipIcon;
|
||||
|
||||
return messageInfo;
|
||||
}
|
||||
|
||||
@@ -360,9 +343,6 @@
|
||||
case NIMChatroomEventTypeEnter:///进入房间
|
||||
{
|
||||
NSString* nick = member.nick.length > 0 ? member.nick : @"";
|
||||
if ([nick isEqualToString:@"Platform New User"]) {
|
||||
nick = @"";
|
||||
}
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||||
NSDictionary * dic = [(NSDictionary *)messageExt.roomExt.toJSONObject objectForKey:message.from];
|
||||
XPMessageRemoteExtModel * extModel = [XPMessageRemoteExtModel modelWithDictionary:dic];
|
||||
@@ -379,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]];
|
||||
@@ -525,44 +500,50 @@
|
||||
|
||||
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"]){
|
||||
if (!messageInfo.extraSizeArray) {
|
||||
messageInfo.extraSizeArray = @[].mutableCopy;
|
||||
}
|
||||
CGSize placeHolderSize = CGSizeMake(model.width, model.height);
|
||||
[messageInfo.extraSizeArray addObject:[NSValue valueWithCGSize:placeHolderSize]];
|
||||
NSMutableAttributedString *attImage = [self createUrlImageAttribute:model.image size:placeHolderSize];
|
||||
NSMutableAttributedString *attImage = [self createUrlImageAttribute:model.image size:CGSizeMake(model.width, model.height)];
|
||||
[attImage appendAttributedString:[self createSapceAttribute:2]];
|
||||
if ([attribute.string containsString:[NSString stringWithFormat:@"{%@}",model.key]]){
|
||||
[attribute replaceCharactersInRange:[attribute.string rangeOfString:[NSString stringWithFormat:@"{%@}",model.key]] withAttributedString:attImage];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
messageInfo.content = attribute;
|
||||
@@ -825,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];
|
||||
}
|
||||
@@ -1160,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]];
|
||||
}
|
||||
|
||||
@@ -1270,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]];
|
||||
@@ -1374,16 +1355,43 @@
|
||||
|
||||
#pragma mark - private base methods
|
||||
///铭牌
|
||||
- (NSMutableAttributedString *)createNameplateAttibute:(NSString *)tagName image:(NSString *)imageName textFont:(UIFont *)textFont {
|
||||
- (NSMutableAttributedString *)createNameplateAttibute:(NSString *)tagName
|
||||
image:(NSString *)imageName
|
||||
textFont:(UIFont *)textFont {
|
||||
NetImageConfig *config = [[NetImageConfig alloc]init];
|
||||
///先这样吧
|
||||
CGSize defaultSize = CGSizeMake(60, kFontRegular(kRoomMessageDefalutFont).lineHeight);
|
||||
config.autoLoad = YES;
|
||||
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageName config:config];
|
||||
UIImage* image = imageView.image;
|
||||
if (image) {
|
||||
CGFloat scale = image.size.width / image.size.height;
|
||||
imageView.bounds = CGRectMake(0, 0, 18 * scale, 18);
|
||||
} else {
|
||||
NetImageView *imageView = [[NetImageView alloc] initWithUrl:imageName config:config];
|
||||
imageView.bounds = CGRectMake(0, 0, defaultSize.width, defaultSize.height);
|
||||
|
||||
// 异步加载图片
|
||||
// @kWeakify(self);
|
||||
[imageView loadImageWithUrl:imageName completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
|
||||
// @kStrongify(self);
|
||||
if (image) {
|
||||
CGFloat scale = image.size.width / image.size.height;
|
||||
CGSize newSize = scale > 0 ? CGSizeMake(60 * scale, kFontRegular(kRoomMessageDefalutFont).lineHeight) : defaultSize;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
imageView.bounds = CGRectMake(0, 0, newSize.width, newSize.height);
|
||||
});
|
||||
}
|
||||
}];
|
||||
// [imageView loadImageWithUrl:imageName completion:^(UIImage * _Nullable loadedImage) {
|
||||
// @kStrongify(self);
|
||||
// if (loadedImage) {
|
||||
// CGFloat scale = loadedImage.size.width / loadedImage.size.height;
|
||||
// CGSize newSize = scale > 0 ? CGSizeMake(18 * scale, 18) : defaultSize;
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// imageView.bounds = CGRectMake(0, 0, newSize.width, newSize.height);
|
||||
// });
|
||||
// }
|
||||
// }];
|
||||
|
||||
// UIImage* image = imageView.image;
|
||||
// if (image) {
|
||||
// CGFloat scale = image.size.width / image.size.height;
|
||||
// } else {
|
||||
// NSURL *imgUrl = [NSURL URLWithString:imageName];
|
||||
// UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
|
||||
// if (myImage) {
|
||||
@@ -1394,12 +1402,13 @@
|
||||
// imageView.bounds = CGRectMake(0, 0, 18* scale, 18);
|
||||
// }
|
||||
// } else {
|
||||
imageView.bounds = CGRectMake(0, 0, 60, 18);
|
||||
// imageView.bounds = CGRectMake(0, 0, 60, 18);
|
||||
// }
|
||||
}
|
||||
// }
|
||||
|
||||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
// 铭牌文字
|
||||
if ([NSString isEmpty:tagName]) {
|
||||
if (![NSString isEmpty:tagName]) {
|
||||
UILabel *label = [[UILabel alloc] init];
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
label.font = [UIFont boldSystemFontOfSize:12];
|
||||
@@ -1414,7 +1423,11 @@
|
||||
}];
|
||||
}
|
||||
|
||||
NSMutableAttributedString *string = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:imageView.bounds.size alignToFont:[UIFont boldSystemFontOfSize:12] alignment:YYTextVerticalAlignmentCenter];
|
||||
NSMutableAttributedString *string = [NSMutableAttributedString yy_attachmentStringWithContent:imageView
|
||||
contentMode:UIViewContentModeScaleAspectFit
|
||||
attachmentSize:imageView.bounds.size
|
||||
alignToFont:kFontRegular(kRoomMessageDefalutFont)
|
||||
alignment:YYTextVerticalAlignmentCenter];
|
||||
return string;
|
||||
}
|
||||
|
||||
@@ -1429,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;
|
||||
@@ -1462,8 +1475,8 @@
|
||||
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);
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -1476,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;
|
||||
|
||||
}
|
||||
@@ -1487,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;
|
||||
}
|
||||
|
||||
@@ -1512,8 +1525,8 @@
|
||||
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paraStyle.lineSpacing = 4.0f;//行间距
|
||||
// 强制排版(从左到右)
|
||||
paraStyle.alignment = isMSRTL() ? NSTextAlignmentRight : NSTextAlignmentLeft;
|
||||
paraStyle.baseWritingDirection = isMSRTL() ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight;
|
||||
paraStyle.alignment = NSTextAlignmentNatural;
|
||||
paraStyle.baseWritingDirection = isMSRTL() ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight;
|
||||
return paraStyle;
|
||||
}
|
||||
|
||||
@@ -1522,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
|
||||
|
||||
|
@@ -16,31 +16,7 @@
|
||||
if (!attributedText) return;
|
||||
|
||||
NSMutableAttributedString* attributedTextCopy = [attributedText mutableCopy];
|
||||
CGSize maxSize = CGSizeMake(kRoomMessageMaxWidth - 24, MAXFLOAT);
|
||||
// if (isMSRTL()) {
|
||||
// attributedTextCopy.yy_writingDirection = @[@(kCTWritingDirectionRightToLeft)];
|
||||
// }
|
||||
// YYTextLayout * layout = [YYTextLayout layoutWithContainerSize:maxSize text:attributedText];
|
||||
// for (int i = 0; i< layout.attachments.count; i++) {
|
||||
// YYTextAttachment * attachment = [layout.attachments xpSafeObjectAtIndex:i];
|
||||
// if (!attachment || ![attachment.content isKindOfClass:[NetImageView class]]) continue;
|
||||
// NetImageView* imageView = attachment.content;
|
||||
// NSValue * value = [layout.attachmentRanges xpSafeObjectAtIndex:i];
|
||||
// NSRange range = value.rangeValue;
|
||||
// if (!imageView.imageUrl) continue;
|
||||
//
|
||||
// if (imageView.state == NetImageStateLoaded) {
|
||||
// attributedTextCopy = [self updateNetImageAttribute:imageView attributes:attributedTextCopy range:range];
|
||||
// continue;
|
||||
// }else {
|
||||
// [imageView loadImage:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
|
||||
// imageView.image = image;
|
||||
// [super setAttributedText:[self updateNetImageAttribute:imageView attributes:attributedTextCopy range:range]];
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
|
||||
self.maxWidth = maxSize.width - 8;
|
||||
CGSize maxSize = CGSizeMake(kRoomMessageMaxWidth - 24, MAXFLOAT);
|
||||
|
||||
CGSize size = [attributedText boundingRectWithSize:maxSize
|
||||
options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin
|
||||
@@ -49,8 +25,8 @@
|
||||
YYTextContainer *container = [YYTextContainer containerWithSize:CGSizeMake(size.width, MAXFLOAT)];
|
||||
container.truncationType = YYTextTruncationTypeEnd;
|
||||
|
||||
YYTextLayout * layout = [YYTextLayout layoutWithContainerSize:maxSize text:attributedTextCopy];
|
||||
// YYTextLayout * layout = [YYTextLayout layoutWithContainer:container text:attributedText];
|
||||
YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:maxSize
|
||||
text:attributedTextCopy];
|
||||
|
||||
for (NSUInteger i = 0; i < layout.attachments.count; i++) {
|
||||
YYTextAttachment *attachment = [layout.attachments xpSafeObjectAtIndex:i];
|
||||
@@ -69,7 +45,6 @@
|
||||
}
|
||||
|
||||
NSRange range = value.rangeValue;
|
||||
|
||||
if (imageView.state == NetImageStateLoaded) {
|
||||
attributedTextCopy = [self updateNetImageAttribute:imageView
|
||||
attributes:attributedTextCopy
|
||||
@@ -78,7 +53,9 @@
|
||||
@kWeakify(self);
|
||||
[imageView loadImage:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
|
||||
@kStrongify(self);
|
||||
@kWeakify(self);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@kStrongify(self);
|
||||
[self updateImageAndRefresh:imageView
|
||||
attributedText:attributedTextCopy
|
||||
range:range];
|
||||
@@ -87,30 +64,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 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];
|
||||
// continue;
|
||||
// }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]];
|
||||
// }];
|
||||
// }
|
||||
// }
|
||||
|
||||
self.textWidth = layout.textBoundingRect.size.width;
|
||||
[super setAttributedText:attributedTextCopy];
|
||||
[super setAttributedText:attributedTextCopy];
|
||||
}
|
||||
|
||||
- (void)updateImageAndRefresh:(NetImageView *)imageView
|
||||
@@ -118,7 +72,9 @@
|
||||
range:(NSRange)range {
|
||||
if (!imageView || !attributedText) return;
|
||||
imageView.image = imageView.image ?: [UIImage new];
|
||||
NSMutableAttributedString *updatedAttributes = [self updateNetImageAttribute:imageView attributes:attributedText range:range];
|
||||
NSMutableAttributedString *updatedAttributes = [self updateNetImageAttribute:imageView
|
||||
attributes:attributedText
|
||||
range:range];
|
||||
[super setAttributedText:updatedAttributes];
|
||||
}
|
||||
|
||||
@@ -129,37 +85,26 @@
|
||||
return attributes;
|
||||
}
|
||||
|
||||
CGSize size = imageView.bounds.size;
|
||||
if (CGSizeEqualToSize(size, CGSizeZero)) {
|
||||
size = CGSizeMake(kFontRegular(kRoomMessageDefalutFont).lineHeight,
|
||||
kFontRegular(kRoomMessageDefalutFont).lineHeight);
|
||||
}
|
||||
UIImage *image = imageView.image;
|
||||
CGSize size = CGSizeMake(16, 16); // Default size
|
||||
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:[UIFont systemFontOfSize:15.0]
|
||||
alignToFont:kFontRegular(kRoomMessageDefalutFont)
|
||||
alignment:YYTextVerticalAlignmentCenter];
|
||||
[attributes replaceCharactersInRange:range withAttributedString:replaceAttr];
|
||||
return attributes;
|
||||
|
||||
|
||||
// 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(16, 16);
|
||||
// imageView.bounds = CGRectMake(0, 0, 16, 16);
|
||||
// }
|
||||
// NSMutableAttributedString * replaceAttr = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:size alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
// [attributes replaceCharactersInRange:range withAttributedString:replaceAttr];
|
||||
// return attributes;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -53,36 +53,41 @@
|
||||
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);
|
||||
}];
|
||||
} else {
|
||||
[self.bubbleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.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(10);
|
||||
make.centerY.mas_equalTo(self.bubbleView);
|
||||
}];
|
||||
}
|
||||
// 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);
|
||||
make.bottom.mas_equalTo(self).offset(-10);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.mas_equalTo(self).inset(10);
|
||||
make.centerY.mas_equalTo(self.bubbleView);
|
||||
}];
|
||||
}
|
||||
|
||||
///获取头部的高度
|
||||
- (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,24 +35,19 @@
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
if (isMSRTL()) {
|
||||
self.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
|
||||
}
|
||||
[self initSubViews];
|
||||
if ([reuseIdentifier isEqualToString:@"XPRoomMessageTableViewCell_Boom"]) {
|
||||
[self layoutBoom];
|
||||
} else {
|
||||
[self layoutCell];
|
||||
}
|
||||
// TODO:延迟聊天列表的加载时机,在房间信息确认后再加载 / 进房后首次加载可以尝试delay后二次刷新列表
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.clipsToBounds = NO;
|
||||
self.contentView.clipsToBounds = NO;
|
||||
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
[self.contentView addSubview:self.bubbleImageView];
|
||||
[self.contentView addSubview:self.blurEffectView];
|
||||
[self.contentView addSubview:self.contentLabel];
|
||||
@@ -61,85 +56,57 @@
|
||||
self.tapEmptyRecognizer = tap;
|
||||
[self.contentView addGestureRecognizer:self.tapEmptyRecognizer];
|
||||
|
||||
[self.contentView addSubview:self.leftBigImageView];
|
||||
|
||||
}
|
||||
|
||||
- (void)layoutCell {
|
||||
- (void)initSubViewConstraints {
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.contentLabel).offset(-16);
|
||||
make.top.mas_equalTo(self.contentLabel).offset(0);
|
||||
make.bottom.mas_equalTo(self.contentLabel).offset(10);
|
||||
make.trailing.mas_equalTo(self.contentLabel).offset(20);
|
||||
}];
|
||||
|
||||
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(12);
|
||||
make.bottom.mas_equalTo(-20);
|
||||
make.top.mas_equalTo(10);
|
||||
make.width.mas_equalTo(kRoomMessageMaxWidth);
|
||||
}];
|
||||
|
||||
// if (isMSRTL()){
|
||||
// [self.bubbleImageView 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.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.leading.trailing.mas_equalTo(self).inset(15);
|
||||
// make.centerY.mas_equalTo(self.bubbleImageView);
|
||||
// }];
|
||||
// } else {
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.top.mas_equalTo(self);
|
||||
make.width.mas_equalTo(kRoomMessageMaxWidth-10);
|
||||
make.trailing.mas_equalTo(self.contentLabel.mas_trailing).offset(-20);
|
||||
make.bottom.mas_equalTo(self).offset(-10);
|
||||
}];
|
||||
|
||||
[self.blurEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.bubbleImageView);
|
||||
[self.blurEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.bubbleImageView);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setIsLeftBigImage:(BOOL)isLeftBigImage {
|
||||
_isLeftBigImage = isLeftBigImage;
|
||||
if (isLeftBigImage) {
|
||||
[self.contentView addSubview:self.leftBigImageView];
|
||||
[self.leftBigImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(0);
|
||||
make.top.mas_equalTo(6);
|
||||
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(60), kGetScaleWidth(60)));
|
||||
}];
|
||||
|
||||
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self).inset(10);
|
||||
make.trailing.mas_greaterThanOrEqualTo(self.contentView).inset(10);
|
||||
make.centerY.mas_equalTo(self.bubbleImageView);
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.leftBigImageView.mas_centerX);
|
||||
make.top.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(self.leftBigImageView).offset(6);
|
||||
make.trailing.mas_equalTo(-8);
|
||||
}];
|
||||
|
||||
[self.contentLabel mas_remakeConstraints:^(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);
|
||||
}];
|
||||
// }
|
||||
|
||||
return;
|
||||
|
||||
//TODO: 重新理解 layout 方案
|
||||
|
||||
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.contentView);
|
||||
// make.leading.mas_equalTo(12);
|
||||
// make.bottom.mas_equalTo(-20);
|
||||
// make.top.mas_equalTo(10);
|
||||
// if (isMSRTL()) {
|
||||
// make.width.mas_equalTo(20);
|
||||
// }
|
||||
}];
|
||||
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.contentLabel).offset(-12);
|
||||
make.top.mas_equalTo(self.contentLabel).offset(-10);
|
||||
make.bottom.mas_equalTo(self.contentLabel).offset(10);
|
||||
make.trailing.mas_equalTo(self.contentLabel).offset(12);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)layoutBoom {
|
||||
[self.bubbleImageView mas_makeConstraints:^(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));
|
||||
}];
|
||||
|
||||
[self.contentLabel mas_makeConstraints:^(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_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.bubbleImageView);
|
||||
}];
|
||||
self.blurEffectView.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - tool
|
||||
@@ -149,7 +116,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 {
|
||||
@@ -167,91 +135,98 @@
|
||||
[self.delegate xPRoomMessageTableViewCellDidTapEmpty:self];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)clickBtnAction{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setMessageInfo:(XPMessageInfoModel *)messageInfo {
|
||||
if ([messageInfo.content isEqualToAttributedString:_messageInfo.content]) {
|
||||
return;
|
||||
}
|
||||
_messageInfo = messageInfo;
|
||||
if (_messageInfo) {
|
||||
if (messageInfo) {
|
||||
self.contentLabel.attributedText = messageInfo.content;
|
||||
|
||||
if (messageInfo.bubbleImageUrl.length) {
|
||||
@kWeakify(self);
|
||||
[self.bubbleImageView loadImageWithUrl:messageInfo.bubbleImageUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
|
||||
@kStrongify(self);
|
||||
self.blurEffectView.hidden = YES;
|
||||
UIImage *image1 = [UIImage imageWithCGImage:image.CGImage scale:2.0 orientation:UIImageOrientationUp];
|
||||
UIImage *cutImage = [image1 cropRightAndBottomPixels:2];
|
||||
self.bubbleImageView.image = [self resizableImage:cutImage];
|
||||
}];
|
||||
} else {
|
||||
self.blurEffectView.hidden = NO;
|
||||
self.bubbleImageView.image = [UIImage imageWithColor:[DJDKMIMOMColor messageBubbleColor]];
|
||||
}
|
||||
/*
|
||||
// [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.leading.mas_equalTo(self.bubbleImageView).offset(_messageInfo.contentLeftMargin);
|
||||
// make.trailing.mas_equalTo(self.bubbleImageView).offset(-_messageInfo.contentRightMargin);
|
||||
// make.top.mas_equalTo(self.bubbleImageView).offset(_messageInfo.contentTopMargin);
|
||||
// make.bottom.mas_equalTo(self.bubbleImageView).offset(-_messageInfo.contentBottomMargin);
|
||||
// }];
|
||||
|
||||
if (self.isLeftBoomImage) {
|
||||
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.top.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentTopMargin);
|
||||
make.bottom.mas_equalTo(self.bubbleImageView).offset(-self.messageInfo.contentBottomMargin);
|
||||
}];
|
||||
} else {
|
||||
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.bubbleImageView).offset(_messageInfo.contentLeftMargin);
|
||||
// if ([self RTLLabelWidth] <= 300) {
|
||||
// make.width.mas_equalTo([self RTLLabelWidth]);
|
||||
// } else {
|
||||
// make.trailing.mas_equalTo(self.bubbleImageView).offset(-_messageInfo.contentRightMargin);
|
||||
// }
|
||||
make.top.mas_equalTo(self.bubbleImageView).offset(_messageInfo.contentTopMargin);
|
||||
make.bottom.mas_equalTo(self.bubbleImageView).offset(-_messageInfo.contentBottomMargin);
|
||||
}];
|
||||
// [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
// make.leading.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentLeftMargin);
|
||||
// make.top.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentTopMargin);
|
||||
// make.bottom.mas_equalTo(self.bubbleImageView).offset(-self.messageInfo.contentBottomMargin);
|
||||
// if (isMSRTL()) { // MARK: 可能会有性能问题,但源代码已经使用了更新 layout 的方案,推测是头像框和气泡会导致卡顿
|
||||
// make.width.mas_equalTo([self RTLLabelWidth]);
|
||||
//// make.width.mas_equalTo(messageInfo.textWidth);
|
||||
// }
|
||||
// }];
|
||||
[self updateLayout];
|
||||
}
|
||||
*/
|
||||
_bubbleImageView.hidden = _messageInfo.isHiddenBubble;
|
||||
// [self layoutIfNeeded];
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)RTLLabelWidth {
|
||||
return MIN(self.contentLabel.textWidth + 88 + self.messageInfo.contentLeftMargin + self.messageInfo.contentRightMargin, self.contentLabel.maxWidth);
|
||||
- (void)updateLayout {
|
||||
if ([NSString isEmpty:self.messageInfo.bubbleImageUrl]) {
|
||||
[self updateLayoutWithoutBubble];
|
||||
}else {
|
||||
[self updateLayoutWithBubble];
|
||||
}
|
||||
|
||||
[self.contentView setNeedsLayout];
|
||||
[self.contentView layoutIfNeeded];
|
||||
}
|
||||
|
||||
- (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;
|
||||
- (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.cellBottomMargin);
|
||||
// make.width.mas_equalTo([self RTLLabelWidth]);
|
||||
// 设置宽度限制
|
||||
make.width.mas_lessThanOrEqualTo([self RTLLabelWidth]).priority(UILayoutPriorityDefaultHigh); // 优先使用宽度限制
|
||||
make.trailing.mas_lessThanOrEqualTo(self.contentView).offset(-self.messageInfo.contentLeftMargin).priority(UILayoutPriorityRequired); // 当宽度到达边缘时,使用右间距
|
||||
}];
|
||||
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.contentLabel);
|
||||
make.size.mas_equalTo(self.contentLabel).multipliedBy(1.1);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)updateLayoutWithoutBubble {
|
||||
self.blurEffectView.hidden = NO;
|
||||
self.bubbleImageView.image = [UIImage imageWithColor:[DJDKMIMOMColor messageBubbleColor]];
|
||||
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.messageInfo.contentTopMargin);
|
||||
make.bottom.mas_equalTo(-self.messageInfo.cellBottomMargin);
|
||||
make.leading.mas_equalTo(self.messageInfo.contentLeftMargin);
|
||||
// make.width.mas_equalTo([self RTLLabelWidth]);
|
||||
// 设置宽度限制
|
||||
make.width.mas_lessThanOrEqualTo([self RTLLabelWidth]).priority(UILayoutPriorityDefaultHigh); // 优先使用宽度限制
|
||||
// 设置右间距
|
||||
make.trailing.mas_lessThanOrEqualTo(self.contentView).offset(-self.messageInfo.contentLeftMargin).priority(UILayoutPriorityRequired); // 当宽度到达边缘时,使用右间距
|
||||
}];
|
||||
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.bottom.mas_equalTo(self.contentLabel);
|
||||
make.leading.mas_equalTo(self.contentLabel).offset(-self.messageInfo.contentLeftMargin);
|
||||
make.trailing.mas_equalTo(self.contentLabel).offset(self.messageInfo.contentLeftMargin);
|
||||
}];
|
||||
}
|
||||
|
||||
- (CGSize)RTLLabelSize {
|
||||
return [self.contentLabel.attributedText boundingRectWithSize:CGSizeMake(kRoomMessageMaxWidth, 0)
|
||||
options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin
|
||||
context:nil].size;
|
||||
}
|
||||
- (CGFloat)RTLLabelWidth {
|
||||
return MIN(ceil([self RTLLabelSize].width) + self.messageInfo.contentLeftMargin,
|
||||
kRoomMessageMaxWidth - self.messageInfo.contentLeftMargin);
|
||||
}
|
||||
|
||||
- (CGFloat)RTLLabelHeight {
|
||||
return ceil([self RTLLabelSize].height);
|
||||
}
|
||||
|
||||
- (void)setRoomType:(RoomType)roomType {
|
||||
@@ -260,35 +235,18 @@
|
||||
return;
|
||||
}
|
||||
if (_roomType == RoomType_MiniGame) {
|
||||
self.bubbleImageView.image = [UIImage imageWithColor:[UIColor colorWithWhite:1 alpha:0.2]];
|
||||
_bubbleImageView.image = [UIImage imageWithColor:[UIColor colorWithWhite:1 alpha:0.2]];
|
||||
} else {
|
||||
self.bubbleImageView.image = [UIImage imageWithColor:[DJDKMIMOMColor messageBubbleColor]];
|
||||
_bubbleImageView.image = [UIImage imageWithColor:[DJDKMIMOMColor messageBubbleColor]];
|
||||
}
|
||||
}
|
||||
|
||||
- (UIVisualEffectView *)blurEffectView {
|
||||
if (!_blurEffectView) {
|
||||
// 创建模糊效果
|
||||
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; // 选择模糊样式(例如:Light, Dark, ExtraLight 等)
|
||||
|
||||
// 创建包含模糊效果的视图
|
||||
_blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
|
||||
|
||||
// 设置模糊视图的大小与目标视图一致
|
||||
_blurEffectView.frame = CGRectMake(0, 0, KScreenWidth, 200);
|
||||
_blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; // 使模糊视图适应目标视图的尺寸变化
|
||||
_blurEffectView.hidden = YES;
|
||||
}
|
||||
return _blurEffectView;
|
||||
}
|
||||
|
||||
|
||||
- (NetImageView *)bubbleImageView {
|
||||
if (!_bubbleImageView) {
|
||||
_bubbleImageView = [[NetImageView alloc] init];
|
||||
_bubbleImageView.clipsToBounds = NO;
|
||||
_bubbleImageView.userInteractionEnabled = YES;
|
||||
_bubbleImageView.layer.masksToBounds = YES;
|
||||
_bubbleImageView.layer.cornerRadius = 7;
|
||||
[_bubbleImageView setCornerRadius:8];
|
||||
}
|
||||
return _bubbleImageView;
|
||||
}
|
||||
@@ -305,7 +263,7 @@
|
||||
- (XPNetImageYYLabel *)contentLabel {
|
||||
if (!_contentLabel) {
|
||||
_contentLabel = [[XPNetImageYYLabel alloc] init];
|
||||
_contentLabel.preferredMaxLayoutWidth = kRoomMessageMaxWidth - 24;
|
||||
_contentLabel.preferredMaxLayoutWidth = kRoomMessageMaxWidth ;
|
||||
_contentLabel.numberOfLines = 0;
|
||||
_contentLabel.userInteractionEnabled = YES;
|
||||
}
|
||||
@@ -319,4 +277,19 @@
|
||||
}
|
||||
return _clickBtn;
|
||||
}
|
||||
|
||||
- (UIVisualEffectView *)blurEffectView {
|
||||
if (!_blurEffectView) {
|
||||
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
|
||||
_blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
|
||||
|
||||
// 设置模糊视图的大小与目标视图一致
|
||||
_blurEffectView.frame = CGRectMake(0, 0, KScreenWidth*2/3, 200);
|
||||
_blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
_blurEffectView.hidden = YES;
|
||||
|
||||
[_blurEffectView setCornerRadius:8];
|
||||
}
|
||||
return _blurEffectView;
|
||||
}
|
||||
@end
|
||||
|
@@ -45,8 +45,6 @@
|
||||
#import "SDPhotoBrowser.h"
|
||||
#import "XPSkillCardPlayerManager.h"
|
||||
|
||||
#import "RoomCahtCell.h"
|
||||
|
||||
// Boom
|
||||
#import "BoomInfoModel.h"
|
||||
|
||||
@@ -84,10 +82,6 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
@property(nonatomic,assign) BOOL isLoadHistoryMessage;
|
||||
|
||||
@property (nonatomic, assign) NSInteger displayType;
|
||||
|
||||
@property (nonatomic, strong) NSMutableDictionary<NSIndexPath *, NSNumber *> *heightCache;
|
||||
@property (nonatomic, strong) NSMutableDictionary<NSIndexPath *, NSNumber *> *heightCache_2;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -100,8 +94,6 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.heightCache = @{}.mutableCopy;
|
||||
self.heightCache_2 = @{}.mutableCopy;
|
||||
self.displayType = 1;
|
||||
self.isLoadHistoryMessage = YES;
|
||||
self.hostDelegate = delegate;
|
||||
@@ -112,8 +104,10 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
}
|
||||
|
||||
- (void)changeType:(NSInteger)type {
|
||||
if (self.displayType == type) {
|
||||
return;
|
||||
}
|
||||
self.displayType = type;
|
||||
[self updateAllDataSource];
|
||||
[self.messageTableView reloadData];
|
||||
|
||||
if (self.displayType == 1) {
|
||||
@@ -127,11 +121,15 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
});
|
||||
}
|
||||
|
||||
- (void)updateAllDataSource {
|
||||
self.datasource_chat = @[].mutableCopy;
|
||||
self.datasource_gift = @[].mutableCopy;
|
||||
|
||||
for (XPMessageInfoModel *model in self.datasource) {
|
||||
/// 更新其他 tag 的数据源,若传入空数组,则初始化并从 datasource 中获取数据
|
||||
- (void)updateAllDataSource:(NSArray *)datas {
|
||||
if (!datas || datas.count == 0) {
|
||||
self.datasource_chat = @[].mutableCopy;
|
||||
self.datasource_gift = @[].mutableCopy;
|
||||
datas = self.datasource;
|
||||
}
|
||||
|
||||
for (XPMessageInfoModel *model in datas) {
|
||||
switch (model.first) {
|
||||
case NIMMessageTypeText:
|
||||
[self.datasource_chat addObject:model];
|
||||
@@ -168,123 +166,295 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
|
||||
///追加数据源
|
||||
- (void)appendAndScrollToAtUser {
|
||||
if (self.incomingMessages.count < 1) {
|
||||
NSInteger rows = self.datasource.count;
|
||||
if (!self.locationArray.count) {
|
||||
[self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
self.messageTipsBtn.hidden = YES;
|
||||
self.isPending = NO;
|
||||
self.atCount = 0;
|
||||
self.atTipBtn.hidden = YES;
|
||||
// 1. 检查 incomingMessages 是否为空
|
||||
if (self.incomingMessages.count < 1) {
|
||||
NSInteger rows = self.datasource.count;
|
||||
|
||||
// 2. 安全检查 locationArray 是否为空
|
||||
if (self.locationArray.count == 0) {
|
||||
[self scrollToBottomWithTipsHidden:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 获取首个 @ 消息的索引,并进行安全检查
|
||||
int index = [self safeGetIndexFromLocationArrayAt:0];
|
||||
if (index == NSNotFound) {
|
||||
[self scrollToBottomWithTipsHidden:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
|
||||
if (rows > indexPath.row) {
|
||||
[self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
if (rows == indexPath.row + 1) {
|
||||
self.messageTipsBtn.hidden = YES;
|
||||
self.isPending = NO;
|
||||
}
|
||||
} else {
|
||||
[self scrollToBottomWithTipsHidden:YES];
|
||||
}
|
||||
|
||||
[self safelyRemoveLocationAtIndex:0];
|
||||
[self updateAtTipButton];
|
||||
return;
|
||||
}
|
||||
int index = [self.locationArray[0] intValue];
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
|
||||
if (rows > indexPath.row) {
|
||||
[self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
if (rows == indexPath.row + 1) {
|
||||
self.messageTipsBtn.hidden = YES;
|
||||
self.isPending = NO;
|
||||
}
|
||||
} else {
|
||||
[self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
//滚动到底部时隐藏@提示
|
||||
self.messageTipsBtn.hidden = YES;
|
||||
}
|
||||
if (self.locationArray.count) {
|
||||
[self.locationArray removeObjectAtIndex:0];
|
||||
self.atCount -= 1;
|
||||
[self.atTipBtn setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageContainerView0"), (unsigned long)self.locationArray.count] forState:UIControlStateNormal];
|
||||
if (self.locationArray.count == 0) {
|
||||
self.atTipBtn.hidden = YES;
|
||||
}
|
||||
} else {
|
||||
self.atTipBtn.hidden = YES;
|
||||
}
|
||||
} else {
|
||||
|
||||
// 4. 超长消息处理逻辑
|
||||
if (self.datasource.count > kRoomMessageMaxLength) {
|
||||
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
||||
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
||||
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||
[self updateAllDataSource];
|
||||
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
|
||||
for (int i = 0; i<self.locationArray.count; i++) {///移除掉前面消息的数据后,前面如果有at我的消息,也一并移除掉
|
||||
NSNumber *number = self.locationArray[i];
|
||||
if (number.integerValue < kRoomMessageMaxLength / 2) {
|
||||
self.atCount--;
|
||||
[indexSet addIndex:i];
|
||||
}
|
||||
}
|
||||
[self.locationArray removeObjectsAtIndexes:indexSet];
|
||||
for (int i = 0; i<self.locationArray.count; i++) {//移除前面的at消息后,后面的at消息需要更新索引
|
||||
NSNumber *number = self.locationArray[i];
|
||||
number = @(number.integerValue - kRoomMessageMaxLength / 2);
|
||||
[self.locationArray replaceObjectAtIndex:i withObject:number];
|
||||
}
|
||||
NSInteger removedCount = kRoomMessageMaxLength / 2;
|
||||
[self safelyRemoveMessages:removedCount];
|
||||
}
|
||||
|
||||
// 执行插入
|
||||
NSMutableArray *indexPaths = [NSMutableArray array];
|
||||
// 5. 插入新消息
|
||||
NSMutableArray *indexPaths = @[].mutableCopy;
|
||||
NSMutableArray *tempNewDatas = @[].mutableCopy;
|
||||
for (id item in self.incomingMessages) {
|
||||
XPMessageInfoModel *model = nil;
|
||||
if ([item isKindOfClass:[NIMMessage class]]) {
|
||||
model = [self.messageParser parseMessageAttribute:item];
|
||||
} else if ([item isKindOfClass:[NIMBroadcastMessage class]]) {
|
||||
model = [self.messageParser parseBroadcastMessageAttribute:item];
|
||||
}
|
||||
if (!model) {
|
||||
continue;
|
||||
}
|
||||
XPMessageInfoModel *model = [self parseMessage:item];
|
||||
if (!model) continue;
|
||||
|
||||
[tempNewDatas addObject:model];
|
||||
[self.datasource addObject:model];
|
||||
[indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
|
||||
if ([item isKindOfClass:[NIMMessage class]]) {
|
||||
id nickNameInfos = [(NIMMessage*)item remoteExt][@"atUids"];
|
||||
if ([nickNameInfos isKindOfClass:[NSArray class]]) {
|
||||
for (NSString *nick in nickNameInfos) {
|
||||
if ([nick isEqualToString:[AccountInfoStorage instance].getUid]) {
|
||||
[self.locationArray addObject:@(self.datasource.count-1)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[self processAtMentionsForMessage:item];
|
||||
}
|
||||
[self updateAllDataSource];
|
||||
[self updateAllDataSource:tempNewDatas];
|
||||
[self.incomingMessages removeAllObjects];
|
||||
[self.messageTableView reloadData];
|
||||
|
||||
NSInteger rows = self.datasource.count;
|
||||
if (!self.locationArray.count) {
|
||||
[self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
self.messageTipsBtn.hidden = YES;
|
||||
self.isPending = NO;
|
||||
self.atCount = 0;
|
||||
self.atTipBtn.hidden = YES;
|
||||
return;
|
||||
}
|
||||
int index = [self.locationArray[0] intValue];
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
|
||||
if (rows > indexPath.row) {
|
||||
[self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
if (rows == indexPath.row + 1) {
|
||||
self.messageTipsBtn.hidden = YES;
|
||||
self.isPending = NO;
|
||||
}
|
||||
} else {
|
||||
[self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
//滚动到底部时隐藏@提示
|
||||
self.messageTipsBtn.hidden = YES;
|
||||
}
|
||||
if (self.locationArray.count) {
|
||||
[self.locationArray removeObjectAtIndex:0];
|
||||
self.atCount -= 1;
|
||||
[self.atTipBtn setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageContainerView1"), (unsigned long)self.locationArray.count] forState:UIControlStateNormal];
|
||||
if (self.locationArray.count == 0) {
|
||||
self.atTipBtn.hidden = YES;
|
||||
}
|
||||
} else {
|
||||
self.atTipBtn.hidden = YES;
|
||||
// 6. 滚动到指定位置或底部
|
||||
[self scrollToFirstLocationOrBottom];
|
||||
|
||||
// if (self.incomingMessages.count < 1) {
|
||||
// NSInteger rows = self.datasource.count;
|
||||
// if (!self.locationArray.count) {
|
||||
// [self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
// self.messageTipsBtn.hidden = YES;
|
||||
// self.isPending = NO;
|
||||
// self.atCount = 0;
|
||||
// self.atTipBtn.hidden = YES;
|
||||
// return;
|
||||
// }
|
||||
// int index = [self.locationArray[0] intValue];
|
||||
// NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
|
||||
// if (rows > indexPath.row) {
|
||||
// [self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
// if (rows == indexPath.row + 1) {
|
||||
// self.messageTipsBtn.hidden = YES;
|
||||
// self.isPending = NO;
|
||||
// }
|
||||
// } else {
|
||||
// [self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
// //滚动到底部时隐藏@提示
|
||||
// self.messageTipsBtn.hidden = YES;
|
||||
// }
|
||||
// if (self.locationArray.count) {
|
||||
// [self.locationArray removeObjectAtIndex:0];
|
||||
// self.atCount -= 1;
|
||||
// [self.atTipBtn setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageContainerView0"), (unsigned long)self.locationArray.count] forState:UIControlStateNormal];
|
||||
// if (self.locationArray.count == 0) {
|
||||
// self.atTipBtn.hidden = YES;
|
||||
// }
|
||||
// } else {
|
||||
// self.atTipBtn.hidden = YES;
|
||||
// }
|
||||
// } else {
|
||||
// if (self.datasource.count > kRoomMessageMaxLength) {
|
||||
// NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
||||
// NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
||||
// [self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||
// [self updateAllDataSource:nil];
|
||||
// NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
|
||||
// for (int i = 0; i<self.locationArray.count; i++) {///移除掉前面消息的数据后,前面如果有at我的消息,也一并移除掉
|
||||
// NSNumber *number = self.locationArray[i];
|
||||
// if (number.integerValue < kRoomMessageMaxLength / 2) {
|
||||
// self.atCount--;
|
||||
// [indexSet addIndex:i];
|
||||
// }
|
||||
// }
|
||||
// [self.locationArray removeObjectsAtIndexes:indexSet];
|
||||
// for (int i = 0; i<self.locationArray.count; i++) {//移除前面的at消息后,后面的at消息需要更新索引
|
||||
// NSNumber *number = self.locationArray[i];
|
||||
// number = @(number.integerValue - kRoomMessageMaxLength / 2);
|
||||
// [self.locationArray replaceObjectAtIndex:i withObject:number];
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 执行插入
|
||||
// NSMutableArray *indexPaths = @[].mutableCopy;
|
||||
// NSMutableArray *tempNewDatas = @[].mutableCopy;
|
||||
// for (id item in self.incomingMessages) {
|
||||
// XPMessageInfoModel *model = nil;
|
||||
// if ([item isKindOfClass:[NIMMessage class]]) {
|
||||
// model = [self.messageParser parseMessageAttribute:item];
|
||||
// } else if ([item isKindOfClass:[NIMBroadcastMessage class]]) {
|
||||
// model = [self.messageParser parseBroadcastMessageAttribute:item];
|
||||
// }
|
||||
// if (!model) {
|
||||
// continue;
|
||||
// }
|
||||
// [tempNewDatas addObject:model];
|
||||
// [self.datasource addObject:model];
|
||||
// [indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
|
||||
// if ([item isKindOfClass:[NIMMessage class]]) {
|
||||
// id nickNameInfos = [(NIMMessage*)item remoteExt][@"atUids"];
|
||||
// if ([nickNameInfos isKindOfClass:[NSArray class]]) {
|
||||
// for (NSString *nick in nickNameInfos) {
|
||||
// if ([nick isEqualToString:[AccountInfoStorage instance].getUid]) {
|
||||
// [self.locationArray addObject:@(self.datasource.count-1)];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// [self updateAllDataSource:tempNewDatas];
|
||||
// [self.incomingMessages removeAllObjects];
|
||||
// [self.messageTableView reloadData];
|
||||
//
|
||||
// NSInteger rows = self.datasource.count;
|
||||
// if (!self.locationArray.count) {
|
||||
// [self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
// self.messageTipsBtn.hidden = YES;
|
||||
// self.isPending = NO;
|
||||
// self.atCount = 0;
|
||||
// self.atTipBtn.hidden = YES;
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// int index = [self.locationArray[0] intValue];
|
||||
// NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
|
||||
// if (rows > indexPath.row) {
|
||||
// [self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
// if (rows == indexPath.row + 1) {
|
||||
// self.messageTipsBtn.hidden = YES;
|
||||
// self.isPending = NO;
|
||||
// }
|
||||
// } else {
|
||||
// [self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
// //滚动到底部时隐藏@提示
|
||||
// self.messageTipsBtn.hidden = YES;
|
||||
// }
|
||||
// if (self.locationArray.count) {
|
||||
// [self.locationArray removeObjectAtIndex:0];
|
||||
// self.atCount -= 1;
|
||||
// [self.atTipBtn setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageContainerView1"), (unsigned long)self.locationArray.count] forState:UIControlStateNormal];
|
||||
// if (self.locationArray.count == 0) {
|
||||
// self.atTipBtn.hidden = YES;
|
||||
// }
|
||||
// } else {
|
||||
// self.atTipBtn.hidden = YES;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
- (void)scrollToBottomWithTipsHidden:(BOOL)hidden {
|
||||
NSInteger rows = self.datasource.count;
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:(rows - 1) inSection:0];
|
||||
[self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
self.messageTipsBtn.hidden = hidden;
|
||||
self.isPending = NO;
|
||||
self.atCount = 0;
|
||||
self.atTipBtn.hidden = hidden;
|
||||
}
|
||||
|
||||
- (void)updateLocationArrayForMessageRemoval:(NSInteger)removedCount {
|
||||
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
|
||||
for (int i = 0; i < self.locationArray.count; i++) {
|
||||
NSNumber *number = self.locationArray[i];
|
||||
if (number.integerValue < removedCount) {
|
||||
self.atCount--;
|
||||
[indexSet addIndex:i];
|
||||
}
|
||||
}
|
||||
[self.locationArray removeObjectsAtIndexes:indexSet];
|
||||
for (int i = 0; i < self.locationArray.count; i++) {
|
||||
NSNumber *number = self.locationArray[i];
|
||||
self.locationArray[i] = @(number.integerValue - removedCount);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateAtTipButton {
|
||||
if (self.locationArray.count == 0) {
|
||||
self.atTipBtn.hidden = YES;
|
||||
} else {
|
||||
[self.atTipBtn setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageContainerView0"), (unsigned long)self.locationArray.count] forState:UIControlStateNormal];
|
||||
self.atTipBtn.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (int)safeGetIndexFromLocationArrayAt:(NSUInteger)index {
|
||||
if (index < self.locationArray.count) {
|
||||
NSNumber *number = self.locationArray[index];
|
||||
return [number intValue];
|
||||
}
|
||||
return NSNotFound; // 返回一个无效值,避免崩溃
|
||||
}
|
||||
|
||||
- (void)safelyRemoveLocationAtIndex:(NSUInteger)index {
|
||||
if (index < self.locationArray.count) {
|
||||
[self.locationArray removeObjectAtIndex:index];
|
||||
self.atCount = MAX(0, self.atCount - 1);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)safelyRemoveMessages:(NSInteger)count {
|
||||
if (self.datasource.count >= count) {
|
||||
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, count)];
|
||||
[self.datasource removeObjectsAtIndexes:set];
|
||||
[self updateAllDataSource:nil];
|
||||
|
||||
// 更新 locationArray
|
||||
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
|
||||
for (NSUInteger i = 0; i < self.locationArray.count; i++) {
|
||||
NSNumber *number = self.locationArray[i];
|
||||
if (number.integerValue < count) {
|
||||
[indexSet addIndex:i];
|
||||
} else {
|
||||
self.locationArray[i] = @(number.integerValue - count);
|
||||
}
|
||||
}
|
||||
[self.locationArray removeObjectsAtIndexes:indexSet];
|
||||
}
|
||||
}
|
||||
|
||||
- (XPMessageInfoModel *)parseMessage:(id)item {
|
||||
if ([item isKindOfClass:[NIMMessage class]]) {
|
||||
return [self.messageParser parseMessageAttribute:item];
|
||||
} else if ([item isKindOfClass:[NIMBroadcastMessage class]]) {
|
||||
return [self.messageParser parseBroadcastMessageAttribute:item];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)processAtMentionsForMessage:(id)item {
|
||||
if ([item isKindOfClass:[NIMMessage class]]) {
|
||||
NSArray *nickNameInfos = [(NIMMessage *)item remoteExt][@"atUids"];
|
||||
if ([nickNameInfos isKindOfClass:[NSArray class]]) {
|
||||
for (NSString *nick in nickNameInfos) {
|
||||
if ([nick isEqualToString:[AccountInfoStorage instance].getUid]) {
|
||||
[self.locationArray addObject:@(self.datasource.count - 1)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)scrollToFirstLocationOrBottom {
|
||||
NSInteger rows = self.datasource.count;
|
||||
if (self.locationArray.count == 0) {
|
||||
[self scrollToBottomWithTipsHidden:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
int index = [self safeGetIndexFromLocationArrayAt:0];
|
||||
if (index == NSNotFound || index >= rows) {
|
||||
[self scrollToBottomWithTipsHidden:YES];
|
||||
} else {
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
|
||||
[self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
|
||||
[self safelyRemoveLocationAtIndex:0];
|
||||
}
|
||||
[self updateAtTipButton];
|
||||
}
|
||||
|
||||
#pragma mark - @我
|
||||
@@ -314,6 +484,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.clipsToBounds = YES;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addCustomMessage:) name:@"message" object:nil];
|
||||
[self addSubview:self.messageTableView];
|
||||
[self addSubview:self.messageTipsBtn];
|
||||
@@ -331,7 +502,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
}];
|
||||
|
||||
[self.messageTipsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_greaterThanOrEqualTo(100);
|
||||
make.width.mas_equalTo(100);
|
||||
make.height.mas_equalTo(30);
|
||||
make.bottom.mas_equalTo(self.mas_bottom).offset(-5);
|
||||
make.leading.mas_equalTo(self);
|
||||
@@ -366,6 +537,20 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
if(self.isLoadHistoryMessage == YES)return;
|
||||
[self.incomingMessages addObject:messageData];
|
||||
|
||||
NSInteger messageCount = 0;
|
||||
switch (self.displayType) {
|
||||
case 1:
|
||||
messageCount = self.datasource.count;
|
||||
break;
|
||||
case 2:
|
||||
messageCount = self.datasource_chat.count;
|
||||
break;
|
||||
case 3:
|
||||
messageCount = self.datasource_gift.count;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ([messageData isKindOfClass:[NIMBroadcastMessage class]]) {
|
||||
NIMBroadcastMessage *broadcastMessage = (NIMBroadcastMessage *)messageData;
|
||||
[[XPRoomMiniManager shareManager] saveRoomMessage:broadcastMessage];
|
||||
@@ -388,6 +573,19 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
}
|
||||
|
||||
if (self.isPending) {
|
||||
// switch (self.displayType) {
|
||||
// case 1:
|
||||
// self.messageTipsBtn.hidden = self.datasource.count == messageCount;
|
||||
// break;
|
||||
// case 2:
|
||||
// self.messageTipsBtn.hidden = self.datasource_chat.count == messageCount;
|
||||
// break;
|
||||
// case 3:
|
||||
// self.messageTipsBtn.hidden = self.datasource_gift.count == messageCount;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
self.messageTipsBtn.hidden = NO;
|
||||
[self findAtMeNumber];
|
||||
} else {
|
||||
@@ -409,23 +607,26 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||
}
|
||||
|
||||
|
||||
NSMutableArray *tempArray = @[].mutableCopy;
|
||||
@kWeakify(self);
|
||||
[self.incomingMessages enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
@kStrongify(self);
|
||||
id model = nil;
|
||||
if ([obj isKindOfClass:[NIMMessage class]]) {
|
||||
XPMessageInfoModel *model = [self.messageParser parseMessageAttribute:(NIMMessage *)obj];
|
||||
[self.datasource addObject:model];
|
||||
model = [self.messageParser parseMessageAttribute:(NIMMessage *)obj];
|
||||
} else if ([obj isKindOfClass:[NIMBroadcastMessage class]]) {
|
||||
XPMessageInfoModel *model = [self.messageParser parseBroadcastMessageAttribute:(NIMBroadcastMessage *)obj];
|
||||
if (model) {
|
||||
[self.datasource addObject:model];
|
||||
}
|
||||
model = [self.messageParser parseBroadcastMessageAttribute:(NIMBroadcastMessage *)obj];
|
||||
}
|
||||
if (model) {
|
||||
[tempArray addObject:model];
|
||||
[self.datasource addObject:model];
|
||||
}
|
||||
}];
|
||||
|
||||
[self updateAllDataSource];
|
||||
|
||||
[self.incomingMessages removeAllObjects];
|
||||
|
||||
[self updateAllDataSource:tempArray];
|
||||
[self.messageTableView reloadData];
|
||||
|
||||
//执行插入动画并滚动
|
||||
@@ -750,9 +951,10 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
||||
if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) {
|
||||
if (attachment.first == CustomMessageType_Update_RoomInfo &&
|
||||
attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) {
|
||||
[self.datasource removeAllObjects];
|
||||
[self updateAllDataSource];
|
||||
[self updateAllDataSource:nil];
|
||||
[self.incomingMessages removeAllObjects];
|
||||
[self.locationArray removeAllObjects];
|
||||
self.atCount = 0;
|
||||
@@ -762,9 +964,10 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
||||
[self addRoomMessage:message];
|
||||
return;
|
||||
} else if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_CleanScreen) {
|
||||
} else if (attachment.first == CustomMessageType_Update_RoomInfo &&
|
||||
attachment.second == Custom_Message_Sub_Update_RoomInfo_CleanScreen) {
|
||||
[self.datasource removeAllObjects];
|
||||
[self updateAllDataSource];
|
||||
[self updateAllDataSource:nil];
|
||||
[self.incomingMessages removeAllObjects];
|
||||
[self.locationArray removeAllObjects];
|
||||
self.atCount = 0;
|
||||
@@ -774,7 +977,8 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
||||
[self addRoomMessage:message];
|
||||
return;
|
||||
} else if(attachment.first == CustomMessageType_Candy_Tree && attachment.second == Custom_Message_Sub_Candy_Tree_Me) {
|
||||
} else if(attachment.first == CustomMessageType_Candy_Tree &&
|
||||
attachment.second == Custom_Message_Sub_Candy_Tree_Me) {
|
||||
CandyTreeGiftInfoModel * model = [CandyTreeGiftInfoModel modelWithDictionary:attachment.data];
|
||||
if (model.uid.integerValue != [AccountInfoStorage instance].getUid.integerValue) {
|
||||
return;
|
||||
@@ -866,6 +1070,50 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleFetchNewestMessage:(NIMMessage *)message {
|
||||
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
||||
NSString *roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
|
||||
NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init];
|
||||
option.limit = [ClientConfig shareConfig].configInfo.roomMessageCount;
|
||||
option.order = NIMMessageSearchOrderDesc;
|
||||
option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeCustom)];
|
||||
@kWeakify(self);
|
||||
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId
|
||||
option:option
|
||||
result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
|
||||
@kStrongify(self);
|
||||
if(error != nil){
|
||||
self.isLoadHistoryMessage = NO;
|
||||
}
|
||||
if (self.datasource.count > kRoomMessageMaxLength) {
|
||||
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
||||
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
||||
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||
}
|
||||
// 执行插入
|
||||
for (NIMMessage *item in messages.reverseObjectEnumerator) {
|
||||
[self dealWithHistoryDataWithMessage:item];
|
||||
}
|
||||
self.isLoadHistoryMessage = NO;
|
||||
BOOL hideEnter = [self handleHideEnter:message];
|
||||
if (!hideEnter) {
|
||||
///插入进房消息及房间公告提示
|
||||
[self addRoomMessage:message];
|
||||
}
|
||||
if (!roomInfo.hasAnimationEffect) {
|
||||
[self roomInfoNoGiftAnimationMessage:message];
|
||||
}
|
||||
[self createUserEnterRoomAddRoomTopicMessage];
|
||||
|
||||
[self updateAllDataSource:nil];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.messageTableView reloadData];
|
||||
[self scrollToBottom:YES];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)handleFetchHistoryMessage:(NIMMessage *)message {
|
||||
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
||||
NSString *roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
|
||||
@@ -874,79 +1122,45 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
option.startTime = self.hostDelegate.getRoomInfo.clearScreenTime / 1000.0;
|
||||
option.order = NIMMessageSearchOrderAsc;
|
||||
option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeCustom)];
|
||||
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
|
||||
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId
|
||||
option:option
|
||||
result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
|
||||
if(error != nil){
|
||||
self.isLoadHistoryMessage = NO;
|
||||
}
|
||||
if (messages.count) {
|
||||
//如果拉取的数量等于请求的数量,说明这个时间点以后的消息数量大于等于需要拉取的数量,直接拉取最新的50条
|
||||
if (messages.count == [ClientConfig shareConfig].configInfo.roomMessageCount) {
|
||||
NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init];
|
||||
option.limit = [ClientConfig shareConfig].configInfo.roomMessageCount;
|
||||
option.order = NIMMessageSearchOrderDesc;
|
||||
option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeCustom)];
|
||||
@kWeakify(self);
|
||||
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
|
||||
@kStrongify(self);
|
||||
if(error != nil){
|
||||
self.isLoadHistoryMessage = NO;
|
||||
}
|
||||
if (self.datasource.count > kRoomMessageMaxLength) {
|
||||
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
||||
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
||||
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||
}
|
||||
// 执行插入
|
||||
for (NIMMessage *item in messages.reverseObjectEnumerator) {
|
||||
[self dealWithHistoryDataWithMessage:item];
|
||||
}
|
||||
self.isLoadHistoryMessage = NO;
|
||||
BOOL hideEnter = [self handleHideEnter:message];
|
||||
if (!hideEnter) {
|
||||
///插入进房消息及房间公告提示
|
||||
[self addRoomMessage:message];
|
||||
}
|
||||
if (!roomInfo.hasAnimationEffect) {
|
||||
[self roomInfoNoGiftAnimationMessage:message];
|
||||
}
|
||||
[self createUserEnterRoomAddRoomTopicMessage];
|
||||
[self handleFetchNewestMessage:message];
|
||||
} else {
|
||||
if (self.datasource.count > kRoomMessageMaxLength) {
|
||||
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
||||
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
||||
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||
}
|
||||
// 执行插入
|
||||
for (NIMMessage *item in messages) {
|
||||
[self dealWithHistoryDataWithMessage:item];
|
||||
}
|
||||
|
||||
[self updateAllDataSource];
|
||||
self.isLoadHistoryMessage = NO;
|
||||
BOOL hideEnter = [self handleHideEnter:message];
|
||||
if (!hideEnter) {
|
||||
///插入进房消息及房间公告提示
|
||||
[self addRoomMessage:message];
|
||||
}
|
||||
if (!roomInfo.hasAnimationEffect) {
|
||||
[self roomInfoNoGiftAnimationMessage:message];
|
||||
}
|
||||
[self createUserEnterRoomAddRoomTopicMessage];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.messageTableView reloadData];
|
||||
[self scrollToBottom:YES];
|
||||
});
|
||||
}];
|
||||
return;
|
||||
}
|
||||
if (self.datasource.count > kRoomMessageMaxLength) {
|
||||
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
||||
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
||||
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||
}
|
||||
// 执行插入
|
||||
for (NIMMessage *item in messages) {
|
||||
[self dealWithHistoryDataWithMessage:item];
|
||||
}
|
||||
[self updateAllDataSource:nil];
|
||||
|
||||
self.isLoadHistoryMessage = NO;
|
||||
BOOL hideEnter = [self handleHideEnter:message];
|
||||
if (!hideEnter) {
|
||||
///插入进房消息及房间公告提示
|
||||
[self addRoomMessage:message];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.messageTableView reloadData];
|
||||
[self scrollToBottom:YES];
|
||||
});
|
||||
}
|
||||
if (!roomInfo.hasAnimationEffect) {
|
||||
[self roomInfoNoGiftAnimationMessage:message];
|
||||
}
|
||||
[self createUserEnterRoomAddRoomTopicMessage];
|
||||
|
||||
[self updateAllDataSource];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.messageTableView reloadData];
|
||||
[self scrollToBottom:YES];
|
||||
});
|
||||
}else{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{///回到主线程
|
||||
self.isLoadHistoryMessage = NO;
|
||||
@@ -961,6 +1175,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
[self createUserEnterRoomAddRoomTopicMessage];
|
||||
});
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
-(void)dealWithHistoryDataWithMessage:(NIMMessage *)item{
|
||||
@@ -974,6 +1189,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
if (attachment.first == CustomMessageType_Room_Album && attachment.second == Custom_Message_Sub_Room_Album) {
|
||||
isHaveSave = YES;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(isHaveSave == NO)return;
|
||||
@@ -1015,20 +1231,22 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
self.isLoadHistoryMessage = NO;
|
||||
///最小化进房 不需要请求任何接口 但是如果不加延迟的话 无法滚动到底部 原因还不知道
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
NSMutableArray *tempArray = @[].mutableCopy;
|
||||
NSArray * temArray = [XPRoomMiniManager shareManager].getLocalCurrentRoomMessage;
|
||||
[temArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
id model = nil;
|
||||
if ([obj isKindOfClass:[NIMMessage class]]) {
|
||||
XPMessageInfoModel *model = [self.messageParser parseMessageAttribute:(NIMMessage *)obj];
|
||||
[self.datasource addObject:model];
|
||||
model = [self.messageParser parseMessageAttribute:(NIMMessage *)obj];
|
||||
} else if ([obj isKindOfClass:[NIMBroadcastMessage class]]) {
|
||||
XPMessageInfoModel *model = [self.messageParser parseBroadcastMessageAttribute:(NIMBroadcastMessage *)obj];
|
||||
if (model) {
|
||||
[self.datasource addObject:model];
|
||||
}
|
||||
model = [self.messageParser parseBroadcastMessageAttribute:(NIMBroadcastMessage *)obj];
|
||||
}
|
||||
if (model) {
|
||||
[tempArray addObject:model];
|
||||
[self.datasource addObject:model];
|
||||
}
|
||||
}];
|
||||
|
||||
[self updateAllDataSource];
|
||||
[self updateAllDataSource:tempArray];
|
||||
[self.messageTableView reloadData];
|
||||
//执行插入动画并滚动
|
||||
[self scrollToBottom:YES];
|
||||
@@ -1036,7 +1254,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
}
|
||||
|
||||
- (void)onRoomEntered {
|
||||
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
||||
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
||||
self.headerView.bubbleColor = self.hostDelegate.getRoomInfo.type == RoomType_MiniGame ? [UIColor colorWithWhite:1 alpha:0.2] : [UIColor colorWithWhite:1 alpha:0.3];
|
||||
}
|
||||
|
||||
@@ -1098,35 +1316,14 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
|
||||
|
||||
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
NSArray *source = @[];
|
||||
switch (self.displayType) {
|
||||
case 1: {
|
||||
case 1:
|
||||
source = self.datasource;
|
||||
XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row];
|
||||
NSNumber *cacheHeight = self.heightCache[indexPath];
|
||||
if (cacheHeight) {
|
||||
return cacheHeight.floatValue;
|
||||
} else {
|
||||
CGFloat height = [self calculateHeightForMessage:model];
|
||||
self.heightCache[indexPath] = @(height);
|
||||
return height;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
case 2:
|
||||
source = self.datasource_chat;
|
||||
XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row];
|
||||
NSNumber *cacheHeight = self.heightCache_2[indexPath];
|
||||
if (cacheHeight) {
|
||||
return cacheHeight.floatValue;
|
||||
} else {
|
||||
CGFloat height = [self calculateHeightForMessage:model];
|
||||
self.heightCache_2[indexPath] = @(height);
|
||||
return height;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
source = self.datasource_gift;
|
||||
@@ -1137,21 +1334,18 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row];
|
||||
|
||||
// // 如果 model 中有高度数据,使用 model 的高度
|
||||
// if (model.rowHeight > 0) {
|
||||
//// NSLog(@"---00--- : %f", model.rowHeight);
|
||||
// return model.rowHeight;
|
||||
// }
|
||||
|
||||
|
||||
// 如果 model 中有高度数据,使用 model 的高度
|
||||
if (model.rowHeight > 0) {
|
||||
return model.rowHeight;
|
||||
}
|
||||
|
||||
// 否则,使用自适应高度
|
||||
// return 100;
|
||||
return UITableViewAutomaticDimension;
|
||||
}
|
||||
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
switch (self.displayType) {
|
||||
case 1:
|
||||
@@ -1188,7 +1382,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
break;
|
||||
}
|
||||
XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row];
|
||||
NSString *cellKey = NSStringFromClass([XPRoomMessageTableViewCell class]);
|
||||
NSString *cellKey = [NSString isEmpty:model.cellKey] ? NSStringFromClass([XPRoomMessageTableViewCell class]) : model.cellKey;
|
||||
if(model.first == CustomMessageType_Room_Album){
|
||||
PIRoomMessagePhotoAlbumCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([PIRoomMessagePhotoAlbumCell class])];
|
||||
cell.delegate = self;
|
||||
@@ -1200,51 +1394,40 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
cellKey = @"XPRoomMessageTableViewCell_Boom";
|
||||
}
|
||||
|
||||
RoomCahtCell *cell = [RoomCahtCell cellFor:tableView];
|
||||
XPRoomMessageTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellKey];
|
||||
cell.delegate = self;
|
||||
if (model.isBoom) {
|
||||
cell.isLeftBigImage = model.isBoom;
|
||||
}
|
||||
cell.messageInfo = model;
|
||||
|
||||
// XPRoomMessageTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellKey];
|
||||
// cell.delegate = self;
|
||||
// cell.isLeftBoomImage = model.isBoom;
|
||||
// cell.messageInfo = model;
|
||||
// cell.roomType = self.hostDelegate.getRoomInfo.type;
|
||||
cell.roomType = self.hostDelegate.getRoomInfo.type;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)calculateHeightForMessage:(XPMessageInfoModel *)messageInfo {
|
||||
if (!messageInfo) return 60; // 返回默认高度
|
||||
|
||||
CGFloat totalHeight = 0;
|
||||
|
||||
// 1. 计算富文本内容的高度
|
||||
NSMutableAttributedString *content = [[NSMutableAttributedString alloc] initWithAttributedString:messageInfo.content];
|
||||
CGFloat maxWidth = kRoomMessageMaxWidth - 24; // 内容最大宽度
|
||||
CGSize boundingSize = CGSizeMake(maxWidth, CGFLOAT_MAX);
|
||||
|
||||
YYTextContainer *textContainer = [YYTextContainer containerWithSize:boundingSize];
|
||||
YYTextLayout *textLayout = [YYTextLayout layoutWithContainer:textContainer text:content];
|
||||
totalHeight += textLayout.textBoundingSize.height;
|
||||
|
||||
// // 2. 计算图片的高度(如果存在图片)
|
||||
// if (messageInfo.bubbleImageUrl && !messageInfo.isHiddenBubble) {
|
||||
// UIImage *cachedImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:messageInfo.bubbleImageUrl];
|
||||
// if (cachedImage) {
|
||||
// CGFloat imageWidth = cachedImage.size.width;
|
||||
// CGFloat imageHeight = cachedImage.size.height;
|
||||
// CGFloat scale = imageWidth / imageHeight;
|
||||
// CGFloat adjustedImageHeight = maxWidth / scale; // 根据宽度调整高度
|
||||
// totalHeight += adjustedImageHeight;
|
||||
// } else {
|
||||
// // 如果图片尚未加载,使用默认占位高度
|
||||
// totalHeight += 100; // 默认图片高度
|
||||
// }
|
||||
//- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
// NSArray *source = @[];
|
||||
// switch (self.displayType) {
|
||||
// case 1:
|
||||
// source = self.datasource;
|
||||
// break;
|
||||
// case 2:
|
||||
// source = self.datasource_chat;
|
||||
// break;
|
||||
// case 3:
|
||||
// source = self.datasource_gift;
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// source = self.datasource;
|
||||
// break;
|
||||
// }
|
||||
// XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row];
|
||||
// if (model.rowHeight == 0) {
|
||||
// model.rowHeight = CGRectGetHeight(cell.frame);
|
||||
// }
|
||||
//}
|
||||
|
||||
// 3. 加上内边距
|
||||
totalHeight += 16 * 2; // 顶部和底部的 padding
|
||||
return totalHeight;
|
||||
}
|
||||
|
||||
#pragma mark - XPRoomMessageTableViewCellDelegate
|
||||
- (void)xPRoomMessageTableViewCellDidTapEmpty:(XPRoomMessageTableViewCell *)view {
|
||||
@@ -1286,6 +1469,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
- (void)unlockRoomAlbumImageWithAlbumModel:(PIRoomPhotoAlbumItemModel *)albumModel{
|
||||
[XNDJTDDLoadingTool showLoading];
|
||||
[Api unlockRoomAlbumPhoto:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
|
||||
[XNDJTDDLoadingTool hideHUD];
|
||||
if(code == 200){
|
||||
NSMutableDictionary *getData = [NSMutableDictionary dictionary];
|
||||
@@ -1353,20 +1537,21 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
||||
_messageTableView.delegate = self;
|
||||
_messageTableView.dataSource = self;
|
||||
_messageTableView.rowHeight = UITableViewAutomaticDimension;
|
||||
_messageTableView.estimatedRowHeight = 100; // 预估高度
|
||||
// _messageTableView.estimatedRowHeight = 44; // 预估高度
|
||||
_messageTableView.tableFooterView = [UIView new];
|
||||
_messageTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
_messageTableView.backgroundColor = [UIColor clearColor];
|
||||
_messageTableView.showsVerticalScrollIndicator = NO;
|
||||
_messageTableView.clipsToBounds = NO;
|
||||
_messageTableView.tag = 666;
|
||||
if (@available(iOS 11.0, *)) {
|
||||
_messageTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
[_messageTableView registerClass:[XPRoomMessageTableViewCell class] forCellReuseIdentifier:@"XPRoomMessageTableViewCell_Boom"];
|
||||
[_messageTableView registerClass:[XPRoomMessageTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])];
|
||||
[_messageTableView registerClass:[XPRoomMessageTableViewCell class] forCellReuseIdentifier:@"ChatMessage"];
|
||||
[_messageTableView registerClass:[PIRoomMessagePhotoAlbumCell class] forCellReuseIdentifier:NSStringFromClass([PIRoomMessagePhotoAlbumCell class])];
|
||||
|
||||
[RoomCahtCell registerTo:_messageTableView];
|
||||
}
|
||||
return _messageTableView;
|
||||
}
|
||||
|
@@ -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,19 +165,24 @@
|
||||
[array addObject:roomPK];
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
|
||||
|
||||
if (isCreator && roomInfo.type != RoomType_MiniGame) {
|
||||
if(roomInfo.type != RoomType_Anchor){
|
||||
[array addObject:acrossRoomPK];
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isOnMic) {
|
||||
[array addObject:musicPanel];
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
|
||||
if (isCreator && roomInfo.type == RoomType_Anchor) {
|
||||
[array addObject:anchorRoomPK];
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
|
||||
|
||||
if ((isCreator || isManager || isSuperAdmin) && roomInfo.hasWishGiftPermit) {
|
||||
[array addObject:wishGift];
|
||||
}
|
||||
@@ -183,13 +194,12 @@
|
||||
}
|
||||
[array addObject:trumpet];
|
||||
[array addObject:giftEffect];
|
||||
[array addObject:roomSetting];
|
||||
if (isCreator || isManager || isSuperAdmin) {
|
||||
[array addObject:bgValue];
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
[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:
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#import "MSRoomGameModel.h"
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import "XPMessageRemoteExtModel.h"
|
||||
#import "XPSkillCardPlayerManager.h"
|
||||
|
||||
@implementation MSRoomGamePresenter
|
||||
|
||||
-(void)getCoinNum{
|
||||
@@ -43,16 +45,13 @@
|
||||
|
||||
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
UserInfoModel * infoModel = [UserInfoModel modelWithJSON:data.data];
|
||||
|
||||
[[XPSkillCardPlayerManager shareInstance] setUserInfoModel:infoModel];
|
||||
[user sendNext:infoModel];
|
||||
[user sendCompleted];
|
||||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||
[user sendError:nil];
|
||||
} showLoading:NO errorToast:NO] uid:uid];
|
||||
|
||||
|
||||
|
||||
|
||||
[Api getRoomGameHomeConfig:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
MSTabbarRoomGameModel *model = [MSTabbarRoomGameModel modelWithJSON:data.data];
|
||||
[game sendNext:model];
|
||||
|
@@ -51,6 +51,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
-(NSInteger)getPublicScreenType;
|
||||
|
||||
- (void)displayMusicPanel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -17,7 +17,8 @@ typedef enum : NSUInteger {
|
||||
ComboAction_RemovePanel,
|
||||
ComboAction_Error,
|
||||
ComboAction_Combo_Count_Update,
|
||||
ComboAction_Update_After_Send_Success
|
||||
ComboAction_Update_After_Send_Success,
|
||||
ComboAction_SendGift_Gold_Update
|
||||
} ComboActionType;
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
@@ -31,8 +32,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface GiftComboManager : NSObject
|
||||
|
||||
@property (nonatomic, assign, readonly) BOOL enableCombo;
|
||||
//@property(nonatomic, strong, nullable) GiftComboView *comboView;
|
||||
@property (nonatomic, strong) GiftReceiveInfoModel *sendGiftReceiveInfo;
|
||||
@property(nonatomic, copy) void(^handleComboSuccess)(GiftReceiveInfoModel *receiveModel, NSMutableDictionary *originDic);
|
||||
@property(nonatomic, copy) void(^handleRoomUIChanged)(BOOL comboViewDisplay);
|
||||
|
||||
// 单例方法
|
||||
+ (instancetype)sharedManager;
|
||||
|
@@ -72,6 +72,8 @@
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// 添加 GiftReceiveInfoModel 和 metadata 到队列
|
||||
- (void)addGiftComboWithInfo:(GiftReceiveInfoModel *)info andMetadata:(NSDictionary *)metadata {
|
||||
if (info && metadata) {
|
||||
@@ -104,6 +106,10 @@
|
||||
self.actionCallback(ComboAction_ShowPanel);
|
||||
self.isCombing = YES;
|
||||
}
|
||||
|
||||
if (self.handleRoomUIChanged) {
|
||||
self.handleRoomUIChanged(YES);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)registerActions:(void (^)(ComboActionType))action {
|
||||
@@ -116,6 +122,9 @@
|
||||
if (self.actionCallback) {
|
||||
self.actionCallback(ComboAction_RemovePanel);
|
||||
}
|
||||
if (self.handleRoomUIChanged) {
|
||||
self.handleRoomUIChanged(NO);
|
||||
}
|
||||
self.isCombing = NO;
|
||||
}
|
||||
|
||||
@@ -419,33 +428,6 @@
|
||||
|
||||
[self.requestQueue addObject:dic];
|
||||
[self startProcessingQueue];
|
||||
|
||||
// @kWeakify(self);
|
||||
// [Api requestSendGift:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
// @kStrongify(self);
|
||||
// if (!self) {
|
||||
// return;
|
||||
// }
|
||||
// if (code == 200) {
|
||||
// GiftReceiveInfoModel *receive = [GiftReceiveInfoModel modelWithJSON:data.data];
|
||||
// receive.sourceType = self.giftSourceType;
|
||||
// receive.roomSendGiftType = self.roomSendGiftType;
|
||||
// [self handleSendGiftSuccess:data];
|
||||
// } else {
|
||||
// self.errorMessage = msg;
|
||||
// self.actionCallback(ComboAction_RemovePanel);
|
||||
// self.actionCallback(ComboAction_Error);
|
||||
// }
|
||||
// }
|
||||
// targetUids:allUIDs
|
||||
// giftNum:self.giftNumPerTimes
|
||||
// sendType:[NSString stringWithFormat:@"%ld", GiftSendType_OnMic]
|
||||
// giftId:[NSString stringWithFormat:@"%ld", self.giftInfo.giftId]
|
||||
// giftSource:[NSString stringWithFormat:@"%ld", self.giftSourceType]
|
||||
// giftType:[NSString stringWithFormat:@"%ld", self.roomSendGiftType]
|
||||
// roomUid:self.roomUID
|
||||
// msg:@""
|
||||
// uid:[AccountInfoStorage instance].getUid];
|
||||
}
|
||||
|
||||
- (void)handleSendGift:(NSDictionary *)dic {
|
||||
@@ -463,6 +445,10 @@
|
||||
NSArray *array = [allUIDs componentsSeparatedByString:@","];
|
||||
receive.receiveGiftNumberUser = array.count;
|
||||
[self handleSendGiftSuccess:receive sourceData:data];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"receiveLuckGiftWinning"
|
||||
object:@{@"CurrentGold": receive.userPurse.diamonds,
|
||||
@"Price": @(receive.gift.goldPrice * receive.giftNum * array.count),
|
||||
@"isFromWinning":@(NO)}];
|
||||
} else {
|
||||
self.errorMessage = msg;
|
||||
self.actionCallback(ComboAction_RemovePanel);
|
||||
@@ -482,9 +468,6 @@
|
||||
|
||||
- (void)handleSendGiftSuccess:(GiftReceiveInfoModel *)receive
|
||||
sourceData:(BaseModel *)response {
|
||||
|
||||
// self.combo += 1;
|
||||
|
||||
if (self.actionCallback) {
|
||||
self.actionCallback(ComboAction_Combo_Count_Update);
|
||||
}
|
||||
@@ -495,55 +478,6 @@
|
||||
if (self.handleComboSuccess) {
|
||||
self.handleComboSuccess(receive, dic);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
self.sendGiftReceiveInfo = receive;
|
||||
if (self.actionCallback) {
|
||||
self.actionCallback(ComboAction_Update_After_Send_Success);
|
||||
}
|
||||
|
||||
NSDictionary *tempDic = response.data;
|
||||
NSMutableDictionary *data = [NSMutableDictionary dictionary];
|
||||
[data addEntriesFromDictionary:tempDic];
|
||||
|
||||
AttachmentModel *attachment = [[AttachmentModel alloc] init];
|
||||
switch (self.roomSendGiftType) {
|
||||
case RoomSendGiftType_AllMic: {
|
||||
attachment.first = CustomMessageType_AllMicroSend;
|
||||
attachment.second = Custom_Message_Sub_AllMicroSend;
|
||||
[data setObject:[tempDic valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
|
||||
attachment.data = data;
|
||||
}
|
||||
break;
|
||||
case RoomSendGiftType_MutableOnMic: {
|
||||
attachment.first = CustomMessageType_AllMicroSend;
|
||||
attachment.second = Custom_Message_Sub_AllBatchSend;
|
||||
attachment.data = data;
|
||||
}
|
||||
break;
|
||||
case RoomSendGiftType_ToOne: {
|
||||
attachment.first = CustomMessageType_Gift;
|
||||
attachment.second = Custom_Message_Sub_Gift_Send;
|
||||
NSDictionary *targetUsers = ((NSArray *)[data objectForKey:@"targetUsers"]).firstObject;
|
||||
NSString *avatar = [targetUsers valueForKeyPath:@"avatar"];
|
||||
[data setObject:[targetUsers valueForKeyPath:@"uid"] forKey:@"targetUid"];
|
||||
[data setObject:[targetUsers valueForKeyPath:@"nick"] forKey:@"targetNick"];
|
||||
if (avatar.length > 0) {
|
||||
[data setObject:avatar forKey:@"targetAvatar"];
|
||||
}
|
||||
attachment.data = data;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
attachment = nil;
|
||||
break;
|
||||
}
|
||||
|
||||
if (attachment) {
|
||||
[attachment.data setObject:@(self.combo) forKey:@"comboCount"];
|
||||
[self sendCustomMessage:attachment];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)sendCustomMessage:(AttachmentModel *)attachment {
|
||||
|
@@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (instancetype)initWithFrame:(CGRect)frame duration:(NSInteger)duration;
|
||||
- (void)startCountdown;
|
||||
- (void)resetCountdown; // 重置功能
|
||||
- (void)stopCountdown;
|
||||
- (void)setCompletionHandler:(void (^__nullable)(void))completionHandler; // 计时结束的回调
|
||||
|
||||
@end
|
||||
|