完成版本需求
This commit is contained in:
@@ -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
|
||||
@@ -327,9 +327,7 @@ static NSArray<NSDictionary<NSString *, NSNumber *> *> *MyDressUpOptions(void) {
|
||||
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){
|
||||
|
@@ -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);
|
||||
|
@@ -214,7 +214,7 @@ HWDMP4PlayDelegate>
|
||||
[array addObject:black];
|
||||
}
|
||||
|
||||
if (self.userInfo.hasSuperRole) {
|
||||
if ([XPSkillCardPlayerManager shareInstance].userInfoModel.hasSuperRole) {
|
||||
TTActionSheetConfig *superBlock = [TTActionSheetConfig normalTitle:YMLocalizedString(@"1.0.30_text_26") clickAction:^{
|
||||
@kStrongify(self);
|
||||
SuperBlockViewController *vc = [[SuperBlockViewController alloc] init];
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -367,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;}
|
||||
@@ -506,7 +511,6 @@ PIUniversalBannerViewDelegate>
|
||||
#pragma mark - 收到送礼者中奖飘屏
|
||||
- (void)receiveLuckGiftWinning:(AttachmentModel *)attachment {
|
||||
RoomInfoModel *roomInfo = self.delegate.getRoomInfo;
|
||||
|
||||
[LuckyGiftWinningFlagView display:self
|
||||
with:attachment
|
||||
roomID:roomInfo.roomId
|
||||
@@ -1138,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) {
|
||||
|
@@ -92,18 +92,10 @@
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.leftBigImageView.mas_centerX);
|
||||
make.top.mas_equalTo(0);
|
||||
// make.bottom.mas_equalTo(-self.messageInfo.contentBottomMargin);
|
||||
make.bottom.mas_equalTo(self.leftBigImageView).offset(6);
|
||||
make.trailing.mas_equalTo(-8);
|
||||
}];
|
||||
|
||||
// [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
|
||||
// make.trailing.mas_equalTo(self.contentView).offset(-8);
|
||||
//// make.centerY.mas_equalTo(self.contentView);
|
||||
// make.centerY.mas_equalTo(self.leftBigImageView);
|
||||
// }];
|
||||
|
||||
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.bottom.mas_equalTo(self.bubbleImageView);
|
||||
make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
|
||||
@@ -114,17 +106,6 @@
|
||||
make.edges.mas_equalTo(self.bubbleImageView);
|
||||
}];
|
||||
self.blurEffectView.hidden = NO;
|
||||
|
||||
// [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
// make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
|
||||
// make.trailing.mas_equalTo(-self.messageInfo.contentRightMargin - 8);
|
||||
// make.top.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentTopMargin);
|
||||
// make.bottom.mas_equalTo(self.bubbleImageView).offset(-self.messageInfo.contentBottomMargin);
|
||||
//// if (isMSRTL()) {
|
||||
//// make.width.mas_equalTo([self RTLLabelWidth] - 65);
|
||||
//// }
|
||||
// }];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +152,6 @@
|
||||
self.leftBigImageView.imageUrl = messageInfo.boomImageUrl;
|
||||
} else {
|
||||
[self updateLayout];
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,8 +209,9 @@
|
||||
}];
|
||||
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.contentLabel);
|
||||
make.size.mas_equalTo(self.contentLabel).multipliedBy(1.1);
|
||||
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);
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -240,7 +221,7 @@
|
||||
context:nil].size;
|
||||
}
|
||||
- (CGFloat)RTLLabelWidth {
|
||||
return MIN(ceil([self RTLLabelSize].width),// + self.messageInfo.contentLeftMargin + self.messageInfo.contentRightMargin + 8,
|
||||
return MIN(ceil([self RTLLabelSize].width) + self.messageInfo.contentLeftMargin,
|
||||
kRoomMessageMaxWidth - self.messageInfo.contentLeftMargin);
|
||||
}
|
||||
|
||||
@@ -299,15 +280,12 @@
|
||||
|
||||
- (UIVisualEffectView *)blurEffectView {
|
||||
if (!_blurEffectView) {
|
||||
// 创建模糊效果
|
||||
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; // 选择模糊样式(例如:Light, Dark, ExtraLight 等)
|
||||
|
||||
// 创建包含模糊效果的视图
|
||||
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
|
||||
_blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
|
||||
|
||||
// 设置模糊视图的大小与目标视图一致
|
||||
_blurEffectView.frame = CGRectMake(0, 0, KScreenWidth, 200);
|
||||
_blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; // 使模糊视图适应目标视图的尺寸变化
|
||||
_blurEffectView.frame = CGRectMake(0, 0, KScreenWidth*2/3, 200);
|
||||
_blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
_blurEffectView.hidden = YES;
|
||||
|
||||
[_blurEffectView setCornerRadius:8];
|
||||
|
@@ -104,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) {
|
||||
@@ -164,126 +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: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];
|
||||
}
|
||||
NSInteger removedCount = kRoomMessageMaxLength / 2;
|
||||
[self safelyRemoveMessages:removedCount];
|
||||
}
|
||||
|
||||
// 执行插入
|
||||
// 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: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 - @我
|
||||
@@ -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 {
|
||||
|
@@ -166,11 +166,6 @@
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
|
||||
if (isOnMic) {
|
||||
[array addObject:musicPanel];
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
|
||||
if (isCreator && roomInfo.type != RoomType_MiniGame) {
|
||||
if(roomInfo.type != RoomType_Anchor){
|
||||
[array addObject:acrossRoomPK];
|
||||
@@ -178,6 +173,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (isOnMic) {
|
||||
[array addObject:musicPanel];
|
||||
indexOfRoomAlbum += 1;
|
||||
}
|
||||
|
||||
if (isCreator && roomInfo.type == RoomType_Anchor) {
|
||||
[array addObject:anchorRoomPK];
|
||||
indexOfRoomAlbum += 1;
|
||||
@@ -194,11 +194,11 @@
|
||||
}
|
||||
[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];
|
||||
|
@@ -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
|
||||
|
@@ -23,9 +23,7 @@
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
self.completionHandler = nil;
|
||||
[self.timer invalidate];
|
||||
self.timer = nil;
|
||||
[self stopCountdown];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame duration:(NSInteger)duration {
|
||||
@@ -51,14 +49,6 @@
|
||||
endAngle:(M_PI * 2) - M_PI_2
|
||||
clockwise:YES];
|
||||
|
||||
// 背景圆环
|
||||
// self.backgroundLayer = [CAShapeLayer layer];
|
||||
// self.backgroundLayer.path = circularPath.CGPath;
|
||||
// self.backgroundLayer.strokeColor = UIColorFromRGB(0x04D5C6).CGColor;
|
||||
// self.backgroundLayer.lineWidth = 7;
|
||||
// self.backgroundLayer.fillColor = [UIColor clearColor].CGColor;
|
||||
// [self.layer addSublayer:self.backgroundLayer];
|
||||
|
||||
// 前景倒计时圆环
|
||||
self.foregroundLayer = [CAShapeLayer layer];
|
||||
self.foregroundLayer.path = circularPath.CGPath;
|
||||
@@ -119,6 +109,9 @@
|
||||
self.remainingTime -= 0.1;
|
||||
|
||||
if (self.remainingTime <= 0) {
|
||||
|
||||
// TODO: 这里的timer 只负责动画,manager 处增加处理逻辑的 timer
|
||||
|
||||
[self.timer invalidate];
|
||||
self.timer = nil;
|
||||
|
||||
@@ -128,6 +121,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopCountdown {
|
||||
self.completionHandler = nil;
|
||||
[self.timer invalidate];
|
||||
self.timer = nil;
|
||||
}
|
||||
|
||||
// 环形倒计时动画
|
||||
- (void)animateRing {
|
||||
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
|
||||
|
@@ -12,9 +12,10 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface GiftComboView : UIView
|
||||
|
||||
- (void)setupCurrentGold:(double)gold;
|
||||
- (void)updateCurrentGold:(double)gold giftPrice:(double)price isFromWinning:(BOOL)isFromWinning;
|
||||
- (void)updateCount;
|
||||
|
||||
- (void)stopTimer;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -12,23 +12,39 @@
|
||||
#import <SVGA.h>
|
||||
#import <AudioToolbox/AudioToolbox.h>
|
||||
|
||||
@interface GiftComboView ()<SVGAPlayerDelegate>
|
||||
@interface GiftComboView ()<SVGAPlayerDelegate, UIGestureRecognizerDelegate>
|
||||
|
||||
@property (nonatomic, strong) UIView *container;
|
||||
@property (nonatomic, strong) UILabel *comboCountLabel;
|
||||
@property(nonatomic, strong) UILabel *comboGoldLabel;
|
||||
@property(nonatomic, strong) UILabel *updateGoldLabel;
|
||||
@property (nonatomic, strong) SVGAImageView *playImageView;
|
||||
@property (nonatomic, strong) SVGAVideoEntity *svgaVideoEntity;
|
||||
@property (nonatomic, strong) CountdownRingView *countdownRingView;
|
||||
|
||||
@property(nonatomic, strong) NSMutableArray *updateGoldQueue;
|
||||
@property(nonatomic, assign) BOOL isAnimatingUpdateGold;
|
||||
|
||||
@end
|
||||
|
||||
@implementation GiftComboView
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self.countdownRingView stopCountdown];
|
||||
[self.countdownRingView removeFromSuperview];
|
||||
self.countdownRingView = nil;
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapSpace)];
|
||||
[self addGestureRecognizer:tap];
|
||||
self.updateGoldQueue = @[].mutableCopy;
|
||||
[self setupNotification];
|
||||
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapSpace)];
|
||||
tap.delegate = self;
|
||||
[self addGestureRecognizer:tap];
|
||||
[self setupUI];
|
||||
[self setupTimer];
|
||||
[self updateCount];
|
||||
@@ -50,6 +66,30 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupNotification {
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:@"receiveLuckGiftWinning"
|
||||
object:nil
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
usingBlock:^(NSNotification * _Nonnull notification) {
|
||||
if ([notification.object isKindOfClass:[NSString class]]) {
|
||||
NSString *coin = (NSString *)notification.object;
|
||||
if (![NSString isEmpty:coin]) {
|
||||
[self updateCurrentGold:coin.doubleValue giftPrice:0 isFromWinning:YES];
|
||||
}
|
||||
} else if ([notification.object isKindOfClass:[NSDictionary class]]) {
|
||||
NSDictionary *dic = (NSDictionary *)notification.object;
|
||||
double coin = [[dic objectForKey:@"CurrentGold"] doubleValue];
|
||||
double price = [[dic objectForKey:@"Price"] doubleValue];
|
||||
BOOL isFromWinning = [[dic objectForKey:@"isFromWinning"] boolValue];
|
||||
[self updateCurrentGold:coin giftPrice:price isFromWinning:isFromWinning];
|
||||
// [[NSNotificationCenter defaultCenter] postNotificationName:@"receiveLuckGiftWinning"
|
||||
// object:@{@"CurrentGold": receive.userPurse.diamonds,
|
||||
// @"Price": @(receive.gift.goldPrice),
|
||||
// @"isFromWinning":@(NO)}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)updateCount {
|
||||
NSString *countStr = [NSString stringWithFormat:@"x%ld", [[GiftComboManager sharedManager] loadComboCount]];
|
||||
NSShadow *shadow = [[NSShadow alloc] init];
|
||||
@@ -63,11 +103,15 @@
|
||||
self.comboCountLabel.attributedText = string;
|
||||
}
|
||||
|
||||
- (void)stopTimer {
|
||||
[self.countdownRingView stopCountdown];
|
||||
}
|
||||
|
||||
- (void)setupUI {
|
||||
[self addSubview:self.container];
|
||||
[self.container mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.trailing.mas_equalTo(self).offset(-16);
|
||||
make.bottom.mas_equalTo(self).offset(-20);
|
||||
make.bottom.mas_equalTo(self).offset(-26);
|
||||
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(170), kGetScaleWidth(310)));
|
||||
}];
|
||||
|
||||
@@ -90,6 +134,41 @@
|
||||
make.bottom.mas_equalTo(self.playImageView.mas_bottom).offset(4);
|
||||
make.width.height.mas_equalTo(kGetScaleWidth(90));
|
||||
}];
|
||||
|
||||
[self setupGoldArea];
|
||||
}
|
||||
|
||||
- (void)setupGoldArea {
|
||||
[self addSubview:self.comboGoldLabel];
|
||||
[self.comboGoldLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(44);
|
||||
make.bottom.mas_equalTo(-74);
|
||||
}];
|
||||
|
||||
UIImageView *coin = [[UIImageView alloc] initWithImage:kImage(@"moli_money_icon")];
|
||||
[self addSubview:coin];
|
||||
[coin mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self.comboGoldLabel);
|
||||
make.trailing.mas_equalTo(self.comboGoldLabel.mas_leading).offset(-4);
|
||||
make.size.mas_equalTo(CGSizeMake(22, 22));
|
||||
}];
|
||||
|
||||
UIView *bg = [[UIView alloc] init];
|
||||
bg.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
|
||||
[bg setCornerRadius:18];
|
||||
[self insertSubview:bg belowSubview:self.comboGoldLabel];
|
||||
[bg mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(coin.mas_leading).offset(-8);
|
||||
make.trailing.mas_equalTo(self.comboGoldLabel.mas_trailing).offset(8);
|
||||
make.centerY.mas_equalTo(self.comboGoldLabel);
|
||||
make.height.mas_equalTo(36);
|
||||
}];
|
||||
|
||||
[self addSubview:self.updateGoldLabel];
|
||||
[self.updateGoldLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(bg);
|
||||
make.bottom.mas_equalTo(self.comboGoldLabel.mas_bottom).offset(0);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setupTimer {
|
||||
@@ -103,10 +182,10 @@
|
||||
}
|
||||
|
||||
- (void)handleTap {
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// 1521 连续震动 3 次
|
||||
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
|
||||
// });
|
||||
});
|
||||
|
||||
[[GiftComboManager sharedManager] sendGift];
|
||||
[self.playImageView startAnimation];
|
||||
@@ -114,7 +193,7 @@
|
||||
}
|
||||
|
||||
- (void)handleTapSpace {
|
||||
|
||||
[[GiftComboManager sharedManager] forceRemove];
|
||||
}
|
||||
|
||||
// SVGAPlayerDelegate: 当动画播放完毕时调用
|
||||
@@ -122,6 +201,71 @@
|
||||
[self.playImageView stepToPercentage:0 andPlay:NO];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
- (void)setupCurrentGold:(double)gold {
|
||||
self.comboGoldLabel.text = @(gold).stringValue;
|
||||
}
|
||||
|
||||
- (void)updateCurrentGold:(double)gold giftPrice:(double)price isFromWinning:(BOOL)isFromWinning {
|
||||
if (isFromWinning) {
|
||||
[self.updateGoldQueue addObject:[NSString stringWithFormat:@"+ %@", @(gold)]];
|
||||
} else {
|
||||
[self.updateGoldQueue addObject:@(-price).stringValue];
|
||||
self.comboGoldLabel.text = @(gold).stringValue;
|
||||
}
|
||||
|
||||
if (!self.isAnimatingUpdateGold) {
|
||||
[self processNextUpdateGold];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)processNextUpdateGold {
|
||||
if (self.updateGoldQueue.count == 0) {
|
||||
self.isAnimatingUpdateGold = NO;
|
||||
return;
|
||||
}
|
||||
|
||||
NSNumber *goldNum = [self.updateGoldQueue xpSafeObjectAtIndex:0];
|
||||
[self.updateGoldQueue removeObjectAtIndex:0];
|
||||
|
||||
self.isAnimatingUpdateGold = YES;
|
||||
|
||||
self.updateGoldLabel.text = goldNum.stringValue;
|
||||
self.updateGoldLabel.alpha = 0;
|
||||
[UIView animateWithDuration:0.25 animations:^{
|
||||
[self.updateGoldLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.comboGoldLabel.mas_bottom).offset(-40);
|
||||
}];
|
||||
self.updateGoldLabel.alpha = 1;
|
||||
[self layoutIfNeeded];
|
||||
} completion:^(BOOL finished) {
|
||||
[UIView animateWithDuration:0.25
|
||||
delay:0.25
|
||||
options:UIViewAnimationOptionCurveLinear
|
||||
animations:^{
|
||||
[self.updateGoldLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.comboGoldLabel.mas_bottom).offset(0);
|
||||
}];
|
||||
self.updateGoldLabel.alpha = 0;
|
||||
[self layoutIfNeeded];
|
||||
} completion:^(BOOL finished) {
|
||||
self.isAnimatingUpdateGold = NO;
|
||||
[self processNextUpdateGold];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark -
|
||||
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
|
||||
// 如果触摸点在 UITextView 或 UICollectionView 内,则不触发手势
|
||||
if (touch.view == self.container || touch.view == self.playImageView) {
|
||||
return NO;
|
||||
}
|
||||
return YES; // 触发手势
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (UIView *)container {
|
||||
if (!_container) {
|
||||
@@ -142,6 +286,20 @@
|
||||
return _comboCountLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)comboGoldLabel {
|
||||
if (!_comboGoldLabel) {
|
||||
_comboGoldLabel = [UILabel labelInitWithText:@"" font:kFontSemibold(20) textColor:UIColorFromRGB(0xffd54c)];
|
||||
}
|
||||
return _comboGoldLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)updateGoldLabel {
|
||||
if (!_updateGoldLabel) {
|
||||
_updateGoldLabel = [UILabel labelInitWithText:@"" font:kFontSemibold(24) textColor:UIColorFromRGB(0xffd54c)];
|
||||
}
|
||||
return _updateGoldLabel;
|
||||
}
|
||||
|
||||
- (SVGAImageView *)playImageView {
|
||||
if (_playImageView == nil) {
|
||||
_playImageView = [[SVGAImageView alloc]init];
|
||||
@@ -155,7 +313,8 @@
|
||||
- (CountdownRingView *)countdownRingView {
|
||||
if (!_countdownRingView) {
|
||||
_countdownRingView = [[CountdownRingView alloc] initWithFrame:CGRectMake(0, 0, kGetScaleWidth(90), kGetScaleWidth(90))
|
||||
duration:555];
|
||||
duration:5];
|
||||
_countdownRingView.userInteractionEnabled = YES;
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap)];
|
||||
[_countdownRingView addGestureRecognizer:tap];
|
||||
}
|
||||
|
@@ -345,7 +345,6 @@
|
||||
diamondAtt.image = iconImage;
|
||||
NSAttributedString *diamondAttribute = [NSMutableAttributedString attributedStringWithAttachment:(NSTextAttachment *)diamondAtt];
|
||||
|
||||
|
||||
if (_walletInfoModel.canGoldSendGift == NO){
|
||||
NSString * title = [NSString stringWithFormat:@" %@",diamonds];
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:highlightColor}];
|
||||
|
@@ -174,6 +174,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
|
||||
if (self->_luckyBroadcastView) {
|
||||
self.luckyBroadcastView.hidden = NO;
|
||||
}
|
||||
[self.comboView stopTimer];
|
||||
[self.comboView removeFromSuperview];
|
||||
self.comboView = nil;
|
||||
}
|
||||
@@ -194,6 +195,10 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
|
||||
} else {
|
||||
self.giftBarView.walletInfoModel = receiveInfo.userPurse;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ComboAction_SendGift_Gold_Update: {
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -928,12 +933,15 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
|
||||
@kStrongify(self);
|
||||
if (self) {
|
||||
[self sendCustomMessage:receiveInfo oringinDic:originDic];
|
||||
[[GiftComboManager sharedManager] resetCombo];
|
||||
@kWeakify(self);
|
||||
[[GiftComboManager sharedManager] setHandleComboSuccess:^(GiftReceiveInfoModel * _Nonnull receiveModel, NSMutableDictionary * _Nonnull originDic) {
|
||||
@kStrongify(self);
|
||||
[self sendCustomMessage:receiveInfo oringinDic:originDic.copy];
|
||||
}];
|
||||
if ([GiftComboManager sharedManager].enableCombo) {
|
||||
[[GiftComboManager sharedManager] resetCombo];
|
||||
[self.comboView setupCurrentGold:receiveInfo.userPurse.diamonds.doubleValue];
|
||||
@kWeakify(self);
|
||||
[[GiftComboManager sharedManager] setHandleComboSuccess:^(GiftReceiveInfoModel * _Nonnull receiveModel, NSMutableDictionary * _Nonnull originDic) {
|
||||
@kStrongify(self);
|
||||
[self sendCustomMessage:receiveInfo oringinDic:originDic.copy];
|
||||
}];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -46,6 +46,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
//- (BOOL)isEmpty;
|
||||
|
||||
- (NSString *)pureURLString;
|
||||
|
||||
+ (NSString *)formatNumberToKOrM_NoRounding:(NSString *)string;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@@ -102,6 +102,61 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSString *)formatNumberToKOrM_NoRounding:(NSString *)string {
|
||||
// 定义数值单位
|
||||
NSDecimalNumber *thousand = [NSDecimalNumber decimalNumberWithString:@"1000"];
|
||||
NSDecimalNumber *nine = [NSDecimalNumber decimalNumberWithString:@"9999"];
|
||||
NSDecimalNumber *million = [NSDecimalNumber decimalNumberWithString:@"1000000"];
|
||||
NSDecimalNumber *billion = [NSDecimalNumber decimalNumberWithString:@"1000000000"];
|
||||
NSDecimalNumber *trillion = [NSDecimalNumber decimalNumberWithString:@"1000000000000"];
|
||||
// 创建 NSDecimalNumber 对象
|
||||
NSDecimalNumber *number = [NSDecimalNumber decimalNumberWithString:string];
|
||||
|
||||
// 判断数值范围并处理
|
||||
if ([number compare:nine] == NSOrderedAscending) {
|
||||
// 小于 10000,直接返回原始值
|
||||
return [NSString stringWithFormat:@"%@", string];
|
||||
} else if ([number compare:nine] != NSOrderedAscending && [number compare:million] == NSOrderedAscending) {
|
||||
// 10000 到 9999999,用K表示
|
||||
NSDecimalNumber *result = [number decimalNumberByDividingBy:thousand];
|
||||
return [self truncateDecimal:result withUnit:@"K"];
|
||||
} else if ([number compare:million] != NSOrderedAscending && [number compare:billion] == NSOrderedAscending) {
|
||||
// 超过 1000000,用M表示
|
||||
NSDecimalNumber *result = [number decimalNumberByDividingBy:million];
|
||||
return [self truncateDecimal:result withUnit:@"M"];
|
||||
} else if ([number compare:billion] != NSOrderedAscending && [number compare:trillion] == NSOrderedAscending) {
|
||||
// 超过十亿,用 B 表示
|
||||
NSDecimalNumber *result = [number decimalNumberByDividingBy:billion];
|
||||
return [self truncateDecimal:result withUnit:@"B"];
|
||||
} else {
|
||||
// 超过一万亿,可以继续增加更高单位
|
||||
NSDecimalNumber *result = [number decimalNumberByDividingBy:trillion];
|
||||
return [self truncateDecimal:result withUnit:@"T"]; // T 表示万亿 (Trillion)
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化并截断小数位
|
||||
+ (NSString *)truncateDecimal:(NSDecimalNumber *)decimal withUnit:(NSString *)unit {
|
||||
// 获取字符串形式的结果,并截断到一位小数
|
||||
NSString *decimalString = decimal.stringValue;
|
||||
NSArray<NSString *> *components = [decimalString componentsSeparatedByString:@"."];
|
||||
NSString *integerPart = components.firstObject;
|
||||
NSString *decimalPart = components.count > 1 ? components[1] : @"";
|
||||
|
||||
if (decimalPart.length > 1) {
|
||||
decimalPart = [decimalPart substringToIndex:1]; // 截断到一位小数
|
||||
}
|
||||
|
||||
if (decimalPart.length == 0 || [decimalPart isEqualToString:@"0"]) {
|
||||
// 如果小数部分为空或为 0,只返回整数部分
|
||||
return [NSString stringWithFormat:@"%@%@", integerPart, unit];
|
||||
} else {
|
||||
// 返回截断后的结果
|
||||
return [NSString stringWithFormat:@"%@.%@%@", integerPart, decimalPart, unit];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+ (NSString *)formatResult:(NSDecimalNumber *)result withUnit:(NSString *)unit {
|
||||
// 将 NSDecimalNumber 转为浮点数
|
||||
CGFloat floatValue = result.floatValue;
|
||||
|
@@ -940,8 +940,8 @@
|
||||
"XPMineDressUpListViewController11" = "عزيزي المستخدم، ليس لديك زينات رأس بعد!";
|
||||
"XPMineDressUpListViewController12" = "عزيزي المستخدم، ليس لديك مركبات بعد!";
|
||||
|
||||
"XPDressUpShopViewController0" = "تجهيزاتي";
|
||||
"XPDressUpShopViewController1" = "متجر الزينة";
|
||||
"XPDressUpShopViewController0" = "منجمي";
|
||||
"XPDressUpShopViewController1" = "مول";
|
||||
"XPDressUpShopViewController6" = "فقاعات الدردشة";
|
||||
"XPDressUpShopViewController7" = "كوينزاتي";
|
||||
"XPDressUpShopViewController8" = "إعادة شحن";
|
||||
|
@@ -282,8 +282,8 @@
|
||||
"XPMineDressUpListViewController11" = "Sevgili kullanıcı, henüz bir başlık takımınız yok!";
|
||||
"XPMineDressUpListViewController12" = "Sevgili kullanıcı, henüz bir araba süslemeniz yok!";
|
||||
|
||||
"XPDressUpShopViewController0" = "Benim Giyimim";
|
||||
"XPDressUpShopViewController1" = "Giyim Mağazası";
|
||||
"XPDressUpShopViewController0" = "Benim";
|
||||
"XPDressUpShopViewController1" = "Mağaza";
|
||||
"XPDressUpShopViewController6" = "Sohbet Balonları";
|
||||
"XPDressUpShopViewController7" = "Benim Altınlarım";
|
||||
"XPDressUpShopViewController8" = "Yükleme";
|
||||
|
@@ -3431,7 +3431,7 @@
|
||||
"1.0.18_10" = "更新";
|
||||
"1.0.18_11" = "購買提示";
|
||||
"1.0.18_12" = "您確定要使用此圖像作為背景嗎?";
|
||||
"1.0.18_14" = "天";
|
||||
//"1.0.18_14" = "天";
|
||||
"1.0.18_13" = "您確定要購買嗎?";
|
||||
"1.0.18_14" = "1000/15Days";
|
||||
"1.0.18_15" = "提交";
|
||||
|
Reference in New Issue
Block a user